dima-jeweler 0.9.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/ChangeLog.markdown +54 -1
- data/README.markdown +89 -20
- data/ROADMAP +12 -0
- data/Rakefile +52 -12
- data/VERSION.yml +3 -3
- data/features/generator/cucumber.feature +83 -0
- data/features/generator/directory_layout.feature +76 -0
- data/features/generator/dotdocument.feature +14 -0
- data/features/generator/env_options.feature +9 -0
- data/features/generator/git.feature +94 -0
- data/features/generator/license.feature +11 -0
- data/features/generator/rakefile.feature +151 -0
- data/features/generator/readme.feature +12 -0
- data/features/generator/test.feature +41 -0
- data/features/generator/test_helper.feature +49 -0
- data/features/placeholder.feature +5 -0
- data/features/step_definitions/debug_steps.rb +6 -0
- data/features/step_definitions/filesystem_steps.rb +68 -0
- data/features/step_definitions/generator_steps.rb +284 -0
- data/features/step_definitions/task_steps.rb +6 -0
- data/features/support/env.rb +29 -0
- data/features/tasks/build_gem.feature +9 -0
- data/features/tasks/version.feature +24 -0
- data/features/tasks/version_bumping.feature +33 -0
- data/jeweler.gemspec +225 -0
- data/lib/jeweler.rb +39 -52
- data/lib/jeweler/commands.rb +2 -0
- data/lib/jeweler/commands/build_gem.rb +9 -0
- data/lib/jeweler/commands/check_dependencies.rb +52 -0
- data/lib/jeweler/commands/install_gem.rb +23 -2
- data/lib/jeweler/commands/release.rb +52 -12
- data/lib/jeweler/commands/release_to_rubyforge.rb +32 -9
- data/lib/jeweler/commands/setup_rubyforge.rb +57 -0
- data/lib/jeweler/commands/validate_gemspec.rb +9 -0
- data/lib/jeweler/commands/version/base.rb +13 -2
- data/lib/jeweler/commands/write_gemspec.rb +13 -0
- data/lib/jeweler/errors.rb +13 -1
- data/lib/jeweler/gemspec_helper.rb +31 -3
- data/lib/jeweler/generator.rb +80 -120
- data/lib/jeweler/generator/application.rb +12 -3
- data/lib/jeweler/generator/bacon_mixin.rb +43 -0
- data/lib/jeweler/generator/micronaut_mixin.rb +41 -0
- data/lib/jeweler/generator/minitest_mixin.rb +42 -0
- data/lib/jeweler/generator/options.rb +37 -3
- data/lib/jeweler/generator/rdoc_mixin.rb +9 -0
- data/lib/jeweler/generator/rspec_mixin.rb +42 -0
- data/lib/jeweler/generator/shoulda_mixin.rb +42 -0
- data/lib/jeweler/generator/testunit_mixin.rb +39 -0
- data/lib/jeweler/generator/yard_mixin.rb +14 -0
- data/lib/jeweler/rubyforge_tasks.rb +98 -0
- data/lib/jeweler/specification.rb +66 -0
- data/lib/jeweler/tasks.rb +72 -39
- data/lib/jeweler/templates/.document +5 -0
- data/lib/jeweler/templates/README.rdoc +12 -1
- data/lib/jeweler/templates/Rakefile +83 -49
- data/lib/jeweler/templates/bacon/helper.rb +1 -1
- data/lib/jeweler/templates/features/support/env.rb +4 -7
- data/lib/jeweler/templates/micronaut/helper.rb +1 -1
- data/lib/jeweler/templates/minitest/helper.rb +1 -1
- data/lib/jeweler/templates/rspec/flunking.rb +1 -1
- data/lib/jeweler/templates/rspec/helper.rb +4 -3
- data/lib/jeweler/templates/shoulda/helper.rb +1 -1
- data/lib/jeweler/templates/testunit/helper.rb +1 -1
- data/lib/jeweler/version_helper.rb +78 -33
- data/test/fixtures/bar/bin/foo_the_ultimate_bin +1 -0
- data/test/fixtures/bar/hey_include_me_in_gemspec +0 -0
- data/test/fixtures/bar/lib/foo_the_ultimate_lib.rb +1 -0
- data/test/fixtures/existing-project-with-version-plaintext/.document +5 -0
- data/test/fixtures/existing-project-with-version-plaintext/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-plaintext/LICENSE +20 -0
- data/test/fixtures/existing-project-with-version-plaintext/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/Rakefile +82 -0
- data/test/fixtures/existing-project-with-version-plaintext/VERSION +1 -0
- data/test/fixtures/existing-project-with-version-plaintext/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-plaintext/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-plaintext/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/test/test_helper.rb +10 -0
- data/test/fixtures/existing-project-with-version-yaml/.document +5 -0
- data/test/fixtures/existing-project-with-version-yaml/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-yaml/LICENSE +20 -0
- data/test/fixtures/existing-project-with-version-yaml/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-yaml/Rakefile +82 -0
- data/test/fixtures/existing-project-with-version-yaml/VERSION.yml +4 -0
- data/test/fixtures/existing-project-with-version-yaml/bin/foo_the_ultimate_bin +0 -0
- data/test/fixtures/existing-project-with-version-yaml/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-yaml/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-yaml/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-yaml/test/test_helper.rb +10 -0
- data/test/jeweler/commands/test_build_gem.rb +20 -1
- data/test/jeweler/commands/test_install_gem.rb +74 -0
- data/test/jeweler/commands/test_release.rb +289 -77
- data/test/jeweler/commands/test_release_to_rubyforge.rb +66 -50
- data/test/jeweler/commands/test_setup_rubyforge.rb +182 -0
- data/test/jeweler/commands/test_validate_gemspec.rb +27 -0
- data/test/jeweler/commands/test_write_gemspec.rb +34 -0
- data/test/jeweler/commands/version/test_base.rb +32 -0
- data/test/jeweler/commands/version/test_bump_major.rb +1 -0
- data/test/test_application.rb +31 -1
- data/test/test_gemspec_helper.rb +4 -0
- data/test/test_generator.rb +101 -114
- data/test/test_generator_initialization.rb +156 -0
- data/test/test_generator_mixins.rb +18 -0
- data/test/test_helper.rb +104 -16
- data/test/test_jeweler.rb +134 -96
- data/test/test_options.rb +59 -0
- data/test/test_specification.rb +61 -0
- data/test/test_tasks.rb +13 -18
- data/test/test_version_helper.rb +47 -9
- metadata +174 -43
- data/TODO +0 -11
- data/test/generators/initialization_test.rb +0 -146
@@ -0,0 +1,57 @@
|
|
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
|
+
if package_exists?
|
15
|
+
output.puts "#{@gemspec.name} package already exists in the #{@gemspec.rubyforge_project} project"
|
16
|
+
return
|
17
|
+
end
|
18
|
+
|
19
|
+
output.puts "Creating #{@gemspec.name} package in the #{@gemspec.rubyforge_project} project"
|
20
|
+
create_package
|
21
|
+
end
|
22
|
+
|
23
|
+
def package_exists?
|
24
|
+
begin
|
25
|
+
@rubyforge.lookup 'package', @gemspec.name
|
26
|
+
true
|
27
|
+
rescue RuntimeError => e
|
28
|
+
raise unless e.message == "no <package_id> configured for <#{@gemspec.name}>"
|
29
|
+
false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_package
|
34
|
+
begin
|
35
|
+
@rubyforge.create_package(@gemspec.rubyforge_project, @gemspec.name)
|
36
|
+
rescue StandardError => e
|
37
|
+
case e.message
|
38
|
+
when /no <group_id> configured for <#{Regexp.escape @gemspec.rubyforge_project}>/
|
39
|
+
raise RubyForgeProjectNotConfiguredError, @gemspec.rubyforge_project
|
40
|
+
else
|
41
|
+
raise
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.build_for(jeweler)
|
47
|
+
command = new
|
48
|
+
|
49
|
+
command.gemspec = jeweler.gemspec
|
50
|
+
command.output = jeweler.output
|
51
|
+
command.rubyforge = jeweler.rubyforge
|
52
|
+
|
53
|
+
command
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -20,10 +20,21 @@ class Jeweler
|
|
20
20
|
|
21
21
|
def commit_version
|
22
22
|
if self.repo
|
23
|
-
self.repo.add(
|
24
|
-
self.repo.commit("Version bump to #{self.version_helper.to_s}"
|
23
|
+
self.repo.add(version_helper.path)
|
24
|
+
self.repo.commit("Version bump to #{self.version_helper.to_s}")
|
25
25
|
end
|
26
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
|
27
38
|
end
|
28
39
|
end
|
29
40
|
end
|
@@ -21,6 +21,19 @@ class Jeweler
|
|
21
21
|
@gemspec_helper ||= GemSpecHelper.new(self.gemspec, self.base_dir)
|
22
22
|
end
|
23
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
|
+
|
24
37
|
end
|
25
38
|
end
|
26
39
|
end
|
data/lib/jeweler/errors.rb
CHANGED
@@ -5,4 +5,16 @@ class Jeweler
|
|
5
5
|
|
6
6
|
class VersionYmlError < StandardError
|
7
7
|
end
|
8
|
-
|
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
|
@@ -19,10 +19,21 @@ class Jeweler
|
|
19
19
|
false
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def write
|
24
|
+
normalize_files(:files)
|
25
|
+
normalize_files(:files)
|
26
|
+
normalize_files(:extra_rdoc_files)
|
27
|
+
|
24
28
|
File.open(path, 'w') do |f|
|
25
|
-
|
29
|
+
gemspec_ruby = @spec.to_ruby
|
30
|
+
gemspec_ruby = prettyify_array(gemspec_ruby, :files)
|
31
|
+
gemspec_ruby = prettyify_array(gemspec_ruby, :test_files)
|
32
|
+
gemspec_ruby = prettyify_array(gemspec_ruby, :extra_rdoc_files)
|
33
|
+
f.puts "# Generated by jeweler"
|
34
|
+
f.puts "# DO NOT EDIT THIS FILE"
|
35
|
+
f.puts "# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`"
|
36
|
+
f.write gemspec_ruby
|
26
37
|
end
|
27
38
|
end
|
28
39
|
|
@@ -35,10 +46,27 @@ class Jeweler
|
|
35
46
|
def parse
|
36
47
|
data = File.read(path)
|
37
48
|
parsed_gemspec = nil
|
38
|
-
Thread.new { parsed_gemspec = eval("$SAFE = 3\n#{data}", binding, path) }.join
|
49
|
+
Thread.new { parsed_gemspec = eval("$SAFE = 3\n#{data}", binding, path) }.join
|
39
50
|
parsed_gemspec
|
40
51
|
end
|
41
52
|
|
53
|
+
def normalize_files(array_name)
|
54
|
+
array = @spec.send(array_name)
|
55
|
+
# only keep files, no directories, and sort
|
56
|
+
array = array.select do |path|
|
57
|
+
File.file? File.join(@base_dir, path)
|
58
|
+
end.sort
|
59
|
+
|
60
|
+
@spec.send("#{array_name}=", array)
|
61
|
+
end
|
62
|
+
|
63
|
+
def prettyify_array(gemspec_ruby, array_name)
|
64
|
+
gemspec_ruby.gsub(/s\.#{array_name.to_s} = \[.+?\]/) do |match|
|
65
|
+
leadin, files = match[0..-2].split("[")
|
66
|
+
leadin + "[\n #{files.split(",").join(",\n ")}\n ]"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
42
70
|
def gem_path
|
43
71
|
File.join(@base_dir, 'pkg', parse.file_name)
|
44
72
|
end
|
data/lib/jeweler/generator.rb
CHANGED
@@ -4,6 +4,16 @@ require 'erb'
|
|
4
4
|
require 'net/http'
|
5
5
|
require 'uri'
|
6
6
|
|
7
|
+
require 'jeweler/generator/bacon_mixin'
|
8
|
+
require 'jeweler/generator/micronaut_mixin'
|
9
|
+
require 'jeweler/generator/minitest_mixin'
|
10
|
+
require 'jeweler/generator/rspec_mixin'
|
11
|
+
require 'jeweler/generator/shoulda_mixin'
|
12
|
+
require 'jeweler/generator/testunit_mixin'
|
13
|
+
|
14
|
+
require 'jeweler/generator/rdoc_mixin'
|
15
|
+
require 'jeweler/generator/yard_mixin'
|
16
|
+
|
7
17
|
class Jeweler
|
8
18
|
class NoGitUserName < StandardError
|
9
19
|
end
|
@@ -21,29 +31,56 @@ class Jeweler
|
|
21
31
|
end
|
22
32
|
|
23
33
|
class Generator
|
24
|
-
attr_accessor :target_dir, :user_name, :user_email, :summary,
|
25
|
-
:
|
26
|
-
:repo, :should_create_repo,
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
34
|
+
attr_accessor :target_dir, :user_name, :user_email, :summary,
|
35
|
+
:description, :project_name, :github_username, :github_token,
|
36
|
+
:repo, :should_create_repo,
|
37
|
+
:testing_framework, :documentation_framework,
|
38
|
+
:should_use_cucumber, :should_setup_rubyforge,
|
39
|
+
:should_use_reek, :should_use_roodi,
|
40
|
+
:development_dependencies
|
41
|
+
|
42
|
+
DEFAULT_TESTING_FRAMEWORK = :shoulda
|
43
|
+
DEFAULT_DOCUMENTATION_FRAMEWORK = :rdoc
|
44
|
+
|
45
|
+
def initialize(project_name, options = {})
|
46
|
+
if project_name.nil? || project_name.squeeze.strip == ""
|
32
47
|
raise NoGitHubRepoNameGiven
|
33
48
|
end
|
34
49
|
|
35
|
-
self.
|
50
|
+
self.development_dependencies = []
|
51
|
+
|
52
|
+
self.project_name = project_name
|
36
53
|
|
37
|
-
self.testing_framework = (options[:testing_framework] ||
|
38
|
-
|
54
|
+
self.testing_framework = (options[:testing_framework] || DEFAULT_TESTING_FRAMEWORK).to_sym
|
55
|
+
self.documentation_framework = options[:documentation_framework] || DEFAULT_DOCUMENTATION_FRAMEWORK
|
56
|
+
begin
|
57
|
+
generator_mixin_name = "#{self.testing_framework.to_s.capitalize}Mixin"
|
58
|
+
generator_mixin = self.class.const_get(generator_mixin_name)
|
59
|
+
extend generator_mixin
|
60
|
+
rescue NameError => e
|
39
61
|
raise ArgumentError, "Unsupported testing framework (#{testing_framework})"
|
40
62
|
end
|
41
63
|
|
42
|
-
|
64
|
+
begin
|
65
|
+
generator_mixin_name = "#{self.documentation_framework.to_s.capitalize}Mixin"
|
66
|
+
generator_mixin = self.class.const_get(generator_mixin_name)
|
67
|
+
extend generator_mixin
|
68
|
+
rescue NameError => e
|
69
|
+
raise ArgumentError, "Unsupported documentation framework (#{documentation_framework})"
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
self.target_dir = options[:directory] || self.project_name
|
74
|
+
|
75
|
+
self.should_create_repo = options[:create_repo]
|
76
|
+
self.summary = options[:summary] || 'TODO: one-line summary of your gem'
|
77
|
+
self.description = options[:description] || 'TODO: longer description of your gem'
|
78
|
+
self.should_use_cucumber = options[:use_cucumber]
|
79
|
+
self.should_use_reek = options[:use_reek]
|
80
|
+
self.should_use_roodi = options[:use_roodi]
|
81
|
+
self.should_setup_rubyforge = options[:rubyforge]
|
43
82
|
|
44
|
-
|
45
|
-
self.summary = options[:summary] || 'TODO'
|
46
|
-
self.should_use_cucumber= options[:use_cucumber]
|
83
|
+
development_dependencies << "cucumber" if should_use_cucumber
|
47
84
|
|
48
85
|
use_user_git_config
|
49
86
|
|
@@ -52,112 +89,49 @@ class Jeweler
|
|
52
89
|
def run
|
53
90
|
create_files
|
54
91
|
gitify
|
55
|
-
$stdout.puts "Jeweler has prepared your gem in #{
|
92
|
+
$stdout.puts "Jeweler has prepared your gem in #{target_dir}"
|
56
93
|
if should_create_repo
|
57
94
|
create_and_push_repo
|
58
|
-
$stdout.puts "Jeweler has pushed your repo to #{
|
95
|
+
$stdout.puts "Jeweler has pushed your repo to #{project_homepage}"
|
59
96
|
enable_gem_for_repo
|
60
97
|
$stdout.puts "Jeweler has enabled gem building for your repo"
|
61
98
|
end
|
62
99
|
end
|
63
100
|
|
64
|
-
|
65
|
-
|
66
|
-
test_or_spec
|
101
|
+
def git_remote
|
102
|
+
"git@github.com:#{github_username}/#{project_name}.git"
|
67
103
|
end
|
68
104
|
|
69
|
-
|
70
|
-
|
71
|
-
case testing_framework.to_sym
|
72
|
-
when :shoulda, :testunit, :minitest
|
73
|
-
'test'
|
74
|
-
when :bacon, :rspec
|
75
|
-
'spec'
|
76
|
-
when :micronaut
|
77
|
-
'examples'
|
78
|
-
else
|
79
|
-
raise ArgumentError, "Don't know default task for #{testing_framework}"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def feature_support_require
|
84
|
-
case testing_framework.to_sym
|
85
|
-
when :testunit, :shoulda, :bacon # NOTE bacon doesn't really work inside of cucumber
|
86
|
-
'test/unit/assertions'
|
87
|
-
when :minitest
|
88
|
-
'mini/test'
|
89
|
-
when :rspec
|
90
|
-
'spec/expectations'
|
91
|
-
when :micronaut
|
92
|
-
'micronaut/expectations'
|
93
|
-
else
|
94
|
-
raise "Don't know what to require for #{testing_framework}"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def feature_support_extend
|
99
|
-
case testing_framework.to_sym
|
100
|
-
when :testunit, :shoulda, :bacon # NOTE bacon doesn't really work inside of cucumber
|
101
|
-
'Test::Unit::Assertions'
|
102
|
-
when :minitest
|
103
|
-
'Mini::Test::Assertions'
|
104
|
-
when :rspec
|
105
|
-
nil
|
106
|
-
when :micronaut
|
107
|
-
'Micronaut::Matchers'
|
108
|
-
else
|
109
|
-
raise "Don't know what to extend for #{testing_framework}"
|
110
|
-
end
|
105
|
+
def project_homepage
|
106
|
+
"http://github.com/#{github_username}/#{project_name}"
|
111
107
|
end
|
112
|
-
|
113
|
-
def
|
114
|
-
|
108
|
+
|
109
|
+
def constant_name
|
110
|
+
self.project_name.split(/[-_]/).collect{|each| each.capitalize }.join
|
115
111
|
end
|
116
112
|
|
117
|
-
def
|
118
|
-
"
|
113
|
+
def lib_filename
|
114
|
+
"#{project_name}.rb"
|
119
115
|
end
|
120
116
|
|
121
|
-
|
122
|
-
|
123
|
-
self.github_repo_name.split(/[-_]/).collect{|each| each.capitalize }.join
|
117
|
+
def require_name
|
118
|
+
self.project_name
|
124
119
|
end
|
125
120
|
|
126
121
|
def file_name_prefix
|
127
|
-
self.
|
122
|
+
self.project_name.gsub('-', '_')
|
128
123
|
end
|
129
124
|
|
130
125
|
def lib_dir
|
131
126
|
'lib'
|
132
127
|
end
|
133
128
|
|
134
|
-
def test_dir
|
135
|
-
case testing_framework.to_sym
|
136
|
-
when :shoulda, :testunit, :minitest
|
137
|
-
'test'
|
138
|
-
when :bacon, :rspec
|
139
|
-
'spec'
|
140
|
-
when :micronaut
|
141
|
-
'examples'
|
142
|
-
else
|
143
|
-
raise ArgumentError, "Don't know test dir for #{testing_framework.inspect}"
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_filename
|
148
|
-
"#{file_name_prefix}_#{test_or_spec}.rb"
|
149
|
-
end
|
150
|
-
|
151
|
-
def test_helper_filename
|
152
|
-
"#{test_or_spec}_helper.rb"
|
153
|
-
end
|
154
|
-
|
155
129
|
def feature_filename
|
156
|
-
"#{
|
130
|
+
"#{project_name}.feature"
|
157
131
|
end
|
158
132
|
|
159
133
|
def steps_filename
|
160
|
-
"#{
|
134
|
+
"#{project_name}_steps.rb"
|
161
135
|
end
|
162
136
|
|
163
137
|
def features_dir
|
@@ -172,28 +146,11 @@ class Jeweler
|
|
172
146
|
File.join(features_dir, 'step_definitions')
|
173
147
|
end
|
174
148
|
|
175
|
-
def test_or_spec
|
176
|
-
case testing_framework.to_sym
|
177
|
-
when :shoulda, :testunit, :minitest
|
178
|
-
'test'
|
179
|
-
when :bacon, :rspec
|
180
|
-
'spec'
|
181
|
-
when :micronaut
|
182
|
-
'example'
|
183
|
-
else
|
184
|
-
raise ArgumentError, "Unknown test style: #{testing_framework}"
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
|
189
149
|
protected
|
190
150
|
|
191
151
|
# This is in a separate method so we can stub it out during testing
|
192
152
|
def read_git_config
|
193
|
-
|
194
|
-
# ... which we don't have yet, since this is part of a sanity check
|
195
|
-
lib = Git::Lib.new(nil, nil)
|
196
|
-
config = lib.parse_config '~/.gitconfig'
|
153
|
+
Git.global_config
|
197
154
|
end
|
198
155
|
|
199
156
|
private
|
@@ -209,9 +166,10 @@ class Jeweler
|
|
209
166
|
output_template_in_target 'Rakefile'
|
210
167
|
output_template_in_target 'LICENSE'
|
211
168
|
output_template_in_target 'README.rdoc'
|
169
|
+
output_template_in_target '.document'
|
212
170
|
|
213
171
|
mkdir_in_target lib_dir
|
214
|
-
touch_in_target File.join(lib_dir,
|
172
|
+
touch_in_target File.join(lib_dir, lib_filename)
|
215
173
|
|
216
174
|
mkdir_in_target test_dir
|
217
175
|
output_template_in_target File.join(testing_framework.to_s, 'helper.rb'), File.join(test_dir, test_helper_filename)
|
@@ -245,8 +203,10 @@ class Jeweler
|
|
245
203
|
raise NoGitHubUser
|
246
204
|
end
|
247
205
|
|
248
|
-
|
249
|
-
|
206
|
+
if should_create_repo
|
207
|
+
unless git_config.has_key? 'github.token'
|
208
|
+
raise NoGitHubToken
|
209
|
+
end
|
250
210
|
end
|
251
211
|
|
252
212
|
self.user_name = git_config['user.name']
|
@@ -261,7 +221,7 @@ class Jeweler
|
|
261
221
|
template_contents = File.read(File.join(template_dir, source))
|
262
222
|
template = ERB.new(template_contents, nil, '<>')
|
263
223
|
|
264
|
-
template_result = template.result(binding)
|
224
|
+
template_result = template.result(binding).gsub(/\n\n\n+/, "\n\n")
|
265
225
|
|
266
226
|
File.open(final_destination, 'w') {|file| file.write(template_result)}
|
267
227
|
|
@@ -304,13 +264,13 @@ class Jeweler
|
|
304
264
|
end
|
305
265
|
|
306
266
|
begin
|
307
|
-
@repo.commit "Initial commit to #{
|
267
|
+
@repo.commit "Initial commit to #{project_name}."
|
308
268
|
rescue Git::GitExecuteError => e
|
309
269
|
raise
|
310
270
|
end
|
311
271
|
|
312
272
|
begin
|
313
|
-
@repo.add_remote('origin',
|
273
|
+
@repo.add_remote('origin', git_remote)
|
314
274
|
rescue Git::GitExecuteError => e
|
315
275
|
puts "Encountered an error while adding origin remote. Maybe you have some weird settings in ~/.gitconfig?"
|
316
276
|
raise
|
@@ -325,13 +285,13 @@ class Jeweler
|
|
325
285
|
'login' => github_username,
|
326
286
|
'token' => github_token,
|
327
287
|
'repository[description]' => summary,
|
328
|
-
'repository[name]' =>
|
288
|
+
'repository[name]' => project_name
|
329
289
|
# TODO do a HEAD request to see when it's ready
|
330
290
|
@repo.push('origin')
|
331
291
|
end
|
332
292
|
|
333
293
|
def enable_gem_for_repo
|
334
|
-
url = "https://github.com/#{github_username}/#{
|
294
|
+
url = "https://github.com/#{github_username}/#{project_name}/update"
|
335
295
|
`curl -F 'login=#{github_username}' -F 'token=#{github_token}' -F 'field=repository_rubygem' -F 'value=1' #{url} 2>/dev/null`
|
336
296
|
# FIXME use NET::HTTP instead of curl
|
337
297
|
#Net::HTTP.post_form URI.parse(url),
|