tug 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tug (0.1.2)
4
+ tug (0.2.0)
5
5
  thor
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -129,6 +129,8 @@ $ tug deploy hockeyapp
129
129
 
130
130
  ### Provision
131
131
 
132
+ > :warning: Beware of running this command on a local dev machine, this should only be run on CI servers as your keychain is altered.
133
+
132
134
  Tug can provision a new machine ready for signing ipas by installing the certificates and provisioning profile required for generating a signed ipa of your application, this is very useful for CI environments like Travis.
133
135
 
134
136
  ```
@@ -6,4 +6,4 @@ keychain:
6
6
  apple_certificate: apple.cer
7
7
  distribution_certificate: dist.cer
8
8
  distribution_profile: profile.mobileprovision
9
- private_key: dist.p12
9
+ private_key: dist.p12
@@ -30,8 +30,8 @@ module Tug
30
30
  end
31
31
 
32
32
  def initialize(path)
33
- config = YAML::load_file(path)
34
- @project = Tug::Project.new(config)
33
+ config = YAML::load_file(path)
34
+ @project = Tug::Project.new(config)
35
35
  @keychain = Tug::Keychain.keychain(config)
36
36
  end
37
37
 
@@ -108,7 +108,19 @@ module Tug
108
108
  execute(__method__.to_s, config_file)
109
109
  end
110
110
 
111
- desc "provision", "provision system distrubution certificates and provisioning profile"
111
+ desc "notify", "notify your team via slack"
112
+ option :message,
113
+ :aliases => "-m",
114
+ :required => true
115
+ option :webhook_url,
116
+ :aliases => "-w",
117
+ :default => ENV['TUG_SLACK_WEBHOOK_URL']
118
+ def notify
119
+ slack = Tug::Slack.new(options)
120
+ slack.notify(options[:message])
121
+ end
122
+
123
+ desc "provision", "provision system distrubution certificates and provisioning profile, don't run this on a local dev machine"
112
124
  option :config,
113
125
  :default => "#{Dir.pwd}/.tug.yml",
114
126
  :aliases => "-c"
@@ -0,0 +1,31 @@
1
+ module Tug
2
+ class Slack
3
+
4
+ attr_accessor :url
5
+
6
+ def initialize(options)
7
+ @url = options[:webhook_url]
8
+ end
9
+
10
+ def notify(text)
11
+ unless @url.nil?
12
+ IO.popen("curl #{@url} -X POST -# #{params(text)}") do |pipe|
13
+ puts pipe.read
14
+ end
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def params(text)
21
+ "-F payload='#{payload(text).to_json}'"
22
+ end
23
+
24
+ def payload(text)
25
+ {
26
+ "text" => text,
27
+ "color"=> "good",
28
+ }
29
+ end
30
+ end
31
+ end
data/lib/tug/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tug
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/tug.rb CHANGED
@@ -2,6 +2,7 @@ require "optparse"
2
2
  require 'yaml'
3
3
  require 'thor'
4
4
  require 'fileutils'
5
+ require 'json'
5
6
 
6
7
  require "tug/version"
7
8
 
@@ -30,4 +31,6 @@ require "tug/deployment/deployer"
30
31
  require "tug/deployment/testflight"
31
32
  require "tug/deployment/hockeyapp"
32
33
  require "tug/deployment/notes_parser"
33
- require "tug/deployment/notes_file_parser"
34
+ require "tug/deployment/notes_file_parser"
35
+
36
+ require "tug/notify/slack"
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Tug::Keychain do
3
+ describe Tug::Keychain do
4
4
 
5
5
  before(:each) do
6
6
  @yaml = keychain_yaml
@@ -104,7 +104,7 @@ describe Tug::Keychain do
104
104
  end
105
105
 
106
106
  describe "when importing profiles" do
107
-
107
+
108
108
  before(:each) do
109
109
  allow(FileUtils).to receive(:mkdir_p)
110
110
  end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Tug::Slack do
4
+
5
+ before(:each) do
6
+ @options = {:webhook_url => "slack_url"}
7
+ @slack = Tug::Slack.new(@options)
8
+ end
9
+
10
+ describe "when notifying" do
11
+ it "should send a payload to slack with text" do
12
+ expect(IO).to receive(:popen).with(/"text\":\"text\"/)
13
+ @slack.notify("text")
14
+ end
15
+
16
+ it "should send a payload to slack with a color" do
17
+ expect(IO).to receive(:popen).with(/\"color\":\"good\"/)
18
+ @slack.notify("text")
19
+ end
20
+
21
+ it "should send a payload with the webhook url" do
22
+ expect(IO).to receive(:popen).with(/slack_url/)
23
+ @slack.notify("text")
24
+ end
25
+
26
+ it "shouldn't send a payload if missing a url" do
27
+ slack = Tug::Slack.new({"foo" => "bar"})
28
+ expect(IO).to_not receive(:popen)
29
+ slack.notify("text")
30
+ end
31
+ end
32
+ end
data/spec/spec_helper.rb CHANGED
@@ -5,17 +5,37 @@ CodeClimate::TestReporter.start
5
5
 
6
6
  module Helpers
7
7
  def project_yaml
8
- {"project" => {"workspace" => "workspace",
9
- "schemes" => ["scheme"],
10
- "ipa_config" => "config",
11
- "ipa_profile" => "profile"}}
8
+ {
9
+ "project" =>
10
+ {
11
+ "workspace" => "workspace",
12
+ "schemes" => ["scheme"],
13
+ "ipa_config" => "config",
14
+ "ipa_profile" => "profile"
15
+ }
16
+ }
12
17
  end
13
18
 
14
19
  def keychain_yaml
15
- {"keychain" => {"apple_certificate" => "apple",
16
- "distribution_certificate" => "dist",
17
- "distribution_profile" => "path/to/profile",
18
- "private_key" => "private"}}
20
+ {
21
+ "keychain" =>
22
+ {
23
+ "apple_certificate" => "apple",
24
+ "distribution_certificate" => "dist",
25
+ "distribution_profile" => "path/to/profile",
26
+ "private_key" => "private"
27
+ }
28
+ }
29
+ end
30
+
31
+ def slack_yaml
32
+ {
33
+ "slack" =>
34
+ {
35
+ "team" => "slack_team",
36
+ "channel" => "#slack_channel"
37
+ }
38
+ }
19
39
  end
20
40
 
21
41
  def release_notes_path
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
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: 2015-01-15 00:00:00.000000000 Z
12
+ date: 2015-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -143,6 +143,7 @@ files:
143
143
  - lib/tug/deployment/testflight.rb
144
144
  - lib/tug/interface/interface.rb
145
145
  - lib/tug/keychain/keychain.rb
146
+ - lib/tug/notify/slack.rb
146
147
  - lib/tug/project/project.rb
147
148
  - lib/tug/tool/xcode_build.rb
148
149
  - lib/tug/tool/xctool.rb
@@ -162,6 +163,7 @@ files:
162
163
  - spec/output.txt
163
164
  - spec/project_spec.rb
164
165
  - spec/release_notes_spec.rb
166
+ - spec/slack_spec.rb
165
167
  - spec/spec_helper.rb
166
168
  - spec/test_notes.txt
167
169
  - spec/test_special_notes.txt
@@ -207,6 +209,7 @@ test_files:
207
209
  - spec/output.txt
208
210
  - spec/project_spec.rb
209
211
  - spec/release_notes_spec.rb
212
+ - spec/slack_spec.rb
210
213
  - spec/spec_helper.rb
211
214
  - spec/test_notes.txt
212
215
  - spec/test_special_notes.txt