zenslap 0.2.6 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/zenslap +56 -34
  2. data/zenslap.gemspec +2 -2
  3. metadata +10 -11
@@ -4,40 +4,62 @@ require 'rubygems'
4
4
  require 'heroku'
5
5
  require 'heroku/command'
6
6
 
7
- def error_out(message)
8
- puts message
9
- exit 1
10
- end
11
-
12
- def find_app
13
- github_url = `git config --get remote.origin.url`
14
- zenslap_id = github_url[/github.com.(.+)/, 1].gsub(/\.git$/, "")
15
- error_out "Unable to find zenslap id" unless zenslap_id
16
- puts "Searching for a heroku app for #{zenslap_id}"
17
- heroku = Heroku::Command::Auth.new(nil).client
18
- app = heroku.list.map{|a|a[0]}.find do |app|
19
- heroku.config_vars(app)['ZENSLAP_GITHUB_REPOSITORY'] == zenslap_id
20
- end
21
- error_out "Failed!" unless app
22
- puts "Found #{app}"
23
- app
24
- end
25
-
26
- def retrieve_app
27
- @app ||= %x{ git config zenslap.zenslap }
28
- end
29
-
30
- def store_app(name)
31
- system "git config zenslap.zenslap #{name}"
32
- end
33
-
34
- def app
35
- name = retrieve_app
36
- if name == ""
37
- name = find_app
38
- store_app(name)
7
+ module Zenslap
8
+ extend self
9
+
10
+ module GitConfig
11
+ extend self
12
+
13
+ def zenslap_app
14
+ @app ||= begin
15
+ name = %x{ git config zenslap.zenslap }
16
+ name != "" && name
17
+ end
18
+ end
19
+
20
+ def zenslap_app=(name)
21
+ system "git config zenslap.zenslap #{name}"
22
+ name
23
+ end
24
+
25
+ def github_repository
26
+ @github_repository ||= begin
27
+ github_url = `git config --get remote.origin.url`
28
+ github_repository = github_url[/github.com.(.+)/, 1].gsub(/\.git$/, "")
29
+ error_out "Unable to find a github repository in git config" unless github_repository
30
+ github_repository
31
+ end
32
+ end
33
+
34
+ private
35
+ def error_out(message)
36
+ puts message
37
+ exit 1
38
+ end
39
+ end
40
+
41
+ module Heroku
42
+ extend self
43
+
44
+ def find_app
45
+ puts "Searching for zenslap build environment on heroku"
46
+ app = client.list.map{|a|a[0]}.find do |app|
47
+ client.config_vars(app)['ZENSLAP_GITHUB_REPOSITORY'] == GitConfig.github_repository
48
+ end
49
+ error_out "Failed!" unless app
50
+ puts "Found #{app}"
51
+ app
52
+ end
53
+
54
+ private
55
+ def client
56
+ @client ||= ::Heroku::Auth.client
57
+ end
58
+ end
59
+
60
+ def app
61
+ GitConfig.zenslap_app ||= Heroku.find_app
39
62
  end
40
- name
41
63
  end
42
64
 
43
- exec "heroku #{ARGV.join(" ")} --app #{app}"
65
+ exec "heroku #{ARGV.join(" ")} --app #{Zenslap.app}"
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{zenslap}
8
- s.version = "0.2.6"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["opsb"]
@@ -22,6 +22,6 @@ Gem::Specification.new do |s|
22
22
  s.rubygems_version = %q{1.3.7}
23
23
  s.summary = %q{Client for zenslap continuous integration}
24
24
  s.test_files = Dir.glob("spec/**/*")
25
- s.add_dependency('heroku', ["~> 1.17.8"])
25
+ s.add_dependency('heroku', ["~> 2.0"])
26
26
  end
27
27
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zenslap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease:
4
+ hash: 17
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 6
10
- version: 0.2.6
8
+ - 3
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - opsb
@@ -26,12 +26,11 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 67
29
+ hash: 3
30
30
  segments:
31
- - 1
32
- - 17
33
- - 8
34
- version: 1.17.8
31
+ - 2
32
+ - 0
33
+ version: "2.0"
35
34
  type: :runtime
36
35
  version_requirements: *id001
37
36
  description: Client for zenslap continuous integration
@@ -75,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
74
  requirements: []
76
75
 
77
76
  rubyforge_project:
78
- rubygems_version: 1.6.2
77
+ rubygems_version: 1.3.7
79
78
  signing_key:
80
79
  specification_version: 3
81
80
  summary: Client for zenslap continuous integration