instapusher 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
data/bin/instapusher CHANGED
@@ -28,5 +28,5 @@ end.parse!
28
28
  if options[:version]
29
29
  puts Instapusher::VERSION
30
30
  else
31
- Instapusher::Commands.deploy(options)
31
+ Instapusher::Commands.new(options).deploy
32
32
  end
@@ -5,33 +5,55 @@ require 'instapusher'
5
5
 
6
6
  module Instapusher
7
7
  class Commands
8
+
8
9
  DEFAULT_HOSTNAME = 'instapusher.com'
9
10
 
10
- def self.deploy(_options)
11
+ attr_reader :debug, :api_key, :branch_name, :project_name
11
12
 
12
- debug = _options(:debug)
13
+ def initialize init_options = {}
13
14
 
14
- hostname = ENV['INSTAPUSHER_HOST'] || DEFAULT_HOSTNAME
15
- hostname = "localhost:3000" if _options[:local]
15
+ @debug = init_options[:debug]
16
+ @quick = init_options[:quick]
17
+ @local = init_options[:local]
16
18
 
17
- url = "http://#{hostname}/heroku.json"
18
19
  git = Git.new
19
- branch_name = _options[:project_name] || ENV['INSTAPUSHER_BRANCH'] || git.current_branch
20
- project_name = _options[:branch_name] || ENV['INSTAPUSHER_PROJECT'] || git.project_name
20
+ @branch_name = init_options[:project_name] || ENV['INSTAPUSHER_BRANCH'] || git.current_branch
21
+ @project_name = init_options[:branch_name] || ENV['INSTAPUSHER_PROJECT'] || git.project_name
22
+ end
23
+
24
+ def options
25
+ @options ||= begin
26
+ { project: project_name,
27
+ branch: branch_name,
28
+ quick: @quick,
29
+ local: @local,
30
+ api_key: api_key }
31
+ end
32
+ end
21
33
 
22
- api_key = ENV['API_KEY'] || Instapusher::Configuration.api_key || ""
34
+ def verify_api_key
35
+ @api_key = ENV['API_KEY'] || Instapusher::Configuration.api_key || ""
23
36
 
24
- if api_key.to_s.length == 0
37
+ if @api_key.to_s.length == 0
25
38
  puts "Please enter instapusher api_key at ~/.instapusher "
26
39
  end
40
+ end
41
+
42
+ def url
43
+ @url ||= begin
44
+ hostname = if options[:local]
45
+ "localhost:3000"
46
+ else
47
+ ENV['INSTAPUSHER_HOST'] || DEFAULT_HOSTNAME
48
+ end
49
+ "http://#{hostname}/heroku.json"
50
+ end
51
+ end
27
52
 
28
- options = { project: project_name,
29
- branch: branch_name,
30
- quick: _options[:quick],
31
- local: _options[:local],
32
- api_key: api_key }
53
+ def deploy
54
+ verify_api_key
33
55
 
34
- if debug || true
56
+ if debug
35
57
  puts "url to hit: #{url.inspect}"
36
58
  puts "options being passed to the url: #{options.inspect}"
37
59
  end
@@ -1,3 +1,3 @@
1
1
  module Instapusher
2
- VERSION = "0.0.19"
2
+ VERSION = "0.0.20"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instapusher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -81,7 +81,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
81
  version: '0'
82
82
  segments:
83
83
  - 0
84
- hash: -1609321625595153078
84
+ hash: -3703911192431955424
85
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  segments:
92
92
  - 0
93
- hash: -1609321625595153078
93
+ hash: -3703911192431955424
94
94
  requirements: []
95
95
  rubyforge_project:
96
96
  rubygems_version: 1.8.23