hanzo 0.1.2 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,15 @@
1
- # Hanzo
2
-
3
- Hanzo is a Ruby library that allows a team to easily share environment endpoints for Heroku apps.
1
+ <p align="center">
2
+ <a href="https://github.com/mirego/hanzo">
3
+ <img src="http://i.imgur.com/RZbJy1u.png" alt="Hanzo" />
4
+ </a>
5
+ <br />
6
+ Hanzo is a sharp tool to handle deployments in multiple environments on Heroku.
7
+ <br /><br />
8
+ <a href="https://rubygems.org/gems/hanzo"><img src="https://badge.fury.io/rb/hanzo.png" /></a>
9
+ <a href="https://codeclimate.com/github/mirego/hanzo"><img src="https://codeclimate.com/github/mirego/hanzo.png" /></a>
10
+ </p>
11
+
12
+ ---
4
13
 
5
14
  ## Installation
6
15
 
data/hanzo.gemspec CHANGED
@@ -24,5 +24,4 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'rspec'
25
25
 
26
26
  spec.add_dependency 'highline'
27
- spec.add_dependency 'heroku'
28
27
  end
data/lib/hanzo/heroku.rb CHANGED
@@ -3,7 +3,7 @@ module Hanzo
3
3
  class << self
4
4
 
5
5
  def available_labs
6
- `bundle exec heroku labs`.each_line.to_a.inject([]) do |memo, line|
6
+ `heroku labs`.each_line.to_a.inject([]) do |memo, line|
7
7
  if line = /^\[\s\]\s+(?<name>\w+)\s+(?<description>.+)$/.match(line)
8
8
  memo << [line[:name], line[:description]]
9
9
  else
@@ -5,6 +5,10 @@ module Hanzo
5
5
 
6
6
  def initialize_variables
7
7
  @env = extract_argument(1)
8
+
9
+ if @env.nil? and Hanzo::Installers::Remotes.environments.keys.length == 1
10
+ @env = Hanzo::Installers::Remotes.environments.keys.first
11
+ end
8
12
  end
9
13
 
10
14
  def initialize_cli
@@ -19,15 +23,15 @@ module Hanzo
19
23
  end
20
24
 
21
25
  def deploy
22
- branch = ask("-----> Branch to deploy in #{@env}: ") { |q| q.default = "HEAD" }
26
+ branch = Hanzo.ask("Branch to deploy in #{@env}:") { |q| q.default = "HEAD" }
23
27
 
24
- `git push -f #{@env} #{branch}:master`
28
+ Hanzo.run "git push -f #{@env} #{branch}:master"
25
29
  end
26
30
 
27
31
  def run_migrations
28
32
  if Dir.exists?('db/migrate')
29
- migration = agree("-----> Run migrations? ")
30
- `bundle exec heroku run rake db:migrate --remote #{@env}` if migration
33
+ migration = Hanzo.agree('Run migrations?')
34
+ Hanzo.run "heroku run rake db:migrate --remote #{@env}" if migration
31
35
  end
32
36
  end
33
37
  end
@@ -2,10 +2,10 @@ module Hanzo
2
2
  module Installers
3
3
  module Labs
4
4
  def install_labs
5
- puts '-----> Activating Heroku Labs'
5
+ Hanzo.title 'Activating Heroku Labs'
6
6
 
7
7
  Hanzo::Heroku.available_labs.each do |name, description|
8
- if agree(" Add #{name}? ")
8
+ if Hanzo.agree("Add #{name}?")
9
9
  Hanzo::Installers::Remotes.environments.each_pair do |env, app|
10
10
  Hanzo::Installers::Labs.enable(env, lab)
11
11
  end
@@ -14,8 +14,8 @@ module Hanzo
14
14
  end
15
15
 
16
16
  def self.enable(env, lab)
17
- `bundle exec heroku labs:enable #{lab} --remote #{env}`
18
- puts " - Enabled for #{env}"
17
+ Hanzo.run "heroku labs:enable #{lab} --remote #{env}"
18
+ Hanzo.print "- Enabled for #{env}"
19
19
  end
20
20
  end
21
21
  end
@@ -2,7 +2,7 @@ module Hanzo
2
2
  module Installers
3
3
  module Remotes
4
4
  def install_remotes
5
- puts '-----> Creating git remotes'
5
+ Hanzo.title 'Creating git remotes'
6
6
 
7
7
  Hanzo::Installers::Remotes.environments.each_pair do |env, app|
8
8
  Hanzo::Installers::Remotes.add_remote(app, env)
@@ -10,16 +10,16 @@ module Hanzo
10
10
  end
11
11
 
12
12
  def self.add_remote(app, env)
13
- puts " Adding #{env}"
14
- `git remote rm #{env} 2>&1 > /dev/null`
15
- `git remote add #{env} git@heroku.com:#{app}.git`
13
+ Hanzo.print "Adding #{env}"
14
+ Hanzo.run "git remote rm #{env} 2>&1 > /dev/null"
15
+ Hanzo.run "git remote add #{env} git@heroku.com:#{app}.git"
16
16
  end
17
17
 
18
18
  def self.environments
19
19
  return YAML.load_file('.heroku-remotes') if File.exists?('.heroku-remotes')
20
20
 
21
- puts ' Can\'t locate .heroku-remotes'
22
- puts ' For more information, please read https://github.com/mirego/hanzo'
21
+ Hanzo.print 'Cannot locate .heroku-remotes'
22
+ Hanzo.print 'For more information, please read https://github.com/mirego/hanzo'
23
23
  exit
24
24
  end
25
25
  end
data/lib/hanzo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hanzo
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2'
3
3
  end
data/lib/hanzo.rb CHANGED
@@ -6,3 +6,27 @@ require 'hanzo/base'
6
6
  require 'hanzo/cli'
7
7
  require 'hanzo/heroku'
8
8
  require 'hanzo/version'
9
+
10
+ module Hanzo
11
+ def self.run(command)
12
+ print(command, :green)
13
+ `#{command}`
14
+ end
15
+
16
+ def self.print(text, *colors)
17
+ colors = colors.map { |c| HighLine.const_get(c.to_s.upcase) }
18
+ HighLine.say HighLine.color(" #{text}", *colors)
19
+ end
20
+
21
+ def self.title(text)
22
+ HighLine.say HighLine.color("-----> #{text}", :blue)
23
+ end
24
+
25
+ def self.agree(question)
26
+ HighLine.agree " #{question} "
27
+ end
28
+
29
+ def self.ask(question, &blk)
30
+ HighLine.ask "-----> #{question} ", &blk
31
+ end
32
+ end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanzo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: '0.2'
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Samuel Garneau
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-07-25 00:00:00.000000000 Z
12
+ date: 2013-08-28 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,57 +30,49 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: rspec
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: highline
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - '>='
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
69
  version: '0'
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: heroku
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '>='
75
+ - - ! '>='
81
76
  - !ruby/object:Gem::Version
82
77
  version: '0'
83
78
  description: Hanzo is a tool to handle deployments in multiple environments on Heroku.
@@ -106,25 +101,26 @@ files:
106
101
  homepage: https://github.com/mirego/hanzo
107
102
  licenses:
108
103
  - BSD 3-Clause
109
- metadata: {}
110
104
  post_install_message:
111
105
  rdoc_options: []
112
106
  require_paths:
113
107
  - lib
114
108
  required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
115
110
  requirements:
116
- - - '>='
111
+ - - ! '>='
117
112
  - !ruby/object:Gem::Version
118
113
  version: '0'
119
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
120
116
  requirements:
121
- - - '>='
117
+ - - ! '>='
122
118
  - !ruby/object:Gem::Version
123
119
  version: '0'
124
120
  requirements: []
125
121
  rubyforge_project:
126
- rubygems_version: 2.0.0
122
+ rubygems_version: 1.8.23
127
123
  signing_key:
128
- specification_version: 4
124
+ specification_version: 3
129
125
  summary: Hanzo is a tool to handle deployments in multiple environments on Heroku.
130
126
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 3c77d5a3e8dfa20f17f19f447906413f36890ea8
4
- data.tar.gz: 86a9c70c060753753efca232c4fc34d8394b06c3
5
- SHA512:
6
- metadata.gz: 8c77f31638430a595a1f3e90707e486afba04bf3fbcf486ac0b8f1a7ee345359a619962692aa42c80d496d8beca6b051e6b8eaf9681832c95a1b4af15c5f19bc
7
- data.tar.gz: 4b045bcc335ccfe2ec7acf7f029149c8c17b72454c8e3d498a4a559c4a8fd50ebc3b3f747332a637d1e5c6e679e181e521105c3db88cb9a51f7c365c148ca45e