app_manifest 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/app_manifest.gemspec +1 -0
- data/lib/app_manifest.rb +9 -0
- data/lib/app_manifest/addon.rb +10 -0
- data/lib/app_manifest/buildpack.rb +8 -0
- data/lib/app_manifest/env.rb +11 -0
- data/lib/app_manifest/environment.rb +7 -0
- data/lib/app_manifest/environment_attributes.rb +21 -0
- data/lib/app_manifest/formation.rb +9 -0
- data/lib/app_manifest/manifest.rb +12 -12
- data/lib/app_manifest/nullable_array.rb +13 -0
- data/lib/app_manifest/serializer.rb +29 -0
- data/lib/app_manifest/version.rb +1 -1
- metadata +24 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98e7fd7a9df5650e85261c7075ba606fee8577a3
|
4
|
+
data.tar.gz: d05a3fc7de5170ee6382f374bf11bbe00cc7d23d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52af724010c244dfa20b5f17ce50f109089acc3e0189ce268ce3391ba781a39a0ece6639aa224ebb6936a801e07ab02fa6538c3097426996f01a1e20fc1a542e
|
7
|
+
data.tar.gz: 695439ffdb68a4a023ed50e8ce522a87275f37cc41bb834e647d4151995d49c021c1746aefee6a52a2a0ec0fb317d4380655800a7adb0d5c450a40d4911c5065
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
7
7
|
|
8
8
|
## Unreleased
|
9
9
|
|
10
|
+
## [0.3.0] - 2017-06-18
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- Manifests are now fully modeled. There are now getters and setters for
|
14
|
+
nested data (for example: `manifest.addons.first.plan`).
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
- `Manifest#to_hash` now returns a hash for the current manifest state, rather
|
18
|
+
than the hash that was passed in.
|
19
|
+
- `Manifest#environment` now returns an `Environment` instance, as a result,
|
20
|
+
it's serialization will not include nested `environments` data.
|
21
|
+
|
22
|
+
### Removed
|
23
|
+
- `Manifest#manifest` was removed as it was superfluous and potentially
|
24
|
+
confusing. `Manifest#to_hash` may be a suitable replacement.
|
25
|
+
|
10
26
|
## [0.2.1] - 2017-04-04
|
11
27
|
### Fixed
|
12
28
|
- Prevent `NoMethodError on TrueClass` when a `true` or `false` environment variable is provided.
|
data/app_manifest.gemspec
CHANGED
data/lib/app_manifest.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
require 'multi_json'
|
2
|
+
require 'virtus'
|
2
3
|
|
3
4
|
require "app_manifest/version"
|
5
|
+
require "app_manifest/nullable_array"
|
6
|
+
require "app_manifest/serializer"
|
7
|
+
require "app_manifest/addon"
|
8
|
+
require "app_manifest/buildpack"
|
9
|
+
require "app_manifest/env"
|
10
|
+
require "app_manifest/formation"
|
11
|
+
require "app_manifest/environment_attributes"
|
12
|
+
require "app_manifest/environment"
|
4
13
|
require "app_manifest/manifest"
|
5
14
|
|
6
15
|
# Create a new manifest from json string or a hash
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module AppManifest
|
2
|
+
# Setup attributes that are shared on Manifest and Environment models
|
3
|
+
module EnvironmentAttributes
|
4
|
+
def self.included(base)
|
5
|
+
base.attribute :addons, NullableArray[Addon]
|
6
|
+
base.attribute :buildpacks, NullableArray[Buildpack]
|
7
|
+
base.attribute :description, String
|
8
|
+
base.attribute :env, Hash[String => Env], default: nil
|
9
|
+
base.attribute :formation, Hash[String => Formation], default: nil
|
10
|
+
base.attribute :image, String
|
11
|
+
base.attribute :keywords, NullableArray[String]
|
12
|
+
base.attribute :logo, String
|
13
|
+
base.attribute :name, String
|
14
|
+
base.attribute :repository, String
|
15
|
+
base.attribute :scripts, Hash[String => String], default: nil
|
16
|
+
base.attribute :stack, String
|
17
|
+
base.attribute :success_url, String
|
18
|
+
base.attribute :website, String
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,26 +1,26 @@
|
|
1
1
|
module AppManifest
|
2
2
|
# A simple model-like wrapper around a manifest hash.
|
3
3
|
class Manifest
|
4
|
+
include Virtus.model
|
5
|
+
include EnvironmentAttributes
|
6
|
+
include Serializer
|
7
|
+
|
8
|
+
attribute :environments, Hash[String => Environment], default: nil
|
9
|
+
|
4
10
|
def self.from_json(string)
|
5
11
|
hash = MultiJson.load(string)
|
6
|
-
|
12
|
+
new(hash)
|
7
13
|
end
|
8
14
|
|
9
15
|
def initialize(hash)
|
10
|
-
|
16
|
+
canonicalized = AppManifest.canonicalize(hash)
|
17
|
+
super(canonicalized)
|
11
18
|
end
|
12
19
|
|
13
20
|
def environment(name)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
def to_hash
|
19
|
-
manifest
|
21
|
+
scoped_data = (environments || {}).fetch(name.to_s, {}).to_hash
|
22
|
+
global_data = to_hash
|
23
|
+
Environment.new(global_data.merge(scoped_data))
|
20
24
|
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
attr_reader :manifest
|
25
25
|
end
|
26
26
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module AppManifest
|
2
|
+
# Serialization logic for AppManifest models
|
3
|
+
module Serializer
|
4
|
+
def self.serialize(value)
|
5
|
+
case value
|
6
|
+
when Array
|
7
|
+
value.map { |v| serialize(v) }
|
8
|
+
when Hash
|
9
|
+
value.each_with_object({}) do |(k, v), h|
|
10
|
+
h[k] = serialize(v)
|
11
|
+
end
|
12
|
+
when Integer, Float, String, Symbol, TrueClass, FalseClass, NilClass
|
13
|
+
value
|
14
|
+
else
|
15
|
+
if value.respond_to?(:attributes)
|
16
|
+
value.attributes.each_with_object({}) do |(key, val), hash|
|
17
|
+
hash[key] = serialize(val) unless val.nil?
|
18
|
+
end
|
19
|
+
else
|
20
|
+
val.to_s
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_hash
|
26
|
+
Serializer.serialize(self)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/app_manifest/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app_manifest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Owen Jacobson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-07-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -67,6 +67,20 @@ dependencies:
|
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '1.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: virtus
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.0'
|
70
84
|
description: Parse app manifests used by Heroku Button, Heroku Review Apps, and Heroku
|
71
85
|
CI.
|
72
86
|
email:
|
@@ -86,7 +100,15 @@ files:
|
|
86
100
|
- bin/console
|
87
101
|
- bin/setup
|
88
102
|
- lib/app_manifest.rb
|
103
|
+
- lib/app_manifest/addon.rb
|
104
|
+
- lib/app_manifest/buildpack.rb
|
105
|
+
- lib/app_manifest/env.rb
|
106
|
+
- lib/app_manifest/environment.rb
|
107
|
+
- lib/app_manifest/environment_attributes.rb
|
108
|
+
- lib/app_manifest/formation.rb
|
89
109
|
- lib/app_manifest/manifest.rb
|
110
|
+
- lib/app_manifest/nullable_array.rb
|
111
|
+
- lib/app_manifest/serializer.rb
|
90
112
|
- lib/app_manifest/version.rb
|
91
113
|
homepage: https://devcenter.heroku.com/articles/app-json-schema
|
92
114
|
licenses: []
|