versioncake 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjUzNjczOGFiZjY3NDliNmRmYzJhZTI5NDIzNDhhYWM4YTgxMGE2YQ==
4
+ OTZjMGMyZDYzMThlZTljNzJlYjliY2FkMmYwZGRhOWYyMTc5YjZjNw==
5
5
  data.tar.gz: !binary |-
6
- YzM4MzAwZjk2MDNlYThjZjRkMWE5NTk1MTM3Mzg3NzlmYmY2NzdlYg==
6
+ MWVhM2IzMGVlODFhYWFhOTkyNTc2MTYzMzMzMTlmNTExODM4YjAxMQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MWU4NTRjNzNkMzA4MmRkZTcxYWI2M2MxMmY2NmQwZDM4NTMyYzM0MTEyZDE1
10
- N2I2NTY3MzQyMzUxYjgyNjUwYTE1ZGI3NGVlZjU0YjI1MDQ2MzAwMDhmNmQx
11
- NGQ5NmU3YjI3MWU5ZWNiMWI4MGVkMzUxNjE1MmU0MzU3OGIzNzU=
9
+ YTg2MjZkMWI1ODkxMzM1MjJlZWExMDNjZGQyZjYwZjc3N2MwODkzNjM4OGZj
10
+ NGQxMDY2ZWZiZGZiOWI3MTBiOGE1YzdhZTExOGJmMTIzYjczYjk4ZTNjMTU2
11
+ NDM2MDMwOTVjMmIzMDBhNmM0YzQxN2JlOTJiZWYyYjQzOGM5NzA=
12
12
  data.tar.gz: !binary |-
13
- MDJkNTJlM2QxMmE0ZmU2Y2JiNmMyZDk3Y2Q1ZWE5NjU3ZjI4YmU3NzBkZDZj
14
- MmJiMDAxMTAyMzYxMTZlMmNiNjVlNjNjMWI5MWM2M2VmM2IzZjkwYzViYmVh
15
- MDNiMzY1NjJiN2RjM2I1ODk2Y2IxNzFiZmMyNzM4ODkxOTM4Njg=
13
+ OTJhNDY0ZDM1MGFlNDI5NDZjN2MyNGNmMGI1NDcwYTc3MzVmNjgwNjJmMGQy
14
+ NjFmOTg5NzI5ODkwYjY1ODczYzkwODI2NjBhODQyZDY3NTNjNDRjMTZhZjky
15
+ MjQ2MjEyNjkwODMzZGQ1OGZkZTVlMmYzNWFjZTMxNmI4ZGU5MmI=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- versioncake (2.1.0)
4
+ versioncake (2.2.0)
5
5
  actionpack (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  railties (>= 3.2)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- versioncake (2.1.0)
4
+ versioncake (2.2.0)
5
5
  actionpack (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  railties (>= 3.2)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- versioncake (2.1.0)
4
+ versioncake (2.2.0)
5
5
  actionpack (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  railties (>= 3.2)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- versioncake (2.1.0)
4
+ versioncake (2.2.0)
5
5
  actionpack (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  railties (>= 3.2)
@@ -5,7 +5,13 @@ module VersionCake
5
5
 
6
6
  def extract(request)
7
7
  version = execute(request)
8
- return version.to_i if version && /[0-9]+/.match(version)
8
+ if version.is_a?(Fixnum)
9
+ version
10
+ elsif version.is_a?(String) && /[0-9]+/.match(version)
11
+ version.to_i
12
+ else
13
+ nil
14
+ end
9
15
  end
10
16
 
11
17
  def version_key
@@ -1,3 +1,3 @@
1
1
  module VersionCake
2
- VERSION = "2.1.0"
2
+ VERSION = "2.2.0"
3
3
  end
@@ -7,13 +7,27 @@ class ExtractionStrategyTest < ActiveSupport::TestCase
7
7
  end
8
8
  end
9
9
 
10
- test "extract will convert the result to integer" do
10
+ test "custom strategy result will be converted to integer" do
11
11
  class TestStrategy < VersionCake::ExtractionStrategy
12
12
  def execute(request); "123"; end
13
13
  end
14
14
  assert_equal 123, TestStrategy.new.extract("request")
15
15
  end
16
16
 
17
+ test "custom strategy result will be returned" do
18
+ class TestStrategy < VersionCake::ExtractionStrategy
19
+ def execute(request); 123; end
20
+ end
21
+ assert_equal 123, TestStrategy.new.extract("request")
22
+ end
23
+
24
+ test "custom strategy will fail if it returns unexpected result" do
25
+ class TestStrategy < VersionCake::ExtractionStrategy
26
+ def execute(request); Object.new; end
27
+ end
28
+ assert_nil TestStrategy.new.extract("request")
29
+ end
30
+
17
31
  test "it can lookup a strategy" do
18
32
  strategy = VersionCake::ExtractionStrategy.lookup(:query_parameter)
19
33
  assert_equal VersionCake::QueryParameterStrategy, strategy.class
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versioncake
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Jones
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-03 00:00:00.000000000 Z
12
+ date: 2014-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack