wsdsl 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/wsdsl.rb +25 -1
- data/spec/wsdsl_spec.rb +9 -0
- data/wsdsl.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/wsdsl.rb
CHANGED
@@ -124,7 +124,11 @@ class WSDSL
|
|
124
124
|
@doc = WSDSL::Documentation.new
|
125
125
|
@response = WSDSL::Response.new
|
126
126
|
@name = extract_service_root_name(url)
|
127
|
-
|
127
|
+
if WSDSL.use_pluralized_controllers
|
128
|
+
@controller_name = "#{ExtlibCopy.classify(ExtlibCopy::Inflection.pluralize(name))}Controller"
|
129
|
+
else
|
130
|
+
@controller_name = "#{ExtlibCopy.classify(name)}Controller"
|
131
|
+
end
|
128
132
|
@action = extract_service_action(url)
|
129
133
|
@verb = :get
|
130
134
|
@formats = []
|
@@ -134,6 +138,26 @@ class WSDSL
|
|
134
138
|
@extra = {}
|
135
139
|
end
|
136
140
|
|
141
|
+
# Checks the WSDSL flag to see if the controller names are pluralized.
|
142
|
+
#
|
143
|
+
# @return [Boolean] The updated value, default to false
|
144
|
+
# @api public
|
145
|
+
# @since 0.1.1
|
146
|
+
def self.use_pluralized_controllers
|
147
|
+
@pluralized_controllers ||= false
|
148
|
+
end
|
149
|
+
|
150
|
+
# Sets a WSDSL global flag so all controller names will be automatically pluralized.
|
151
|
+
#
|
152
|
+
# @param [Boolean] True if the controllers are pluralized, False otherwise.
|
153
|
+
#
|
154
|
+
# @return [Boolean] The updated value
|
155
|
+
# @api public
|
156
|
+
# @since 0.1.1
|
157
|
+
def self.use_pluralized_controllers=(val)
|
158
|
+
@pluralized_controllers = val
|
159
|
+
end
|
160
|
+
|
137
161
|
# Offers a way to dispatch the service at runtime
|
138
162
|
# Basically, it dispatches the request to the defined controller/action
|
139
163
|
# The full request cycle looks like that:
|
data/spec/wsdsl_spec.rb
CHANGED
@@ -75,6 +75,15 @@ describe WSDSL do
|
|
75
75
|
service.extra[:custom_name].should == 'fooBar'
|
76
76
|
end
|
77
77
|
|
78
|
+
it "should respect the global controller pluralization flag" do
|
79
|
+
WSDSL.use_pluralized_controllers = true
|
80
|
+
service = WSDSL.new("player/:id.xml")
|
81
|
+
service.controller_name.should == "PlayersController"
|
82
|
+
WSDSL.use_pluralized_controllers = false
|
83
|
+
service = WSDSL.new("player/:id.xml")
|
84
|
+
service.controller_name.should == "PlayerController"
|
85
|
+
end
|
86
|
+
|
78
87
|
describe WSDSL::Params do
|
79
88
|
|
80
89
|
before(:all) do
|
data/wsdsl.gemspec
CHANGED