calasmash 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in calasmash.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,17 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ calasmash (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.1.0)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.3)
16
+ calasmash!
17
+ rake
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Alex Fish
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Alex Fish
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ calasmash
2
+ =========
3
+
4
+ A hacky gem to compile a calabash ios target, set some settings bundle values then run cucumber tests
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'calasmash'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install calasmash
19
+
20
+ ## Usage
21
+
22
+ Simply run the command below and pass valid options, workspace and scheme are required.
23
+
24
+ calasmash
25
+
26
+ ### Options
27
+
28
+ -t, --tags TAGS the cucumber tags to test against
29
+ -w, --workspace WORKSPACE the workspace to build
30
+ -s, --scheme SCHEME the scheme to build
31
+ -h, --help help
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/calasmash ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'calasmash'
4
+
5
+ Calasmash::Runner.new(ARGV)
data/calasmash.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'calasmash/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "calasmash"
8
+ spec.version = Calasmash::VERSION
9
+ spec.authors = ["Alex Fish"]
10
+ spec.email = ["fish@ustwo.co.uk"]
11
+ spec.description = "A gift for Juan"
12
+ spec.summary = "Compile an app, run sinatra, point the app at sinatra, run the app tests with calabash"
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+
24
+ spec.add_runtime_dependency "CFPropertyList"
25
+
26
+ spec.executables << "calasmash"
27
+ end
@@ -0,0 +1,3 @@
1
+ module Calasmash
2
+ VERSION = "0.0.3"
3
+ end
data/lib/calasmash.rb ADDED
@@ -0,0 +1,121 @@
1
+ require "calasmash/version"
2
+
3
+ require 'optparse'
4
+ require 'socket'
5
+ require 'cfpropertylist'
6
+ require 'find'
7
+
8
+ module Calasmash
9
+ class Runner
10
+
11
+ def initialize(args)
12
+ @options = parse(args)
13
+ if @options[:valid]
14
+ start
15
+ end
16
+ end
17
+
18
+ def start
19
+ puts "Starting..."
20
+ compile
21
+ update_plist
22
+ sleep(2)
23
+ run_cucumber
24
+ end
25
+
26
+ def parse(args)
27
+ options = {}
28
+ @opt_parser = OptionParser.new do |opt|
29
+ opt.banner = "Usage: calasmash [OPTIONS]"
30
+ opt.separator ""
31
+ opt.separator "Options"
32
+
33
+ opt.on("-t","--tags TAGS","the tags to test against") do |tags|
34
+ options[:tags] = tags
35
+ end
36
+
37
+ opt.on("-w","--workspace WORKSPACE","the workspace to build") do |tags|
38
+ options[:workspace] = tags
39
+ end
40
+
41
+ opt.on("-s","--scheme SCHEME","the scheme to build") do |tags|
42
+ options[:scheme] = tags
43
+ end
44
+
45
+ opt.on("-h","--help","help") do
46
+ puts @opt_parser
47
+ end
48
+ end
49
+
50
+ @opt_parser.parse! args
51
+
52
+ options[:valid] = true
53
+
54
+ validate_options(options)
55
+ end
56
+
57
+ def validate_options(options)
58
+ if options[:workspace].nil?
59
+ puts "Workspace path required, see --help for more information"
60
+ options[:valid] = false
61
+ elsif options[:scheme].nil?
62
+ puts "Scheme required, see --help for more information"
63
+ options[:valid] = false
64
+ end
65
+ options
66
+ end
67
+
68
+ def compile
69
+ puts "Compiling..."
70
+ IO.popen("xcodebuild -workspace #{@options[:workspace]} -scheme #{@options[:scheme]} -sdk iphonesimulator CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO") {|output|
71
+ puts output.read
72
+ }
73
+ end
74
+
75
+ def update_plist
76
+ puts "Updating plist..."
77
+
78
+ ip = Socket.ip_address_list.find {|a| a.ipv4? && !a.ipv4_loopback?}.ip_address
79
+ port = 4567 #sinatras default port
80
+
81
+ plist_file = CFPropertyList::List.new(:file => plist_path)
82
+ plist = CFPropertyList.native_types(plist_file.value)
83
+
84
+ plist["url_preference"] = ip
85
+ plist["port_preference"] = port
86
+
87
+ puts("plist: #{plist}")
88
+
89
+ plist_file.value = CFPropertyList.guess(plist)
90
+ plist_file.save(plist_path, CFPropertyList::List::FORMAT_XML)
91
+
92
+ end
93
+
94
+ def run_cucumber
95
+ puts "Running cucumber..."
96
+ IO.popen("cucumber --tags #{@options[:tags]}") {|output|
97
+ puts output.read
98
+ }
99
+ end
100
+
101
+ def app_path
102
+ files = []
103
+
104
+ Find.find("#{File.expand_path('~')}/Library/Developer/Xcode/DerivedData/") do |path|
105
+ files << path if path =~ /#{@options[:scheme]}.app$/
106
+ end
107
+
108
+ app_path = files.sort_by { |filename| File.mtime(filename)}.last # get the latest
109
+
110
+ return app_path
111
+ end
112
+
113
+ def plist_path
114
+
115
+ plist_path = app_path + "/server_config.plist"
116
+ return plist_path
117
+ end
118
+ end
119
+ end
120
+
121
+
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: calasmash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alex Fish
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-09-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: CFPropertyList
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: A gift for Juan
63
+ email:
64
+ - fish@ustwo.co.uk
65
+ executables:
66
+ - calasmash
67
+ extensions: []
68
+ extra_rdoc_files: []
69
+ files:
70
+ - .gitignore
71
+ - Gemfile
72
+ - Gemfile.lock
73
+ - LICENSE
74
+ - LICENSE.txt
75
+ - README.md
76
+ - Rakefile
77
+ - bin/calasmash
78
+ - calasmash.gemspec
79
+ - lib/calasmash.rb
80
+ - lib/calasmash/version.rb
81
+ homepage: ''
82
+ licenses:
83
+ - MIT
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 1.8.23
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: Compile an app, run sinatra, point the app at sinatra, run the app tests
106
+ with calabash
107
+ test_files: []
108
+ has_rdoc: