angular_sprinkles 0.2.14 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +55 -0
- data/VERSION +1 -1
- data/angular_sprinkles.gemspec +14 -13
- data/lib/angular_sprinkles.rb +7 -5
- data/lib/angular_sprinkles/{directive → element}/attributes.rb +1 -1
- data/lib/angular_sprinkles/{directive → element}/html.rb +1 -1
- data/lib/angular_sprinkles/{directive → element}/input.rb +1 -1
- data/lib/angular_sprinkles/{directive/controller.rb → element/scope.rb} +5 -5
- data/lib/angular_sprinkles/helpers.rb +3 -0
- data/lib/angular_sprinkles/helpers/controller_helper.rb +13 -0
- data/lib/angular_sprinkles/helpers/directive_helper.rb +5 -18
- data/lib/angular_sprinkles/helpers/element_helper.rb +31 -0
- data/lib/angular_sprinkles/helpers/isolate_helper.rb +13 -0
- data/lib/angular_sprinkles/java_script.rb +4 -0
- data/spec/angular_sprinkles/{directive → element}/attributes_spec.rb +1 -1
- data/spec/angular_sprinkles/{directive → element}/html_spec.rb +1 -1
- data/spec/angular_sprinkles/{directive → element}/input_spec.rb +1 -1
- data/spec/angular_sprinkles/{directive/controller_spec.rb → element/scope_spec.rb} +8 -8
- data/spec/dummy/app/assets/javascripts/application.js +4 -0
- data/spec/dummy/app/views/test/javascript_bindings.html.erb +9 -0
- data/spec/features/javascript_bindings_spec.rb +2 -0
- metadata +13 -12
- data/lib/angular_sprinkles/directive/name.rb +0 -19
- data/spec/angular_sprinkles/directive/name_spec.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2ca75f5bc2cc8cdd98f994baec30cccf119ab8c
|
4
|
+
data.tar.gz: 39b1c5dfaff4c05c824ec7372573e74010b0474c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cb89f9dcca04611c218c3057d2bfd23cc29862e06ac51f9da227ed54bb29a553fafc7ace16add21bccdb89f83e2d91c7762c47895d36385ed31e06d6e79f678
|
7
|
+
data.tar.gz: dd63bd3d015ac50937a6aeebca8e143e382849264ceaf69d800ec72113b013921da62e5fd73cdfc3eddc810f2ace3da09d48a1f3631b0aa760ccc20fe7d730ca
|
data/README.md
CHANGED
@@ -42,6 +42,7 @@ Include and `angular_sprinkles` into your `application.js`.
|
|
42
42
|
|
43
43
|
- [Two-way binding](#two-way-binding)
|
44
44
|
- [Directives](#directives)
|
45
|
+
- [Controllers and Isolate Scopes](#controllers-and-isolate-scopes)
|
45
46
|
- [Inlining function calls](#inlining-function-calls)
|
46
47
|
- [Form helpers](#form-helpers)
|
47
48
|
|
@@ -79,6 +80,60 @@ sprinkles.directive('blink', function () {
|
|
79
80
|
<% end %>
|
80
81
|
```
|
81
82
|
|
83
|
+
Directives can also return it's controller to a ruby block if the directive uses transclusion.
|
84
|
+
|
85
|
+
```erb
|
86
|
+
<script>
|
87
|
+
sprinkles.directive('someDirective', function () {
|
88
|
+
return {
|
89
|
+
transclude: true,
|
90
|
+
template: '<div ng-transclude></div>',
|
91
|
+
// note: 'controllerAs' must be the directive name + 'Ctrl'
|
92
|
+
controllerAs: 'someDirectiveCtrl',
|
93
|
+
controller: function () {
|
94
|
+
this.alertMe = function (name) {
|
95
|
+
alert('Hi, ' + name);
|
96
|
+
};
|
97
|
+
}
|
98
|
+
}
|
99
|
+
});
|
100
|
+
</script>
|
101
|
+
|
102
|
+
<%= directive(:someDirective) do |some_ctrl| %>
|
103
|
+
<button ng-click="<%= some_ctrl.call('Gabe') %>">CLICK ME!</button>
|
104
|
+
<% end %>
|
105
|
+
```
|
106
|
+
|
107
|
+
### Controllers and Isolate Scopes
|
108
|
+
|
109
|
+
If you would rather skip the directive and just create a controller, there is the `ctrl` helper.
|
110
|
+
|
111
|
+
```erb
|
112
|
+
<script>
|
113
|
+
sprinkles.controller('someCtrl', function () {
|
114
|
+
this.alertMe = function (name) {
|
115
|
+
alert('Hi, ' + name);
|
116
|
+
};
|
117
|
+
});
|
118
|
+
</script>
|
119
|
+
|
120
|
+
<%= ctrl(:someCtrl) do |some_ctrl| %>
|
121
|
+
<button ng-click="<%= some_ctrl.call('Gabe') %>">CLICK ME!</button>
|
122
|
+
<% end %>
|
123
|
+
```
|
124
|
+
|
125
|
+
This is good for localizing JavaScript behavior. Additionally, if you'd just like to create a new
|
126
|
+
scope, you can use the `isolate` helper which creates an "anonymous" controller to wrap your element.
|
127
|
+
|
128
|
+
```erb
|
129
|
+
<%= isolate do |iso_ctrl| %>
|
130
|
+
<input ng-model="<%= iso_ctrl.bind(:isolated_binding) %>">
|
131
|
+
{{ <%= iso_ctrl.bind(:isolated_binding) %> }}
|
132
|
+
<% end %>
|
133
|
+
```
|
134
|
+
|
135
|
+
In contrast with the `bind` helper, bindings made here do not apply to the scope of the root controller.
|
136
|
+
|
82
137
|
### Inlining function calls
|
83
138
|
|
84
139
|
Call services directly from the view with the `service` helper.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/angular_sprinkles.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: angular_sprinkles 0.
|
5
|
+
# stub: angular_sprinkles 0.3.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "angular_sprinkles"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.3.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Gabe Scholz"]
|
14
|
-
s.date = "2014-10-
|
14
|
+
s.date = "2014-10-22"
|
15
15
|
s.description = "Add a few sprinkles of AngularJS to your Rails App"
|
16
16
|
s.email = "gabe@brewhouse.io"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -35,11 +35,10 @@ Gem::Specification.new do |s|
|
|
35
35
|
"lib/angular_sprinkles/content_yielder.rb",
|
36
36
|
"lib/angular_sprinkles/context.rb",
|
37
37
|
"lib/angular_sprinkles/counter.rb",
|
38
|
-
"lib/angular_sprinkles/
|
39
|
-
"lib/angular_sprinkles/
|
40
|
-
"lib/angular_sprinkles/
|
41
|
-
"lib/angular_sprinkles/
|
42
|
-
"lib/angular_sprinkles/directive/name.rb",
|
38
|
+
"lib/angular_sprinkles/element/attributes.rb",
|
39
|
+
"lib/angular_sprinkles/element/html.rb",
|
40
|
+
"lib/angular_sprinkles/element/input.rb",
|
41
|
+
"lib/angular_sprinkles/element/scope.rb",
|
43
42
|
"lib/angular_sprinkles/engine.rb",
|
44
43
|
"lib/angular_sprinkles/form_binder/base.rb",
|
45
44
|
"lib/angular_sprinkles/form_binder/check_box.rb",
|
@@ -47,7 +46,10 @@ Gem::Specification.new do |s|
|
|
47
46
|
"lib/angular_sprinkles/helpers.rb",
|
48
47
|
"lib/angular_sprinkles/helpers/bind_form_for_helper.rb",
|
49
48
|
"lib/angular_sprinkles/helpers/bind_helper.rb",
|
49
|
+
"lib/angular_sprinkles/helpers/controller_helper.rb",
|
50
50
|
"lib/angular_sprinkles/helpers/directive_helper.rb",
|
51
|
+
"lib/angular_sprinkles/helpers/element_helper.rb",
|
52
|
+
"lib/angular_sprinkles/helpers/isolate_helper.rb",
|
51
53
|
"lib/angular_sprinkles/helpers/service_helper.rb",
|
52
54
|
"lib/angular_sprinkles/java_script.rb",
|
53
55
|
"lib/angular_sprinkles/key_generator.rb",
|
@@ -62,11 +64,10 @@ Gem::Specification.new do |s|
|
|
62
64
|
"spec/angular_sprinkles/content_yielder_spec.rb",
|
63
65
|
"spec/angular_sprinkles/context_spec.rb",
|
64
66
|
"spec/angular_sprinkles/counter_spec.rb",
|
65
|
-
"spec/angular_sprinkles/
|
66
|
-
"spec/angular_sprinkles/
|
67
|
-
"spec/angular_sprinkles/
|
68
|
-
"spec/angular_sprinkles/
|
69
|
-
"spec/angular_sprinkles/directive/name_spec.rb",
|
67
|
+
"spec/angular_sprinkles/element/attributes_spec.rb",
|
68
|
+
"spec/angular_sprinkles/element/html_spec.rb",
|
69
|
+
"spec/angular_sprinkles/element/input_spec.rb",
|
70
|
+
"spec/angular_sprinkles/element/scope_spec.rb",
|
70
71
|
"spec/angular_sprinkles/form_binder/base_spec.rb",
|
71
72
|
"spec/angular_sprinkles/form_binder/check_box_spec.rb",
|
72
73
|
"spec/angular_sprinkles/form_binder/default_spec.rb",
|
data/lib/angular_sprinkles.rb
CHANGED
@@ -2,11 +2,10 @@ require "angular_sprinkles/cache"
|
|
2
2
|
require "angular_sprinkles/constructor"
|
3
3
|
require "angular_sprinkles/constructor_collection"
|
4
4
|
require "angular_sprinkles/content_yielder"
|
5
|
-
require "angular_sprinkles/
|
6
|
-
require "angular_sprinkles/
|
7
|
-
require "angular_sprinkles/
|
8
|
-
require "angular_sprinkles/
|
9
|
-
require "angular_sprinkles/directive/html"
|
5
|
+
require "angular_sprinkles/element/attributes"
|
6
|
+
require "angular_sprinkles/element/html"
|
7
|
+
require "angular_sprinkles/element/input"
|
8
|
+
require "angular_sprinkles/element/scope"
|
10
9
|
require "angular_sprinkles/context"
|
11
10
|
require "angular_sprinkles/counter"
|
12
11
|
require "angular_sprinkles/engine"
|
@@ -15,7 +14,10 @@ require "angular_sprinkles/form_binder/check_box"
|
|
15
14
|
require "angular_sprinkles/form_binder/default"
|
16
15
|
require "angular_sprinkles/helpers/bind_form_for_helper"
|
17
16
|
require "angular_sprinkles/helpers/bind_helper"
|
17
|
+
require "angular_sprinkles/helpers/controller_helper"
|
18
18
|
require "angular_sprinkles/helpers/directive_helper"
|
19
|
+
require "angular_sprinkles/helpers/element_helper"
|
20
|
+
require "angular_sprinkles/helpers/isolate_helper"
|
19
21
|
require "angular_sprinkles/helpers/service_helper"
|
20
22
|
require "angular_sprinkles/helpers"
|
21
23
|
require "angular_sprinkles/java_script"
|
@@ -1,19 +1,19 @@
|
|
1
1
|
module AngularSprinkles
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Element
|
3
|
+
class Scope
|
4
4
|
def initialize(args)
|
5
|
-
@
|
5
|
+
@base = args.fetch(:base)
|
6
6
|
@object_wrapper = args.fetch(:object_wrapper)
|
7
7
|
@bind_json_wrapper = args.fetch(:bind_json_wrapper)
|
8
8
|
@call_json_wrapper = args.fetch(:call_json_wrapper)
|
9
9
|
end
|
10
10
|
|
11
11
|
def bind(attribute = nil)
|
12
|
-
@object_wrapper.new(@
|
12
|
+
@object_wrapper.new(@base, attribute, @bind_json_wrapper)
|
13
13
|
end
|
14
14
|
|
15
15
|
def call(function, *input)
|
16
|
-
@object_wrapper.new(@
|
16
|
+
@object_wrapper.new(@base, function, input, @call_json_wrapper)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module AngularSprinkles
|
2
|
+
module Helpers
|
3
|
+
module ControllerHelper
|
4
|
+
def ctrl(controller_name, opts = {}, &block)
|
5
|
+
options = opts.dup.symbolize_keys
|
6
|
+
|
7
|
+
options['ng-controller'] = "#{controller_name} as #{controller_name}"
|
8
|
+
options[:scope_name] ||= controller_name
|
9
|
+
_element(options, &block)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,25 +1,12 @@
|
|
1
1
|
module AngularSprinkles
|
2
2
|
module Helpers
|
3
3
|
module DirectiveHelper
|
4
|
-
def directive(directive_name,
|
5
|
-
|
6
|
-
controller = Directive::Controller.new({
|
7
|
-
name: "#{directive_name}Ctrl",
|
8
|
-
object_wrapper: ObjectKeyWrapper,
|
9
|
-
bind_json_wrapper: JavaScript::NoOp,
|
10
|
-
call_json_wrapper: JavaScript::BindService
|
11
|
-
})
|
4
|
+
def directive(directive_name, opts = {}, &block)
|
5
|
+
options = opts.dup.symbolize_keys
|
12
6
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
name = Directive::Name.new(directive_name)
|
17
|
-
input = Directive::Input.new(options.except(:html))
|
18
|
-
html = Directive::Html.new(options[:html])
|
19
|
-
|
20
|
-
attributes = Directive::Attributes.new([name, input, html], tag: html.tag, content: content)
|
21
|
-
|
22
|
-
content_tag(*attributes.to_content_tag)
|
7
|
+
options[directive_name] = ""
|
8
|
+
options[:scope_name] ||= "#{directive_name}Ctrl"
|
9
|
+
_element(options, &block)
|
23
10
|
end
|
24
11
|
end
|
25
12
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module AngularSprinkles
|
2
|
+
module Helpers
|
3
|
+
module ElementHelper
|
4
|
+
def _element(opts = {}, &block)
|
5
|
+
options = opts.dup.symbolize_keys
|
6
|
+
|
7
|
+
scope_name = options.delete(:scope_name)
|
8
|
+
html_options = options.delete(:html) || {}
|
9
|
+
input_options = options # use remaining options
|
10
|
+
|
11
|
+
if block_given?
|
12
|
+
scope = Element::Scope.new({
|
13
|
+
base: scope_name,
|
14
|
+
object_wrapper: ObjectKeyWrapper,
|
15
|
+
bind_json_wrapper: JavaScript::NoOp,
|
16
|
+
call_json_wrapper: JavaScript::BindService
|
17
|
+
})
|
18
|
+
|
19
|
+
content = capture(scope, &block)
|
20
|
+
end
|
21
|
+
|
22
|
+
input = Element::Input.new(input_options)
|
23
|
+
html = Element::Html.new(html_options)
|
24
|
+
|
25
|
+
attributes = Element::Attributes.new([input, html], tag: html.tag, content: content)
|
26
|
+
|
27
|
+
content_tag(*attributes.to_content_tag)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module AngularSprinkles
|
2
|
+
module Helpers
|
3
|
+
module IsolateHelper
|
4
|
+
def isolate(opts = {}, &block)
|
5
|
+
controller_name = "isolate_#{SecureRandom.hex}"
|
6
|
+
isolate_controller = ObjectKeyWrapper.new(controller_name, JavaScript::IsolateController)
|
7
|
+
|
8
|
+
@_sprinkles.content_yielder.call(isolate_controller)
|
9
|
+
ctrl(controller_name, opts, &block)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe AngularSprinkles::
|
4
|
-
let(:
|
3
|
+
describe AngularSprinkles::Element::Scope do
|
4
|
+
let(:base) { double }
|
5
5
|
let(:object_wrapper) { double }
|
6
6
|
let(:bind_json_wrapper) { double }
|
7
7
|
let(:call_json_wrapper) { double }
|
8
8
|
|
9
9
|
subject do
|
10
10
|
described_class.new({
|
11
|
-
|
11
|
+
base: base,
|
12
12
|
object_wrapper: object_wrapper,
|
13
13
|
bind_json_wrapper: bind_json_wrapper,
|
14
14
|
call_json_wrapper: call_json_wrapper
|
@@ -16,23 +16,23 @@ describe AngularSprinkles::Directive::Controller do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "#bind" do
|
19
|
-
it "wraps the controller
|
19
|
+
it "wraps the controller base" do
|
20
20
|
attribute = double
|
21
21
|
|
22
|
-
expect(object_wrapper).to receive(:new).with(
|
22
|
+
expect(object_wrapper).to receive(:new).with(base, attribute, bind_json_wrapper)
|
23
23
|
subject.bind(attribute)
|
24
24
|
|
25
|
-
expect(object_wrapper).to receive(:new).with(
|
25
|
+
expect(object_wrapper).to receive(:new).with(base, nil, bind_json_wrapper)
|
26
26
|
subject.bind
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "#call" do
|
31
|
-
it "wraps the controller
|
31
|
+
it "wraps the controller base" do
|
32
32
|
function = double
|
33
33
|
input = [double, double]
|
34
34
|
|
35
|
-
expect(object_wrapper).to receive(:new).with(
|
35
|
+
expect(object_wrapper).to receive(:new).with(base, function, input, call_json_wrapper)
|
36
36
|
subject.call(function, *input)
|
37
37
|
end
|
38
38
|
end
|
@@ -9,6 +9,15 @@
|
|
9
9
|
<%= directive(:nested_directive, name: @model.bind(:name), html: { tag: 'h1' }) %>
|
10
10
|
<% end %>
|
11
11
|
|
12
|
+
<%= ctrl(:someCtrl, html: { id: "ctrl-div" }) do |some_ctrl| %>
|
13
|
+
{{ <%= some_ctrl.bind(:someValue) %> }}
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%= isolate do |some_ctrl| %>
|
17
|
+
<div ng-init="<%= some_ctrl.bind(:someValue) %> = 42"></div>
|
18
|
+
<div id="isolate-div" ng-bind="<%= some_ctrl.bind(:someValue) %>"></div>
|
19
|
+
<% end %>
|
20
|
+
|
12
21
|
<div id="model-bind">
|
13
22
|
<label for="input">Input</label>
|
14
23
|
<input id="input" name="input" type="text" ng-model="<%= @model.bind(:name) %>" />
|
@@ -28,5 +28,7 @@ feature "javascript_bindings", js: true do
|
|
28
28
|
# directive controller results
|
29
29
|
expect(find("#directive-ctrl-bind")).to have_content("bigHelloWorldCtrlAttribute")
|
30
30
|
expect(find("#directive-ctrl-call")).to have_content('func result')
|
31
|
+
expect(find("#ctrl-div")).to have_content(42)
|
32
|
+
expect(find("#isolate-div")).to have_content(42)
|
31
33
|
end
|
32
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: angular_sprinkles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabe Scholz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -82,11 +82,10 @@ files:
|
|
82
82
|
- lib/angular_sprinkles/content_yielder.rb
|
83
83
|
- lib/angular_sprinkles/context.rb
|
84
84
|
- lib/angular_sprinkles/counter.rb
|
85
|
-
- lib/angular_sprinkles/
|
86
|
-
- lib/angular_sprinkles/
|
87
|
-
- lib/angular_sprinkles/
|
88
|
-
- lib/angular_sprinkles/
|
89
|
-
- lib/angular_sprinkles/directive/name.rb
|
85
|
+
- lib/angular_sprinkles/element/attributes.rb
|
86
|
+
- lib/angular_sprinkles/element/html.rb
|
87
|
+
- lib/angular_sprinkles/element/input.rb
|
88
|
+
- lib/angular_sprinkles/element/scope.rb
|
90
89
|
- lib/angular_sprinkles/engine.rb
|
91
90
|
- lib/angular_sprinkles/form_binder/base.rb
|
92
91
|
- lib/angular_sprinkles/form_binder/check_box.rb
|
@@ -94,7 +93,10 @@ files:
|
|
94
93
|
- lib/angular_sprinkles/helpers.rb
|
95
94
|
- lib/angular_sprinkles/helpers/bind_form_for_helper.rb
|
96
95
|
- lib/angular_sprinkles/helpers/bind_helper.rb
|
96
|
+
- lib/angular_sprinkles/helpers/controller_helper.rb
|
97
97
|
- lib/angular_sprinkles/helpers/directive_helper.rb
|
98
|
+
- lib/angular_sprinkles/helpers/element_helper.rb
|
99
|
+
- lib/angular_sprinkles/helpers/isolate_helper.rb
|
98
100
|
- lib/angular_sprinkles/helpers/service_helper.rb
|
99
101
|
- lib/angular_sprinkles/java_script.rb
|
100
102
|
- lib/angular_sprinkles/key_generator.rb
|
@@ -109,11 +111,10 @@ files:
|
|
109
111
|
- spec/angular_sprinkles/content_yielder_spec.rb
|
110
112
|
- spec/angular_sprinkles/context_spec.rb
|
111
113
|
- spec/angular_sprinkles/counter_spec.rb
|
112
|
-
- spec/angular_sprinkles/
|
113
|
-
- spec/angular_sprinkles/
|
114
|
-
- spec/angular_sprinkles/
|
115
|
-
- spec/angular_sprinkles/
|
116
|
-
- spec/angular_sprinkles/directive/name_spec.rb
|
114
|
+
- spec/angular_sprinkles/element/attributes_spec.rb
|
115
|
+
- spec/angular_sprinkles/element/html_spec.rb
|
116
|
+
- spec/angular_sprinkles/element/input_spec.rb
|
117
|
+
- spec/angular_sprinkles/element/scope_spec.rb
|
117
118
|
- spec/angular_sprinkles/form_binder/base_spec.rb
|
118
119
|
- spec/angular_sprinkles/form_binder/check_box_spec.rb
|
119
120
|
- spec/angular_sprinkles/form_binder/default_spec.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module AngularSprinkles
|
2
|
-
module Directive
|
3
|
-
class Name
|
4
|
-
def initialize(*names)
|
5
|
-
@names = names.flatten.map { |name| name.to_s.underscore.dasherize }
|
6
|
-
end
|
7
|
-
|
8
|
-
def attributes
|
9
|
-
{ data: to_empty_hash }
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def to_empty_hash
|
15
|
-
Hash[@names.product([''])]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe AngularSprinkles::Directive::Name do
|
4
|
-
let(:args) { [:first, :second, :third] }
|
5
|
-
|
6
|
-
subject { described_class.new(args) }
|
7
|
-
|
8
|
-
it 'turns the args hash into an empty data hash' do
|
9
|
-
expect(subject.attributes).to eq({ data: { "first" => '', "second" => '', "third" => '' } })
|
10
|
-
end
|
11
|
-
end
|