version_info 0.7.1 → 1.0.0

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/README.md CHANGED
@@ -21,9 +21,9 @@ Include VersionInfo in your main project module (or class):
21
21
  include VersionInfo
22
22
  end
23
23
 
24
- From here, is better to use the builtin rake/thor tasks (see it fordward). Here is how VersionInfo works and their user options:
24
+ From here, is better to use the builtin rake/thor tasks (see it forward). Here is how VersionInfo works and their user options:
25
25
 
26
- After you included VersionIinfo, a new class MyProject::Version is defined (it inherit from VersionIinfo::Data). Also a new constant MyProject::VERSION is created holding an object of class MyProject::VersionIinfo.
26
+ After you included VersionIinfo, a new constant MyProject::VERSION is created holding an object of class VersionInfo::Data
27
27
 
28
28
  VersionInfo use yaml file to store version data:
29
29
 
@@ -33,9 +33,10 @@ VersionInfo use yaml file to store version data:
33
33
  patch: 0
34
34
  author: jcangas
35
35
 
36
- By default the file is named version_info.yml and stored near the main file with the include VersionIinfo thing.
36
+ By default the file is named version_info.yml and stored in the current dir, useful
37
+ when using Rake or Thor.
37
38
 
38
- Anyway, you can change this:
39
+ Anyway, you can change this (recomended):
39
40
  module MyProject
40
41
  include VersionInfo
41
42
  VERISION.file_name = '/path/to/my_file.yaml'
@@ -84,7 +85,7 @@ And you get a few tasks with a namespace vinfo:
84
85
  rake vinfo:patch # Bumps version segment PATCH
85
86
  rake vinfo:show # Show current version tag and create version_info.yml if missing
86
87
 
87
- Or, if you prefer Thor:
88
+ If you prefer Thor:
88
89
 
89
90
  VersionInfo::ThorTasks.install(:class => MyProject) # use the thing where you included VersionInfo
90
91
 
@@ -99,5 +100,7 @@ Or, if you prefer Thor:
99
100
 
100
101
  ### Install
101
102
 
103
+ VersionInfo is [https://rubygems.org/gems/version_info](https://rubygems.org/gems/version_info) at so:
104
+
102
105
  gem install version_info
103
106
 
data/Rakefile CHANGED
@@ -9,6 +9,7 @@ require 'version_info/version'
9
9
 
10
10
 
11
11
  VersionInfo::RakeTasks.install(:class => VersionInfo)
12
+
12
13
  # now we have VersionInfo::VERSION defined, can load this
13
14
  Bundler::GemHelper.install_tasks
14
15
 
data/lib/version_info.rb CHANGED
@@ -2,19 +2,18 @@ require 'version_info/data'
2
2
 
3
3
  module VersionInfo
4
4
 
5
-
6
5
  def self.segments
7
- [:major, :minor, :patch, :state, :build]
6
+ [:major, :minor, :patch]
8
7
  end
9
8
 
10
9
  def self.included(other)
11
- data = Class.new(Data)
12
- other.const_set('Version', data)
13
- other.const_set('VERSION', data.new)
10
+ # data = Class.new(Data)
11
+ # other.const_set('Version', data)
12
+ other.const_set('VERSION', Data.new)
14
13
  end
15
14
 
16
- autoload :RakeTasks, 'version_info/tasks'
17
- autoload :ThorTasks, 'version_info/tasks'
15
+ autoload :RakeTasks, 'version_info/rake_tasks'
16
+ autoload :ThorTasks, 'version_info/thor_tasks'
18
17
 
19
18
  end
20
19
 
@@ -14,7 +14,7 @@ module VersionInfo
14
14
  end
15
15
 
16
16
  def file_name
17
- @file_name ||= Dir.pwd + '/' + underscore(self.class.name) + '_info.yml'
17
+ @file_name ||= Dir.pwd + '/' + 'version_info.yml'
18
18
  end
19
19
 
20
20
  def file_name=(value)
@@ -28,7 +28,7 @@ module VersionInfo
28
28
  VersionInfo.segments[idx..-1].each do |sgm|
29
29
  send("#{sgm}=", 0) if send(sgm)
30
30
  end
31
- send("#{key}=", 1 + send(key))
31
+ send("#{key}=", 1 + send(key).to_i)
32
32
  end
33
33
 
34
34
  def load
@@ -1,39 +1,4 @@
1
- module VersionInfo
2
- module ThorTasks
3
- def self.install(opts = {})
4
- Class.new(::Thor) do
5
- @target = opts[:class]
6
- class << self
7
- attr_reader :target
8
- end
9
- namespace :vinfo
10
-
11
- desc 'show', "Show version tag and create version_info.yml if missing"
12
- def show
13
- puts target::VERSION.tag
14
- target::VERSION.save unless File.exist?(target::VERSION.file_name)
15
- end
16
-
17
- desc "inspect", "Show complete version info"
18
- def inspect
19
- puts target::VERSION.inspect
20
- end
21
-
22
- desc "bump SEGMENT=patch", "bumps segment: [#{VersionInfo.segments.join(', ')}]"
23
- def bump(sgm = :patch)
24
- target::VERSION.bump(sgm)
25
- puts "version changed to #{target::VERSION}"
26
- target::VERSION.save
27
- end
28
-
29
- protected
30
- def target
31
- self.class.target
32
- end
33
- end
34
- end
35
- end
36
-
1
+ module VersionInfo
37
2
  class RakeTasks
38
3
 
39
4
  def self.install(opts = {})
@@ -0,0 +1,37 @@
1
+ module VersionInfo
2
+ module ThorTasks
3
+ def self.install(opts = {})
4
+ Class.new(::Thor) do
5
+ @target = opts[:class]
6
+ class << self
7
+ attr_reader :target
8
+ end
9
+ namespace :vinfo
10
+
11
+ desc 'show', "Show version tag and create version_info.yml if missing"
12
+ def show
13
+ puts target::VERSION.tag
14
+ target::VERSION.save unless File.exist?(target::VERSION.file_name)
15
+ end
16
+
17
+ desc "inspect", "Show complete version info"
18
+ def inspect
19
+ puts target::VERSION.inspect
20
+ end
21
+
22
+ desc "bump SEGMENT=patch", "bumps segment: [#{VersionInfo.segments.join(', ')}]"
23
+ def bump(sgm = :patch)
24
+ target::VERSION.bump(sgm)
25
+ puts "version changed to #{target::VERSION}"
26
+ target::VERSION.save
27
+ end
28
+
29
+ protected
30
+ def target
31
+ self.class.target
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+
@@ -1,7 +1,5 @@
1
1
  module VersionInfo
2
- Version = Class.new(Data)
3
-
4
- VERSION = Version.new
2
+ VERSION = Data.new
5
3
  VERSION.file_name = 'lib/version_info/version_info.yml'
6
4
  end
7
5
 
@@ -1,4 +1,4 @@
1
1
  ---
2
- major: 0
3
- minor: 7
4
- patch: 1
2
+ major: 1
3
+ minor: 0
4
+ patch: 0
@@ -3,26 +3,26 @@ require 'spec_helper'
3
3
  require 'version_info/test_file'
4
4
 
5
5
  describe "VersionInfo" do
6
+
6
7
  before :each do
7
8
  module TestFile
8
- include VersionInfo # force new VERSION data
9
+ include VersionInfo # force new VERSION value
9
10
  end
10
11
  end
12
+
11
13
  after :each do
12
14
  module TestFile
13
15
  remove_const :VERSION
14
- remove_const :Version
16
+ # remove_const :Version
15
17
  end
16
- end
17
-
18
-
18
+ end
19
19
 
20
20
  it "is initalized" do
21
21
  TestFile::VERSION.marshal_dump.should == {:major => 0, :minor => 0, :patch => 0 }
22
22
  end
23
23
 
24
24
  it "has default filename" do
25
- TestFile::VERSION.file_name.should == Dir.pwd + '/test_file/version_info.yml'
25
+ TestFile::VERSION.file_name.should == Dir.pwd + '/version_info.yml'
26
26
  end
27
27
 
28
28
  it "can assign filename" do
metadata CHANGED
@@ -3,10 +3,10 @@ name: version_info
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
- - 0
7
- - 7
8
6
  - 1
9
- version: 0.7.1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jorge L. Cangas
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-23 00:00:00 +01:00
17
+ date: 2011-05-07 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -62,7 +62,8 @@ files:
62
62
  - autotest/discover.rb
63
63
  - lib/version_info.rb
64
64
  - lib/version_info/data.rb
65
- - lib/version_info/tasks.rb
65
+ - lib/version_info/rake_tasks.rb
66
+ - lib/version_info/thor_tasks.rb
66
67
  - lib/version_info/version.rb
67
68
  - lib/version_info/version_info.yml
68
69
  - spec/spec_helper.rb