Class: HerokuAddonProvider
- Inherits:
-
Object
- Object
- HerokuAddonProvider
- Defined in:
- lib/heroku_addon_provider.rb,
lib/heroku_addon_provider/version.rb
Constant Summary collapse
- VERSION =
'0.0.1'.freeze
Class Attribute Summary collapse
-
.manifest_path ⇒ Object
Returns the value of attribute manifest_path.
Class Method Summary collapse
- .application_info(heroku_id) ⇒ Object
- .configure {|_self| ... } ⇒ Object
- .installed_applications ⇒ Object
- .manifest ⇒ Object
- .owner_email(heroku_id) ⇒ Object
- .owner_emails ⇒ Object
- .password ⇒ Object
- .provider_id ⇒ Object
- .sso_salt ⇒ Object
- .sso_token(user_id, timestamp) ⇒ Object
Class Attribute Details
.manifest_path ⇒ Object
Returns the value of attribute manifest_path.
11 12 13 |
# File 'lib/heroku_addon_provider.rb', line 11 def manifest_path @manifest_path end |
Class Method Details
.application_info(heroku_id) ⇒ Object
44 45 46 |
# File 'lib/heroku_addon_provider.rb', line 44 def application_info(heroku_id) faraday.get("/vendor/apps/#{heroku_id}").body end |
.configure {|_self| ... } ⇒ Object
59 60 61 |
# File 'lib/heroku_addon_provider.rb', line 59 def configure(&block) yield self end |
.installed_applications ⇒ Object
40 41 42 |
# File 'lib/heroku_addon_provider.rb', line 40 def installed_applications faraday.get('/vendor/apps').body end |
.manifest ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/heroku_addon_provider.rb', line 13 def manifest if manifest_path @manifest ||= JSON.load(File.read(manifest_path)) elsif (defined?(Rails) && File.exists?("#{Rails.root}/addon-manifest.json")) @manifest ||= JSON.load(File.read("#{Rails.root}/addon-manifest.json")) else raise 'Addon manifest not found' end end |
.owner_email(heroku_id) ⇒ Object
48 49 50 51 |
# File 'lib/heroku_addon_provider.rb', line 48 def owner_email(heroku_id) info = application_info(heroku_id) info['owner_email'] end |
.owner_emails ⇒ Object
53 54 55 56 57 |
# File 'lib/heroku_addon_provider.rb', line 53 def owner_emails installed_applications.map do |app| owner_email(app['heroku_id']) end end |
.password ⇒ Object
27 28 29 |
# File 'lib/heroku_addon_provider.rb', line 27 def password manifest['api']['password'] end |
.provider_id ⇒ Object
23 24 25 |
# File 'lib/heroku_addon_provider.rb', line 23 def provider_id manifest['id'] end |
.sso_salt ⇒ Object
31 32 33 |
# File 'lib/heroku_addon_provider.rb', line 31 def sso_salt manifest['api']['sso_salt'] end |
.sso_token(user_id, timestamp) ⇒ Object
35 36 37 38 |
# File 'lib/heroku_addon_provider.rb', line 35 def sso_token(user_id, ) pre_token = "#{user_id}:#{sso_salt}:#{timestamp}" Digest::SHA1.hexdigest(pre_token).to_s end |