choosy 0.4.3 → 0.4.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.
- data/Gemfile.lock +1 -1
- data/Rakefile +2 -6
- data/lib/VERSION.yml +2 -2
- data/lib/choosy/rake.rb +1 -1
- data/lib/choosy/version.rb +49 -17
- data/spec/choosy/version_spec.rb +17 -0
- metadata +7 -10
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -2,12 +2,8 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'rspec/core/rake_task'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
rescue LoadError => e
|
8
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
|
9
|
-
require 'choosy/rake'
|
10
|
-
end
|
5
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
|
6
|
+
require 'choosy/rake'
|
11
7
|
|
12
8
|
desc "Default task"
|
13
9
|
task :default => [:spec]
|
data/lib/VERSION.yml
CHANGED
data/lib/choosy/rake.rb
CHANGED
data/lib/choosy/version.rb
CHANGED
@@ -60,26 +60,48 @@ module Choosy
|
|
60
60
|
"#{major}.#{minor}.#{tiny}"
|
61
61
|
end
|
62
62
|
|
63
|
-
def
|
64
|
-
|
65
|
-
|
66
|
-
elsif options[:dir]
|
67
|
-
if options[:relpath]
|
68
|
-
File.join(options[:dir], options[:relpath])
|
69
|
-
else
|
70
|
-
options[:dir]
|
71
|
-
end
|
72
|
-
else
|
73
|
-
Choosy::ConfigurationError.new("No file given.")
|
74
|
-
end
|
63
|
+
def ==(other)
|
64
|
+
major == other.major && minor == other.minor && tiny == other.tiny
|
65
|
+
end
|
75
66
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
67
|
+
def eql?(other)
|
68
|
+
self == other
|
69
|
+
end
|
70
|
+
|
71
|
+
def <=>(other)
|
72
|
+
if major >= other.major || minor >= other.minor || tiny >= other.tiny
|
73
|
+
1
|
74
|
+
elsif major <= other.major || minor <= other.minor || tiny <= other.tiny
|
75
|
+
-1
|
76
|
+
else
|
77
|
+
0
|
80
78
|
end
|
79
|
+
end
|
81
80
|
|
82
|
-
|
81
|
+
def self.method_missing(method, *args, &block)
|
82
|
+
if method.to_s =~ /^load_from_(.*)$/
|
83
|
+
parts = $1.split(/_/)
|
84
|
+
parts.map! do |part|
|
85
|
+
case part
|
86
|
+
when 'here' then '.'
|
87
|
+
when 'parent' then '..'
|
88
|
+
else part
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
basedir = if args.length == 0
|
93
|
+
# Find the path to the calling file
|
94
|
+
# How awesome is this !?
|
95
|
+
File.dirname(caller(1)[0].split(/:/)[0])
|
96
|
+
else
|
97
|
+
args.join(File::Separator)
|
98
|
+
end
|
99
|
+
|
100
|
+
path = File.join(basedir, *parts)
|
101
|
+
load_from(path)
|
102
|
+
else
|
103
|
+
super
|
104
|
+
end
|
83
105
|
end
|
84
106
|
|
85
107
|
private
|
@@ -89,5 +111,15 @@ module Choosy
|
|
89
111
|
MAJOR = 'major'
|
90
112
|
VERSIONS = [TINY, MINOR, MAJOR]
|
91
113
|
DATE = 'date'
|
114
|
+
|
115
|
+
def self.load_from(basepath)
|
116
|
+
[File.join(basepath, 'VERSION.yml'), File.join(basepath, 'version.yml')].each do |path|
|
117
|
+
if File.exist?(path)
|
118
|
+
return Version.new(path)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
raise Choosy::ConfigurationError.new("No version file given from: #{basepath}")
|
123
|
+
end
|
92
124
|
end
|
93
125
|
end
|
data/spec/choosy/version_spec.rb
CHANGED
@@ -27,6 +27,23 @@ module Choosy
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
describe "attempting to load a file" do
|
31
|
+
it "should allow you to specify a search path via a method" do
|
32
|
+
version = Version.load_from_parent_parent_spec_choosy
|
33
|
+
@version.should eql(version)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should allow you to specify the current directory" do
|
37
|
+
version = Version.load_from_here
|
38
|
+
@version.should eql(version)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should allow you to load from a specific directory" do
|
42
|
+
version = Version.load_from_spec_choosy Dir.pwd
|
43
|
+
@version.should eql(version)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
30
47
|
describe "while altering the config file" do
|
31
48
|
before :each do
|
32
49
|
@tmp = Tempfile.new('version.yml')
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 4
|
9
|
+
version: 0.4.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Gabe McArthur
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-03-
|
17
|
+
date: 2011-03-31 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -23,12 +23,11 @@ dependencies:
|
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
segments:
|
29
|
-
-
|
30
|
-
|
31
|
-
version: "2.5"
|
29
|
+
- 0
|
30
|
+
version: "0"
|
32
31
|
type: :development
|
33
32
|
version_requirements: *id001
|
34
33
|
- !ruby/object:Gem::Dependency
|
@@ -66,10 +65,8 @@ dependencies:
|
|
66
65
|
- - ">="
|
67
66
|
- !ruby/object:Gem::Version
|
68
67
|
segments:
|
69
|
-
- 4
|
70
|
-
- 5
|
71
68
|
- 0
|
72
|
-
version:
|
69
|
+
version: "0"
|
73
70
|
type: :development
|
74
71
|
version_requirements: *id004
|
75
72
|
description: This is a DSL for creating more complicated command line tools.
|