brock 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/brock.rb +0 -16
- data/lib/brock/field.rb +23 -7
- data/lib/brock/field_template.rb +1 -1
- data/lib/brock/fields/boolean_field.rb +13 -1
- data/lib/brock/fields/integer_field.rb +6 -2
- data/lib/brock/fields/select_field.rb +26 -0
- data/lib/brock/fields/string_field.rb +8 -0
- data/lib/brock/fields/text_field.rb +15 -0
- data/lib/brock/schema.rb +19 -17
- data/lib/brock/version.rb +5 -1
- data/share/boolean_field.erb +3 -2
- data/share/integer_field.erb +3 -1
- data/share/select_field.erb +24 -0
- data/share/string_field.erb +3 -1
- data/share/text_field.erb +15 -0
- data/spec/brock/field_template_spec.rb +1 -1
- data/spec/brock/fields/boolean_field_spec.rb +38 -11
- data/spec/brock/fields/integer_field_spec.rb +8 -12
- data/spec/brock/fields/select_field_spec.rb +44 -0
- data/spec/brock/fields/string_field_spec.rb +15 -11
- data/spec/brock/fields/text_field_spec.rb +24 -0
- data/spec/brock/schema_spec.rb +14 -0
- data/spec/fixtures/boolean_field.html +2 -2
- data/spec/fixtures/integer_field.html +2 -2
- data/spec/fixtures/select_field.html +20 -0
- data/spec/fixtures/string_field.html +2 -2
- data/spec/fixtures/text_field.html +6 -0
- data/spec/spec_helper.rb +1 -19
- data/spec/support/field_spec.rb +35 -0
- data/spec/support/fixture_helpers.rb +11 -0
- metadata +12 -3
- data/spec/brock/field_spec.rb +0 -29
data/lib/brock.rb
CHANGED
@@ -1,18 +1,2 @@
|
|
1
1
|
require 'brock/schema'
|
2
2
|
require 'brock/version'
|
3
|
-
|
4
|
-
module Brock
|
5
|
-
|
6
|
-
def self.version
|
7
|
-
VERSION
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.to_html(schema, values, options={})
|
11
|
-
Schema.new(schema).to_html(values)
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.parse_params(schema, params)
|
15
|
-
Schema.new(schema).parse_paras(params)
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
data/lib/brock/field.rb
CHANGED
@@ -13,13 +13,16 @@ module Brock
|
|
13
13
|
|
14
14
|
attr_reader :description
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
def self.detect(params)
|
17
|
+
params['type'] == type.to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.new_from_params(params)
|
21
|
+
new(params.fetch('name'), params)
|
22
|
+
end
|
21
23
|
|
22
|
-
|
24
|
+
def initialize(name, params = {})
|
25
|
+
@name, @params = name.to_sym, params
|
23
26
|
end
|
24
27
|
|
25
28
|
def to_html(value=nil)
|
@@ -27,7 +30,20 @@ module Brock
|
|
27
30
|
end
|
28
31
|
|
29
32
|
def parse_param(value)
|
30
|
-
raise ParamParseError
|
33
|
+
raise ParamParseError.new(value)
|
34
|
+
end
|
35
|
+
|
36
|
+
def label
|
37
|
+
@params['label'] or
|
38
|
+
name.to_s.gsub(/[^[:alnum:]]+/,' ').sub(/^(.)/) {|l| l.upcase }
|
39
|
+
end
|
40
|
+
|
41
|
+
def default
|
42
|
+
@params['default']
|
43
|
+
end
|
44
|
+
|
45
|
+
def description
|
46
|
+
@params['description']
|
31
47
|
end
|
32
48
|
|
33
49
|
end
|
data/lib/brock/field_template.rb
CHANGED
@@ -3,8 +3,20 @@ require 'brock/field'
|
|
3
3
|
module Brock
|
4
4
|
class BooleanField < Field
|
5
5
|
|
6
|
+
def self.type
|
7
|
+
:boolean
|
8
|
+
end
|
9
|
+
|
10
|
+
def default
|
11
|
+
if @params.has_key?('default')
|
12
|
+
@params['default']
|
13
|
+
else
|
14
|
+
true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
6
18
|
def parse_param(value)
|
7
|
-
value == '1' || value == 'true' || value == true
|
19
|
+
value == 'on' || value == '1' || value == 'true' || value == true
|
8
20
|
end
|
9
21
|
|
10
22
|
end
|
@@ -3,10 +3,14 @@ require 'brock/field'
|
|
3
3
|
module Brock
|
4
4
|
class IntegerField < Field
|
5
5
|
|
6
|
+
def self.type
|
7
|
+
:integer
|
8
|
+
end
|
9
|
+
|
6
10
|
def parse_param(value)
|
7
11
|
Integer(value)
|
8
|
-
rescue ArgumentError
|
9
|
-
|
12
|
+
rescue ArgumentError, TypeError
|
13
|
+
super(value)
|
10
14
|
end
|
11
15
|
|
12
16
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'brock/field'
|
2
|
+
|
3
|
+
module Brock
|
4
|
+
class SelectField < Field
|
5
|
+
|
6
|
+
def self.type
|
7
|
+
:select
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.detect(field)
|
11
|
+
super(field) or (
|
12
|
+
field['values'] and
|
13
|
+
(field['type'] == 'string' or not field.has_key?('type'))
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse_param(value)
|
18
|
+
value.to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
def values
|
22
|
+
@params['values'] || []
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/brock/schema.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'brock/fields/boolean_field'
|
2
2
|
require 'brock/fields/integer_field'
|
3
|
+
require 'brock/fields/select_field'
|
3
4
|
require 'brock/fields/string_field'
|
5
|
+
require 'brock/fields/text_field'
|
4
6
|
|
5
7
|
module Brock
|
6
8
|
|
@@ -11,36 +13,36 @@ module Brock
|
|
11
13
|
|
12
14
|
attr_reader :fields
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
FIELD_TYPES = [
|
17
|
+
IntegerField,
|
18
|
+
BooleanField,
|
19
|
+
TextField,
|
20
|
+
SelectField,
|
21
|
+
StringField
|
22
|
+
]
|
23
|
+
|
24
|
+
def self.field_for(raw)
|
25
|
+
klass = FIELD_TYPES.detect {|type| type.detect(raw) }
|
26
|
+
if klass
|
27
|
+
klass.new_from_params(raw)
|
22
28
|
else
|
23
|
-
raise FieldTypeNotSupported
|
29
|
+
raise FieldTypeNotSupported.new(raw)
|
24
30
|
end
|
25
31
|
end
|
26
32
|
|
27
33
|
def initialize(raw_fields)
|
28
|
-
@fields = raw_fields.map
|
29
|
-
klass = self.class.field_for_type(raw_field.fetch('type'))
|
30
|
-
klass.new(raw_field)
|
31
|
-
end
|
34
|
+
@fields = raw_fields.map {|raw_field| self.class.field_for(raw_field) }
|
32
35
|
end
|
33
36
|
|
34
37
|
def to_html(values = {})
|
35
38
|
fields.map do |field|
|
36
|
-
field.to_html(values[field.name])
|
39
|
+
field.to_html(values[field.name.to_s])
|
37
40
|
end.join("\n")
|
38
41
|
end
|
39
42
|
|
40
43
|
def parse_params(params)
|
41
|
-
|
42
|
-
field =
|
43
|
-
settings[field.name] = field.parse_param(value)
|
44
|
+
fields.each_with_object({}) do |field, settings|
|
45
|
+
settings[field.name] = field.parse_param(params[field.name])
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
data/lib/brock/version.rb
CHANGED
data/share/boolean_field.erb
CHANGED
data/share/integer_field.erb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
<div class="control-group brock-field brock-field-select">
|
2
|
+
<div class="control-label">
|
3
|
+
<%= label %>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<div class="controls">
|
7
|
+
<% values.each do |v| %>
|
8
|
+
<label class="radio brock-label">
|
9
|
+
<input class="brock-field"
|
10
|
+
type="radio"
|
11
|
+
name="brock[<%= name %>]"
|
12
|
+
value="<%= v['value'] %>"
|
13
|
+
<% if value == v['value'] or (not value and v['value'] == default) %>
|
14
|
+
checked
|
15
|
+
<% end %>
|
16
|
+
/>
|
17
|
+
<%= v['label'] %>
|
18
|
+
<% if v['description'] %>
|
19
|
+
<p class="help-block"><%= v['description'] %></p>
|
20
|
+
<% end %>
|
21
|
+
</label>
|
22
|
+
<% end %>
|
23
|
+
</div>
|
24
|
+
</div>
|
data/share/string_field.erb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
<div class="control-group brock-field brock-field-text">
|
2
|
+
<label class="control-label brock-label"><%= label %></label>
|
3
|
+
<div class="controls">
|
4
|
+
<textarea class="brock-field"
|
5
|
+
name="brock[<%= name %>]"
|
6
|
+
<% if default %>
|
7
|
+
placeholder="<%= default %>"
|
8
|
+
<% end %>
|
9
|
+
/><% if value %><%= value %><% end %></textarea>
|
10
|
+
|
11
|
+
<% if description %>
|
12
|
+
<p class="help-block brock-description"><%= description %></p>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
15
|
+
</div>
|
@@ -3,21 +3,34 @@ require 'brock/fields/boolean_field'
|
|
3
3
|
|
4
4
|
describe Brock::BooleanField do
|
5
5
|
|
6
|
-
subject {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
subject { described_class.new(:espresso) }
|
7
|
+
|
8
|
+
it_behaves_like "a field"
|
9
|
+
|
10
|
+
it "asdf" do
|
11
|
+
|
12
|
+
expect(subject.to_html(true)).to match(/checked/)
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
describe ".detect" do
|
17
|
+
|
18
|
+
it "picks fields with type boolean" do
|
19
|
+
expect(described_class.detect('type' => 'boolean'))
|
20
|
+
end
|
21
|
+
|
22
|
+
it "picks fields with boolean defaults" do
|
23
|
+
expect(described_class.detect('default' => true))
|
24
|
+
end
|
25
|
+
|
17
26
|
end
|
18
27
|
|
19
28
|
describe "#parse_param" do
|
20
29
|
|
30
|
+
it "works with on" do
|
31
|
+
expect(subject.parse_param('on')).to eq(true)
|
32
|
+
end
|
33
|
+
|
21
34
|
it "works with 1" do
|
22
35
|
expect(subject.parse_param('1')).to eq(true)
|
23
36
|
end
|
@@ -31,4 +44,18 @@ describe Brock::BooleanField do
|
|
31
44
|
end
|
32
45
|
|
33
46
|
end
|
47
|
+
|
48
|
+
describe "#default" do
|
49
|
+
|
50
|
+
it "can be set in the constructor" do
|
51
|
+
subject = described_class.new(:latte, 'default' => false)
|
52
|
+
expect(subject.default).to be_false
|
53
|
+
end
|
54
|
+
|
55
|
+
it "defaults to true" do
|
56
|
+
expect(subject.default)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
34
61
|
end
|
@@ -3,18 +3,9 @@ require 'brock/fields/integer_field'
|
|
3
3
|
|
4
4
|
describe Brock::IntegerField do
|
5
5
|
|
6
|
-
subject {
|
7
|
-
|
8
|
-
|
9
|
-
'name' => 'rounds',
|
10
|
-
'label' => 'Rounds',
|
11
|
-
'default' => 10
|
12
|
-
)
|
13
|
-
}
|
14
|
-
|
15
|
-
it "#to_html works" do
|
16
|
-
expect(subject.to_html(5)).to be_similar_to_fixture('integer_field.html')
|
17
|
-
end
|
6
|
+
subject { described_class.new(:espresso) }
|
7
|
+
|
8
|
+
it_behaves_like "a field"
|
18
9
|
|
19
10
|
describe "#parse_param" do
|
20
11
|
|
@@ -33,4 +24,9 @@ describe Brock::IntegerField do
|
|
33
24
|
end
|
34
25
|
|
35
26
|
end
|
27
|
+
|
28
|
+
it "#default is optional" do
|
29
|
+
expect(subject.default).to eq(nil)
|
30
|
+
end
|
31
|
+
|
36
32
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'brock/fields/select_field'
|
3
|
+
|
4
|
+
describe Brock::SelectField do
|
5
|
+
|
6
|
+
subject {
|
7
|
+
described_class.new(:espresso, 'values' => [
|
8
|
+
{'value' => 0, 'label' => 'First', 'description' => 'The first'},
|
9
|
+
{'value' => 1, 'label' => 'Second', 'description' => 'The second'}
|
10
|
+
])
|
11
|
+
}
|
12
|
+
|
13
|
+
it_behaves_like "a field"
|
14
|
+
|
15
|
+
describe ".detect" do
|
16
|
+
|
17
|
+
it "is true for fields without a type and just a value" do
|
18
|
+
expect(described_class.detect("type" => "string", "values" => []))
|
19
|
+
end
|
20
|
+
|
21
|
+
it "is true for fields without a type and just a value" do
|
22
|
+
expect(described_class.detect("values" => []))
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#parse_param" do
|
28
|
+
|
29
|
+
it "works with string" do
|
30
|
+
expect(subject.parse_param('foo')).to eq('foo')
|
31
|
+
end
|
32
|
+
|
33
|
+
it "calls to_s on other objects" do
|
34
|
+
obj = stub(to_s: 'sentinal')
|
35
|
+
expect(subject.parse_param(obj)).to eq('sentinal')
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
it "#default is optional" do
|
41
|
+
expect(subject.default).to eq(nil)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -3,17 +3,16 @@ require 'brock/fields/string_field'
|
|
3
3
|
|
4
4
|
describe Brock::StringField do
|
5
5
|
|
6
|
-
subject {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
expect(subject.to_html(5)).to be_similar_to_fixture('string_field.html')
|
6
|
+
subject { described_class.new(:espresso) }
|
7
|
+
|
8
|
+
it_behaves_like "a field"
|
9
|
+
|
10
|
+
describe ".detect" do
|
11
|
+
|
12
|
+
it "is true for fields without a type" do
|
13
|
+
expect(described_class.detect({}))
|
14
|
+
end
|
15
|
+
|
17
16
|
end
|
18
17
|
|
19
18
|
describe "#parse_param" do
|
@@ -28,4 +27,9 @@ describe Brock::StringField do
|
|
28
27
|
end
|
29
28
|
|
30
29
|
end
|
30
|
+
|
31
|
+
it "#default is optional" do
|
32
|
+
expect(subject.default).to eq(nil)
|
33
|
+
end
|
34
|
+
|
31
35
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'brock/fields/text_field'
|
3
|
+
|
4
|
+
describe Brock::TextField do
|
5
|
+
|
6
|
+
subject {
|
7
|
+
described_class.new(:espresso)
|
8
|
+
}
|
9
|
+
|
10
|
+
it_behaves_like "a field"
|
11
|
+
|
12
|
+
describe "#parse_param" do
|
13
|
+
|
14
|
+
it "works with string" do
|
15
|
+
expect(subject.parse_param('foo')).to eq('foo')
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
it "#default is optional" do
|
21
|
+
expect(subject.default).to eq(nil)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/spec/brock/schema_spec.rb
CHANGED
@@ -16,6 +16,10 @@ describe Brock::Schema do
|
|
16
16
|
"type" => "boolean",
|
17
17
|
"label" => "Auto Team Balance",
|
18
18
|
"default" => true
|
19
|
+
}, {
|
20
|
+
"name" => "first_name",
|
21
|
+
"label" => "First name",
|
22
|
+
"default" => "Chris"
|
19
23
|
}
|
20
24
|
]
|
21
25
|
}
|
@@ -26,5 +30,15 @@ describe Brock::Schema do
|
|
26
30
|
expect { subject }.to_not raise_error(Brock::FieldTypeNotSupported)
|
27
31
|
end
|
28
32
|
|
33
|
+
{
|
34
|
+
{"name" => "a"} => Brock::StringField,
|
35
|
+
{"name" => "a", "values" => []} => Brock::SelectField,
|
36
|
+
{"name" => "a", "type" => "string", "values" => []} => Brock::SelectField
|
37
|
+
}.each do |raw, klass|
|
38
|
+
it ".field_for matches a shortcut to #{klass}" do
|
39
|
+
described_class.field_for(raw).should be_a(klass)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
29
43
|
end
|
30
44
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<div class="control-group brock-field brock-field-boolean">
|
2
2
|
<div class="controls checkbox">
|
3
3
|
<label class="control-label brock-label">
|
4
|
-
<input class="brock-field" type="checkbox" name="brock[
|
5
|
-
|
4
|
+
<input class="brock-field" type="checkbox" name="brock[espresso]" checked />
|
5
|
+
Espresso
|
6
6
|
</label>
|
7
7
|
</div>
|
8
8
|
</div>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<div class="control-group brock-field brock-field-integer">
|
2
|
-
<label class="control-label brock-label">
|
2
|
+
<label class="control-label brock-label">Espresso</label>
|
3
3
|
<div class="controls">
|
4
|
-
<input class="brock-field" type="number" name="brock[
|
4
|
+
<input class="brock-field" type="number" name="brock[espresso]" />
|
5
5
|
</div>
|
6
6
|
</div>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div class="control-group brock-field brock-field-select">
|
2
|
+
<div class="control-label">
|
3
|
+
Espresso
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<div class="controls">
|
7
|
+
<label class="radio brock-label">
|
8
|
+
<input class="brock-field" type="radio" name="brock[espresso]" value="0" />
|
9
|
+
First
|
10
|
+
|
11
|
+
<p class="help-block">The first</p>
|
12
|
+
</label>
|
13
|
+
<label class="radio brock-label">
|
14
|
+
<input class="brock-field" type="radio" name="brock[espresso]" value="1" />
|
15
|
+
Second
|
16
|
+
|
17
|
+
<p class="help-block">The second</p>
|
18
|
+
</label>
|
19
|
+
</div>
|
20
|
+
</div>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<div class="control-group brock-field brock-field-string">
|
2
|
-
<label class="control-label brock-label">
|
2
|
+
<label class="control-label brock-label">Espresso</label>
|
3
3
|
<div class="controls">
|
4
|
-
<input class="brock-field" type="text" name="brock[
|
4
|
+
<input class="brock-field" type="text" name="brock[espresso]" />
|
5
5
|
</div>
|
6
6
|
</div>
|
data/spec/spec_helper.rb
CHANGED
@@ -1,22 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
def fixture(path)
|
4
|
-
File.read(File.join(File.dirname(__FILE__), 'fixtures', path))
|
5
|
-
end
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
RSpec::Matchers.define :be_similar_to_fixture do |fixture_path|
|
10
|
-
|
11
|
-
def scrub(str)
|
12
|
-
str.gsub(/\s+/, ' ')
|
13
|
-
end
|
14
|
-
|
15
|
-
match do |actual|
|
16
|
-
scrub(actual) == scrub(fixture(fixture_path))
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
1
|
+
Dir["./spec/support/**/*.rb"].sort.each {|f| require f }
|
20
2
|
|
21
3
|
RSpec.configure do |config|
|
22
4
|
config.include(FixtureHelpers)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'brock/field'
|
2
|
+
|
3
|
+
shared_examples "a field" do
|
4
|
+
|
5
|
+
let(:default_fixture) { "#{described_class.type}_field.html" }
|
6
|
+
|
7
|
+
it "is a Brock::Field" do
|
8
|
+
expect(subject).to be_a(Brock::Field)
|
9
|
+
end
|
10
|
+
|
11
|
+
it ".type is a symbol" do
|
12
|
+
expect(described_class.type).to be_a(Symbol)
|
13
|
+
end
|
14
|
+
|
15
|
+
it '.detect with same type' do
|
16
|
+
expect(described_class.detect('type' => described_class.type.to_s))
|
17
|
+
end
|
18
|
+
|
19
|
+
it "#name is a symbol" do
|
20
|
+
expect(subject.name).to be_a(Symbol)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "#label is optional" do
|
24
|
+
subject.instance_variable_set('@label', nil)
|
25
|
+
subject.stub(name: 'mp_tag')
|
26
|
+
expect(subject.label).to eq('Mp tag')
|
27
|
+
end
|
28
|
+
|
29
|
+
it "#to_html matches the fixture" do
|
30
|
+
scrubbed_html = scrub_html(subject.to_html)
|
31
|
+
scrubbed_fixture = scrub_html(fixture(default_fixture))
|
32
|
+
expect(scrubbed_html).to eq(scrubbed_fixture)
|
33
|
+
end
|
34
|
+
|
35
|
+
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.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -58,24 +58,33 @@ files:
|
|
58
58
|
- lib/brock/field_template_context.rb
|
59
59
|
- lib/brock/fields/boolean_field.rb
|
60
60
|
- lib/brock/fields/integer_field.rb
|
61
|
+
- lib/brock/fields/select_field.rb
|
61
62
|
- lib/brock/fields/string_field.rb
|
63
|
+
- lib/brock/fields/text_field.rb
|
62
64
|
- lib/brock/schema.rb
|
63
65
|
- lib/brock/version.rb
|
64
66
|
- lib/brock.rb
|
65
67
|
- share/boolean_field.erb
|
66
68
|
- share/integer_field.erb
|
69
|
+
- share/select_field.erb
|
67
70
|
- share/string_field.erb
|
68
|
-
-
|
71
|
+
- share/text_field.erb
|
69
72
|
- spec/brock/field_template_context_spec.rb
|
70
73
|
- spec/brock/field_template_spec.rb
|
71
74
|
- spec/brock/fields/boolean_field_spec.rb
|
72
75
|
- spec/brock/fields/integer_field_spec.rb
|
76
|
+
- spec/brock/fields/select_field_spec.rb
|
73
77
|
- spec/brock/fields/string_field_spec.rb
|
78
|
+
- spec/brock/fields/text_field_spec.rb
|
74
79
|
- spec/brock/schema_spec.rb
|
75
80
|
- spec/fixtures/boolean_field.html
|
76
81
|
- spec/fixtures/integer_field.html
|
82
|
+
- spec/fixtures/select_field.html
|
77
83
|
- spec/fixtures/string_field.html
|
84
|
+
- spec/fixtures/text_field.html
|
78
85
|
- spec/spec_helper.rb
|
86
|
+
- spec/support/field_spec.rb
|
87
|
+
- spec/support/fixture_helpers.rb
|
79
88
|
homepage: https://minefold.com
|
80
89
|
licenses: []
|
81
90
|
post_install_message:
|
data/spec/brock/field_spec.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'brock/field'
|
3
|
-
|
4
|
-
describe Brock::Field do
|
5
|
-
|
6
|
-
subject {
|
7
|
-
described_class.new(
|
8
|
-
'type' => 'str',
|
9
|
-
'name' => 'a',
|
10
|
-
'label' => 'A',
|
11
|
-
'default' => 'a'
|
12
|
-
)
|
13
|
-
}
|
14
|
-
|
15
|
-
it "#type is a symbol" do
|
16
|
-
expect(subject.type).to be_a(Symbol)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "#name is a symbol" do
|
20
|
-
expect(subject.type).to be_a(Symbol)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "#parse_param raises by default" do
|
24
|
-
expect {
|
25
|
-
subject.parse_param(nil)
|
26
|
-
}.to raise_error(Brock::ParamParseError)
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|