class Heroku::Kensa::Manifest
Constants
- REGIONS
Public Class Methods
new(options = {})
click to toggle source
# File lib/heroku/kensa/manifest.rb, line 8 def initialize(options = {}) @method = options.fetch(:method, 'post').to_sym @filename = options[:filename] @options = options end
Public Instance Methods
foreman()
click to toggle source
# File lib/heroku/kensa/manifest.rb, line 57 def foreman <<-ENV SSO_SALT=#{@sso_salt} HEROKU_USERNAME=myaddon HEROKU_PASSWORD=#{@password} ENV end
get_skeleton()
click to toggle source
# File lib/heroku/kensa/manifest.rb, line 20 def get_skeleton <<-JSON { "id": "myaddon", "api": { "config_vars": [ "MYADDON_URL" ], "regions": [ "us" ], "password": "#{@password}",#{ sso_key } "production": "https://yourapp.com/", "test": "http://localhost:#{@port}/" } } JSON end
post_skeleton()
click to toggle source
# File lib/heroku/kensa/manifest.rb, line 35 def post_skeleton <<-JSON { "id": "myaddon", "api": { "config_vars": [ "MYADDON_URL" ], "regions": [ "us" ], "password": "#{@password}",#{ sso_key } "production": { "base_url": "https://yourapp.com/heroku/resources", "sso_url": "https://yourapp.com/sso/login" }, "test": { "base_url": "http://localhost:#{@port}/heroku/resources", "sso_url": "http://localhost:#{@port}/sso/login" } } } JSON end
skeleton()
click to toggle source
# File lib/heroku/kensa/manifest.rb, line 65 def skeleton OkJson.decode skeleton_json end
skeleton_json()
click to toggle source
# File lib/heroku/kensa/manifest.rb, line 14 def skeleton_json @password = generate_password(16) @port = @options[:foreman] ? 5000 : 4567 (@method == :get) ? get_skeleton : post_skeleton end
write()
click to toggle source
# File lib/heroku/kensa/manifest.rb, line 69 def write File.open(@filename, 'w') { |f| f << skeleton_json } File.open('.env', 'w') { |f| f << foreman } if @options[:foreman] end
Private Instance Methods
generate_password(size=8)
click to toggle source
# File lib/heroku/kensa/manifest.rb, line 83 def generate_password(size=8) SecureRandom.hex(size) end
sso_key()
click to toggle source
# File lib/heroku/kensa/manifest.rb, line 76 def sso_key @sso_salt = generate_password(16) unless @options[:sso] === false %Q{\n "sso_salt": "#{@sso_salt}",} end end