angular_sprinkles 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/angular_sprinkles.gemspec +4 -4
- data/lib/angular_sprinkles/controller.rb +5 -0
- data/spec/controller_spec.rb +50 -28
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1aa73b9e39b4a5a18d3c3b14d39bce928a4c78d6
|
4
|
+
data.tar.gz: d53aee79dc7d3950758677702a1ee564883a3611
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7b5ffa915e647ec7bfc49980e85b3bd93eebd7a349471b3cdbcb176f74422f8a27072dcc7f14007d2f6ccbf2db7237a3212eb409ae1662adfa6ebc5bc502e26
|
7
|
+
data.tar.gz: ba0706e68ba26006a90394b297da96f80b05ff0ea30850200d3cd2c7600e11ed1395d068acfa4dd51c967993a8128d873012bffb9b075e284bfcb6643e5ede2b
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem|
|
|
17
17
|
gem.name = "angular_sprinkles"
|
18
18
|
gem.homepage = "http://github.com/BrewhouseTeam/angular_sprinkles"
|
19
19
|
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{Add few sprinkles of AngularJS to your Rails App}
|
21
|
-
gem.description = %Q{Add few sprinkles of AngularJS to your Rails App}
|
20
|
+
gem.summary = %Q{Add just a few sprinkles of AngularJS to your Rails App}
|
21
|
+
gem.description = %Q{Add just a few sprinkles of AngularJS to your Rails App}
|
22
22
|
gem.email = "gabe@brewhouse.io"
|
23
23
|
gem.authors = ["Gabe Scholz"]
|
24
24
|
# dependencies defined in Gemfile
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/angular_sprinkles.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
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.0.
|
5
|
+
# stub: angular_sprinkles 0.0.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "angular_sprinkles"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.2"
|
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
14
|
s.date = "2014-08-22"
|
15
|
-
s.description = "Add few sprinkles of AngularJS to your Rails App"
|
15
|
+
s.description = "Add just a few sprinkles of AngularJS to your Rails App"
|
16
16
|
s.email = "gabe@brewhouse.io"
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE.txt",
|
@@ -53,7 +53,7 @@ Gem::Specification.new do |s|
|
|
53
53
|
s.homepage = "http://github.com/BrewhouseTeam/angular_sprinkles"
|
54
54
|
s.licenses = ["MIT"]
|
55
55
|
s.rubygems_version = "2.4.1"
|
56
|
-
s.summary = "Add few sprinkles of AngularJS to your Rails App"
|
56
|
+
s.summary = "Add just a few sprinkles of AngularJS to your Rails App"
|
57
57
|
|
58
58
|
if s.respond_to? :specification_version then
|
59
59
|
s.specification_version = 4
|
@@ -7,6 +7,11 @@ module AngularSprinkles
|
|
7
7
|
include AngularSprinkles::Mixins::JsTransformable
|
8
8
|
include AngularSprinkles::Mixins::Initializable
|
9
9
|
|
10
|
+
def bindable_collection(objects)
|
11
|
+
objects.map! { |object| bindable(object) }
|
12
|
+
bindable(objects)
|
13
|
+
end
|
14
|
+
|
10
15
|
def bindable(object)
|
11
16
|
klass = object.class
|
12
17
|
key = "#{klass}_#{inc_sprinkles_counter(klass)}"
|
data/spec/controller_spec.rb
CHANGED
@@ -3,50 +3,72 @@ require 'spec_helper'
|
|
3
3
|
describe AngularSprinkles::Controller do
|
4
4
|
class StubController
|
5
5
|
include AngularSprinkles::Controller
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
@params = params
|
9
|
-
end
|
8
|
+
let(:controller) { StubController.new }
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
describe '#assignable' do
|
11
|
+
let(:key) { 'key' }
|
12
|
+
let(:value) { 'value' }
|
13
|
+
context 'when given a hash' do
|
14
|
+
context 'and it is not empty' do
|
15
|
+
let(:params) { { key => value } }
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
it 'preloads the input data' do
|
18
|
+
result = [
|
19
|
+
AngularSprinkles::CONSTRUCTOR_DEFINITION,
|
20
|
+
%{#{AngularSprinkles::CONTROLLER_FN}.prototype.#{key} = #{AngularSprinkles::CONTROLLER_FN}.prototype.#{key} || "#{value}"}
|
21
|
+
]
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
expect(controller.assignable(params)).to eq(result)
|
24
|
+
end
|
25
|
+
end
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
AngularSprinkles::CONSTRUCTOR_DEFINITION,
|
27
|
-
%{#{AngularSprinkles::CONTROLLER_FN}.prototype.#{key} = #{AngularSprinkles::CONTROLLER_FN}.prototype.#{key} || "#{value}"}
|
28
|
-
]
|
27
|
+
context 'and it is an empty hash' do
|
28
|
+
let(:params) { {} }
|
29
29
|
|
30
|
-
|
30
|
+
it 'only returns the prototype definition' do
|
31
|
+
result = [AngularSprinkles::CONSTRUCTOR_DEFINITION]
|
32
|
+
expect(controller.assignable(params)).to eq(result)
|
33
|
+
end
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
34
|
-
context '
|
35
|
-
let(:params) {
|
37
|
+
context 'when given anything else' do
|
38
|
+
let(:params) { value }
|
36
39
|
|
37
|
-
it '
|
38
|
-
|
39
|
-
expect(controller.index).to eq(result)
|
40
|
+
it 'raises an exception' do
|
41
|
+
expect { controller.assignable(params) }.to raise_error(TypeError)
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
+
describe '#bindable' do
|
47
|
+
before do
|
48
|
+
expect(controller).to receive(:assignable)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'returns a decorated object that responds to #bind' do
|
52
|
+
object = controller.bindable(Object.new)
|
46
53
|
|
47
|
-
|
48
|
-
expect
|
54
|
+
expect(object.respond_to?(:bind)).to eq(true)
|
55
|
+
expect(object.class).to eq(AngularSprinkles::Decorators::Bind)
|
49
56
|
end
|
50
57
|
end
|
51
58
|
|
59
|
+
describe '#bindable_collection' do
|
60
|
+
let(:times) { 5 }
|
61
|
+
|
62
|
+
before do
|
63
|
+
expect(controller).to receive(:assignable).exactly(times + 1).times
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'returns a collection of objects that respond to #bind' do
|
67
|
+
collection = (1..times).map { Object.new }
|
68
|
+
objects = controller.bindable_collection(collection)
|
69
|
+
|
70
|
+
expect(objects.all? { |o| o.respond_to?(:bind) }).to eq(true)
|
71
|
+
expect(objects.all? { |o| o.class == AngularSprinkles::Decorators::Bind }).to eq(true)
|
72
|
+
end
|
73
|
+
end
|
52
74
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: angular_sprinkles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabe Scholz
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
-
description: Add few sprinkles of AngularJS to your Rails App
|
139
|
+
description: Add just a few sprinkles of AngularJS to your Rails App
|
140
140
|
email: gabe@brewhouse.io
|
141
141
|
executables: []
|
142
142
|
extensions: []
|
@@ -197,5 +197,5 @@ rubyforge_project:
|
|
197
197
|
rubygems_version: 2.4.1
|
198
198
|
signing_key:
|
199
199
|
specification_version: 4
|
200
|
-
summary: Add few sprinkles of AngularJS to your Rails App
|
200
|
+
summary: Add just a few sprinkles of AngularJS to your Rails App
|
201
201
|
test_files: []
|