apperol 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db158e412b26ecb904f357742bd9e6560d573627
4
- data.tar.gz: 9d9939c3ec0104b2a3c1b860268b9a6cee9c22ae
3
+ metadata.gz: 91a4bdc6aea992758e4cdc112eab66f5b7a9fb4a
4
+ data.tar.gz: 680dd1c4cc9449cfce6a1befb765e6997402fbbd
5
5
  SHA512:
6
- metadata.gz: d15027aed70b6c7850587104b070477df35d4eecca06a640c4ab5a1c583b61a88682aa4cbf7a50881cd1ef2a33dff2eba09e124cb170b923d6201b8c3b5b366d
7
- data.tar.gz: 059e5e660c1b8c106ec44492df8d5505e128fe04f264f7ff78c065778ee15a41a8f2849cb5985d3ca7a1d885825daf453b6b1a1a1aedc2fbe686325f1c71ceda
6
+ metadata.gz: 819ddb160d318ba1219955f387c0580ba4024f62b33972aaf62f8f887d4de726e43afb44537b1492c0e321207539bd445f67e17d68e69848550b7eaccb3c5261
7
+ data.tar.gz: dd90401ab6224e5ee517339359aec58c063be4570b1cd8d92bba4416367a1d6f7b031b05c4fab5367ac124bb712fa2eb4dc56e828b577ce68c419d1f0c11a49c
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Apperol
2
2
 
3
+ ![](http://cl.ly/image/0C230a0p2p0G/apperol.png)
4
+
3
5
  Create apps from heroku repositories on GitHub.
4
6
  Use app.json to customize options.
5
7
 
@@ -41,7 +43,7 @@ Usage: apperol [options] [app_extension]
41
43
 
42
44
  ## Contributing
43
45
 
44
- 1. Fork it ( https://github.com/[my-github-username]/apperol/fork )
46
+ 1. Fork it ( https://github.com/ys/apperol/fork )
45
47
  2. Create your feature branch (`git checkout -b my-new-feature`)
46
48
  3. Commit your changes (`git commit -am 'Add some feature'`)
47
49
  4. Push to the branch (`git push origin my-new-feature`)
data/apperol.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["yannick@heroku.com"]
11
11
  spec.summary = %q{Create heroku app from heroku repository}
12
12
  spec.description = %q{Create heroku app from heroku repository with app.json}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/ys/apperol"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
data/lib/apperol/cli.rb CHANGED
@@ -19,27 +19,27 @@ module Apperol
19
19
  option_key_name = key.downcase.gsub("_", "-")
20
20
  option_key_key = key.downcase.to_sym
21
21
  # Set default
22
- @options[option_key_key] = definition["value"]
23
- opts.on("--#{option_key_name} value", "#{definition["description"]} (Default: '#{definition["value"]}')") do |value|
22
+ value = definition.is_a?(String) ? definition : definition["value"]
23
+ @options[option_key_key] = value
24
+ required = definition.is_a?(String) || definition["required"].nil? || definition["required"] ? " required" : ""
25
+ description = definition.is_a?(String) ? key : definition["description"]
26
+ opts.on("--#{option_key_name} value", "#{description} (Default: '#{value}' #{required}) ") do |value|
24
27
  @options[option_key_key] = value
25
28
  end
26
29
  end
27
30
  opts.on("-p", "--personal", "Force app in personal apps instead of orgs") do
28
31
  @options[:personal] = true
29
32
  end
30
- opts.on("-r", "--repo repo", "GitHub repository used for the deploy") do |repo|
33
+ opts.on("-r", "--repo repo", "GitHub repository used for the deploy (Default: user/dir_name)") do |repo|
31
34
  @options[:repo] = repo
32
35
  end
33
- opts.on("-o", "--org org", "GitHub org where current repo is located") do |org|
34
- @options[:org] = org
36
+ opts.on("-u", "--user user", "GitHub user where current repo is located (Default: Your GitHub username)") do |user|
37
+ @options[:user] = user
35
38
  end
36
- opts.on("-u", "--user user", "GitHub user where current repo is located") do |user|
37
- @options[:org] = user
38
- end
39
- opts.on("-s", "--stack stack", "Stack for app on heroku") do |stack|
39
+ opts.on("-s", "--stack stack", "Stack for app on heroku (Default: cedar-14)") do |stack|
40
40
  @options[:stack] = stack
41
41
  end
42
- opts.on("-b", "--branch branch", "Branch to setup app from") do |branch|
42
+ opts.on("-b", "--branch branch", "Branch to setup app from (Default: master)") do |branch|
43
43
  @options[:branch] = branch
44
44
  end
45
45
  opts.on('-h', '--help', 'Displays Help') do
@@ -58,7 +58,8 @@ module Apperol
58
58
  end
59
59
 
60
60
  def call
61
- heroku_app_setup
61
+ # heroku_app_setup
62
+ app_setup_payload
62
63
  end
63
64
 
64
65
  def heroku_app_setup
@@ -144,7 +145,7 @@ module Apperol
144
145
  required_not_filled = []
145
146
  app_json["env"].each do |key, definition|
146
147
  value = @options[key.downcase.to_sym]
147
- if definition["required"] && value.strip.empty?
148
+ if (definition["required"].nil? || definition["required"]) && value.strip.empty?
148
149
  required_not_filled << key
149
150
  end
150
151
  payload[:overrides][:env][key] = value
@@ -159,17 +160,22 @@ module Apperol
159
160
 
160
161
  def github_tarball_location
161
162
  $stdout.puts("Getting tarball location for empirical branch #{github_branch}")
162
- req = Net::HTTP::Get.new(github_url)
163
- req.basic_auth *github_creds
164
- res = github_http.request(req)
163
+ res = github_get(tarball_path)
165
164
  if res["Location"]
166
165
  res["Location"]
167
166
  else
168
- $stderr.puts("error: No tarball found for #{github_url} : #{JSON.parse(res.body)["message"]}")
167
+ $stderr.puts("error: No tarball found for #{github_url + tarball_path} : #{JSON.parse(res.body)["message"]}")
169
168
  exit 1
170
169
  end
171
170
  end
172
171
 
172
+ def github_get(path)
173
+ puts github_url + path
174
+ req = Net::HTTP::Get.new(github_url + path)
175
+ req.basic_auth *github_creds
176
+ github_http.request(req)
177
+ end
178
+
173
179
  def github_http
174
180
  @github_http ||= Net::HTTP.new(github_url.hostname, github_url.port).tap do |http|
175
181
  http.use_ssl = true
@@ -185,11 +191,14 @@ module Apperol
185
191
  end
186
192
 
187
193
  def default_repo
188
- "#{org}/#{heroku_app_name}"
194
+ "#{user}/#{heroku_app_name}"
189
195
  end
190
196
 
191
- def org
192
- @options.fetch(:org, "heroku")
197
+ def user
198
+ @user ||= @options.fetch(:user) {
199
+ res = github_get("/user")
200
+ JSON.parse(res.body)["login"]
201
+ }
193
202
  end
194
203
 
195
204
  def rollbar_token
@@ -214,7 +223,11 @@ module Apperol
214
223
  end
215
224
 
216
225
  def github_url
217
- @github_url ||= URI("https://api.github.com/repos/#{repo}/tarball/#{github_branch}")
226
+ URI("https://api.github.com")
227
+ end
228
+
229
+ def tarball_path
230
+ "/repos/#{repo}/tarball/#{github_branch}"
218
231
  end
219
232
 
220
233
  def github_creds
@@ -1,3 +1,3 @@
1
1
  module Apperol
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apperol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yannick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-22 00:00:00.000000000 Z
11
+ date: 2014-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,7 +84,7 @@ files:
84
84
  - lib/apperol.rb
85
85
  - lib/apperol/cli.rb
86
86
  - lib/apperol/version.rb
87
- homepage: ''
87
+ homepage: https://github.com/ys/apperol
88
88
  licenses:
89
89
  - MIT
90
90
  metadata: {}