angular_sprinkles 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f6308b16a728b1c5e29241e0e94be0eec1d3735
4
- data.tar.gz: c1f09fbcc331e60afe3860ea39283b990e4e21dd
3
+ metadata.gz: 1aa73b9e39b4a5a18d3c3b14d39bce928a4c78d6
4
+ data.tar.gz: d53aee79dc7d3950758677702a1ee564883a3611
5
5
  SHA512:
6
- metadata.gz: 7831c173521e159f22de88877f5796f65740dafb22578a3ec0bda94a7431fa7975a669093f1d06180c022b31c0b9ed808e83150a3c50cd1581b2deca35653fb5
7
- data.tar.gz: 3b5cd766296c41a6ea3f08008e51356ca6470aad47b05b931339f1f808bcd4a8412d0723738eeea36d26122ee687e2ddf85b57caa4b7b01973e21882969ed371
6
+ metadata.gz: c7b5ffa915e647ec7bfc49980e85b3bd93eebd7a349471b3cdbcb176f74422f8a27072dcc7f14007d2f6ccbf2db7237a3212eb409ae1662adfa6ebc5bc502e26
7
+ data.tar.gz: ba0706e68ba26006a90394b297da96f80b05ff0ea30850200d3cd2c7600e11ed1395d068acfa4dd51c967993a8128d873012bffb9b075e284bfcb6643e5ede2b
data/README.md CHANGED
@@ -74,6 +74,7 @@ class UserController < ApplicationController
74
74
  def show
75
75
  @user = bindable(User.find(params[:id]))
76
76
  end
77
+ end
77
78
  ```
78
79
 
79
80
  Our user is now also able to use `bind`
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
1
+ 0.0.2
@@ -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.1 ruby lib
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.1"
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)}"
@@ -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
- def initialize(params)
8
- @params = params
9
- end
8
+ let(:controller) { StubController.new }
10
9
 
11
- def index
12
- assignable(@params)
13
- end
14
- end
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
- let(:key) { 'key' }
17
- let(:value) { 'value' }
18
- let(:controller) { StubController.new(params) }
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
- context 'when given a hash' do
21
- context 'and it is not empty' do
22
- let(:params) { { key => value } }
23
+ expect(controller.assignable(params)).to eq(result)
24
+ end
25
+ end
23
26
 
24
- it 'preloads the input data' do
25
- result = [
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
- expect(controller.index).to eq(result)
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 'and it is an empty hash' do
35
- let(:params) { {} }
37
+ context 'when given anything else' do
38
+ let(:params) { value }
36
39
 
37
- it 'only returns the prototype definition' do
38
- result = [AngularSprinkles::CONSTRUCTOR_DEFINITION]
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
- context 'when given anything else' do
45
- let(:params) { value }
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
- it 'raises an exception' do
48
- expect { controller.index }.to raise_error(TypeError)
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.1
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: []