versions.rb 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -0
  3. data/lib/versions.rb +37 -7
  4. metadata +10 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78041bf2a4df73df1793b184202621848d58eb03
4
- data.tar.gz: 378de3a0716626eb7a5bd0607e387bb5a7c0f4cb
3
+ metadata.gz: 046f37b7141e3bbca1436bcfdaf16a0be79c721c
4
+ data.tar.gz: 16f3cc8ed2e379a9cf154cc6add663bc4788060f
5
5
  SHA512:
6
- metadata.gz: 444f3ef345bd9b74e6b02b9b4c71c0cc4a1ecae6fc497f5179e9548ea4ecc71fd4dd560f020f54d5735601029cac227b7825d87efc47fda42bb25a4365e3e179
7
- data.tar.gz: 06ef5277923a34863ef55a03d8e66719fcf9047affd9dac124afed3fb1a9d317f31f6ae22caac473054100575250d334f53e230a7d38c130db8d0c1b6636e599
6
+ metadata.gz: bee3c591304e503f4ab60cbccfedbbf1d73214cebde7126be572bc5e9ec13ea73ab533bbc56232a321c92ece808a7d4226440d7b0a69c1f74b0d972408be389a
7
+ data.tar.gz: c5170793897cd54cb037df8cd197ac8dd4abf8121737dbe44464ae7efb76be42dbfd806f11c6da80df065e54c2e8c9b5024f409acb9f09cd908ad11fe3bd2d85
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Sean Callan.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/lib/versions.rb CHANGED
@@ -1,6 +1,7 @@
1
- DEPENDENCIES = %w{versionable configurable file_helpers class_helpers}
2
-
3
- DEPENDENCIES.each { |d| require File.join(File.dirname(__FILE__), 'versions', "#{d}.rb") }
1
+ require 'versions/versionable.rb'
2
+ require 'versions/configurable.rb'
3
+ require 'versions/file_helpers.rb'
4
+ require 'versions/class_helpers.rb'
4
5
 
5
6
  class Versions
6
7
  extend Versionable
@@ -9,15 +10,31 @@ class Versions
9
10
  include FileHelpers
10
11
  include ClassHelpers
11
12
 
13
+ # Public: Sets up and returns a new instance
14
+ #
15
+ # mod - Symbol or String of the library name
16
+ #
17
+ # Returns an instance of Versions
12
18
  def self.for(mod)
13
19
  new(mod)
14
20
  end
15
21
 
22
+ # Public: Sets the base directory for this instance
23
+ #
24
+ # path - path to the directory
25
+ #
26
+ # Returns self
16
27
  def at(path)
17
28
  @path = path
18
29
  self
19
30
  end
20
31
 
32
+ # Public: Selects a version
33
+ #
34
+ # version - a version string
35
+ #
36
+ # Returns the versioned Class
37
+ # Raises VersionNotAvailableError
21
38
  def select(version)
22
39
  if file = mapped_versions[version]
23
40
  load_class(version, file)
@@ -26,26 +43,39 @@ class Versions
26
43
  end
27
44
  end
28
45
 
46
+ # Public: Whether a version is available or not
47
+ #
48
+ # version - a version string
49
+ #
50
+ # Returns a Boolean
29
51
  def available?(version)
30
52
  !!mapped_versions[version]
31
53
  end
32
54
 
55
+ # Public: Get the available versions
56
+ #
57
+ # Returns an Array of version strings
33
58
  def versions
34
59
  mapped_versions.keys.sort
35
60
  end
36
61
 
37
62
  protected
38
63
 
64
+ # Internal: Create a new instance
65
+ #
66
+ # mod - Symbol or String of the library name
67
+ #
68
+ # Returns a new instance
39
69
  def initialize(mod)
40
70
  @library_name = mod.to_s
41
71
  end
42
72
 
73
+ # Internal: An internal map of versions and their respective files,
74
+ # the Hash keys are version strings and files as value.
75
+ #
76
+ # Returns a Hash
43
77
  def mapped_versions
44
78
  @file_version_mapping ||= map_file_versions
45
79
  end
46
-
47
- def config
48
- Versions.config
49
- end
50
80
  end
51
81
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versions.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - doomspork
@@ -14,16 +14,16 @@ dependencies:
14
14
  name: pry
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.9.12.6
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.9.12.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rr
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,13 +66,15 @@ dependencies:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.8.2
69
- description: Versions.rb provides a simple means to loading versioned libraries.
69
+ description: Versions.rb provides a simple method for handling libraries that require
70
+ versioning.
70
71
  email: iamdoomspork@gmail.com
71
72
  executables: []
72
73
  extensions: []
73
74
  extra_rdoc_files: []
74
75
  files:
75
76
  - lib/versions.rb
77
+ - LICENSE
76
78
  homepage: https://github.com/doomspork/versions.rb
77
79
  licenses:
78
80
  - MIT
@@ -85,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
87
  requirements:
86
88
  - - '>='
87
89
  - !ruby/object:Gem::Version
88
- version: '0'
90
+ version: 1.8.7
89
91
  required_rubygems_version: !ruby/object:Gem::Requirement
90
92
  requirements:
91
93
  - - '>='
@@ -96,6 +98,6 @@ rubyforge_project:
96
98
  rubygems_version: 2.0.3
97
99
  signing_key:
98
100
  specification_version: 4
99
- summary: Library versioning made simple.
101
+ summary: Ruby class versioning made simple.
100
102
  test_files: []
101
103
  has_rdoc: