Skip to content

Commit

Permalink
Don't look at VERSION file - encode it directly in the code
Browse files Browse the repository at this point in the history
  • Loading branch information
smtlaissezfaire committed Nov 24, 2009
1 parent 91efbdf commit f037d0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
26 changes: 4 additions & 22 deletions lib/prototype_project/version.rb
@@ -1,27 +1,9 @@
module PrototypeProject
module Version
class << self
def string
@string ||= File.read(File.dirname(__FILE__) + "/../../VERSION").chomp
end
MAJOR = 0
MINOR = 0
TINY = 0

def major
version_parts[0]
end

def minor
version_parts[1]
end

def tiny
version_parts[2]
end

private

def version_parts
string.split(".").map { |part| part.to_i }
end
end
STRING = "#{MAJOR}.#{MINOR}.#{TINY}"
end
end
8 changes: 4 additions & 4 deletions spec/prototype_project/version_spec.rb
Expand Up @@ -3,19 +3,19 @@
describe PrototypeProject do
describe "VERSION" do
it "should be at 0.0.0" do
PrototypeProject::Version.string.should == "0.0.0"
PrototypeProject::Version::STRING.should == "0.0.0"
end

it "should have major as 0" do
PrototypeProject::Version.major.should == 0
PrototypeProject::Version::MAJOR.should == 0
end

it "should have minor as 0" do
PrototypeProject::Version.minor.should == 0
PrototypeProject::Version::MINOR.should == 0
end

it "should have tiny as 0" do
PrototypeProject::Version.tiny.should == 0
PrototypeProject::Version::TINY.should == 0
end
end
end

0 comments on commit f037d0a

Please sign in to comment.