moonrope 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/moonrope/dsl/base_dsl.rb +5 -1
- data/lib/moonrope/eval_environment.rb +28 -10
- data/lib/moonrope/version.rb +1 -1
- 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: ef945cc15907ff80fe15bc8d5e8cd01c439183e7
|
4
|
+
data.tar.gz: 29682cb87255200fb7c52dbec08c0e7b18ce6292
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16c45bb324804dc8180a2e71940a952d50cb1c68464df6d619d1bef1b3beb63aa1557647f70a4c5b0294f0f7ba733ac7cf1ec9648e6e37ee1fabe517967c5a57
|
7
|
+
data.tar.gz: c7b40e7fe75f15ca75894c2df47a3db6d6a6dcc3c672c0d084e9a95711a5ea09c7ee9165d14e5946cad1093a7514448ce1920b536f5d15cd17cc0f507819f0f1
|
@@ -21,6 +21,7 @@ module Moonrope
|
|
21
21
|
structure = Moonrope::Structure.new(@base, name)
|
22
22
|
structure.dsl.instance_eval(&block) if block_given?
|
23
23
|
@base.structures << structure
|
24
|
+
structure
|
24
25
|
end
|
25
26
|
|
26
27
|
#
|
@@ -39,6 +40,7 @@ module Moonrope
|
|
39
40
|
end
|
40
41
|
controller.dsl.instance_eval(&block) if block_given?
|
41
42
|
@base.controllers << controller
|
43
|
+
controller
|
42
44
|
end
|
43
45
|
|
44
46
|
#
|
@@ -66,7 +68,9 @@ module Moonrope
|
|
66
68
|
# @yield stores the block to execute for the helper
|
67
69
|
#
|
68
70
|
def helper(name, &block)
|
69
|
-
|
71
|
+
helper_instance = Moonrope::Helper.new(name, nil, &block)
|
72
|
+
@base.helpers << helper_instance
|
73
|
+
helper_instance
|
70
74
|
end
|
71
75
|
|
72
76
|
end
|
@@ -115,27 +115,45 @@ module Moonrope
|
|
115
115
|
# object and return a hash or nil if the structure doesn't
|
116
116
|
# exist.
|
117
117
|
#
|
118
|
-
# @param
|
118
|
+
# @param structure_name [Moonrope::Structure or Symbol] the structure to be used
|
119
119
|
# @param object [Object] the object to pass through the structure
|
120
120
|
# @param options [Hash] options to pass to the strucutre hash generator
|
121
121
|
#
|
122
|
-
def structure(
|
122
|
+
def structure(structure_name, object, options = {})
|
123
123
|
if object
|
124
|
-
structure =
|
125
|
-
|
126
|
-
when Moonrope::Structure then structure
|
127
|
-
else
|
128
|
-
raise Moonrope::Errors::Error, "Invalid structure '#{structure}'"
|
129
|
-
end
|
130
|
-
if structure
|
124
|
+
structure = structure_for(structure_name)
|
125
|
+
if structure.is_a?(Moonrope::Structure)
|
131
126
|
structure.hash(object, options.merge(:request => @request))
|
132
127
|
else
|
133
|
-
raise Moonrope::Errors::Error, "No structure found named '#{
|
128
|
+
raise Moonrope::Errors::Error, "No structure found named '#{structure_name}'"
|
134
129
|
end
|
135
130
|
else
|
136
131
|
nil
|
137
132
|
end
|
138
133
|
end
|
139
134
|
|
135
|
+
#
|
136
|
+
# Return a Moonrope::Structure object for the provided name
|
137
|
+
#
|
138
|
+
# @param structure_name [Symbol or String] the structure to return
|
139
|
+
#
|
140
|
+
def structure_for(structure_name)
|
141
|
+
structure = case structure_name
|
142
|
+
when Symbol, String then @base.structure(structure_name.to_sym)
|
143
|
+
when Moonrope::Structure then structure_name
|
144
|
+
else
|
145
|
+
false
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
#
|
150
|
+
# Return whether or not a given structure name is valid?
|
151
|
+
#
|
152
|
+
# @param structure_name [Symbol or String] the structure to return
|
153
|
+
#
|
154
|
+
def has_structure_for?(structure_name)
|
155
|
+
self.structure_for(structure_name).is_a?(Moonrope::Structure)
|
156
|
+
end
|
157
|
+
|
140
158
|
end
|
141
159
|
end
|
data/lib/moonrope/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moonrope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|