Module: Heroku::Samorau::Manifest

Defined in:
lib/heroku/samorau.rb

Constant Summary collapse

PasswordChars =
chars = ['a'..'z', 'A'..'Z', '0'..'9'].map { |r| r.to_a }.flatten

Class Method Summary collapse

Class Method Details

.generate_password(size = 16) ⇒ Object



48
49
50
# File 'lib/heroku/samorau.rb', line 48

def self.generate_password(size=16)
  Array.new(size) { PasswordChars[rand(PasswordChars.size)] }.join
end

.init(filename) ⇒ Object



12
13
14
# File 'lib/heroku/samorau.rb', line 12

def self.init(filename)
  open(filename, 'w') {|f| f << skeleton_str }
end

.skeletonObject



16
17
18
# File 'lib/heroku/samorau.rb', line 16

def self.skeleton
  Yajl::Parser.parse(skeleton_str)
end

.skeleton_strObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/heroku/samorau.rb', line 20

def self.skeleton_str
  return "{\n  \"id\": \"myaddon\",\n  \"name\": \"My Addon\",\n  \"plans\": [\n    {\n\"id\": \"basic\",\n\"name\": \"Basic\",\n\"price\": \"0\",\n\"price_unit\": \"month\"\n    }\n  ],\n  \"api\": {\n    \"config_vars\": [\n\"MYADDON_URL\"\n    ],\n    \"production\": \"https://yourapp.com/\",\n    \"test\": \"http://localhost:4567/\",\n    \"username\": \"heroku\",\n    \"password\": \"\#{generate_password(16)}\",\n    \"sso_salt\": \"\#{generate_password(16)}\"\n  }\n}\n"
end