wsdsl 0.1.4 → 0.1.5

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -23,7 +23,8 @@ module ParamsVerification
23
23
  :float => /^-?(\d*\.\d+|\d+)$/,
24
24
  :decimal => /^-?(\d*\.\d+|\d+)$/,
25
25
  :datetime => /^[-\d:T\s]+$/, # "T" is for ISO date format
26
- :boolean => /^(1|true|TRUE|T|Y|0|false|FALSE|F|N)$/
26
+ :boolean => /^(1|true|TRUE|T|Y|0|false|FALSE|F|N)$/,
27
+ :array => /,/
27
28
  }
28
29
  end
29
30
 
@@ -232,6 +233,9 @@ module ParamsVerification
232
233
  raise InvalidParamValue, "Could not typecast boolean to appropriate value"
233
234
  end
234
235
  end
236
+ # An array type is a comma delimited string, we need to cast the passed strings.
237
+ when :array
238
+ value.respond_to?(:split) ? value.split(',') : value
235
239
  when :binary, :array, :file
236
240
  value
237
241
  else
@@ -248,6 +252,9 @@ module ParamsVerification
248
252
  #
249
253
  # @return [Nil]
250
254
  # @api public
255
+ # TODO raising an exception really isn't a good idea since it forces the stack to unwind.
256
+ # More than likely developers are using exceptions to control the code flow and a different approach should be used.
257
+ # Catch/throw is a bit more efficient but is still the wrong approach for this specific problem.
251
258
  def self.verify_cast(name, value, expected_type)
252
259
  validation = ParamsVerification.type_validations[expected_type.to_sym]
253
260
  unless validation.nil? || value.to_s =~ validation
@@ -39,6 +39,20 @@ describe ParamsVerification do
39
39
  params.delete('framework')
40
40
  lambda{ ParamsVerification.validate!(params, @service.defined_params) }.should raise_exception(ParamsVerification::MissingParam)
41
41
  end
42
+
43
+ it "should cast a comma delimited string into an array when param marked as an array" do
44
+ service = WSList.all.find{|s| s.url == "services/array_param.xml"}
45
+ service.should_not be_nil
46
+ params = {'seq' => "a,b,c,d,e,g"}
47
+ validated = ParamsVerification.validate!(params, service.defined_params)
48
+ validated['seq'].should == %W{a b c d e g}
49
+ end
50
+
51
+ it "should raise an exception if a req array param doesn't contain a comma" do
52
+ service = WSList.all.find{|s| s.url == "services/array_param.xml"}
53
+ params = {'seq' => "a b c d e g"}
54
+ lambda{ ParamsVerification.validate!(params, service.defined_params) }.should raise_exception(ParamsVerification::InvalidParamType)
55
+ end
42
56
 
43
57
  it "should raise an exception when a param is of the wrong type" do
44
58
  params = @valid_params.dup
@@ -71,3 +71,13 @@ describe_service "services.xml" do |service|
71
71
  service.http_verb :put
72
72
 
73
73
  end
74
+
75
+ describe_service "services/array_param.xml" do |s|
76
+ s.formats :xml
77
+ s.http_verb :post
78
+
79
+ s.params do |p|
80
+ p.array :seq, :required => true
81
+ end
82
+
83
+ end
data/wsdsl.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wsdsl}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Aimonetti"]
12
- s.date = %q{2011-03-15}
12
+ s.date = %q{2011-05-13}
13
13
  s.description = %q{A Ruby DSL describing Web Services without implementation details.}
14
14
  s.email = %q{mattaimonetti@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
43
43
  s.homepage = %q{http://github.com/mattetti/wsdsl}
44
44
  s.licenses = ["MIT"]
45
45
  s.require_paths = ["lib"]
46
- s.rubygems_version = %q{1.3.7}
46
+ s.rubygems_version = %q{1.7.2}
47
47
  s.summary = %q{Web Service DSL}
48
48
  s.test_files = [
49
49
  "spec/hello_world_controller.rb",
@@ -57,7 +57,6 @@ Gem::Specification.new do |s|
57
57
  ]
58
58
 
59
59
  if s.respond_to? :specification_version then
60
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
61
60
  s.specification_version = 3
62
61
 
63
62
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wsdsl
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 4
9
- version: 0.1.4
4
+ prerelease:
5
+ version: 0.1.5
10
6
  platform: ruby
11
7
  authors:
12
8
  - Matt Aimonetti
@@ -14,8 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-03-15 00:00:00 -07:00
18
- default_executable:
13
+ date: 2011-05-13 00:00:00 Z
19
14
  dependencies: []
20
15
 
21
16
  description: A Ruby DSL describing Web Services without implementation details.
@@ -50,7 +45,6 @@ files:
50
45
  - spec/wsdsl_sinatra_ext_spec.rb
51
46
  - spec/wsdsl_spec.rb
52
47
  - wsdsl.gemspec
53
- has_rdoc: true
54
48
  homepage: http://github.com/mattetti/wsdsl
55
49
  licenses:
56
50
  - MIT
@@ -64,21 +58,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - ">="
66
60
  - !ruby/object:Gem::Version
67
- segments:
68
- - 0
69
61
  version: "0"
70
62
  required_rubygems_version: !ruby/object:Gem::Requirement
71
63
  none: false
72
64
  requirements:
73
65
  - - ">="
74
66
  - !ruby/object:Gem::Version
75
- segments:
76
- - 0
77
67
  version: "0"
78
68
  requirements: []
79
69
 
80
70
  rubyforge_project:
81
- rubygems_version: 1.3.7
71
+ rubygems_version: 1.7.2
82
72
  signing_key:
83
73
  specification_version: 3
84
74
  summary: Web Service DSL