restfulness 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f2ec8e38fd8c7293981c340ac6e925b976f4a99
4
- data.tar.gz: e74639ca882ffea8494af1f6dc2e0a7c970b5957
3
+ metadata.gz: 4c6d3884753e3b58d9c9d459a633f5973de4b5f2
4
+ data.tar.gz: 7694025035531b633586bbb361978b543c37a532
5
5
  SHA512:
6
- metadata.gz: bc120a4ca69100131aef149de8e0029611c2e1d5ed584a94a3adabbf50e598ab52463088884c6844e5008c375632cb64cb3df7a69afbf7f4b62a38cbe64bdf01
7
- data.tar.gz: 19e0694cd4b9f4b609762c70abdd07c9d2df487b65bb4884ccf8097b3c3ae59423cc6a0b4e13f496a7109b84162caa618ba96fade17c5b07a9e26f70cca686ad
6
+ metadata.gz: dc2abb03ebf2caea3f7f2e528b19917bbb7d7144c4f4ddc78ee5e8469c0aa53c2a2f45b8d4865b21ca21ffbfaa4c10072864358361238b92eb0b9b84cf7b21d9
7
+ data.tar.gz: ae4f3c662aeb5b5e78a331fc5225d27289727ccc22c22f8d957d89e6178d7dfd262aaa65d45a301d3ae14dfa74b6f7fbf2580f222f7adc5aa9f3dddeab41df68
data/README.md CHANGED
@@ -188,6 +188,19 @@ routes do
188
188
  end
189
189
  ```
190
190
 
191
+ The `add` router method can also except a block which will be interpreted as a scope. The following example will provide the same paths as the `journeys` scope and resource defined above. The most important factor to take into account is that the `Journeys::ListResource` will be added to the route **after** the `active` and `terminated` resources. Order is important!
192
+
193
+ ```ruby
194
+ routes do
195
+ scope 'api' do
196
+ add 'journeys', Journeys::ListResource do
197
+ add 'active', Journeys::ActiveResource
198
+ add 'terminated', Journeys::TerminatedResource
199
+ end
200
+ end
201
+ end
202
+ ```
203
+
191
204
 
192
205
  ### Resources
193
206
 
@@ -605,6 +618,10 @@ Restfulness is still a work in progress but at Cabify we are using it in product
605
618
 
606
619
  ## History
607
620
 
621
+ ### 0.2.6 - March 7, 2014
622
+
623
+ * Support scope block when adding a resource to router. (@samlown)
624
+
608
625
  ### 0.2.5 - March 7, 2014
609
626
 
610
627
  * Added support for scope in routes. (@samlown)
@@ -11,7 +11,9 @@ module Restfulness
11
11
  instance_eval(&block) if block_given?
12
12
  end
13
13
 
14
- def add(*args)
14
+ def add(*args, &block)
15
+ # Do we need to pretend we've been given a scope?
16
+ scope(*args[0..-2], &block) if block_given?
15
17
  routes << Route.new(*(current_scope + args))
16
18
  end
17
19
 
@@ -1,3 +1,3 @@
1
1
  module Restfulness
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -6,6 +6,9 @@ describe Restfulness::Router do
6
6
  class RouterResource < Restfulness::Resource
7
7
  end
8
8
 
9
+ class SecondRouterResource < Restfulness::Resource
10
+ end
11
+
9
12
  let :klass do
10
13
  Restfulness::Router
11
14
  end
@@ -39,6 +42,18 @@ describe Restfulness::Router do
39
42
  route.should be_a(Restfulness::Route)
40
43
  route.path.should eql(['projects'])
41
44
  end
45
+ it "should accept block as scope" do
46
+ obj = klass.new
47
+ obj.add 'project', RouterResource do
48
+ add 'examples', SecondRouterResource
49
+ end
50
+ route = obj.routes.first
51
+ route.resource.should eql(RouterResource)
52
+ route.path.should eql(['project', 'examples'])
53
+ route = obj.routes.last
54
+ route.resource.should eql(SecondRouterResource)
55
+ route.path.should eql(['project'])
56
+ end
42
57
  end
43
58
 
44
59
  describe "#scope" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restfulness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Lown
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-06 00:00:00.000000000 Z
11
+ date: 2014-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack