generate_app_json 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 14ba0f97456839dab9ca926332196d996f28260ff34735931b265ba46fe0ac1e
4
+ data.tar.gz: 967de243137e1b1225c5a7ee3bf71157038088cd2065f9162567ffc18341c4f9
5
+ SHA512:
6
+ metadata.gz: 478dcb0e57b5d452f5711d2fa6fe5dd92e14eaad71afd5105a1dbf324a1b9523849d00a3ca39aa21b821077afcaa45ae883b240eebcbd1b0e3230d76118c4127
7
+ data.tar.gz: f95c3b57b0fc2e6977b01d52c208b1866d27aa6552dcb1b953718b8ccde282843ee16f86dda19892ada67b2307b87038ff3476a67e8c61b46c8143eed2d77715
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in generate_app_json.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Aurélien Noce
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,34 @@
1
+ # `generate_app_json`
2
+
3
+ %q{Generates a simple `app.json` for the current heroku project.
4
+
5
+
6
+ This is a packaged version of [this gist](https://gist.github.com/ushu/129b3340c51a205157c1e2daa1da55fa).
7
+
8
+ ## Installation
9
+
10
+ ```sh
11
+ gem install generate_app_json
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ Go into the Heroku project directory and run
17
+
18
+ ```sh
19
+ $ generate_app_json
20
+ ```
21
+
22
+ ## Development
23
+
24
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
25
+
26
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
27
+
28
+ ## Contributing
29
+
30
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ushu/generate_app_json.
31
+
32
+ ## License
33
+
34
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "generate_app_json"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+ require 'json'
3
+
4
+ # Grab info from the heroku cli
5
+ info = JSON.load(`heroku info --json`)
6
+ env_variables = JSON.load(`heroku config --json`)
7
+ buildpacks = `heroku buildpacks`.lines[1..-1].map{ |l| { 'url' => l[3...-1]}}
8
+ addons = JSON.load(`heroku addons --json`).inject(Hash.new{ |h, k| h[k] = [] }) { |h, e|
9
+ name = e['addon_service']['name']
10
+ plan = e['plan']['name']
11
+ as = e['attachments'][0]['name']
12
+ h[name] << { 'plan' => plan, 'as' => as }
13
+ h
14
+ }
15
+ formation = info['dynos'].inject({}) { |h, ps|
16
+ type = ps['type']
17
+ quantity = h[type] ? h[type]['quantity'] + 1 : 1
18
+ size = ps['size']
19
+ h[type] = { 'quantity' => quantity, 'size' => size }
20
+ h
21
+ }
22
+ name = info['app']['name']
23
+ website = info['app']['web_url']
24
+ repository = info['app']['git_url']
25
+ keywords = []
26
+
27
+ scripts = {}
28
+ if File.file?('config/application.rb')
29
+ # Rails app detected
30
+ scripts['postdeploy'] = 'bundle exec rake db:migrate'
31
+ keywords << 'Rails'
32
+ end
33
+
34
+ app_json = {
35
+ 'name' => name,
36
+ 'description' => '',
37
+ 'keywords' => keywords,
38
+ 'website' => website,
39
+ 'repository' => repository,
40
+ 'buildpacks' => buildpacks,
41
+ 'formation' => formation,
42
+ 'addons' => addons,
43
+ 'env' => env_variables,
44
+ 'scripts' => scripts
45
+ }
46
+ print JSON.pretty_generate(app_json)
@@ -0,0 +1,30 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "generate_app_json/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "generate_app_json"
8
+ spec.version = GenerateAppJson::VERSION
9
+ spec.authors = ["Aurélien Noce"]
10
+ spec.email = ["aurelien@noce.fr"]
11
+ spec.summary = %q{Generates a simple app.json for the current heroku project.}
12
+ spec.description = %q{
13
+ A packaged version of my gist https://gist.github.com/ushu/129b3340c51a205157c1e2daa1da55fa.
14
+ It calls the Heroku CLI to grabs the necessary info, then prints the result on STDOUT.
15
+ }
16
+ spec.homepage = "https://github.com/ushu/generate_app_json"
17
+ spec.license = "MIT"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_development_dependency "bundler", "~> 2.0"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ end
@@ -0,0 +1,6 @@
1
+ require "generate_app_json/version"
2
+
3
+ module GenerateAppJson
4
+ class Error < StandardError; end
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,3 @@
1
+ module GenerateAppJson
2
+ VERSION = "0.1.2"
3
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: generate_app_json
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Aurélien Noce
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-02-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: "\n A packaged version of my gist https://gist.github.com/ushu/129b3340c51a205157c1e2daa1da55fa.\n
42
+ \ It calls the Heroku CLI to grabs the necessary info, then prints the result
43
+ on STDOUT.\n "
44
+ email:
45
+ - aurelien@noce.fr
46
+ executables:
47
+ - generate_app_json
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - ".gitignore"
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - bin/console
57
+ - bin/setup
58
+ - exe/generate_app_json
59
+ - generate_app_json.gemspec
60
+ - lib/generate_app_json.rb
61
+ - lib/generate_app_json/version.rb
62
+ homepage: https://github.com/ushu/generate_app_json
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.7.6
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Generates a simple app.json for the current heroku project.
86
+ test_files: []