fun_with_version_strings 0.0.2 → 0.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9745e4351e58762e6f341572eee4ac60bf66db3f4eb7e613886f67aab510dc83
4
+ data.tar.gz: ee9492bb50d66df5599086fffc7961799ad765f62a49f3ff78e5d338d3519fab
5
+ SHA512:
6
+ metadata.gz: 3127bdd23ac92b3352f4138edbaf537189b2ff3dd31991ba2c3bccefd75dbeb9119d82db5ff2ba2c98f9957e210399ad1c0fbe71bd723db33ac6e406745fde56
7
+ data.tar.gz: 2617ac899558d0970d972f0a3e27edc58886580d722d39e10663666a29fc090fc7c5a4a040974e7cb0f3a0d686371b50b882066c038b269a9ff3cc0ffe90c97c
data/Gemfile CHANGED
@@ -6,10 +6,7 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
- gem "shoulda", ">= 0"
10
- gem "rdoc", "~> 3.12"
11
- gem "bundler", "~> 1.3.5"
12
- gem "jeweler", "~> 1.8.4"
9
+ gem "fun_with_testing", "~> 0.0", ">= 0.0.10"
13
10
  end
14
11
 
15
- gem "fun_with_files"
12
+ gem "fun_with_files", "~> 0.0", ">= 0.0.17"
data/README.rdoc CHANGED
@@ -12,6 +12,8 @@ Then the following is true:
12
12
  MyGem.version.major # => 0
13
13
  MyGem.version.minor # => 0
14
14
  MyGem.version.patch # => 3
15
+
16
+ You can also refer to it using MyGem::VERSION
15
17
 
16
18
  You can also compare versions. Observe:
17
19
 
@@ -24,11 +26,17 @@ You can also compare versions. Observe:
24
26
  version_b > version_a # => true
25
27
  version_b < version_a # => false
26
28
 
27
- But comparisons are a bit tricky. It will try to compare standard strings as version strings, if the standard string is of the proper format. Otherwise
28
- it will compare the two as regular strings. Note that this means that the
29
- comparison behaves differently depending on whether the left-hand side is
30
- a regular string.
31
-
29
+ But comparisons are a bit tricky. It will try to compare standard strings as version strings, if the standard string is of the proper format. Otherwise it will compare the two as regular strings.
30
+
31
+ If the versionized object responds to ".root" and that root is a FunWith::Files::FilePath, you don't need to give a version. versionize() will try to read the version from the VERSION file in the root directory.
32
+
33
+ It's a common pattern with my gems.
34
+
35
+ Other useful stuff:
36
+
37
+ "10.4.9".fwvs_version_string.patch # => 9 (converts a normal string into a FunWith::VersionStrings::VersionString)
38
+
39
+
32
40
 
33
41
  == Contributing to fun_with_version_strings
34
42
 
data/Rakefile CHANGED
@@ -9,10 +9,11 @@ rescue Bundler::BundlerError => e
9
9
  $stderr.puts "Run `bundle install` to install missing gems"
10
10
  exit e.status_code
11
11
  end
12
+
12
13
  require 'rake'
13
14
 
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
15
+ require 'juwelier'
16
+ Juwelier::Tasks.new do |gem|
16
17
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
18
  gem.name = "fun_with_version_strings"
18
19
  gem.homepage = "http://github.com/darthschmoo/fun_with_version_strings"
@@ -23,7 +24,7 @@ Jeweler::Tasks.new do |gem|
23
24
  gem.authors = ["Bryce Anderson"]
24
25
  # dependencies defined in Gemfile
25
26
  end
26
- Jeweler::RubygemsDotOrgTasks.new
27
+ Juwelier::RubygemsDotOrgTasks.new
27
28
 
28
29
  require 'rake/testtask'
29
30
  Rake::TestTask.new(:test) do |test|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.4
@@ -7,18 +7,22 @@ module FunWith
7
7
  # my gems.
8
8
  def versionize( obj, version_string = nil )
9
9
  if obj.respond_to?(:version)
10
- warn( "FunWith::VersionStrings (warn): #{obj.to_s[0..100]} already responds to version()")
10
+ warn( "FunWith::VersionStrings (warn): #{obj.to_s[0..100]} already responds to version(). Leaving alone.")
11
+ return nil
12
+ else
13
+ obj.extend( VersionizeExtender )
14
+ obj.const_set(:VERSION, version_string) unless defined?(obj::VERSION)
11
15
  end
12
16
 
13
17
  if version_string.nil?
14
- if obj.respond_to?(:root) && obj.root("VERSION").file?
18
+ # if VERSION constant is already set for the object, then we don't need to do anything.
19
+ if obj.respond_to?(:root) && obj.root.is_a?(FunWith::Files::FilePath) && obj.root("VERSION").file?
15
20
  version_string = obj.root("VERSION").read
16
21
  else
17
22
  raise "No version string specified, and cannot infer version from VERSION file."
18
23
  end
19
24
  end
20
25
 
21
- obj.extend( VersionizeExtender )
22
26
  obj.version( version_string )
23
27
  end
24
28
  end
@@ -1,9 +1,5 @@
1
1
  class String
2
2
  def fwvs_version_string
3
- if self.is_a?(FunWith::VersionStrings::VersionString)
4
- self.dup
5
- else
6
- FunWith::VersionStrings::VersionString.new( self )
7
- end
3
+ FunWith::VersionStrings::VersionString.new( self )
8
4
  end
9
5
  end
@@ -2,7 +2,7 @@ module FunWith
2
2
  module VersionStrings
3
3
  module VersionizeExtender
4
4
  def version( str = nil )
5
- @fwvs_version_string ||= str.fwvs_version_string
5
+ @fwvs_version_string = str.fwvs_version_string unless str.nil?
6
6
  @fwvs_version_string
7
7
  end
8
8
  end
data/test/helper.rb CHANGED
@@ -1,25 +1,27 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'test/unit'
11
- require 'shoulda'
1
+ # require 'rubygems'
2
+ # require 'bundler'
3
+ # begin
4
+ # Bundler.setup(:default, :development)
5
+ # rescue Bundler::BundlerError => e
6
+ # $stderr.puts e.message
7
+ # $stderr.puts "Run `bundle install` to install missing gems"
8
+ # exit e.status_code
9
+ # end
10
+ # require 'test/unit'
11
+ # require 'shoulda'
12
12
 
13
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
- $LOAD_PATH.unshift(File.dirname(__FILE__))
13
+ # $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ # $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'fun_with_testing'
15
16
  require 'fun_with_version_strings'
16
17
 
17
- include FunWith::VersionStrings
18
18
 
19
- class Test::Unit::TestCase
20
- end
19
+ # class Test::Unit::TestCase
20
+ # end
21
+
22
+ class VersionStringsTestCase < FunWith::Testing::TestCase
23
+ include FunWith::VersionStrings
21
24
 
22
- class VersionStringsTestCase < Test::Unit::TestCase
23
25
  def assert_valid_version_string( str, opts = {} )
24
26
  str = str.fwvs_version_string
25
27
  for level in [:major, :minor, :patch]
@@ -60,20 +60,21 @@ class TestFunWithVersionStrings < VersionStringsTestCase
60
60
  mod = Module.new
61
61
 
62
62
  assert_raises( RuntimeError ) do
63
- FunWith::VersionStrings.versionize( @module )
63
+ FunWith::VersionStrings.versionize( mod )
64
64
  end
65
65
  end
66
66
 
67
67
  should "raise error when root has no VERSION file" do
68
68
  mod = Module.new
69
- FunWith::Files::RootPath.rootify(mod, FunWith::VersionStrings.root("test"))
69
+ FunWith::Files::RootPath.rootify( mod, FunWith::VersionStrings.root("test") )
70
70
  assert_raises( RuntimeError ) do
71
- FunWith::VersionStrings.versionize( @module )
71
+ FunWith::VersionStrings.versionize( mod )
72
72
  end
73
73
  end
74
74
 
75
75
  should "set version by VERSION file when module has a root" do
76
76
  mod = Module.new
77
+
77
78
  FunWith::Files::RootPath.rootify( mod, FunWith::VersionStrings.root )
78
79
  FunWith::VersionStrings.versionize( mod )
79
80
  assert FunWith::VersionStrings.respond_to?(:version)
@@ -82,7 +83,18 @@ class TestFunWithVersionStrings < VersionStringsTestCase
82
83
  end
83
84
  end
84
85
 
85
- should "compare incorrectly when dealing with regular strings" do
86
- flunk "not written"
86
+ should "compare as strings when compared string doesn't fit the format" do
87
+ v = "10.0.10".fwvs_version_string
88
+
89
+ comparisons = [[1, "0a"],
90
+ [1, "--"],
91
+ [1, "..?"],
92
+ [-1, "5 is a number"]
93
+ ]
94
+
95
+
96
+ for compare in comparisons
97
+ assert_equal compare.first, ( v <=> compare.last )
98
+ end
87
99
  end
88
100
  end
metadata CHANGED
@@ -1,96 +1,54 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fun_with_version_strings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bryce Anderson
9
- autorequire:
10
8
  bindir: bin
11
9
  cert_chain: []
12
- date: 2014-02-02 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
13
11
  dependencies:
14
12
  - !ruby/object:Gem::Dependency
15
13
  name: fun_with_files
16
14
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
15
  requirements:
19
- - - ! '>='
16
+ - - "~>"
20
17
  - !ruby/object:Gem::Version
21
- version: '0'
18
+ version: '0.0'
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.17
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
25
  requirements:
27
- - - ! '>='
26
+ - - "~>"
28
27
  - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: shoulda
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
28
+ version: '0.0'
29
+ - - ">="
36
30
  - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
31
+ version: 0.0.17
46
32
  - !ruby/object:Gem::Dependency
47
- name: rdoc
33
+ name: fun_with_testing
48
34
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
35
  requirements:
51
- - - ~>
36
+ - - "~>"
52
37
  - !ruby/object:Gem::Version
53
- version: '3.12'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
38
+ version: '0.0'
39
+ - - ">="
60
40
  - !ruby/object:Gem::Version
61
- version: '3.12'
62
- - !ruby/object:Gem::Dependency
63
- name: bundler
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ~>
68
- - !ruby/object:Gem::Version
69
- version: 1.3.5
41
+ version: 0.0.10
70
42
  type: :development
71
43
  prerelease: false
72
44
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ~>
76
- - !ruby/object:Gem::Version
77
- version: 1.3.5
78
- - !ruby/object:Gem::Dependency
79
- name: jeweler
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
45
  requirements:
83
- - - ~>
46
+ - - "~>"
84
47
  - !ruby/object:Gem::Version
85
- version: 1.8.4
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ~>
48
+ version: '0.0'
49
+ - - ">="
92
50
  - !ruby/object:Gem::Version
93
- version: 1.8.4
51
+ version: 0.0.10
94
52
  description: A simple little gem for adding a version string to any Ruby object.
95
53
  email: keeputahweird@gmail.com
96
54
  executables: []
@@ -99,7 +57,7 @@ extra_rdoc_files:
99
57
  - LICENSE.txt
100
58
  - README.rdoc
101
59
  files:
102
- - .document
60
+ - ".document"
103
61
  - Gemfile
104
62
  - LICENSE.txt
105
63
  - README.rdoc
@@ -116,29 +74,22 @@ files:
116
74
  homepage: http://github.com/darthschmoo/fun_with_version_strings
117
75
  licenses:
118
76
  - MIT
119
- post_install_message:
77
+ metadata: {}
120
78
  rdoc_options: []
121
79
  require_paths:
122
80
  - lib
123
81
  required_ruby_version: !ruby/object:Gem::Requirement
124
- none: false
125
82
  requirements:
126
- - - ! '>='
83
+ - - ">="
127
84
  - !ruby/object:Gem::Version
128
85
  version: '0'
129
- segments:
130
- - 0
131
- hash: 3139587629202339878
132
86
  required_rubygems_version: !ruby/object:Gem::Requirement
133
- none: false
134
87
  requirements:
135
- - - ! '>='
88
+ - - ">="
136
89
  - !ruby/object:Gem::Version
137
90
  version: '0'
138
91
  requirements: []
139
- rubyforge_project:
140
- rubygems_version: 1.8.25
141
- signing_key:
142
- specification_version: 3
92
+ rubygems_version: 3.7.2
93
+ specification_version: 4
143
94
  summary: Add a version string (with :major,:minor, and :patch methods) to a Ruby object.
144
95
  test_files: []