brock 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ module Brock
|
|
7
7
|
class FieldTypeNotSupported < StandardError
|
8
8
|
end
|
9
9
|
|
10
|
-
class
|
10
|
+
class Schema
|
11
11
|
|
12
12
|
attr_reader :fields
|
13
13
|
|
@@ -24,16 +24,16 @@ module Brock
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def initialize(
|
28
|
-
@fields =
|
29
|
-
klass = self.class.field_for_type(
|
30
|
-
klass.new(
|
27
|
+
def initialize(raw_fields)
|
28
|
+
@fields = raw_fields.map do |raw_field|
|
29
|
+
klass = self.class.field_for_type(raw_field.fetch('type'))
|
30
|
+
klass.new(raw_field)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def to_html(values)
|
34
|
+
def to_html(values = {})
|
35
35
|
fields.map do |field|
|
36
|
-
field.to_html(values
|
36
|
+
field.to_html(values[field.name])
|
37
37
|
end.join("\n")
|
38
38
|
end
|
39
39
|
|
data/lib/brock/version.rb
CHANGED
data/lib/brock.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'brock/
|
1
|
+
require 'brock/schema'
|
2
2
|
require 'brock/version'
|
3
3
|
|
4
4
|
module Brock
|
@@ -7,12 +7,12 @@ module Brock
|
|
7
7
|
VERSION
|
8
8
|
end
|
9
9
|
|
10
|
-
def self.to_html(
|
11
|
-
|
10
|
+
def self.to_html(schema, values, options={})
|
11
|
+
Schema.new(schema).to_html(values)
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.parse_params(
|
15
|
-
|
14
|
+
def self.parse_params(schema, params)
|
15
|
+
Schema.new(schema).parse_paras(params)
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -53,25 +53,25 @@ files:
|
|
53
53
|
- Gemfile
|
54
54
|
- README.md
|
55
55
|
- brock.gemspec
|
56
|
-
- lib/brock/definition.rb
|
57
56
|
- lib/brock/field.rb
|
58
57
|
- lib/brock/field_template.rb
|
59
58
|
- lib/brock/field_template_context.rb
|
60
59
|
- lib/brock/fields/boolean_field.rb
|
61
60
|
- lib/brock/fields/integer_field.rb
|
62
61
|
- lib/brock/fields/string_field.rb
|
62
|
+
- lib/brock/schema.rb
|
63
63
|
- lib/brock/version.rb
|
64
64
|
- lib/brock.rb
|
65
65
|
- share/boolean_field.erb
|
66
66
|
- share/integer_field.erb
|
67
67
|
- share/string_field.erb
|
68
|
-
- spec/brock/definition_spec.rb
|
69
68
|
- spec/brock/field_spec.rb
|
70
69
|
- spec/brock/field_template_context_spec.rb
|
71
70
|
- spec/brock/field_template_spec.rb
|
72
71
|
- spec/brock/fields/boolean_field_spec.rb
|
73
72
|
- spec/brock/fields/integer_field_spec.rb
|
74
73
|
- spec/brock/fields/string_field_spec.rb
|
74
|
+
- spec/brock/schema_spec.rb
|
75
75
|
- spec/fixtures/boolean_field.html
|
76
76
|
- spec/fixtures/integer_field.html
|
77
77
|
- spec/fixtures/string_field.html
|