yolo 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,9 +37,10 @@ module Yolo
37
37
  def app_path
38
38
  files = []
39
39
  Find.find(@xcode.build_path) do |path|
40
- files << path if path =~ /.*#{name}-.*\/Build\/Products\/.*-iphoneos\/.*\.app$/
40
+ files << path if path =~ /\/Build\/Products\/.*-iphoneos\/#{name}\.app$/
41
41
  end
42
- files.sort_by { |filename| File.mtime(filename)}.last # get the latest
42
+ path = files.sort_by { |filename| File.mtime(filename)}.last # get the latest
43
+ path
43
44
  end
44
45
 
45
46
  #
@@ -118,24 +119,45 @@ module Yolo
118
119
  # @param ipa_path [String] The full path to the IPA file to deploy
119
120
  #
120
121
  def deploy(ipa_path)
122
+ klass = deploy_class_from_string "#{self.deployment.to_s}"
123
+ if klass
124
+ klass.deploy(ipa_path, options) do |url, password|
125
+ send_notification(url, password)
126
+ end
127
+ end
128
+ end
129
+
130
+ #
131
+ # Sends a notificaiton email from a deployment
132
+ # @param url [String] The URL which the build has been deplyed too
133
+ # @param password [String] The password required to install the build
134
+ #
135
+ # @return [type] [description]
136
+ def send_notification(url, password)
137
+ if url
138
+ mail_options = {
139
+ :to => self.mail_to,
140
+ :ota_url => url,
141
+ :subject => "New #{name} build: #{version}",
142
+ :title => name
143
+ }
144
+ mail_options[:ota_password] = password if password
145
+ @emailer.send(mail_options)
146
+ end
147
+ end
148
+
149
+ #
150
+ # Initlizes an object from a deployment string
151
+ # @param string [String] the deployment class name string
152
+ #
153
+ # @return [Object] an object of type specified in the paramater
154
+ def deploy_class_from_string(string)
121
155
  klass = Object.const_get("Yolo").const_get("Deployment").const_get("#{self.deployment.to_s}").new
122
156
  unless klass
123
157
  @error_formatter.deployment_class_error(self.deployment.to_s)
124
158
  return
125
159
  end
126
-
127
- klass.deploy(ipa_path, options) do |url, password|
128
- if url
129
- mail_options = {
130
- :to => self.mail_to,
131
- :ota_url => url,
132
- :subject => "New #{name} build: #{version}",
133
- :title => name
134
- }
135
- mail_options[:ota_password] = password if password
136
- @emailer.send(mail_options)
137
- end
138
- end
160
+ klass
139
161
  end
140
162
 
141
163
  #
@@ -146,7 +146,8 @@ module Yolo
146
146
  #
147
147
  # @return [String] The commit hash
148
148
  def latest_commit
149
- match = log.scan(/\b[0-9a-f]{5,40}\b/).first
149
+ matches = log.scan(/\b[0-9a-f]{5,40}\b/)
150
+ match = matches.first
150
151
  if match.nil?
151
152
  ""
152
153
  else
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Config::Install do
4
5
  describe "when installing" do
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Config::Settings do
4
5
 
@@ -47,6 +48,12 @@ describe Yolo::Config::Settings do
47
48
  File.stub(:open)
48
49
  File.stub(:exist?){true}
49
50
  File.stub(:directory?){true}
51
+ @yaml = {
52
+ "deployment" => {
53
+ "api_token" => nil,
54
+ "team_token" => nil
55
+ }
56
+ }
50
57
  end
51
58
 
52
59
  it "should add an api token if missing" do
@@ -62,6 +69,16 @@ describe Yolo::Config::Settings do
62
69
  Yolo::Config::Settings.instance.update_config
63
70
  @yaml["deployment"]["team_token"].should eq("example")
64
71
  end
72
+
73
+ it "should write the new config file to disk" do
74
+ YAML.stub(:load_file){@yaml}
75
+ file = mock(File)
76
+ file.stub(:write)
77
+ File.stub(:open).and_yield(file)
78
+
79
+ file.should_receive(:write)
80
+ Yolo::Config::Settings.instance.update_config
81
+ end
65
82
  end
66
83
 
67
84
  describe "when asked for settings" do
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Deployment::BaseDeployer do
4
5
 
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Deployment::OTA do
4
5
 
@@ -90,6 +91,12 @@ describe Yolo::Deployment::OTA do
90
91
  @ota.upload_complete("json")
91
92
  end
92
93
 
94
+ it "should not continue if json parsing fails" do
95
+ JSON.stub(:parse){nil}
96
+ @error_formatter.should_receive(:deploy_failed)
97
+ @ota.upload_complete("json")
98
+ end
99
+
93
100
  it "should parse the response" do
94
101
  @ota.deploy("test", nil) do |url, password|
95
102
  password.should eq("test_password")
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Deployment::TestFlight do
4
5
 
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Notify::Email do
4
5
 
@@ -6,6 +7,9 @@ describe Yolo::Notify::Email do
6
7
  Yolo::Formatters::ErrorFormatter.any_instance.stub(:puts)
7
8
  Yolo::Formatters::ProgressFormatter.any_instance.stub(:puts)
8
9
 
10
+ @error_formatter = mock(Yolo::Formatters::ErrorFormatter)
11
+ Yolo::Formatters::ErrorFormatter.stub(:new){@error_formatter}
12
+
9
13
  @settings = Yolo::Config::Settings
10
14
  @settings.any_instance.stub(:mail_host){"test_host"}
11
15
  @settings.any_instance.stub(:mail_from){"test_from"}
@@ -13,7 +17,6 @@ describe Yolo::Notify::Email do
13
17
  @settings.any_instance.stub(:mail_account){"test_account"}
14
18
  @settings.any_instance.stub(:mail_password){"test_password"}
15
19
  @email = Yolo::Notify::Email.new
16
- @email.stub(:body){"test body"}
17
20
  @email.to = "test_to"
18
21
  end
19
22
 
@@ -37,6 +40,10 @@ describe Yolo::Notify::Email do
37
40
  it "should load a password" do
38
41
  @email.password.should eq("test_password")
39
42
  end
43
+
44
+ it "should return an empty body" do
45
+ @email.body({}).should eq("")
46
+ end
40
47
  end
41
48
 
42
49
  describe "when sending" do
@@ -47,6 +54,7 @@ describe Yolo::Notify::Email do
47
54
  @smtp.stub(:send_message)
48
55
  @smtp.stub(:enable_starttls)
49
56
  @options = {}
57
+ @email.stub(:body){"test body"}
50
58
  end
51
59
 
52
60
  describe "with an account" do
@@ -65,6 +73,7 @@ describe Yolo::Notify::Email do
65
73
  before do
66
74
  @smtp.stub(:start).and_yield(@smtp)
67
75
  @email.account = nil
76
+ @email.stub(:body){"test body"}
68
77
  end
69
78
 
70
79
  it "should not send with tls" do
@@ -76,6 +85,12 @@ describe Yolo::Notify::Email do
76
85
  @smtp.should_receive(:send_message).with("test body", "test_from", "test_to")
77
86
  @email.send(@options)
78
87
  end
88
+
89
+ it "should output an error if missing details" do
90
+ @email.server = nil
91
+ @error_formatter.should_receive(:missing_email_details)
92
+ @email.send(@options)
93
+ end
79
94
  end
80
95
 
81
96
  describe "and loading options" do
@@ -83,6 +98,7 @@ describe Yolo::Notify::Email do
83
98
  before do
84
99
  @email.to = "test_to"
85
100
  @email.send(@options)
101
+ @email.stub(:body){"test body"}
86
102
  end
87
103
 
88
104
  it "should load a server if missing" do
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Notify::Ios::OTAEmail do
4
5
 
@@ -1,5 +1,4 @@
1
1
  require 'coveralls'
2
- require 'yolo'
3
2
  require 'active_support/all'
4
3
 
5
4
  Coveralls.wear!
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Tasks::BaseTask do
4
5
 
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Tasks::Ios::Build do
4
5
  describe "when building an options string" do
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Tasks::Ios::Calabash do
4
5
  before do
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Tasks::Ios::Coverage do
4
5
  before do
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Tasks::Ios::OCUnit do
4
5
  before do
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Tasks::Ios::Release do
4
5
  before do
@@ -1,14 +1,19 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Tools::Git do
4
5
 
5
6
  before do
6
- @git = Yolo::Tools::Git.new
7
- @git.project_name = "test"
8
7
  YAML.stub!(:load_file){{}}
9
8
  Yolo::Formatters::ProgressFormatter.any_instance.stub(:puts)
10
9
  end
11
10
 
11
+ before(:each) do
12
+ @git = Yolo::Tools::Git.new
13
+ @git.project_name = "test"
14
+ File.any_instance.stub(:write)
15
+ end
16
+
12
17
  describe "when checking for new commits" do
13
18
  before do
14
19
  @git.stub(:update_commit)
@@ -25,6 +30,11 @@ describe Yolo::Tools::Git do
25
30
  Yolo::Tools::Git.any_instance.stub(:latest_commit){"old"}
26
31
  @git.has_new_commit("").should eq(false)
27
32
  end
33
+
34
+ it "yaml tag should be empty if no project is set" do
35
+ @git.project_name = nil
36
+ @git.instance_eval{yaml_tag}.should eq("")
37
+ end
28
38
  end
29
39
 
30
40
  describe "when checking for new tags" do
@@ -43,6 +53,11 @@ describe Yolo::Tools::Git do
43
53
  Yolo::Tools::Git.any_instance.stub(:latest_tag){"old"}
44
54
  @git.has_new_tag("").should eq(false)
45
55
  end
56
+
57
+ it "yaml commit should be empty if no project is set" do
58
+ @git.project_name = nil
59
+ @git.instance_eval{yaml_commit}.should eq("")
60
+ end
46
61
  end
47
62
 
48
63
  describe "when updating tags and commits" do
@@ -71,6 +86,20 @@ describe Yolo::Tools::Git do
71
86
  @git.instance_eval{yaml_commit}.should match("new commit")
72
87
  end
73
88
 
89
+ it "should overwrite the existing tag" do
90
+ @yaml = {"test" => {"tag" => "v1.2"}}
91
+ @git.instance_variable_set(:@yaml, @yaml)
92
+ @git.instance_eval{update_tag("new tag")}
93
+ @yaml["test"]["tag"].should eq("new tag")
94
+ end
95
+
96
+ it "should overwrite the existing commit" do
97
+ @yaml = {"test" => {"commit" => "1234567891023"}}
98
+ @git.instance_variable_set(:@yaml, @yaml)
99
+ @git.instance_eval{update_commit("new commit")}
100
+ @yaml["test"]["commit"].should eq("new commit")
101
+ end
102
+
74
103
  end
75
104
 
76
105
  describe "when saving data" do
@@ -96,6 +125,20 @@ describe Yolo::Tools::Git do
96
125
  @git.instance_eval{latest_tag}.should eq("v1.0")
97
126
  end
98
127
 
128
+ it "should not get invalid tags" do
129
+ @log = ""
130
+ @log.stub(:scan){}
131
+ @git.stub(:log){@log}
132
+ @git.instance_eval{latest_tag}.should eq("")
133
+ end
134
+
135
+ it "should not get invalid commits" do
136
+ @log = ""
137
+ @log.stub(:scan){[]}
138
+ @git.stub(:log){@log}
139
+ @git.instance_eval{latest_commit}.should eq("")
140
+ end
141
+
99
142
  it "should ignore jenkins tags" do
100
143
  @git.stub(:log){"tag: jenkins-tag, head, tag: v1.3.1, master"}
101
144
  @git.instance_eval{latest_tag}.should_not eq("jenkins-tag")
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Tools::Ios::Calabash do
4
5
 
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Tools::Ios::Coverage do
4
5
 
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Tools::Ios::IPA do
4
5
 
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Tools::Ios::ReleaseNotes do
4
5
 
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'yolo'
2
3
 
3
4
  describe Yolo::Tools::Ios::Xcode do
4
5
  before do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yolo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-12 00:00:00.000000000 Z
12
+ date: 2013-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xcodebuild-rb