zenslap 0.2.3 → 0.2.4

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.
Files changed (3) hide show
  1. data/bin/zenslap +35 -14
  2. data/zenslap.gemspec +1 -1
  3. metadata +3 -3
data/bin/zenslap CHANGED
@@ -1,23 +1,44 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- def valid_app?(app)
4
- `heroku config --app #{app}`
5
- $?.to_i == 0
3
+ require 'rubygems'
4
+ require 'heroku'
5
+ require 'heroku/command'
6
+ require 'ruby-debug'
7
+
8
+ def error_out(message)
9
+ puts message
10
+ exit 1
11
+ end
12
+
13
+ def find_app
14
+ github_url = `git config --get remote.origin.url`
15
+ zenslap_id = github_url[/github.com.(.+)/, 1].gsub(/\.git$/, "")
16
+ error_out "Unable to find zenslap id" unless zenslap_id
17
+ puts "Searching for a heroku app for #{zenslap_id}"
18
+ heroku = Heroku::Command::Auth.new(nil).client
19
+ app = heroku.list.map{|a|a[0]}.find do |app|
20
+ heroku.config_vars(app)['ZENSLAP_ID'] == zenslap_id
21
+ end
22
+ error_out "Failed!" unless app
23
+ puts "Found #{app}"
24
+ app
25
+ end
26
+
27
+ def retrieve_app
28
+ @app ||= %x{ git config zenslap.zenslap }
29
+ end
30
+
31
+ def store_app(name)
32
+ system "git config zenslap.zenslap #{name}"
6
33
  end
7
34
 
8
35
  def app
9
- app=%x{ git config zenslap.zenslap }
10
- while app == ""
11
- puts "\nEnter the name of the zenslap app"
12
- unvalidated_app = STDIN.gets.chomp
13
- if unvalidated_app == ""
14
- # retry
15
- elsif valid_app? unvalidated_app
16
- system "git config zenslap.zenslap #{unvalidated_app}"
17
- app = unvalidated_app
18
- end
36
+ name = retrieve_app
37
+ if name == ""
38
+ name = find_app
39
+ store_app(name)
19
40
  end
20
- app
41
+ name
21
42
  end
22
43
 
23
44
  exec "heroku #{ARGV.join(" ")} --app #{app}"
data/zenslap.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{zenslap}
8
- s.version = "0.2.3"
8
+ s.version = "0.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["opsb"]
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: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - opsb