magicka 0.2.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +19 -5
- data/README.md +1 -1
- data/config/check_specs.yml +2 -0
- data/config/yardstick.yml +1 -1
- data/lib/magicka.rb +8 -5
- data/lib/magicka/aggregator.rb +19 -0
- data/lib/magicka/aggregator/method_builder.rb +40 -0
- data/lib/magicka/button.rb +9 -0
- data/lib/magicka/element.rb +3 -2
- data/lib/magicka/element/method_builder.rb +40 -0
- data/lib/magicka/form.rb +41 -0
- data/lib/magicka/{input_element.rb → form_element.rb} +3 -1
- data/lib/magicka/input.rb +1 -1
- data/lib/magicka/select.rb +8 -0
- data/lib/magicka/version.rb +1 -1
- data/spec/lib/magicka/button_spec.rb +54 -0
- data/spec/lib/magicka/{method_builder_spec.rb → element/method_builder_spec.rb} +1 -1
- data/spec/lib/magicka/element_spec.rb +2 -2
- data/spec/lib/magicka/form_element_spec.rb +87 -0
- data/spec/lib/magicka/form_spec.rb +156 -0
- data/spec/lib/magicka/{input_element_spec.rb → select_spec.rb} +7 -8
- metadata +14 -6
- data/lib/magicka/method_builder.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05ffde0ed491999459ac688704b00c0ce07e2c93ae89aaa75f78a1c6b8acabba
|
4
|
+
data.tar.gz: 6d08209c27862a6791917a32e322775bfc801a00dcb666924d7b0b387c92f03b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d2aa6d343fe5104e275dc9257fb838c650f0353406452b217fb17f40978ea4152838c56181300bec3f1da208f28764790e947619f5137426545206c540e5952
|
7
|
+
data.tar.gz: 91036aeff9fbefe61eacc3b93005e8f51e9c6cf86ce7cb618e5360ea8059c7ba6df680c4bd5cebf9c57cb3a8154058b63aa1aeb1c362261b4613e4707cf41ca0
|
data/.circleci/config.yml
CHANGED
@@ -7,8 +7,12 @@ workflows:
|
|
7
7
|
filters:
|
8
8
|
tags:
|
9
9
|
only: /.*/
|
10
|
+
- checks:
|
11
|
+
filters:
|
12
|
+
tags:
|
13
|
+
only: /.*/
|
10
14
|
- build-and-release:
|
11
|
-
requires: [test]
|
15
|
+
requires: [test, checks]
|
12
16
|
filters:
|
13
17
|
tags:
|
14
18
|
only: /\d+\.\d+\.\d+/
|
@@ -18,7 +22,7 @@ workflows:
|
|
18
22
|
jobs:
|
19
23
|
test:
|
20
24
|
docker:
|
21
|
-
- image: darthjee/circleci_rails_gems:0.
|
25
|
+
- image: darthjee/circleci_rails_gems:0.6.0
|
22
26
|
environment:
|
23
27
|
PROJECT: magicka
|
24
28
|
steps:
|
@@ -32,12 +36,22 @@ jobs:
|
|
32
36
|
- run:
|
33
37
|
name: RSpec
|
34
38
|
command: bundle exec rspec
|
35
|
-
- run:
|
36
|
-
name: Rubocop
|
37
|
-
command: rubocop
|
38
39
|
- run:
|
39
40
|
name: Coverage Test Report
|
40
41
|
command: cc-test-reporter after-build --exit-code $?
|
42
|
+
checks:
|
43
|
+
docker:
|
44
|
+
- image: darthjee/circleci_rails_gems:0.6.0
|
45
|
+
environment:
|
46
|
+
PROJECT: magicka
|
47
|
+
steps:
|
48
|
+
- checkout
|
49
|
+
- run:
|
50
|
+
name: Bundle Install
|
51
|
+
command: bundle install
|
52
|
+
- run:
|
53
|
+
name: Rubocop
|
54
|
+
command: rubocop
|
41
55
|
- run:
|
42
56
|
name: Yardstick coverage check
|
43
57
|
command: bundle exec rake verify_measurements
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Magicka
|
|
11
11
|
|
12
12
|
Yard Documentation
|
13
13
|
-------------------
|
14
|
-
[https://www.rubydoc.info/gems/magicka/0.
|
14
|
+
[https://www.rubydoc.info/gems/magicka/0.5.0](https://www.rubydoc.info/gems/magicka/0.5.0)
|
15
15
|
|
16
16
|
Installation
|
17
17
|
---------------
|
data/config/check_specs.yml
CHANGED
data/config/yardstick.yml
CHANGED
data/lib/magicka.rb
CHANGED
@@ -10,9 +10,12 @@ require 'sinclair'
|
|
10
10
|
#
|
11
11
|
# module holding herlper to render inputs
|
12
12
|
module Magicka
|
13
|
-
autoload :VERSION,
|
14
|
-
autoload :
|
15
|
-
autoload :
|
16
|
-
autoload :
|
17
|
-
autoload :
|
13
|
+
autoload :VERSION, 'magicka/version'
|
14
|
+
autoload :Aggregator, 'magicka/aggregator'
|
15
|
+
autoload :Button, 'magicka/button'
|
16
|
+
autoload :Element, 'magicka/element'
|
17
|
+
autoload :FormElement, 'magicka/form_element'
|
18
|
+
autoload :Form, 'magicka/form'
|
19
|
+
autoload :Input, 'magicka/input'
|
20
|
+
autoload :Select, 'magicka/select'
|
18
21
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Magicka
|
4
|
+
# @api public
|
5
|
+
#
|
6
|
+
# Class representing an element agregator, representing a model
|
7
|
+
class Aggregator
|
8
|
+
autoload :MethodBuilder, 'magicka/aggregator/method_builder'
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def with_element(element_class, method_name = nil)
|
12
|
+
MethodBuilder
|
13
|
+
.new(self, element_class, method_name)
|
14
|
+
.prepare
|
15
|
+
.build
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Magicka
|
4
|
+
class Aggregator
|
5
|
+
# @api private
|
6
|
+
#
|
7
|
+
# Class responsible for building an {Aggregator} method
|
8
|
+
class MethodBuilder < Sinclair
|
9
|
+
def initialize(klass, element_class, method_name = nil)
|
10
|
+
super(klass)
|
11
|
+
|
12
|
+
@element_class = element_class
|
13
|
+
@method_name = method_name
|
14
|
+
end
|
15
|
+
|
16
|
+
def prepare
|
17
|
+
element_klass = element_class
|
18
|
+
|
19
|
+
add_method(method_name) do |field, model: self.model, **args|
|
20
|
+
element_klass.render(
|
21
|
+
renderer: renderer, field: field, model: model, **args
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :element_class
|
31
|
+
|
32
|
+
def method_name
|
33
|
+
@method_name ||= element_class
|
34
|
+
.name
|
35
|
+
.underscore
|
36
|
+
.gsub(%r{.*/}, '')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/magicka/element.rb
CHANGED
@@ -5,7 +5,8 @@ module Magicka
|
|
5
5
|
#
|
6
6
|
# Base class for element rendering
|
7
7
|
class Element < Sinclair::Options
|
8
|
-
autoload :ClassMethods,
|
8
|
+
autoload :ClassMethods, 'magicka/element/class_methods'
|
9
|
+
autoload :MethodBuilder, 'magicka/element/method_builder'
|
9
10
|
|
10
11
|
skip_validation
|
11
12
|
|
@@ -76,7 +77,7 @@ module Magicka
|
|
76
77
|
#
|
77
78
|
# @return [String]
|
78
79
|
def template
|
79
|
-
name.underscore
|
80
|
+
self.class.name.underscore
|
80
81
|
.gsub(%r{^.*/}, "#{template_folder}/")
|
81
82
|
end
|
82
83
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Magicka
|
4
|
+
class Element
|
5
|
+
# @api private
|
6
|
+
#
|
7
|
+
# class responsible for building methods on {Magicka::Element}
|
8
|
+
class MethodBuilder < Sinclair
|
9
|
+
# adds a mehtod +#template+
|
10
|
+
#
|
11
|
+
# The method will always return the template given in the params
|
12
|
+
#
|
13
|
+
# @param template [String] path to template file
|
14
|
+
#
|
15
|
+
# @return [Array<Sinclair::MethodDefinition>]
|
16
|
+
def add_template(template)
|
17
|
+
add_method(:template) do
|
18
|
+
template
|
19
|
+
end
|
20
|
+
|
21
|
+
build
|
22
|
+
end
|
23
|
+
|
24
|
+
# adds a mehtod +#template_folder+
|
25
|
+
#
|
26
|
+
# The method will always return the template folder given in the params
|
27
|
+
#
|
28
|
+
# @param template_folder [String] path to template folder
|
29
|
+
#
|
30
|
+
# @return [Array<Sinclair::MethodDefinition>]
|
31
|
+
def add_template_folder(folder)
|
32
|
+
add_method(:template_folder) do
|
33
|
+
folder
|
34
|
+
end
|
35
|
+
|
36
|
+
build
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/magicka/form.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Magicka
|
4
|
+
# Class responsible for controlling one object form
|
5
|
+
class Form < Aggregator
|
6
|
+
attr_reader :model
|
7
|
+
|
8
|
+
def initialize(renderer, model)
|
9
|
+
@renderer = renderer
|
10
|
+
@model = model
|
11
|
+
end
|
12
|
+
|
13
|
+
with_element(Input)
|
14
|
+
with_element(Select)
|
15
|
+
|
16
|
+
def button(**args)
|
17
|
+
Button.render(renderer: renderer, **args)
|
18
|
+
end
|
19
|
+
|
20
|
+
def with_model(model)
|
21
|
+
new_model = [self.model, model].join('.')
|
22
|
+
|
23
|
+
yield Form.new(renderer, new_model)
|
24
|
+
end
|
25
|
+
|
26
|
+
def equal?(other)
|
27
|
+
return unless other.class == self.class
|
28
|
+
|
29
|
+
other.renderer == renderer &&
|
30
|
+
other.model == model
|
31
|
+
end
|
32
|
+
|
33
|
+
alias == equal?
|
34
|
+
|
35
|
+
protected
|
36
|
+
|
37
|
+
attr_reader :renderer
|
38
|
+
|
39
|
+
delegate :render, to: :renderer
|
40
|
+
end
|
41
|
+
end
|
@@ -4,11 +4,13 @@ module Magicka
|
|
4
4
|
# @api public
|
5
5
|
#
|
6
6
|
# Basic class for elements for forms
|
7
|
-
class
|
7
|
+
class FormElement < Element
|
8
8
|
with_attribute_locals :field, :label
|
9
9
|
with_attributes :model
|
10
10
|
with_locals :ng_errors, :ng_model
|
11
11
|
|
12
|
+
template_folder 'templates/forms'
|
13
|
+
|
12
14
|
private
|
13
15
|
|
14
16
|
# @api private
|
data/lib/magicka/input.rb
CHANGED
data/lib/magicka/version.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Magicka::Button do
|
6
|
+
let(:renderer) { instance_double('renderer') }
|
7
|
+
let(:template) { 'templates/forms/button' }
|
8
|
+
|
9
|
+
let(:ng_click) { 'controler.click()' }
|
10
|
+
let(:ng_disabled) { 'false' }
|
11
|
+
let(:classes) { 'custom class' }
|
12
|
+
let(:text) { 'Click' }
|
13
|
+
|
14
|
+
let(:locals) do
|
15
|
+
{
|
16
|
+
ng_click: ng_click,
|
17
|
+
ng_disabled: ng_disabled,
|
18
|
+
classes: classes,
|
19
|
+
text: text
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '.render' do
|
24
|
+
let(:arguments) do
|
25
|
+
{
|
26
|
+
renderer: renderer,
|
27
|
+
ng_click: ng_click,
|
28
|
+
ng_disabled: ng_disabled,
|
29
|
+
classes: classes,
|
30
|
+
text: text
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
before do
|
35
|
+
allow(renderer)
|
36
|
+
.to receive(:render)
|
37
|
+
.with(partial: template, locals: locals)
|
38
|
+
end
|
39
|
+
|
40
|
+
it do
|
41
|
+
described_class.render(arguments)
|
42
|
+
|
43
|
+
expect(renderer).to have_received(:render)
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when called with extra params' do
|
47
|
+
it do
|
48
|
+
described_class.render(name: 'Name', **arguments)
|
49
|
+
|
50
|
+
expect(renderer).to have_received(:render)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -67,12 +67,12 @@ describe Magicka::Element do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
context 'when class has only folder defined' do
|
70
|
-
let(:expected_template) { 'templates/forms/
|
70
|
+
let(:expected_template) { 'templates/forms/my_element' }
|
71
71
|
|
72
72
|
before do
|
73
73
|
klass.template_folder(folder)
|
74
74
|
|
75
|
-
method_builder.
|
75
|
+
method_builder.add_class_method(:name) { 'Magicka::MyElement' }
|
76
76
|
method_builder.build
|
77
77
|
end
|
78
78
|
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Magicka::FormElement do
|
6
|
+
let(:renderer) { instance_double('renderer') }
|
7
|
+
let(:template) { 'templates/forms/custom_template' }
|
8
|
+
|
9
|
+
let(:expected_template) { template }
|
10
|
+
|
11
|
+
let(:model) { :my_model }
|
12
|
+
let(:field) { :field }
|
13
|
+
let(:label) { 'Label' }
|
14
|
+
let(:klass) { Class.new(described_class) }
|
15
|
+
|
16
|
+
let(:locals) do
|
17
|
+
{
|
18
|
+
field: field,
|
19
|
+
label: label,
|
20
|
+
ng_errors: 'my_model.errors.field',
|
21
|
+
ng_model: 'my_model.field'
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.render' do
|
26
|
+
let(:arguments) do
|
27
|
+
{
|
28
|
+
renderer: renderer,
|
29
|
+
field: field,
|
30
|
+
label: label,
|
31
|
+
model: model
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
before do
|
36
|
+
allow(renderer)
|
37
|
+
.to receive(:render)
|
38
|
+
.with(partial: expected_template, locals: locals)
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when defined template' do
|
42
|
+
before do
|
43
|
+
klass.template(template)
|
44
|
+
end
|
45
|
+
|
46
|
+
it do
|
47
|
+
klass.render(arguments)
|
48
|
+
|
49
|
+
expect(renderer).to have_received(:render)
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when called with extra params' do
|
53
|
+
it do
|
54
|
+
klass.render(name: 'Name', **arguments)
|
55
|
+
|
56
|
+
expect(renderer).to have_received(:render)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when not defining a template' do
|
62
|
+
let(:method_builder) { Sinclair.new(klass) }
|
63
|
+
let(:expected_template) { 'templates/forms/my_custom_element' }
|
64
|
+
|
65
|
+
before do
|
66
|
+
method_builder.add_class_method(:name) do
|
67
|
+
'Magicka::MyCustomElement'
|
68
|
+
end
|
69
|
+
method_builder.build
|
70
|
+
end
|
71
|
+
|
72
|
+
it do
|
73
|
+
klass.render(arguments)
|
74
|
+
|
75
|
+
expect(renderer).to have_received(:render)
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when called with extra params' do
|
79
|
+
it do
|
80
|
+
klass.render(name: 'Name', **arguments)
|
81
|
+
|
82
|
+
expect(renderer).to have_received(:render)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Magicka::Form do
|
6
|
+
subject(:form) { described_class.new(renderer, model) }
|
7
|
+
|
8
|
+
let(:model) { :my_model }
|
9
|
+
let(:renderer) { instance_double('renderer') }
|
10
|
+
let(:template) { 'templates/forms/input' }
|
11
|
+
let(:locals) { {} }
|
12
|
+
|
13
|
+
before do
|
14
|
+
allow(renderer)
|
15
|
+
.to receive(:render)
|
16
|
+
.with(partial: template, locals: locals)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#input' do
|
20
|
+
let(:template) { 'templates/forms/input' }
|
21
|
+
let(:field) { :field }
|
22
|
+
let(:label) { 'Label' }
|
23
|
+
let(:placeholder) { 'Value' }
|
24
|
+
|
25
|
+
let(:locals) do
|
26
|
+
{
|
27
|
+
field: field,
|
28
|
+
label: label,
|
29
|
+
ng_errors: 'my_model.errors.field',
|
30
|
+
ng_model: 'my_model.field',
|
31
|
+
placeholder: placeholder
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
let(:arguments) do
|
36
|
+
{
|
37
|
+
label: label,
|
38
|
+
placeholder: placeholder
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'renders an input' do
|
43
|
+
form.input(field, arguments)
|
44
|
+
|
45
|
+
expect(renderer).to have_received(:render)
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when passing a custom model' do
|
49
|
+
let(:locals) do
|
50
|
+
{
|
51
|
+
field: field,
|
52
|
+
label: label,
|
53
|
+
ng_errors: 'my_custom_model.errors.field',
|
54
|
+
ng_model: 'my_custom_model.field',
|
55
|
+
placeholder: placeholder
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'renders an input' do
|
60
|
+
form.input(field, model: 'my_custom_model', **arguments)
|
61
|
+
|
62
|
+
expect(renderer).to have_received(:render)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#select' do
|
68
|
+
let(:template) { 'templates/forms/select' }
|
69
|
+
let(:field) { :field }
|
70
|
+
let(:label) { 'Label' }
|
71
|
+
let(:options) { %i[option_a option_b] }
|
72
|
+
|
73
|
+
let(:locals) do
|
74
|
+
{
|
75
|
+
field: field,
|
76
|
+
label: label,
|
77
|
+
ng_errors: 'my_model.errors.field',
|
78
|
+
ng_model: 'my_model.field',
|
79
|
+
options: options
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
let(:arguments) do
|
84
|
+
{
|
85
|
+
label: label,
|
86
|
+
options: options
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'renders a select' do
|
91
|
+
form.select(field, arguments)
|
92
|
+
|
93
|
+
expect(renderer).to have_received(:render)
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'when passing a custom model' do
|
97
|
+
let(:locals) do
|
98
|
+
{
|
99
|
+
field: field,
|
100
|
+
label: label,
|
101
|
+
ng_errors: 'my_custom_model.errors.field',
|
102
|
+
ng_model: 'my_custom_model.field',
|
103
|
+
options: options
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'renders a select' do
|
108
|
+
form.select(field, model: 'my_custom_model', **arguments)
|
109
|
+
|
110
|
+
expect(renderer).to have_received(:render)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe '#button' do
|
116
|
+
let(:template) { 'templates/forms/button' }
|
117
|
+
let(:ng_click) { 'controler.click()' }
|
118
|
+
let(:ng_disabled) { 'false' }
|
119
|
+
let(:classes) { 'custom class' }
|
120
|
+
let(:text) { 'Click' }
|
121
|
+
|
122
|
+
let(:locals) do
|
123
|
+
{
|
124
|
+
ng_click: ng_click,
|
125
|
+
ng_disabled: ng_disabled,
|
126
|
+
classes: classes,
|
127
|
+
text: text
|
128
|
+
}
|
129
|
+
end
|
130
|
+
|
131
|
+
let(:arguments) do
|
132
|
+
{
|
133
|
+
ng_click: ng_click,
|
134
|
+
ng_disabled: ng_disabled,
|
135
|
+
classes: classes,
|
136
|
+
text: text
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'renders an input' do
|
141
|
+
form.button(arguments)
|
142
|
+
|
143
|
+
expect(renderer).to have_received(:render)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe '#with_model' do
|
148
|
+
let(:expected_form) { described_class.new(renderer, 'my_model.inner') }
|
149
|
+
|
150
|
+
it do
|
151
|
+
form.with_model(:inner) do |new_form|
|
152
|
+
expect(new_form).to eq(expected_form)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -2,34 +2,33 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Magicka::
|
5
|
+
describe Magicka::Select do
|
6
6
|
let(:renderer) { instance_double('renderer') }
|
7
|
-
let(:template) { 'templates/forms/
|
7
|
+
let(:template) { 'templates/forms/select' }
|
8
8
|
|
9
9
|
let(:model) { :my_model }
|
10
10
|
let(:field) { :field }
|
11
11
|
let(:label) { 'Label' }
|
12
|
+
let(:options) { %i[option_a option_b] }
|
12
13
|
|
13
14
|
let(:locals) do
|
14
15
|
{
|
15
16
|
field: field,
|
16
17
|
label: label,
|
17
18
|
ng_errors: 'my_model.errors.field',
|
18
|
-
ng_model: 'my_model.field'
|
19
|
+
ng_model: 'my_model.field',
|
20
|
+
options: options
|
19
21
|
}
|
20
22
|
end
|
21
23
|
|
22
|
-
before do
|
23
|
-
described_class.template(template)
|
24
|
-
end
|
25
|
-
|
26
24
|
describe '.render' do
|
27
25
|
let(:arguments) do
|
28
26
|
{
|
29
27
|
renderer: renderer,
|
30
28
|
field: field,
|
31
29
|
label: label,
|
32
|
-
model: model
|
30
|
+
model: model,
|
31
|
+
options: options
|
33
32
|
}
|
34
33
|
end
|
35
34
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magicka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DarthJee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -397,11 +397,16 @@ files:
|
|
397
397
|
- config/yardstick.yml
|
398
398
|
- docker-compose.yml
|
399
399
|
- lib/magicka.rb
|
400
|
+
- lib/magicka/aggregator.rb
|
401
|
+
- lib/magicka/aggregator/method_builder.rb
|
402
|
+
- lib/magicka/button.rb
|
400
403
|
- lib/magicka/element.rb
|
401
404
|
- lib/magicka/element/class_methods.rb
|
405
|
+
- lib/magicka/element/method_builder.rb
|
406
|
+
- lib/magicka/form.rb
|
407
|
+
- lib/magicka/form_element.rb
|
402
408
|
- lib/magicka/input.rb
|
403
|
-
- lib/magicka/
|
404
|
-
- lib/magicka/method_builder.rb
|
409
|
+
- lib/magicka/select.rb
|
405
410
|
- lib/magicka/version.rb
|
406
411
|
- magicka.gemspec
|
407
412
|
- magicka.jpg
|
@@ -466,11 +471,14 @@ files:
|
|
466
471
|
- spec/dummy/storage/.keep
|
467
472
|
- spec/integration/readme/.keep
|
468
473
|
- spec/integration/yard/.keep
|
474
|
+
- spec/lib/magicka/button_spec.rb
|
469
475
|
- spec/lib/magicka/element/class_methods_spec.rb
|
476
|
+
- spec/lib/magicka/element/method_builder_spec.rb
|
470
477
|
- spec/lib/magicka/element_spec.rb
|
471
|
-
- spec/lib/magicka/
|
478
|
+
- spec/lib/magicka/form_element_spec.rb
|
479
|
+
- spec/lib/magicka/form_spec.rb
|
472
480
|
- spec/lib/magicka/input_spec.rb
|
473
|
-
- spec/lib/magicka/
|
481
|
+
- spec/lib/magicka/select_spec.rb
|
474
482
|
- spec/spec_helper.rb
|
475
483
|
- spec/support/models/.keep
|
476
484
|
- spec/support/shared_examples/.keep
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Magicka
|
4
|
-
# @api private
|
5
|
-
#
|
6
|
-
# class responsible for building methods on {Magicka::Element}
|
7
|
-
class MethodBuilder < Sinclair
|
8
|
-
# adds a mehtod +#template+
|
9
|
-
#
|
10
|
-
# The method will always return the template given in the params
|
11
|
-
#
|
12
|
-
# @param template [String] path to template file
|
13
|
-
#
|
14
|
-
# @return [Array<Sinclair::MethodDefinition>]
|
15
|
-
def add_template(template)
|
16
|
-
add_method(:template) do
|
17
|
-
template
|
18
|
-
end
|
19
|
-
|
20
|
-
build
|
21
|
-
end
|
22
|
-
|
23
|
-
# adds a mehtod +#template_folder+
|
24
|
-
#
|
25
|
-
# The method will always return the template folder given in the params
|
26
|
-
#
|
27
|
-
# @param template_folder [String] path to template folder
|
28
|
-
#
|
29
|
-
# @return [Array<Sinclair::MethodDefinition>]
|
30
|
-
def add_template_folder(folder)
|
31
|
-
add_method(:template_folder) do
|
32
|
-
folder
|
33
|
-
end
|
34
|
-
|
35
|
-
build
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|