xclisten 0.0.2 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f69f3b387090495b0ceee3e114cd64bf0808d76
4
- data.tar.gz: b30d9a0c2a2092f0b445b5f5f7f7c1efa2fbb1fb
3
+ metadata.gz: c22544587e1cd66bc74c2efc30277fc4585d678b
4
+ data.tar.gz: 77643232fcda8643ddaf74a60a495e60f7d26342
5
5
  SHA512:
6
- metadata.gz: b24a0b6b21c8b355eb910c36bd41f4769f4de17eeb6c5d24725e6c7d87fb1eb2e013cb411ce2c41080b050a46d449592275f74150184ad45678c993a3aafb47d
7
- data.tar.gz: 6f8f88c59d2d4c508289f041c765d0f2279099bdbf98efa797cb55c513058b51edbd61f2bdafd5a81ce5d1e927522ca29a2e3a7cc2d09c1e7846224836701b58
6
+ metadata.gz: ae89b027b5536f46e230c65c6eba628de77bc2c2a8e20d6071cfd6cdf117ce68045c0a10eba7932dc17051c03b86d0f77a97afd6a9430d02f7e8c7a0120c5e9f
7
+ data.tar.gz: 0a3b5d0679bde7510bbfe90aa6c91e4f5d0cee52090ec9c435e8abf8113bcadeaa0030eed11fc9bd2d20964d1e4da8f794c7623923ac12c0ff58696b14172ca3
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ # 0.0.2
4
+
5
+ ##### Bug Fixes
6
+
7
+ * Kill child processes on Ctrl-C
8
+
9
+
10
+ # 0.0.1
11
+
12
+ * Initial release
13
+
data/bin/xclisten CHANGED
@@ -8,21 +8,29 @@ require 'xclisten'
8
8
  require 'listen'
9
9
  require 'optparse'
10
10
 
11
+ @options = {}
12
+
11
13
  OptionParser.new do |opts|
12
14
  opts.banner = "Usage: xcodebuild [options] | xcpretty"
13
15
  opts.on('--osx', 'Run with OSX sdk (without simulator)') do
14
- XCListen::SDK = ''
16
+ @options[:sdk] = ''
15
17
  end
16
18
  opts.on('--ios', '[DEFAULT] Run with iOS sdk') do
17
- XCListen::SDK = '-sdk iphonesimulator'
19
+ @options[:sdk] = '-sdk iphonesimulator'
20
+ end
21
+ opts.on('-d', '--device', 'Simulated device [iphone5s, iphone5, iphone4]. Default is iphone5s') do |device|
22
+ @options[:device] = device
23
+ end
24
+ opts.on('-s', '--scheme', 'BYOS (Bring your own scheme)') do |scheme|
25
+ @options[:scheme] = scheme
18
26
  end
19
27
  opts.on_tail('-h', '--help', 'Show this message') { puts opts; exit }
20
28
  opts.on_tail("-v", "--version", "Show version") { puts XCListen::VERSION; exit }
21
29
  opts.parse!
22
30
  end
23
31
 
24
- pid = fork { XCListen.listen }
32
+ pid = fork { XCListen.new(@options).listen }
25
33
  trap("SIGINT") { Process.kill(9, pid) }
26
34
 
27
- Process.waitpid(pid)
35
+ Process.wait(pid)
28
36
 
@@ -0,0 +1,13 @@
1
+ class XCListen
2
+
3
+ class ShellTask
4
+
5
+ def self.run(args)
6
+ puts args + "\n\n"
7
+ fork { exec args }
8
+ end
9
+
10
+ end
11
+
12
+ end
13
+
@@ -1,3 +1,4 @@
1
- module XCListen
2
- VERSION = "0.0.2"
1
+ class XCListen
2
+ VERSION = "0.0.3"
3
3
  end
4
+
data/lib/xclisten.rb CHANGED
@@ -1,22 +1,37 @@
1
- require "xclisten/version"
1
+ require 'xclisten/version'
2
+ require 'xclisten/shell_task'
2
3
  require 'listen'
3
4
 
4
- module XCListen
5
+ class XCListen
5
6
 
6
- module_function
7
+ attr_reader :device
8
+ attr_reader :scheme
9
+ attr_reader :sdk
7
10
 
8
- SDK = '-sdk iphonesimulator'
11
+ def initialize(opts = {})
12
+ @device = IOS_DEVICES[opts[:device]] || IOS_DEVICES['iphone5s']
13
+ @scheme = opts[:scheme] || project_name
14
+ @sdk = opts[:sdk] || 'iphonesimulator'
15
+ end
16
+
17
+ IOS_DEVICES = {
18
+ 'iphone5s' => 'iPhone Retina (4-inch 64-bit)',
19
+ 'iphone5' => 'iPhone Retina (4-inch)',
20
+ 'iphone4' => 'iPhone Retina (3.5-inch)'
21
+ }
9
22
 
23
+ #TODO: make this recursive
10
24
  def workspace_name
11
25
  Dir.entries(Dir.pwd).detect { |f| f =~ /.xcworkspace/ }
12
26
  end
13
27
 
28
+ #TODO: when workspace_name gets recursive, use `basename`
14
29
  def project_name
15
30
  workspace_name.split('.').first
16
31
  end
17
32
 
18
33
  def xcodebuild
19
- "xcodebuild -workspace #{workspace_name} -scheme #{project_name} #{SDK}"
34
+ "xcodebuild -workspace #{workspace_name} -scheme #{@scheme} -sdk #{@sdk} -destination 'name=#{@device}'"
20
35
  end
21
36
 
22
37
  def install_pods
@@ -26,9 +41,7 @@ module XCListen
26
41
  end
27
42
 
28
43
  def run_tests
29
- task = "#{xcodebuild} test 2> xcodebuild_error.log | xcpretty -tc"
30
- puts task + "\n\n"
31
- system(task)
44
+ ShellTask.run("#{xcodebuild} test 2> xcodebuild_error.log | xcpretty -tc")
32
45
  end
33
46
 
34
47
  def listen
@@ -0,0 +1,59 @@
1
+ require 'xclisten'
2
+
3
+ class XCListen
4
+
5
+ describe XCListen do
6
+
7
+ class ShellTask
8
+ def run(args)
9
+ @command = args
10
+ end
11
+ end
12
+
13
+ before(:each) do
14
+ Dir.stub(:entries).and_return(['SampleProject.xcworkspace'])
15
+ end
16
+
17
+ context "Defaults" do
18
+
19
+ before(:each) do
20
+ @xclisten = XCListen.new
21
+ end
22
+
23
+ it "runs runs tests on iPhone 5s by default" do
24
+ @xclisten.device.should == 'iPhone Retina (4-inch 64-bit)'
25
+ end
26
+
27
+ it "uses the project name as the default scheme" do
28
+ @xclisten.scheme.should == 'SampleProject'
29
+ end
30
+
31
+ it "uses iphonesimulator sdk by default" do
32
+ @xclisten.sdk.should == 'iphonesimulator'
33
+ end
34
+
35
+ end
36
+
37
+ it "initializes with device" do
38
+ xclisten = XCListen.new(:device => 'iphone5')
39
+ xclisten.device.should == 'iPhone Retina (4-inch)'
40
+ end
41
+
42
+ it "initializes with a different scheme" do
43
+ xclisten = XCListen.new(:scheme => 'AnotherScheme')
44
+ xclisten.scheme.should == 'AnotherScheme'
45
+ end
46
+
47
+ it 'initializes with SDK' do
48
+ xclisten = XCListen.new(:sdk => 'iphonesimulator')
49
+ xclisten.sdk.should == 'iphonesimulator'
50
+ end
51
+
52
+ it 'uses xcodebuild with given flags' do
53
+ xclisten = XCListen.new
54
+ xclisten.xcodebuild.should == "xcodebuild -workspace SampleProject.xcworkspace -scheme SampleProject -sdk iphonesimulator -destination 'name=iPhone Retina (4-inch 64-bit)'"
55
+ end
56
+ end
57
+
58
+ end
59
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xclisten
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marin Usalj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-05 00:00:00.000000000 Z
11
+ date: 2014-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: listen
@@ -62,13 +62,16 @@ extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
64
  - ".gitignore"
65
+ - CHANGELOG.md
65
66
  - Gemfile
66
67
  - LICENSE.txt
67
68
  - README.md
68
69
  - Rakefile
69
70
  - bin/xclisten
70
71
  - lib/xclisten.rb
72
+ - lib/xclisten/shell_task.rb
71
73
  - lib/xclisten/version.rb
74
+ - spec/lib/xclisten_spec.rb
72
75
  - xclisten.gemspec
73
76
  homepage: https://github.com/mneorr/xclisten
74
77
  licenses:
@@ -94,4 +97,5 @@ rubygems_version: 2.2.0
94
97
  signing_key:
95
98
  specification_version: 4
96
99
  summary: Run ObjectiveC tests each time you hit save
97
- test_files: []
100
+ test_files:
101
+ - spec/lib/xclisten_spec.rb