Class: Calasmash::Command
- Inherits:
-
Object
- Object
- Calasmash::Command
- Defined in:
- lib/calasmash/command.rb
Overview
The main point of entry for all commands, Command parses command line arguments and decides what to do about them.
Class Method Summary collapse
-
.compile(scheme, &compiled) ⇒ Object
Kick off a compile.
-
.execute(*args) ⇒ type
Execute a command with some arguments then figure out what we’re supposed to be doing with the arguments.
-
.overview ⇒ Object
Outputs a nice helpful banner overview to STDOUT.
-
.parse(args) ⇒ Hash
parse the arguments and act on them.
-
.run_tests(ios, tags, format = nil, output = nil) ⇒ Object
Run the cucumber tests, that’s why we’re here afterall.
-
.update_plist(scheme) ⇒ Object
Update the applications plist so that the application connects to sinatra.
Class Method Details
.compile(scheme, &compiled) ⇒ Object
Kick off a compile
82 83 84 85 86 87 |
# File 'lib/calasmash/command.rb', line 82 def compile(scheme, &compiled) compiler = Calasmash::Compiler.new(scheme) compiler.compile do |complete| yield end end |
.execute(*args) ⇒ type
Execute a command with some arguments then figure out what we’re supposed to be doing with the arguments
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/calasmash/command.rb', line 24 def execute(*args) return overview unless args.length > 1 = parse(args) scheme = [:scheme] ios = [:ios] = [:tags] format = [:format] output = [:output] # Compile the project compile(scheme) do # Update the plist update_plist(scheme) # Run the tests run_tests(ios, , format, output) end end |
.overview ⇒ Object
Outputs a nice helpful banner overview to STDOUT
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/calasmash/command.rb', line 116 def overview s = "Usage: calasmash [OPTIONS]" s << "\n --tags -t the tags to pass to cucumber, for multiple tags pass one per tag" s << "\n --scheme -s the Xcode scheme to build" s << "\n --ios -i the iOS version to build with" s << "\n --output -o The output directory for the test report" s << "\n --format -f The format of the test report" puts s end |
.parse(args) ⇒ Hash
parse the arguments and act on them
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/calasmash/command.rb', line 48 def parse(args) = {} [:tags] = [] OptionParser.new do |opt| opt.on("-s","--scheme SCHEME","the scheme to build") do || [:scheme] = end opt.on("-t","--tags TAGS","the tags to pass to Cucumber") do |tag_set| [:tags] << tag_set end opt.on("-i", "--ios OS", "iOS simulator version of the sdk to run e.g. 6.0 or 7.0") do || [:ios] = end opt.on("-f", "--format FORMAT", "the format of the test reports to output") do |format| [:format] = format end opt.on("-o", "--output OUTPUT", "the output path for the test results") do |output| [:output] = output end end.parse! return end |
.run_tests(ios, tags, format = nil, output = nil) ⇒ Object
Run the cucumber tests, that’s why we’re here afterall
106 107 108 109 110 111 |
# File 'lib/calasmash/command.rb', line 106 def run_tests(ios, , format=nil, output=nil) cucumber = Calasmash::Cucumber.new(ios, ) cucumber.format = format if format cucumber.output = output if output cucumber.test end |