Class: Xplenty::Kensa::Manifest
- Inherits:
-
Object
- Object
- Xplenty::Kensa::Manifest
- Defined in:
- lib/xplenty/kensa/manifest.rb
Constant Summary collapse
- REGIONS =
%w( amazon-web-services::us-east-1 amazon-web-services::us-west-2 amazon-web-services::eu-west-1 rackspace::dfw rackspace::ord soft-layer::dal05 soft-layer::ams01 soft-layer::sng01 )
Instance Method Summary collapse
- #foreman ⇒ Object
- #get_skeleton ⇒ Object
-
#initialize(options = {}) ⇒ Manifest
constructor
A new instance of Manifest.
- #post_skeleton ⇒ Object
- #skeleton ⇒ Object
- #skeleton_json ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Manifest
Returns a new instance of Manifest.
17 18 19 20 21 |
# File 'lib/xplenty/kensa/manifest.rb', line 17 def initialize( = {}) @method = .fetch(:method, 'post').to_sym @filename = [:filename] = end |
Instance Method Details
#foreman ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/xplenty/kensa/manifest.rb', line 66 def foreman "SSO_SALT=\#{@sso_salt}\nXPLENTY_USERNAME=myaddon\nXPLENTY_PASSWORD=\#{@password}\n" end |
#get_skeleton ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/xplenty/kensa/manifest.rb', line 29 def get_skeleton "{\n \"id\": \"myaddon\",\n \"api\": {\n \"config_vars\": [ \"MYADDON_URL\" ],\n \"regions\": [ \"amazon-web-services::us-east-1\" ],\n \"password\": \"\#{@password}\",\#{ sso_key }\n \"production\": \"https://yourapp.com/\",\n \"test\": \"http://localhost:\#{@port}/\"\n }\n}\n" end |
#post_skeleton ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/xplenty/kensa/manifest.rb', line 44 def post_skeleton "{\n \"id\": \"myaddon\",\n \"api\": {\n \"config_vars\": [ \"MYADDON_URL\" ],\n \"regions\": [ \"amazon-web-services::us-east-1\" ],\n \"password\": \"\#{@password}\",\#{ sso_key }\n \"production\": {\n\"base_url\": \"https://yourapp.com/xplenty/resources\",\n\"sso_url\": \"https://yourapp.com/sso/login\"\n },\n \"test\": {\n\"base_url\": \"http://localhost:\#{@port}/xplenty/resources\",\n\"sso_url\": \"http://localhost:\#{@port}/sso/login\"\n }\n }\n}\n" end |
#skeleton ⇒ Object
74 75 76 |
# File 'lib/xplenty/kensa/manifest.rb', line 74 def skeleton OkJson.decode skeleton_json end |
#skeleton_json ⇒ Object
23 24 25 26 27 |
# File 'lib/xplenty/kensa/manifest.rb', line 23 def skeleton_json @password = generate_password(16) @port = [:foreman] ? 5000 : 4567 (@method == :get) ? get_skeleton : post_skeleton end |
#write ⇒ Object
78 79 80 81 |
# File 'lib/xplenty/kensa/manifest.rb', line 78 def write File.open(@filename, 'w') { |f| f << skeleton_json } File.open('.env', 'w') { |f| f << foreman } if [:foreman] end |