technicalpickles-jeweler 0.0.3 → 0.0.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.
@@ -34,5 +34,5 @@ class Jeweler
34
34
  end
35
35
  end
36
36
 
37
- extend ActiveSupport
37
+ include ActiveSupport
38
38
  end
data/lib/jeweler/tasks.rb CHANGED
@@ -1,37 +1,49 @@
1
1
  desc "Generate a gemspec file for GitHub"
2
2
  task :gemspec do
3
- Jeweler.write_gemspec
3
+ Jeweler.instance.write_gemspec
4
4
  end
5
5
 
6
6
  desc "Displays the current version"
7
7
  task :version do
8
- puts Jeweler.version
8
+ puts Jeweler.instance.version
9
9
  end
10
10
 
11
11
  namespace :version do
12
12
  namespace :bump do
13
13
  desc "Bump the gemspec a major version."
14
14
  task :major do
15
- major = Jeweler.major_version + 1
16
- Jeweler.bump_version(major, 0, 0)
17
- Jeweler.write_gemspec
15
+ jeweler = Jeweler.instance
16
+
17
+ major = jeweler.major_version + 1
18
+
19
+ jeweler.bump_version(major, 0, 0)
20
+ jeweler.write_gemspec
21
+
18
22
  puts "Version bumped to #{Jeweler.version}"
19
23
  end
20
24
 
21
25
  desc "Bump the gemspec a minor version."
22
26
  task :minor do
23
- minor = Jeweler.minor_version + 1
24
- Jeweler.bump_version(Jeweler.major_version, minor, 0)
25
- Jeweler.write_gemspec
26
- puts "Version bumped to #{Jeweler.version}"
27
+ jeweler = Jeweler.instance
28
+
29
+ minor = jeweler.minor_version + 1
30
+
31
+ jeweler.bump_version(jeweler.major_version, minor, 0)
32
+ jeweler.write_gemspec
33
+
34
+ puts "Version bumped to #{jeweler.version}"
27
35
  end
28
36
 
29
37
  desc "Bump the gemspec a patch version."
30
38
  task :patch do
31
- patch = Jeweler.patch_version + 1
32
- Jeweler.bump_version(Jeweler.major_version, Jeweler.minor_version, patch)
33
- Jeweler.write_gemspec
34
- puts "Version bumped to #{Jeweler.version}"
39
+ jeweler = Jeweler.instance
40
+
41
+ patch = jeweler.patch_version + 1
42
+
43
+ jeweler.bump_version(jeweler.major_version, jeweler.minor_version, patch)
44
+ jeweler.write_gemspec
45
+
46
+ puts "Version bumped to #{jeweler.version}"
35
47
  end
36
48
  end
37
49
  end
@@ -2,6 +2,6 @@ class Jeweler
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 3
5
+ PATCH = 4
6
6
  end
7
7
  end
data/lib/jeweler.rb CHANGED
@@ -2,43 +2,47 @@ require 'date'
2
2
 
3
3
  class Jeweler
4
4
  def self.gemspec=(gemspec)
5
- @@gemspec = gemspec
6
- load version_module_path
7
- @@gemspec.version = version
8
- @@gemspec.files ||= FileList["[A-Z]*", "{generators,lib,test,spec}/**/*"]
5
+ @@instance = new(gemspec)
6
+ end
7
+
8
+ def self.instance
9
+ @@instance
10
+ end
11
+
12
+ attr_reader :gemspec
13
+ def initialize(gemspec)
14
+ @gemspec = gemspec
15
+
16
+ load_version()
17
+
18
+ @gemspec.version = version
19
+ @gemspec.files ||= FileList["[A-Z]*", "{generators,lib,test,spec}/**/*"]
9
20
  end
10
21
 
11
- def self.major_version
22
+ def major_version
12
23
  version_module.const_get(:MAJOR)
13
24
  end
14
25
 
15
- def self.minor_version
26
+ def minor_version
16
27
  version_module.const_get(:MINOR)
17
28
  end
18
29
 
19
- def self.patch_version
30
+ def patch_version
20
31
  version_module.const_get(:PATCH)
21
32
  end
22
33
 
23
- def self.version
34
+ def version
24
35
  "#{major_version}.#{minor_version}.#{patch_version}"
25
36
  end
26
37
 
27
- def self.date
38
+ def date
28
39
  date = DateTime.now
29
40
  "#{date.year}-#{date.month}-#{date.day}"
30
41
  end
31
42
 
32
- def self.bump_version(major, minor, patch)
43
+ def bump_version(major, minor, patch)
33
44
  main_module_or_class = constantize(main_module_name)
34
- keyword = case main_module_or_class.class
35
- when Class
36
- 'class'
37
- when Module
38
- 'module'
39
- else
40
- raise "Uh, main_module_name should be a class or module, but was a #{main_module_or_class.class}"
41
- end
45
+ keyword = top_level_keyword
42
46
 
43
47
  File.open(version_module_path, 'w') do |file|
44
48
  file.write <<-END
@@ -51,46 +55,62 @@ class Jeweler
51
55
  end
52
56
  END
53
57
  end
54
- @@gemspec.version = "#{major}.#{minor}.#{patch}"
58
+ @gemspec.version = "#{major}.#{minor}.#{patch}"
55
59
  refresh_version
56
60
  end
57
61
 
58
- def self.write_gemspec
59
- @@gemspec.date = self.date
62
+ def write_gemspec
63
+ @gemspec.date = self.date
60
64
  File.open(gemspec_path, 'w') do |f|
61
- f.write @@gemspec.to_ruby
65
+ f.write @gemspec.to_ruby
62
66
  end
63
67
  end
64
68
 
65
69
  private
66
70
 
67
- def self.gemspec_path
68
- "#{@@gemspec.name}.gemspec"
71
+ def top_level_keyword
72
+ main_module_or_class = constantize(main_module_name)
73
+ case main_module_or_class
74
+ when Class
75
+ 'class'
76
+ when Module
77
+ 'module'
78
+ else
79
+ raise "Uh, main_module_name should be a class or module, but was a #{main_module_or_class.class}"
80
+ end
81
+ end
82
+
83
+ def gemspec_path
84
+ "#{@gemspec.name}.gemspec"
69
85
  end
70
86
 
71
- def self.version_module_path
72
- "lib/#{@@gemspec.name}/version.rb"
87
+ def version_module_path
88
+ "lib/#{@gemspec.name}/version.rb"
73
89
  end
74
90
 
75
- def self.version_module
91
+ def version_module
76
92
  constantize("#{main_module_name}::Version")
77
93
  end
78
94
 
79
- def self.main_module_name
80
- camelize(@@gemspec.name)
95
+ def main_module_name
96
+ camelize(@gemspec.name)
81
97
  end
82
98
 
83
- def self.refresh_version
99
+ def refresh_version
84
100
  # Remove the constants, so we can reload the version_module
85
101
  version_module.module_eval do
86
- remove_const(:MAJOR)
87
- remove_const(:MINOR)
88
- remove_const(:PATCH)
102
+ remove_const(:MAJOR) if const_defined?(:MAJOR)
103
+ remove_const(:MINOR) if const_defined?(:MINOR)
104
+ remove_const(:PATCH) if const_defined?(:PATCH)
89
105
  end
106
+ load_version
107
+ end
108
+
109
+ def load_version
90
110
  load version_module_path
91
111
  end
92
112
  end
93
113
 
94
114
  require 'jeweler/active_support' # Adds the stolen camelize and constantize
95
115
 
96
- require 'jeweler/tasks'
116
+ 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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Nichols