versionist 0.2.3 → 0.2.4

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.
@@ -16,6 +16,7 @@ module Versionist
16
16
  @versioning_strategies.clear
17
17
  @default_version = nil
18
18
  @header_versions.clear
19
+ @parameter_versions.clear
19
20
  end
20
21
  end
21
22
  end
@@ -33,10 +33,10 @@ module Versionist
33
33
  end
34
34
 
35
35
  def configure_path(config, &block)
36
+ config[:path].slice!(0) if config[:path] =~ /^\//
36
37
  path = Versionist::VersioningStrategy::Path.new(config)
37
38
  # Use the :as option and strip out non-word characters from the path to avoid this:
38
39
  # https://github.com/rails/rails/issues/3224
39
- config[:path].slice!(0) if config[:path] =~ /^\//
40
40
  route_hash = {:module => config[:module], :as => config[:path].gsub(/\W/, '_')}
41
41
  route_hash.merge!({:defaults => config[:defaults]}) if config.has_key?(:defaults)
42
42
  namespace(config[:path], route_hash, &block)
@@ -53,14 +53,3 @@ module Versionist
53
53
  end
54
54
  end
55
55
  end
56
-
57
- # Hook to clear versionist cached data when routes are reloaded
58
- module Rails
59
- class Application #:nodoc:
60
- def reload_routes_with_versionist!
61
- Versionist.configuration.clear!
62
- reload_routes_without_versionist!
63
- end
64
- alias_method_chain :reload_routes!, :versionist
65
- end
66
- end
@@ -1,3 +1,3 @@
1
1
  module Versionist
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
@@ -10,17 +10,26 @@ module Versionist
10
10
  raise ArgumentError, "you must pass a configuration Hash" if config.nil? || !config.is_a?(Hash)
11
11
  @config = config
12
12
  @config.symbolize_keys!
13
- Versionist.configuration.versioning_strategies << self
14
- raise ArgumentError, "[VERSIONIST] attempt to set more than one default api version" if !Versionist.configuration.default_version.nil? && @config.has_key?(:default)
15
13
  if @config.has_key?(:default)
16
- Versionist.configuration.default_version = self
17
14
  @default = true
15
+ else
16
+ @default = false
17
+ end
18
+ if !Versionist.configuration.versioning_strategies.include?(self)
19
+ raise ArgumentError, "[VERSIONIST] attempt to set more than one default api version" if !Versionist.configuration.default_version.nil? && self.default? && Versionist.configuration.default_version != self
20
+ Versionist.configuration.versioning_strategies << self
21
+ Versionist.configuration.default_version = self if self.default?
18
22
  end
19
23
  end
20
24
 
21
25
  def default?
22
26
  @default
23
27
  end
28
+
29
+ def ==(other)
30
+ return false if other.nil? || !other.is_a?(Versionist::VersioningStrategy::Base)
31
+ return self.config == other.config && self.default? == other.default?
32
+ end
24
33
  end
25
34
  end
26
35
  end
@@ -7,9 +7,9 @@ module Versionist
7
7
  # - :header the header to inspect
8
8
  # - :value the value of the header specifying the version
9
9
  def initialize(config)
10
+ super
10
11
  raise ArgumentError, "you must specify :header in the configuration Hash" if !config.has_key?(:header)
11
12
  raise ArgumentError, "you must specify :value in the configuration Hash" if !config.has_key?(:value)
12
- super
13
13
  Versionist.configuration.header_versions << config[:value]
14
14
  end
15
15
 
@@ -18,6 +18,12 @@ module Versionist
18
18
  return ((!header_string.blank? && header_string.include?(config[:value])) ||
19
19
  (self.default? && (Versionist.configuration.header_versions.none? {|v| header_string.include?(v)})))
20
20
  end
21
+
22
+ def ==(other)
23
+ super
24
+ return false if !other.is_a?(Versionist::VersioningStrategy::Header)
25
+ return config[:header] == other.config[:header] && self.config[:value] == other.config[:value]
26
+ end
21
27
  end
22
28
  end
23
29
  end
@@ -7,9 +7,9 @@ module Versionist
7
7
  # - :parameter the parameter to inspect
8
8
  # - :value the value of the parameter specifying the version
9
9
  def initialize(config)
10
+ super
10
11
  raise ArgumentError, "you must specify :parameter in the configuration Hash" if !config.has_key?(:parameter)
11
12
  raise ArgumentError, "you must specify :value in the configuration Hash" if !config.has_key?(:value)
12
- super
13
13
  Versionist.configuration.parameter_versions << config[:value]
14
14
  end
15
15
 
@@ -18,6 +18,12 @@ module Versionist
18
18
  return ((!parameter_string.blank? && parameter_string == config[:value]) ||
19
19
  (self.default? && (Versionist.configuration.parameter_versions.none? {|v| parameter_string.include?(v)})))
20
20
  end
21
+
22
+ def ==(other)
23
+ super
24
+ return false if !other.is_a?(Versionist::VersioningStrategy::Parameter)
25
+ return config[:parameter] == other.config[:parameter] && self.config[:value] == other.config[:value]
26
+ end
21
27
  end
22
28
  end
23
29
  end
@@ -7,8 +7,14 @@ module Versionist
7
7
  # Creates a new Path VersioningStrategy object. config must contain the following keys:
8
8
  # - :path the path prefix containing the version
9
9
  def initialize(config)
10
+ super
10
11
  raise ArgumentError, "you must specify :path in the configuration Hash" if !config.has_key?(:path)
12
+ end
13
+
14
+ def ==(other)
11
15
  super
16
+ return false if !other.is_a?(Versionist::VersioningStrategy::Path)
17
+ return config[:path] == other.config[:path]
12
18
  end
13
19
  end
14
20
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: versionist
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.3
5
+ version: 0.2.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Brian Ploetz
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-07-12 00:00:00 Z
13
+ date: 2012-07-26 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -105,7 +105,7 @@ rubyforge_project:
105
105
  rubygems_version: 1.8.17
106
106
  signing_key:
107
107
  specification_version: 3
108
- summary: versionist-0.2.3
108
+ summary: versionist-0.2.4
109
109
  test_files: []
110
110
 
111
111
  has_rdoc: