sinatra_resource 0.4.14 → 0.4.15
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/resource.rb +3 -2
- data/lib/sinatra_resource.rb +1 -0
- data/lib/utility.rb +25 -0
- data/sinatra_resource.gemspec +5 -2
- data/spec/utility_spec.rb +16 -0
- metadata +5 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.15
|
data/lib/resource.rb
CHANGED
@@ -93,7 +93,7 @@ module SinatraResource
|
|
93
93
|
end
|
94
94
|
|
95
95
|
# Specify the path. If not specified, SinatraResource will infer the path
|
96
|
-
# from the resource class (see the +
|
96
|
+
# from the resource class (see the +set_default_path+ method.)
|
97
97
|
#
|
98
98
|
# This method is also useful for nested resources.
|
99
99
|
#
|
@@ -257,7 +257,8 @@ module SinatraResource
|
|
257
257
|
# @return [undefined]
|
258
258
|
def set_default_path
|
259
259
|
unless @resource_config[:path]
|
260
|
-
|
260
|
+
suffix = self.to_s.split('::').last
|
261
|
+
@resource_config[:path] = Utility.underscore(suffix)
|
261
262
|
end
|
262
263
|
end
|
263
264
|
|
data/lib/sinatra_resource.rb
CHANGED
data/lib/utility.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module SinatraResource
|
2
|
+
|
3
|
+
module Utility
|
4
|
+
|
5
|
+
# The reverse of +camelize+. Makes an underscored, lowercase form from
|
6
|
+
# the expression in the string.
|
7
|
+
#
|
8
|
+
# @param [String] camel_cased_word
|
9
|
+
#
|
10
|
+
# @return [String]
|
11
|
+
#
|
12
|
+
# Example:
|
13
|
+
# "SourceGroup".underscore # => "source_group"
|
14
|
+
#
|
15
|
+
# (This method was adapted from ActiveSupport 2.3.5)
|
16
|
+
def self.underscore(camel_cased_word)
|
17
|
+
camel_cased_word.to_s.
|
18
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
19
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
20
|
+
tr("-", "_").
|
21
|
+
downcase
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
data/sinatra_resource.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sinatra_resource}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.15"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David James"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-18}
|
13
13
|
s.description = %q{A DSL for creating RESTful actions with Sinatra and MongoMapper. It embraces the Resource Oriented Architecture as explained by Leonard Richardson and Sam Ruby.}
|
14
14
|
s.email = %q{djames@sunlightfoundation.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -105,6 +105,7 @@ Gem::Specification.new do |s|
|
|
105
105
|
"lib/resource.rb",
|
106
106
|
"lib/roles.rb",
|
107
107
|
"lib/sinatra_resource.rb",
|
108
|
+
"lib/utility.rb",
|
108
109
|
"notes/keywords.mdown",
|
109
110
|
"notes/permissions.mdown",
|
110
111
|
"notes/questions.mdown",
|
@@ -115,6 +116,7 @@ Gem::Specification.new do |s|
|
|
115
116
|
"sinatra_resource.gemspec",
|
116
117
|
"spec/sinatra_resource_spec.rb",
|
117
118
|
"spec/spec_helper.rb",
|
119
|
+
"spec/utility_spec.rb",
|
118
120
|
"tasks/spec.rake",
|
119
121
|
"tasks/yard.rake"
|
120
122
|
]
|
@@ -126,6 +128,7 @@ Gem::Specification.new do |s|
|
|
126
128
|
s.test_files = [
|
127
129
|
"spec/sinatra_resource_spec.rb",
|
128
130
|
"spec/spec_helper.rb",
|
131
|
+
"spec/utility_spec.rb",
|
129
132
|
"examples/datacatalog/app.rb",
|
130
133
|
"examples/datacatalog/config/config.rb",
|
131
134
|
"examples/datacatalog/lib/base.rb",
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/utility')
|
3
|
+
|
4
|
+
describe "Helpers" do
|
5
|
+
|
6
|
+
describe "underscore" do
|
7
|
+
it "Source" do
|
8
|
+
SinatraResource::Utility.underscore("Source").should == "source"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "SourceGroup" do
|
12
|
+
SinatraResource::Utility.underscore("SourceGroup").should == "source_group"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra_resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David James
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-18 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -213,6 +213,7 @@ files:
|
|
213
213
|
- lib/resource.rb
|
214
214
|
- lib/roles.rb
|
215
215
|
- lib/sinatra_resource.rb
|
216
|
+
- lib/utility.rb
|
216
217
|
- notes/keywords.mdown
|
217
218
|
- notes/permissions.mdown
|
218
219
|
- notes/questions.mdown
|
@@ -223,6 +224,7 @@ files:
|
|
223
224
|
- sinatra_resource.gemspec
|
224
225
|
- spec/sinatra_resource_spec.rb
|
225
226
|
- spec/spec_helper.rb
|
227
|
+
- spec/utility_spec.rb
|
226
228
|
- tasks/spec.rake
|
227
229
|
- tasks/yard.rake
|
228
230
|
has_rdoc: true
|
@@ -256,6 +258,7 @@ summary: RESTful actions with Sinatra and MongoMapper
|
|
256
258
|
test_files:
|
257
259
|
- spec/sinatra_resource_spec.rb
|
258
260
|
- spec/spec_helper.rb
|
261
|
+
- spec/utility_spec.rb
|
259
262
|
- examples/datacatalog/app.rb
|
260
263
|
- examples/datacatalog/config/config.rb
|
261
264
|
- examples/datacatalog/lib/base.rb
|