technicalpickles-jeweler 0.0.5 → 0.0.6

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.
@@ -0,0 +1,56 @@
1
+ class Jeweler
2
+ module Bumping
3
+ def bump_patch_version()
4
+ patch = self.patch_version + 1
5
+
6
+ bump_version(major_version, minor_version, patch)
7
+ write_gemspec
8
+ end
9
+
10
+ def bump_minor_version()
11
+ minor = minor_version + 1
12
+
13
+ bump_version(major_version, minor, 0)
14
+ write_gemspec
15
+ end
16
+
17
+ def bump_major_version()
18
+ major = major_version + 1
19
+
20
+ bump_version(major, 0, 0)
21
+ write_gemspec
22
+ end
23
+
24
+ def bump_version(major, minor, patch)
25
+ main_module_or_class = constantize(main_module_name)
26
+ keyword = top_level_keyword()
27
+
28
+ File.open(version_module_path, 'w') do |file|
29
+ file.write <<-END
30
+ #{keyword} #{main_module_name}
31
+ module Version
32
+ MAJOR = #{major}
33
+ MINOR = #{minor}
34
+ PATCH = #{patch}
35
+ end
36
+ end
37
+ END
38
+ end
39
+ @gemspec.version = "#{major}.#{minor}.#{patch}"
40
+ refresh_version
41
+ end
42
+
43
+ protected
44
+ def top_level_keyword
45
+ main_module_or_class = constantize(main_module_name)
46
+ case main_module_or_class
47
+ when Class
48
+ 'class'
49
+ when Module
50
+ 'module'
51
+ else
52
+ raise "Uh, main_module_name should be a class or module, but was a #{main_module_or_class.class}"
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,21 @@
1
+ class Jeweler
2
+ module Gemspec
3
+ def date
4
+ date = DateTime.now
5
+ "#{date.year}-#{date.month}-#{date.day}"
6
+ end
7
+
8
+
9
+ def write_gemspec
10
+ @gemspec.date = self.date
11
+ File.open(gemspec_path, 'w') do |f|
12
+ f.write @gemspec.to_ruby
13
+ end
14
+ end
15
+
16
+ protected
17
+ def gemspec_path
18
+ File.join(@base_dir, "#{@gemspec.name}.gemspec")
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ class Jeweler
2
+ module Singleton
3
+ def self.included(base)
4
+ base.extend(ClassMethods)
5
+ end
6
+
7
+ module ClassMethods
8
+ def gemspec=(gemspec)
9
+ @@instance = new(gemspec)
10
+ end
11
+
12
+ def instance
13
+ @@instance
14
+ end
15
+ end
16
+ end
17
+
18
+ end
@@ -1,7 +1,7 @@
1
- class Jeweler
2
- module Version
3
- MAJOR = 0
4
- MINOR = 0
5
- PATCH = 5
1
+ class Jeweler
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ PATCH = 6
6
+ end
6
7
  end
7
- end
@@ -0,0 +1,46 @@
1
+ class Jeweler
2
+ module Versioning
3
+ def major_version
4
+ version_module.const_get(:MAJOR)
5
+ end
6
+
7
+ def minor_version
8
+ version_module.const_get(:MINOR)
9
+ end
10
+
11
+ def patch_version
12
+ version_module.const_get(:PATCH)
13
+ end
14
+
15
+ def version
16
+ "#{major_version}.#{minor_version}.#{patch_version}"
17
+ end
18
+
19
+ protected
20
+ def version_module_path
21
+ File.join(@base_dir, 'lib', @gemspec.name, 'version.rb')
22
+ end
23
+
24
+ def version_module
25
+ constantize("#{main_module_name}::Version")
26
+ end
27
+
28
+ def refresh_version
29
+ # Remove the constants, so we can reload the version_module
30
+ undefine_versions()
31
+ load_version()
32
+ end
33
+
34
+ def undefine_versions
35
+ version_module.module_eval do
36
+ remove_const(:MAJOR) if const_defined?(:MAJOR)
37
+ remove_const(:MINOR) if const_defined?(:MINOR)
38
+ remove_const(:PATCH) if const_defined?(:PATCH)
39
+ end
40
+ end
41
+
42
+ def load_version
43
+ load version_module_path
44
+ end
45
+ end
46
+ end
data/lib/jeweler.rb CHANGED
@@ -5,6 +5,9 @@ require 'jeweler/versioning'
5
5
  require 'jeweler/singleton'
6
6
  require 'jeweler/gemspec'
7
7
 
8
+ require 'jeweler/tasks' if defined?(Rake)
9
+ require 'jeweler/active_support' # Adds the stolen camelize and constantize
10
+
8
11
  class Jeweler
9
12
  include Jeweler::Singleton
10
13
  include Jeweler::Bumping
@@ -30,6 +33,3 @@ private
30
33
  end
31
34
  end
32
35
 
33
- require 'jeweler/active_support' # Adds the stolen camelize and constantize
34
-
35
- require 'jeweler/tasks' if defined?(Rake)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: technicalpickles-jeweler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Nichols
@@ -28,8 +28,12 @@ files:
28
28
  - TODO
29
29
  - lib/jeweler
30
30
  - lib/jeweler/active_support.rb
31
+ - lib/jeweler/bumping.rb
32
+ - lib/jeweler/gemspec.rb
33
+ - lib/jeweler/singleton.rb
31
34
  - lib/jeweler/tasks.rb
32
35
  - lib/jeweler/version.rb
36
+ - lib/jeweler/versioning.rb
33
37
  - lib/jeweler.rb
34
38
  - test/jeweler_test.rb
35
39
  - test/test_helper.rb