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 CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- choosy (0.3.5)
4
+ choosy (0.4.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/Rakefile CHANGED
@@ -2,12 +2,8 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'rspec/core/rake_task'
4
4
 
5
- begin
6
- require 'choosy/rake'
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
@@ -1,6 +1,6 @@
1
1
  ---
2
- date: 29/03/2011
2
+ date: 31/03/2011
3
3
  version:
4
- tiny: 3
4
+ tiny: 4
5
5
  major: 0
6
6
  minor: 4
data/lib/choosy/rake.rb CHANGED
@@ -55,7 +55,7 @@ namespace :version do
55
55
  if ENV['VERSION_FILE']
56
56
  $version = Choosy::Version.new(ENV['VERSION_FILE'])
57
57
  else
58
- $version = Choosy::Version.load(:dir => Dir.pwd, :relpath => 'lib')
58
+ $version = Choosy::Version.load_from_lib Dir.pwd
59
59
  end
60
60
  end
61
61
 
@@ -60,26 +60,48 @@ module Choosy
60
60
  "#{major}.#{minor}.#{tiny}"
61
61
  end
62
62
 
63
- def self.load(options)
64
- basepath = if options[:file] && options[:relpath]
65
- File.join(File.dirname(options[:file]), options[:relpath])
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
- [File.join(basepath, 'VERSION.yml'), File.join(basepath, 'version.yml')].each do |path|
77
- if File.exist?(path)
78
- return Version.new(path)
79
- end
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
- raise Choosy::ConfigurationError.new("No version file given from: #{basepath}")
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
@@ -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
- - 3
9
- version: 0.4.3
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-29 00:00:00 -07:00
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
- - 2
30
- - 5
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: 4.5.0
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.