Class: Automation::API::CLI
- Inherits:
-
Thor
- Object
- Thor
- Automation::API::CLI
- Defined in:
- lib/automation/api/cli.rb
Overview
Automation::API::CLI
Constant Summary collapse
- DEFAULT_PROFILE =
'starter'
- PROFILE_PATH =
"#{File.('../../../', __dir__)}/config"
- PROFILE_EXAMPLE =
"#{PROFILE_PATH}/profile.yml.example"
- ARCHETYPES =
%w[ complex coffee_shop empty ].freeze
- PROCESSORS =
%w[ tgate_dev tgate_prod tgate_mock clover freedompay_uat tgate_emulator_uat broken none ].freeze
Instance Method Summary collapse
- #create(profile = DEFAULT_PROFILE) ⇒ Object
- #list ⇒ Object
- #new_profile(name = 'custom_profile') ⇒ Object
- #view(store_type = DEFAULT_STORE_TYPE) ⇒ Object
Instance Method Details
#create(profile = DEFAULT_PROFILE) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/automation/api/cli.rb', line 85 def create(profile = DEFAULT_PROFILE) @saved = {} @client = Automation::API::Client.create() file_path = File.("#{profile}.yml", [:profile_path]) raise 'Store profile not found' unless File.exist?(file_path) configuration = YAML.load_file(file_path) configuration.each do |key, value| next unless private_methods.include?(key) send(key, value) end end |
#list ⇒ Object
109 110 111 112 113 114 115 116 117 118 |
# File 'lib/automation/api/cli.rb', line 109 def list regex = %r{([^\/]*).yml$}x file_paths = Dir["#{[:profile_path]}/*"] file_paths.map { |file| file.match(regex) } .compact .map { |match| match[1] } .sort .each { |profile| puts profile } end |
#new_profile(name = 'custom_profile') ⇒ Object
144 145 146 147 148 |
# File 'lib/automation/api/cli.rb', line 144 def new_profile(name = 'custom_profile') dest = File.("#{name}.yml", [:profile_path]) FileUtils.cp(PROFILE_EXAMPLE, dest) end |
#view(store_type = DEFAULT_STORE_TYPE) ⇒ Object
127 128 129 130 131 132 133 134 135 |
# File 'lib/automation/api/cli.rb', line 127 def view(store_type = DEFAULT_STORE_TYPE) path = "#{[:config_path]}/#{store_type}.yml" if File.exist?(path) puts File.read(path) else puts 'No configuration file found' end end |