atdis 0.3.1 → 0.3.2

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: 7fccd4417bbe0c084467f43db250e77b96cfcbe8
4
- data.tar.gz: 5d6c8771f2d059c498d9522981bb33e549d0653b
3
+ metadata.gz: 661d7d16f8ddc03b59e867f8a1bf3a691d66f02a
4
+ data.tar.gz: 0630e75e2045725a519b3fe7b1e6995b0184f2e6
5
5
  SHA512:
6
- metadata.gz: 31d39abe6c1330329902dd0603e28e29fcd4a6560142bbe63d0f2d17bb7df8cc498a97a68ebb0aafe75aab537f4dad08a518f3fb8a042eabf98232d30aa992b9
7
- data.tar.gz: 3e62c64543eb982604b5afddcd459295481cd3a2974810901bd164cf50d4c7304d195ea917c5abad6992a87fb5315211101d38a41c99ddd29744cbb4ac674d05
6
+ metadata.gz: ac95146aa0dd9a03477ec1f7aad2380d0291a1f6585c951f4f6bcef334bc286b25354763f3a4cb2aff618e95b098ff50245d05934e87ed1ca943e9770f648085
7
+ data.tar.gz: 1d1faec28b50806f0b1f804b21d62e3d013cd855cdabed897bcf90ebca6123cfcf4847ade63f6c1f765379828baf10b3482709357b9f15c7fda1f7f207dd6a7f
@@ -54,11 +54,22 @@ module ATDIS
54
54
  # TODO Validate contents of estimated_cost
55
55
 
56
56
  def dat_id_is_url_encoded!
57
- if dat_id && CGI::escape(dat_id) != dat_id
57
+ if dat_id && !Info.url_encoded?(dat_id)
58
58
  errors.add(:dat_id, ErrorMessage.new("should be url encoded", "4.3.1"))
59
59
  end
60
60
  end
61
61
 
62
+ def self.url_encoded?(s)
63
+ url_encoded = true
64
+ s.each_char do |c|
65
+ # These characters are the valid ones in a url encoded string
66
+ unless c =~ /[a-zA-Z0-9\-_.~%+]/
67
+ url_encoded = false
68
+ end
69
+ end
70
+ url_encoded
71
+ end
72
+
62
73
  def related_apps_url_format
63
74
  if related_apps.respond_to?(:all?) && !related_apps.all? {|url| url.to_s =~ /atdis\/1.0\/[^\/]+\.json/}
64
75
  errors.add(:related_apps, ErrorMessage.new("contains url(s) not in the expected format", "4.3.1"))
data/lib/atdis/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Atdis
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -182,6 +182,11 @@ describe ATDIS::Models::Info do
182
182
  a.should_not be_valid
183
183
  a.errors.messages.should == {dat_id: [ATDIS::ErrorMessage["should be url encoded", "4.3.1"]]}
184
184
  end
185
+
186
+ it "should be valid if url encoded" do
187
+ a.dat_id = "010%2F2014%2F00000031%2F001"
188
+ a.should be_valid
189
+ end
185
190
  end
186
191
 
187
192
  describe "#description=" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atdis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Landauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-31 00:00:00.000000000 Z
11
+ date: 2014-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler