Class: LessPainful::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/lesspainful/cli.rb

Constant Summary collapse

FILE_UPLOAD_ENDPOINT =
"upload2"
FORM_URL_ENCODED_ENDPOINT =
"upload"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



16
17
18
# File 'lib/lesspainful/cli.rb', line 16

def api_key
  @api_key
end

#appObject

Returns the value of attribute app.



16
17
18
# File 'lib/lesspainful/cli.rb', line 16

def app
  @app
end

#configObject

Returns the value of attribute config.



16
17
18
# File 'lib/lesspainful/cli.rb', line 16

def config
  @config
end

#dry_runObject

Returns the value of attribute dry_run.



16
17
18
# File 'lib/lesspainful/cli.rb', line 16

def dry_run
  @dry_run
end

#endpoint_pathObject

Returns the value of attribute endpoint_path.



18
19
20
# File 'lib/lesspainful/cli.rb', line 18

def endpoint_path
  @endpoint_path
end

#features_zipObject

Returns the value of attribute features_zip.



16
17
18
# File 'lib/lesspainful/cli.rb', line 16

def features_zip
  @features_zip
end

#hostObject

Returns the value of attribute host.



16
17
18
# File 'lib/lesspainful/cli.rb', line 16

def host
  @host
end

#prettyObject

Returns the value of attribute pretty.



17
18
19
# File 'lib/lesspainful/cli.rb', line 17

def pretty
  @pretty
end

#profileObject

Returns the value of attribute profile.



16
17
18
# File 'lib/lesspainful/cli.rb', line 16

def profile
  @profile
end

#reset_between_scenariosObject

Returns the value of attribute reset_between_scenarios.



16
17
18
# File 'lib/lesspainful/cli.rb', line 16

def reset_between_scenarios
  @reset_between_scenarios
end

#skip_checkObject

Returns the value of attribute skip_check.



16
17
18
# File 'lib/lesspainful/cli.rb', line 16

def skip_check
  @skip_check
end

#workspaceObject

Returns the value of attribute workspace.



16
17
18
# File 'lib/lesspainful/cli.rb', line 16

def workspace
  @workspace
end

Class Method Details

.source_rootObject



24
25
26
# File 'lib/lesspainful/cli.rb', line 24

def self.source_root
  File.join(File.dirname(__FILE__), '..')
end

Instance Method Details

#submit(app, api_key, *args) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/lesspainful/cli.rb', line 81

def submit(app, api_key, *args)

  self.host = options[:host]

  self.pretty = options[:pretty] || false

  unless self.host #if invoked though old-style
    self.host =  ENV["LP_HOST"] || 'https://www.lesspainful.com'
  else

  end

  app_path = File.expand_path(app)
  unless File.exist?(app_path)
    raise "App is not a file: #{app_path}"
  end

  self.app = app_path

  self.dry_run = options["dry-run"]

  self.api_key = api_key

  self.skip_check = ENV['CHECK_IPA'] == '0'
  self.skip_check = options["skip-check"] unless options["skip-check"].nil?

  self.reset_between_scenarios = options["reset-between-scenarios"]

  parse_and_set_config_and_profile



  workspace_path = options[:workspace] || File.expand_path(".")

  if args[0]
    workspace_path = args[0]
  end

  unless File.directory?(workspace_path)
    raise "Provided workspace: #{workspace_path} is not a directory."
  end
  self.workspace = File.join(File.expand_path(workspace_path), File::Separator)


  features_path = options[:features]
  features_path = args[1] if args[1]

  unless features_path.nil?
    if File.exist?(features_path)
      self.features_zip = File.expand_path(features_path)
    else
      raise "Provided features file does not exist #{features_path}"
    end
  end

  if ENV['DEBUG']
    puts "Host = #{self.host}"
    puts "App = #{self.app}"
    puts "API Key = #{self.api_key}"
    puts "Workspace = #{self.workspace}"
    puts "Features Zip = #{self.features_zip}"
    puts "Config = #{self.config}"
    puts "Profile = #{self.profile}"
    puts "Skip Check = #{self.skip_check}"
    puts "Reset Between Scenarios = #{self.reset_between_scenarios}"
  end

  #Argument parsing done
  json = submit_test_job

  unless dry_run
    if pretty and JSON.respond_to?(:pretty_generate)
      puts JSON.pretty_generate(json)
    else
      puts json.to_json
    end
  end

end

#versionObject



29
30
31
# File 'lib/lesspainful/cli.rb', line 29

def version
  puts LessPainful::VERSION
end