bodhi-slam 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bodhi-slam/factory.rb +2 -4
- data/lib/bodhi-slam/properties.rb +6 -1
- data/lib/bodhi-slam/types/index.rb +0 -5
- data/lib/bodhi-slam/types.rb +0 -1
- data/lib/bodhi-slam.rb +2 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2740f7bb58fef86f5fcb168c16736c0c043f7825
|
4
|
+
data.tar.gz: 5211d0755728d31d4ffdf18ad60f755511b8eccc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a650291911ad699c807cf808b4dde162146cf395ab18e2c47057400956743cc0f8091a7ced958b048ffc55b9e3b2e8aa88977e1142c64c12cb9d0549d2dead5
|
7
|
+
data.tar.gz: 089278eff165608ff8f4bc45858aa678f22cf32ce9eda6d68828a6595dd32496fe66a3a61c4898b6630738732ebbd31bb9ba8b726d0eb212e766a06879f5917c
|
data/lib/bodhi-slam/factory.rb
CHANGED
@@ -29,12 +29,10 @@ module Bodhi
|
|
29
29
|
# Resource.factory.build(name: "test") # => #<Resource:0x007fbff403e808 @name="test">
|
30
30
|
def build(options={})
|
31
31
|
options = Bodhi::Support.symbolize_keys(options)
|
32
|
-
object = klass.new(
|
32
|
+
object = klass.new(options)
|
33
33
|
|
34
34
|
@generators.each_pair do |attribute, generator|
|
35
|
-
|
36
|
-
object.send("#{attribute}=", options[attribute])
|
37
|
-
else
|
35
|
+
unless options.has_key?(attribute)
|
38
36
|
object.send("#{attribute}=", generator.call)
|
39
37
|
end
|
40
38
|
end
|
@@ -20,6 +20,7 @@ module Bodhi
|
|
20
20
|
def id; @sys_id; end
|
21
21
|
def persisted?; !@sys_id.nil?; end
|
22
22
|
def new_record?; @sys_id.nil?; end
|
23
|
+
def each; attributes.each{ |k, v| yield(k, v) }; end
|
23
24
|
|
24
25
|
# Initializes a new instance of the class. Accepts a parameter Hash for mass assignment.
|
25
26
|
# If a parameter does not exist for the class, an UndefinedMethod error is raised.
|
@@ -33,6 +34,10 @@ module Bodhi
|
|
33
34
|
# object.name #=> "Bob"
|
34
35
|
# object.email #=> "some@email.com"
|
35
36
|
def initialize(options={})
|
37
|
+
if options.is_a?(String)
|
38
|
+
options = JSON.parse(options)
|
39
|
+
end
|
40
|
+
|
36
41
|
options = Bodhi::Support.symbolize_keys(options)
|
37
42
|
options.each do |property, value|
|
38
43
|
property_options = self.class.properties[property]
|
@@ -93,7 +98,7 @@ module Bodhi
|
|
93
98
|
|
94
99
|
def self.included(base)
|
95
100
|
base.extend(ClassMethods)
|
96
|
-
base.include(InstanceMethods)
|
101
|
+
base.include(InstanceMethods, Enumerable)
|
97
102
|
base.instance_variable_set(:@properties, Hash.new)
|
98
103
|
end
|
99
104
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Bodhi
|
2
2
|
class TypeIndex
|
3
|
-
include Enumerable
|
4
3
|
include Bodhi::Properties
|
5
4
|
include Bodhi::Validations
|
6
5
|
|
@@ -9,9 +8,5 @@ module Bodhi
|
|
9
8
|
|
10
9
|
validates :keys, required: true, multi: true, type: "String"
|
11
10
|
validates :options, type: "Object"
|
12
|
-
|
13
|
-
def each
|
14
|
-
self.attributes.each{ |k, v| yield(k, v) }
|
15
|
-
end
|
16
11
|
end
|
17
12
|
end
|
data/lib/bodhi-slam/types.rb
CHANGED
@@ -28,7 +28,6 @@ module Bodhi
|
|
28
28
|
validates :properties, required: true
|
29
29
|
validates :indexes, type: "Bodhi::TypeIndex", multi: true
|
30
30
|
|
31
|
-
generates :extends, type: "String", matches: "[a-zA-Z_-]{10,20}"
|
32
31
|
generates :name, type: "String", required: true, is_not_blank: true
|
33
32
|
generates :namespace, type: "String", required: true
|
34
33
|
generates :properties, type: "Object", required: true
|
data/lib/bodhi-slam.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "json"
|
2
2
|
require "time"
|
3
3
|
require 'faraday'
|
4
|
+
require 'SecureRandom'
|
4
5
|
require 'faraday_middleware'
|
5
6
|
require 'net/http/persistent'
|
6
7
|
require 'regexp-examples'
|
@@ -39,10 +40,7 @@ class BodhiSlam
|
|
39
40
|
end
|
40
41
|
|
41
42
|
def self.define_resources(context, options={})
|
42
|
-
|
43
|
-
options = options.reduce({}) do |memo, (k, v)|
|
44
|
-
memo.merge({ k.to_sym => v})
|
45
|
-
end
|
43
|
+
options = Bodhi::Support.symbolize_keys(options)
|
46
44
|
|
47
45
|
if context.invalid?
|
48
46
|
raise Bodhi::ContextErrors.new(context.errors.messages), context.errors.to_a.to_s
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bodhi-slam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- willdavis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|