dyno_metadata 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f10f2637f471db69dce5e3d9ff8eae5597595502
4
+ data.tar.gz: 72114d4b79a619fadc9f6aa5afa751f3f394e50b
5
+ SHA512:
6
+ metadata.gz: f393b89067ebc79cdddea96c920f135dc7f8d1062bf94180ec29fd381cbd92f0ec1c50b10ac69b30afb6935b5283774dcd9310fc808733b74f71bb936212f82b
7
+ data.tar.gz: c9bf18c48d92d3e75f642203620d6d416a65a5444c4ed32195c23307c096f1fab52b1a6b3ecd9f9646ff9a7dada4ed93d441f63955dc8e3554f2377de108c92f
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Dyno Metadata
2
+
3
+ Helpers to access [Heroku Dyno Metadata](https://devcenter.heroku.com/articles/dyno-metadata) from [`ENV`](https://ruby-doc.org/core-2.2.0/ENV.html). Graceful fallback to dummy values (useful in development).
4
+
5
+ Installation
6
+
7
+ gem install dyno_metadata
8
+
9
+ Demonstration
10
+
11
+ ```ruby
12
+ $ ruby -I lib -r dyno_metadata.rb -e '(DynoMetadata.methods - \
13
+ Object.methods).each { |method| puts \
14
+ "DynoMetadata.#{method}\n=> #{DynoMetadata.public_send(method)}" }'
15
+ DynoMetadata.app_id
16
+ => 9daa2797-e49b-4624-932f-ec3f9688e3da
17
+ DynoMetadata.app_name
18
+ => example-app
19
+ DynoMetadata.dyno_id
20
+ => 1vac4117-c29f-4312-521e-ba4d8638c1ac
21
+ DynoMetadata.release_created_at
22
+ => 2015-04-02T18:00:42Z
23
+ DynoMetadata.release_version
24
+ => v42
25
+ DynoMetadata.slug_commit
26
+ => 2c3a0b24069af49b3de35b8e8c26765c1dba9ff0
27
+ DynoMetadata.commit
28
+ => 2c3a0b24069af49b3de35b8e8c26765c1dba9ff0
29
+ DynoMetadata.slug_description
30
+ => Deploy 2c3a0b2
31
+ DynoMetadata.short_commit
32
+ => 2c3a0b2
33
+ DynoMetadata.to_h
34
+ => {:app_id=>"9daa2797-e49b-4624-932f-ec3f9688e3da", :app_name=>"example-app", :dyno_id=>"1vac4117-c29f-4312-521e-ba4d8638c1ac", :release_created_at=>"2015-04-02T18:00:42Z", :release_version=>"v42", :slug_commit=>"2c3a0b24069af49b3de35b8e8c26765c1dba9ff0", :slug_description=>"Deploy 2c3a0b2", :short_commit=>"2c3a0b2"}
35
+ ```
36
+
37
+ ## Development
38
+
39
+ ### Release workflow
40
+
41
+ * Update the demonstration in this README if needed.
42
+
43
+ * Bump the version in `version.rb` in a commit, no need to push (the release task does that).
44
+
45
+ * Build and [publish](http://guides.rubygems.org/publishing/) the gem. This will create the proper tag in git, push the commit and tag and upload to RubyGems. Use [keycutter](https://github.com/joshfrench/keycutter) to manage multiple RubyGems accounts.
46
+
47
+ bundle exec rake release
48
+
49
+ * If you are not logged in as on the correct account, the rake task will fail and tell you to set credentials via `gem push`, do that and run the `release` task again. Use [keycutter](https://github.com/joshfrench/keycutter) to manage multiple RubyGems accounts.
50
+
51
+ * Update the changelog with [GitHub Changelog Generator](https://github.com/skywinder/github-changelog-generator/) commit and push manually.
52
+
53
+ github_changelog_generator
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DynoMetadata
4
+ module_function
5
+
6
+ def app_id
7
+ fetch "HEROKU_APP_ID", "9daa2797-e49b-4624-932f-ec3f9688e3da"
8
+ end
9
+
10
+ def app_name
11
+ fetch "HEROKU_APP_NAME", "example-app"
12
+ end
13
+
14
+ def dyno_id
15
+ fetch "HEROKU_DYNO_ID", "1vac4117-c29f-4312-521e-ba4d8638c1ac"
16
+ end
17
+
18
+ def release_created_at
19
+ fetch "HEROKU_RELEASE_CREATED_AT", "2015-04-02T18:00:42Z"
20
+ end
21
+
22
+ def release_version
23
+ fetch "HEROKU_RELEASE_VERSION", "v42"
24
+ end
25
+
26
+ def slug_commit
27
+ fetch "HEROKU_SLUG_COMMIT", "2c3a0b24069af49b3de35b8e8c26765c1dba9ff0"
28
+ end
29
+ singleton_class.send(:alias_method, :commit, :slug_commit)
30
+
31
+ def slug_description
32
+ fetch "HEROKU_SLUG_DESCRIPTION", "Deploy 2c3a0b2"
33
+ end
34
+
35
+ def short_commit
36
+ slug_commit[0, 7]
37
+ end
38
+
39
+ def to_h
40
+ {
41
+ app_id: app_id,
42
+ app_name: app_name,
43
+ dyno_id: dyno_id,
44
+ release_created_at: release_created_at,
45
+ release_version: release_version,
46
+ slug_commit: slug_commit,
47
+ slug_description: slug_description,
48
+ short_commit: short_commit,
49
+ }
50
+ end
51
+
52
+ private_class_method def fetch(variable_name, fallback)
53
+ ENV.fetch(variable_name) { fallback }
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DynoMetadata
4
+ VERSION = "0.0.1".freeze
5
+ end
@@ -0,0 +1,2 @@
1
+ require_relative "dyno_metadata/dyno_metadata"
2
+ require_relative "dyno_metadata/version"
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dyno_metadata
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Patrik Ragnarsson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.46'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.46'
55
+ description: |-
56
+ Gives easy access to details about the release, dyno size,
57
+ application name as well as the unique identifier for the
58
+ particular running dyno.
59
+ email:
60
+ - patrik@starkast.net
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - README.md
66
+ - lib/dyno_metadata.rb
67
+ - lib/dyno_metadata/dyno_metadata.rb
68
+ - lib/dyno_metadata/version.rb
69
+ homepage: http://github.com/dentarg/dyno_metadata
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: 1.9.3
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.4.5.2
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: Information about the app and environment on Heroku.
93
+ test_files: []