jeweler 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.markdown +64 -0
- data/LICENSE +20 -0
- data/README.markdown +164 -0
- data/Rakefile +89 -0
- data/TODO +11 -0
- data/VERSION.yml +4 -0
- data/bin/jeweler +8 -0
- data/lib/jeweler.rb +154 -0
- data/lib/jeweler/commands.rb +12 -0
- data/lib/jeweler/commands/build_gem.rb +31 -0
- data/lib/jeweler/commands/install_gem.rb +26 -0
- data/lib/jeweler/commands/release.rb +59 -0
- data/lib/jeweler/commands/release_to_rubyforge.rb +51 -0
- data/lib/jeweler/commands/setup_rubyforge.rb +38 -0
- data/lib/jeweler/commands/validate_gemspec.rb +30 -0
- data/lib/jeweler/commands/version/base.rb +41 -0
- data/lib/jeweler/commands/version/bump_major.rb +13 -0
- data/lib/jeweler/commands/version/bump_minor.rb +12 -0
- data/lib/jeweler/commands/version/bump_patch.rb +14 -0
- data/lib/jeweler/commands/version/write.rb +12 -0
- data/lib/jeweler/commands/write_gemspec.rb +39 -0
- data/lib/jeweler/errors.rb +20 -0
- data/lib/jeweler/gemspec_helper.rb +51 -0
- data/lib/jeweler/generator.rb +347 -0
- data/lib/jeweler/generator/application.rb +45 -0
- data/lib/jeweler/generator/options.rb +68 -0
- data/lib/jeweler/tasks.rb +119 -0
- data/lib/jeweler/templates/.document +5 -0
- data/lib/jeweler/templates/.gitignore +5 -0
- data/lib/jeweler/templates/LICENSE +20 -0
- data/lib/jeweler/templates/README.rdoc +7 -0
- data/lib/jeweler/templates/Rakefile +125 -0
- data/lib/jeweler/templates/bacon/flunking.rb +7 -0
- data/lib/jeweler/templates/bacon/helper.rb +8 -0
- data/lib/jeweler/templates/features/default.feature +9 -0
- data/lib/jeweler/templates/features/support/env.rb +11 -0
- data/lib/jeweler/templates/micronaut/flunking.rb +7 -0
- data/lib/jeweler/templates/micronaut/helper.rb +17 -0
- data/lib/jeweler/templates/minitest/flunking.rb +7 -0
- data/lib/jeweler/templates/minitest/helper.rb +11 -0
- data/lib/jeweler/templates/rspec/flunking.rb +7 -0
- data/lib/jeweler/templates/rspec/helper.rb +9 -0
- data/lib/jeweler/templates/shoulda/flunking.rb +7 -0
- data/lib/jeweler/templates/shoulda/helper.rb +10 -0
- data/lib/jeweler/templates/testunit/flunking.rb +7 -0
- data/lib/jeweler/templates/testunit/helper.rb +9 -0
- data/lib/jeweler/version_helper.rb +83 -0
- data/test/fixtures/bar/VERSION.yml +4 -0
- data/test/fixtures/existing-project-with-version/LICENSE +20 -0
- data/test/fixtures/existing-project-with-version/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version/Rakefile +82 -0
- data/test/fixtures/existing-project-with-version/VERSION.yml +4 -0
- data/test/fixtures/existing-project-with-version/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version/test/test_helper.rb +10 -0
- data/test/geminstaller.yml +12 -0
- data/test/generators/initialization_test.rb +146 -0
- data/test/jeweler/commands/test_build_gem.rb +72 -0
- data/test/jeweler/commands/test_install_gem.rb +21 -0
- data/test/jeweler/commands/test_release.rb +180 -0
- data/test/jeweler/commands/test_release_to_rubyforge.rb +157 -0
- data/test/jeweler/commands/test_setup_rubyforge.rb +88 -0
- data/test/jeweler/commands/test_validate_gemspec.rb +27 -0
- data/test/jeweler/commands/test_write_gemspec.rb +92 -0
- data/test/jeweler/commands/version/test_base.rb +32 -0
- data/test/jeweler/commands/version/test_bump_major.rb +22 -0
- data/test/jeweler/commands/version/test_bump_minor.rb +19 -0
- data/test/jeweler/commands/version/test_bump_patch.rb +20 -0
- data/test/jeweler/commands/version/test_write.rb +23 -0
- data/test/shoulda_macros/jeweler_macros.rb +35 -0
- data/test/test_application.rb +113 -0
- data/test/test_gemspec_helper.rb +36 -0
- data/test/test_generator.rb +183 -0
- data/test/test_helper.rb +118 -0
- data/test/test_jeweler.rb +177 -0
- data/test/test_options.rb +96 -0
- data/test/test_tasks.rb +41 -0
- data/test/test_version_helper.rb +115 -0
- data/test/version_tmp/VERSION.yml +4 -0
- metadata +171 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'jeweler/commands/build_gem'
|
2
|
+
require 'jeweler/commands/install_gem'
|
3
|
+
require 'jeweler/commands/release'
|
4
|
+
require 'jeweler/commands/release_to_rubyforge'
|
5
|
+
require 'jeweler/commands/setup_rubyforge'
|
6
|
+
require 'jeweler/commands/validate_gemspec'
|
7
|
+
require 'jeweler/commands/write_gemspec'
|
8
|
+
require 'jeweler/commands/version/base'
|
9
|
+
require 'jeweler/commands/version/bump_major'
|
10
|
+
require 'jeweler/commands/version/bump_minor'
|
11
|
+
require 'jeweler/commands/version/bump_patch'
|
12
|
+
require 'jeweler/commands/version/write'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Jeweler
|
2
|
+
module Commands
|
3
|
+
class BuildGem
|
4
|
+
attr_accessor :base_dir, :gemspec_helper, :file_utils
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
self.file_utils = FileUtils
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
gemspec = gemspec_helper.parse
|
12
|
+
gem_file_name = Gem::Builder.new(gemspec).build
|
13
|
+
|
14
|
+
pkg_dir = File.join(base_dir, 'pkg')
|
15
|
+
file_utils.mkdir_p pkg_dir
|
16
|
+
|
17
|
+
gem_file_name = File.join(base_dir, gem_file_name)
|
18
|
+
file_utils.mv gem_file_name, pkg_dir
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.build_for(jeweler)
|
22
|
+
command = new
|
23
|
+
|
24
|
+
command.base_dir = jeweler.base_dir
|
25
|
+
command.gemspec_helper = jeweler.gemspec_helper
|
26
|
+
|
27
|
+
command
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Jeweler
|
2
|
+
module Commands
|
3
|
+
class InstallGem
|
4
|
+
attr_accessor :gemspec_helper, :output
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
self.output = $stdout
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
def run
|
12
|
+
command = "sudo gem install #{gemspec_helper.gem_path}"
|
13
|
+
output.puts "Executing #{command.inspect}:"
|
14
|
+
|
15
|
+
sh command # TODO where does sh actually come from!?
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.build_for(jeweler)
|
19
|
+
command = new
|
20
|
+
command.output = jeweler.output
|
21
|
+
command.gemspec_helper = jeweler.gemspec_helper
|
22
|
+
command
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class Jeweler
|
2
|
+
module Commands
|
3
|
+
class Release
|
4
|
+
attr_accessor :gemspec, :version, :repo, :output, :gemspec_helper, :base_dir
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
self.output = $stdout
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
repo.checkout('master')
|
12
|
+
|
13
|
+
raise "Hey buddy, try committing them files first" if any_pending_changes?
|
14
|
+
|
15
|
+
gemspec_helper.update_version(version)
|
16
|
+
gemspec_helper.write
|
17
|
+
|
18
|
+
repo.add(gemspec_helper.path)
|
19
|
+
output.puts "Committing #{gemspec_helper.path}"
|
20
|
+
repo.commit("Regenerated gemspec for version #{version}")
|
21
|
+
|
22
|
+
output.puts "Pushing master to origin"
|
23
|
+
repo.push
|
24
|
+
|
25
|
+
output.puts "Tagging #{release_tag}"
|
26
|
+
repo.add_tag(release_tag)
|
27
|
+
|
28
|
+
output.puts "Pushing #{release_tag} to origin"
|
29
|
+
repo.push('origin', release_tag)
|
30
|
+
end
|
31
|
+
|
32
|
+
def any_pending_changes?
|
33
|
+
!(@repo.status.added.empty? && @repo.status.deleted.empty? && @repo.status.changed.empty?)
|
34
|
+
end
|
35
|
+
|
36
|
+
def release_tag
|
37
|
+
"v#{version}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemspec_helper
|
41
|
+
@gemspec_helper ||= Jeweler::GemSpecHelper.new(self.gemspec, self.base_dir)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.build_for(jeweler)
|
45
|
+
command = self.new
|
46
|
+
|
47
|
+
command.base_dir = jeweler.base_dir
|
48
|
+
command.gemspec = jeweler.gemspec
|
49
|
+
command.version = jeweler.version
|
50
|
+
command.repo = jeweler.repo
|
51
|
+
command.output = jeweler.output
|
52
|
+
command.gemspec_helper = jeweler.gemspec_helper
|
53
|
+
|
54
|
+
command
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rubyforge'
|
2
|
+
|
3
|
+
class Jeweler
|
4
|
+
module Commands
|
5
|
+
class ReleaseToRubyforge
|
6
|
+
attr_accessor :gemspec, :version, :output, :gemspec_helper, :rubyforge
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
self.output = $stdout
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
raise NoRubyForgeProjectInGemspecError unless @gemspec.rubyforge_project
|
14
|
+
|
15
|
+
@rubyforge.configure rescue nil
|
16
|
+
|
17
|
+
output.puts 'Logging in rubyforge'
|
18
|
+
@rubyforge.login
|
19
|
+
|
20
|
+
@rubyforge.userconfig['release_notes'] = @gemspec.description if @gemspec.description
|
21
|
+
@rubyforge.userconfig['preformatted'] = true
|
22
|
+
|
23
|
+
output.puts "Releasing #{@gemspec.name}-#{@version} to #{@gemspec.rubyforge_project}"
|
24
|
+
begin
|
25
|
+
@rubyforge.add_release(@gemspec.rubyforge_project, @gemspec.name, @version.to_s, @gemspec_helper.gem_path)
|
26
|
+
rescue StandardError => e
|
27
|
+
case e.message
|
28
|
+
when /no <group_id> configured for <#{Regexp.escape @gemspec.rubyforge_project}>/
|
29
|
+
raise RubyForgeProjectNotConfiguredError, @gemspec.rubyforge_project
|
30
|
+
when /no <package_id> configured for <#{Regexp.escape @gemspec.name}>/i
|
31
|
+
raise MissingRubyForgePackageError, @gemspec.name
|
32
|
+
else
|
33
|
+
raise
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.build_for(jeweler)
|
39
|
+
command = new
|
40
|
+
command.gemspec = jeweler.gemspec
|
41
|
+
command.gemspec_helper = jeweler.gemspec_helper
|
42
|
+
command.version = jeweler.version
|
43
|
+
command.rubyforge = jeweler.rubyforge
|
44
|
+
command.output = jeweler.output
|
45
|
+
|
46
|
+
command
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class Jeweler
|
2
|
+
module Commands
|
3
|
+
class SetupRubyforge
|
4
|
+
attr_accessor :gemspec, :output, :rubyforge
|
5
|
+
|
6
|
+
def run
|
7
|
+
raise NoRubyForgeProjectInGemspecError unless @gemspec.rubyforge_project
|
8
|
+
|
9
|
+
@rubyforge.configure
|
10
|
+
|
11
|
+
output.puts "Logging into rubyforge"
|
12
|
+
@rubyforge.login
|
13
|
+
|
14
|
+
output.puts "Creating #{@gemspec.name} package in the #{@gemspec.rubyforge_project} project"
|
15
|
+
begin
|
16
|
+
@rubyforge.create_package(@gemspec.rubyforge_project, @gemspec.name)
|
17
|
+
rescue StandardError => e
|
18
|
+
case e.message
|
19
|
+
when /no <group_id> configured for <#{Regexp.escape @gemspec.rubyforge_project}>/
|
20
|
+
raise RubyForgeProjectNotConfiguredError, @gemspec.rubyforge_project
|
21
|
+
else
|
22
|
+
raise
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.build_for(jeweler)
|
28
|
+
command = new
|
29
|
+
|
30
|
+
command.gemspec = jeweler.gemspec
|
31
|
+
command.output = jeweler.output
|
32
|
+
command.rubyforge = jeweler.rubyforge
|
33
|
+
|
34
|
+
command
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Jeweler
|
2
|
+
module Commands
|
3
|
+
class ValidateGemspec
|
4
|
+
attr_accessor :gemspec_helper, :output
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
self.output = $stdout
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
begin
|
12
|
+
gemspec_helper.parse
|
13
|
+
output.puts "#{gemspec_helper.path} is valid."
|
14
|
+
rescue Exception => e
|
15
|
+
output.puts "#{gemspec_helper.path} is invalid. See the backtrace for more details."
|
16
|
+
raise
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.build_for(jeweler)
|
21
|
+
command = new
|
22
|
+
|
23
|
+
command.gemspec_helper = jeweler.gemspec_helper
|
24
|
+
command.output = jeweler.output
|
25
|
+
|
26
|
+
command
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class Jeweler
|
2
|
+
module Commands
|
3
|
+
module Version
|
4
|
+
class Base
|
5
|
+
|
6
|
+
attr_accessor :repo, :version_helper, :gemspec, :commit
|
7
|
+
|
8
|
+
def run
|
9
|
+
update_version
|
10
|
+
|
11
|
+
self.version_helper.write
|
12
|
+
self.gemspec.version = self.version_helper.to_s
|
13
|
+
|
14
|
+
commit_version if self.repo && self.commit
|
15
|
+
end
|
16
|
+
|
17
|
+
def update_version
|
18
|
+
raise "Subclasses should implement this"
|
19
|
+
end
|
20
|
+
|
21
|
+
def commit_version
|
22
|
+
if self.repo
|
23
|
+
self.repo.add('VERSION.yml')
|
24
|
+
self.repo.commit("Version bump to #{self.version_helper.to_s}", 'VERSION.yml')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def self.build_for(jeweler)
|
30
|
+
command = new
|
31
|
+
command.repo = jeweler.repo
|
32
|
+
command.version_helper = jeweler.version_helper
|
33
|
+
command.gemspec = jeweler.gemspec
|
34
|
+
command.commit = jeweler.commit
|
35
|
+
|
36
|
+
command
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Jeweler
|
2
|
+
module Commands
|
3
|
+
class WriteGemspec
|
4
|
+
attr_accessor :base_dir, :gemspec, :version, :output, :gemspec_helper, :version_helper
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
self.output = $stdout
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
version_helper.refresh
|
12
|
+
gemspec_helper.spec.version = version_helper.to_s
|
13
|
+
gemspec_helper.spec.date = Time.now
|
14
|
+
|
15
|
+
gemspec_helper.write
|
16
|
+
|
17
|
+
output.puts "Generated: #{gemspec_helper.path}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def gemspec_helper
|
21
|
+
@gemspec_helper ||= GemSpecHelper.new(self.gemspec, self.base_dir)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.build_for(jeweler)
|
25
|
+
command = new
|
26
|
+
|
27
|
+
command.base_dir = jeweler.base_dir
|
28
|
+
command.gemspec = jeweler.gemspec
|
29
|
+
command.version = jeweler.version
|
30
|
+
command.output = jeweler.output
|
31
|
+
command.gemspec_helper = jeweler.gemspec_helper
|
32
|
+
command.version_helper = jeweler.version_helper
|
33
|
+
|
34
|
+
command
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Jeweler
|
2
|
+
# Gemspec related error
|
3
|
+
class GemspecError < StandardError
|
4
|
+
end
|
5
|
+
|
6
|
+
class VersionYmlError < StandardError
|
7
|
+
end
|
8
|
+
|
9
|
+
# Occurs when interacting with RubyForge, and an expected project isn't available on RubyForge.
|
10
|
+
class MissingRubyForgePackageError < StandardError
|
11
|
+
end
|
12
|
+
|
13
|
+
# Occurs when interacting with RubyForge, and 'rubyforge_project' isn't set on the Gem::Specification
|
14
|
+
class NoRubyForgeProjectInGemspecError < StandardError
|
15
|
+
end
|
16
|
+
|
17
|
+
# Occurs when interacting with RubyForge, and the 'rubyforge_project' isn't setup in ~/.rubyforge/autoconfig.yml or it doesn't exist on RubyForge
|
18
|
+
class RubyForgeProjectNotConfiguredError < StandardError
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class Jeweler
|
2
|
+
|
3
|
+
class GemSpecHelper
|
4
|
+
|
5
|
+
attr_accessor :spec, :base_dir
|
6
|
+
|
7
|
+
def initialize(spec, base_dir = nil)
|
8
|
+
self.spec = spec
|
9
|
+
self.base_dir = base_dir || ''
|
10
|
+
|
11
|
+
yield spec if block_given?
|
12
|
+
end
|
13
|
+
|
14
|
+
def valid?
|
15
|
+
begin
|
16
|
+
parse
|
17
|
+
true
|
18
|
+
rescue
|
19
|
+
false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def write
|
24
|
+
File.open(path, 'w') do |f|
|
25
|
+
f.write @spec.to_ruby
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def path
|
30
|
+
denormalized_path = File.join(@base_dir, "#{@spec.name}.gemspec")
|
31
|
+
absolute_path = File.expand_path(denormalized_path)
|
32
|
+
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
33
|
+
end
|
34
|
+
|
35
|
+
def parse
|
36
|
+
data = File.read(path)
|
37
|
+
parsed_gemspec = nil
|
38
|
+
Thread.new { parsed_gemspec = eval("$SAFE = 3\n#{data}", binding, path) }.join
|
39
|
+
parsed_gemspec
|
40
|
+
end
|
41
|
+
|
42
|
+
def gem_path
|
43
|
+
File.join(@base_dir, 'pkg', parse.file_name)
|
44
|
+
end
|
45
|
+
|
46
|
+
def update_version(version)
|
47
|
+
@spec.version = version.to_s
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|