namelessjon-jeweler 0.5.1 → 0.6.1
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.markdown +5 -4
- data/Rakefile +1 -1
- data/VERSION.yml +1 -1
- data/bin/jeweler +16 -7
- data/lib/jeweler/generator.rb +46 -21
- data/lib/jeweler/release.rb +4 -1
- data/test/jeweler_generator_test.rb +4 -4
- data/test/jeweler_test.rb +1 -38
- data/test/shoulda_macros/jeweler_macros.rb +38 -0
- data/test/test_helper.rb +7 -3
- metadata +13 -11
data/README.markdown
CHANGED
@@ -75,14 +75,15 @@ Here's a rundown of what's happening:
|
|
75
75
|
|
76
76
|
## Bootstrap a new project
|
77
77
|
|
78
|
-
Before proceeding, take a minute to setup your git environment, specifically your name and
|
78
|
+
Before proceeding, take a minute to setup your git environment, specifically your name, email address, and GitHub username
|
79
79
|
|
80
80
|
$ git config --global user.email johndoe@example.com
|
81
81
|
$ git config --global user.name 'John Doe'
|
82
|
+
$ git config --global github.user johndoe
|
82
83
|
|
83
|
-
Jeweler provides a generator of sorts, `jeweler`. It takes
|
84
|
+
Jeweler provides a generator of sorts, `jeweler`. It requires only argument, the name of a repo you want to create. It also takes a few options: --[shoulda](http://github.com/thoughtbot/shoulda) and --[bacon](http://github.com/chneukirchen/bacon/tree/master). These control what type of tests are created, with the default being shoulda.
|
84
85
|
|
85
|
-
$ jeweler
|
86
|
+
$ jeweler the-perfect-gem
|
86
87
|
|
87
88
|
Basically, this does:
|
88
89
|
|
@@ -96,7 +97,7 @@ Basically, this does:
|
|
96
97
|
* `test/the_perfect_gem.rb`, placeholder failing test
|
97
98
|
* `lib/the_perfect_gem.rb`, placeholder library file
|
98
99
|
* Makes it a git repo
|
99
|
-
* Sets up `git@github.com:
|
100
|
+
* Sets up `git@github.com:johndoe/jeweler.git` as the `origin` git remote
|
100
101
|
* Makes an initial commit, but does not push
|
101
102
|
|
102
103
|
At this point, you probably should create a repository by wandering to [http://github.com/repositories/new](http://github.com/repositories/new). Be sure to use the same project name you told Jeweler.
|
data/Rakefile
CHANGED
data/VERSION.yml
CHANGED
data/bin/jeweler
CHANGED
@@ -7,31 +7,40 @@ require 'jeweler'
|
|
7
7
|
|
8
8
|
class JewelerOpts < Hash
|
9
9
|
attr_reader :opts
|
10
|
+
|
10
11
|
def initialize(args)
|
11
12
|
super()
|
12
|
-
|
13
|
+
|
14
|
+
self[:test_style] = :shoulda
|
15
|
+
|
13
16
|
@opts = OptionParser.new do |o|
|
14
17
|
o.banner = "Usage: #{File.basename($0)} [options] reponame\ne.g. #{File.basename($0)} the-perfect-gem"
|
15
|
-
|
16
|
-
|
18
|
+
|
19
|
+
o.on('--bacon', 'generate bacon specs') do
|
20
|
+
self[:test_style] = :bacon
|
17
21
|
end
|
22
|
+
|
23
|
+
o.on('--shoulda', 'generate shoulda tests') do
|
24
|
+
self[:test_style] = :shoulda
|
25
|
+
end
|
26
|
+
|
18
27
|
o.on_tail('-h', '--help', 'display this help and exit') do
|
19
28
|
puts o
|
20
29
|
exit
|
21
30
|
end
|
22
31
|
end
|
32
|
+
|
23
33
|
@opts.parse!(args)
|
24
34
|
end
|
25
35
|
end
|
26
36
|
|
27
|
-
|
37
|
+
options = JewelerOpts.new(ARGV)
|
28
38
|
|
29
39
|
unless ARGV.size == 1
|
30
|
-
puts
|
40
|
+
puts options.opts
|
31
41
|
exit 1
|
32
42
|
end
|
33
43
|
|
34
44
|
github_repo_name = ARGV.first
|
35
|
-
generator = Jeweler::Generator.new github_repo_name
|
36
|
-
generator.spec = o[:spec]
|
45
|
+
generator = Jeweler::Generator.new github_repo_name, options
|
37
46
|
generator.run
|
data/lib/jeweler/generator.rb
CHANGED
@@ -12,15 +12,18 @@ class Jeweler
|
|
12
12
|
end
|
13
13
|
class NoGitHubUser < StandardError
|
14
14
|
end
|
15
|
+
class GitInitFailed < StandardError
|
16
|
+
end
|
17
|
+
|
15
18
|
|
16
19
|
class Generator
|
17
20
|
attr_accessor :target_dir, :user_name, :user_email,
|
18
21
|
:github_repo_name, :github_remote, :github_url, :github_username,
|
19
|
-
:lib_dir, :constant_name, :file_name_prefix, :config, :
|
22
|
+
:lib_dir, :constant_name, :file_name_prefix, :config, :test_style
|
20
23
|
|
21
|
-
def initialize(github_repo_name,
|
24
|
+
def initialize(github_repo_name, options = {})
|
22
25
|
check_user_git_config()
|
23
|
-
|
26
|
+
|
24
27
|
if github_repo_name.nil?
|
25
28
|
raise NoGitHubRepoNameGiven
|
26
29
|
end
|
@@ -29,8 +32,8 @@ class Jeweler
|
|
29
32
|
self.github_remote = "git@github.com:#{github_username}/#{github_repo_name}.git"
|
30
33
|
self.github_url = "http://github.com/#{github_username}/#{github_repo_name}"
|
31
34
|
|
32
|
-
|
33
|
-
self.target_dir =
|
35
|
+
self.test_style = options[:test_style] || :shoulda
|
36
|
+
self.target_dir = options[:directory] || self.github_repo_name
|
34
37
|
self.lib_dir = File.join(target_dir, 'lib')
|
35
38
|
self.constant_name = self.github_repo_name.split(/[-_]/).collect{|each| each.capitalize }.join
|
36
39
|
self.file_name_prefix = self.github_repo_name.gsub('-', '_')
|
@@ -42,10 +45,11 @@ class Jeweler
|
|
42
45
|
end
|
43
46
|
|
44
47
|
def testspec
|
45
|
-
|
46
|
-
|
47
|
-
else
|
48
|
+
case test_style
|
49
|
+
when :shoulda
|
48
50
|
'test'
|
51
|
+
when :bacon
|
52
|
+
'spec'
|
49
53
|
end
|
50
54
|
end
|
51
55
|
|
@@ -56,11 +60,10 @@ class Jeweler
|
|
56
60
|
|
57
61
|
private
|
58
62
|
def create_files
|
59
|
-
|
63
|
+
unless File.exists?(target_dir) || File.directory?(target_dir)
|
60
64
|
FileUtils.mkdir target_dir
|
61
|
-
|
62
|
-
|
63
|
-
exit 1
|
65
|
+
else
|
66
|
+
raise FileInTheWay, "The directory #{target_dir} already exists, aborting. Maybe move it out of the way before continuing?"
|
64
67
|
end
|
65
68
|
|
66
69
|
FileUtils.mkdir lib_dir
|
@@ -78,12 +81,15 @@ class Jeweler
|
|
78
81
|
|
79
82
|
def check_user_git_config
|
80
83
|
self.config = read_git_config
|
84
|
+
|
81
85
|
unless config.has_key? 'user.name'
|
82
86
|
raise NoGitUserName, %Q{No user.name set in ~/.gitconfig. Set it with: git config --global user.name 'Your Name Here'}
|
83
87
|
end
|
88
|
+
|
84
89
|
unless config.has_key? 'user.email'
|
85
90
|
raise NoGitUserEmail, %Q{No user.name set in ~/.gitconfig. Set it with: git config --global user.name 'Your Name Here'}
|
86
91
|
end
|
92
|
+
|
87
93
|
unless config.has_key? 'github.user'
|
88
94
|
raise NoGitHubUser, %Q{No github.user set in ~/.gitconfig. Set it with: git config --global github.user 'Your username here'}
|
89
95
|
end
|
@@ -95,6 +101,7 @@ class Jeweler
|
|
95
101
|
|
96
102
|
def output_template_in_target(source, destination = source)
|
97
103
|
template = ERB.new(File.read(File.join(File.dirname(__FILE__), 'templates', source)))
|
104
|
+
|
98
105
|
File.open(File.join(target_dir, destination), 'w') {|file| file.write(template.result(binding))}
|
99
106
|
end
|
100
107
|
|
@@ -102,16 +109,34 @@ class Jeweler
|
|
102
109
|
saved_pwd = Dir.pwd
|
103
110
|
Dir.chdir(target_dir)
|
104
111
|
begin
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
112
|
+
begin
|
113
|
+
repo = Git.init()
|
114
|
+
rescue Git::GitExecuteError => e
|
115
|
+
raise GitInitFailed, "Encountered an error during gitification. Maybe the repo already exists, or has already been pushed to?"
|
116
|
+
end
|
117
|
+
|
118
|
+
begin
|
119
|
+
repo.add('.')
|
120
|
+
rescue Git::GitExecuteError => e
|
121
|
+
#raise GitAddFailed, "There was some problem adding this directory to the git changeset"
|
122
|
+
raise
|
123
|
+
end
|
124
|
+
|
125
|
+
begin
|
126
|
+
repo.commit "Initial commit to #{github_repo_name}."
|
127
|
+
rescue Git::GitExecuteError => e
|
128
|
+
raise
|
129
|
+
end
|
130
|
+
|
131
|
+
begin
|
132
|
+
repo.add_remote('origin', github_remote)
|
133
|
+
rescue Git::GitExecuteError => e
|
134
|
+
puts "Encountered an error while adding origin remote. Maybe you have some weird settings in ~/.gitconfig?"
|
135
|
+
raise
|
136
|
+
end
|
137
|
+
ensure
|
138
|
+
Dir.chdir(saved_pwd)
|
113
139
|
end
|
114
|
-
Dir.chdir(saved_pwd)
|
115
140
|
end
|
116
141
|
|
117
142
|
def read_git_config
|
data/lib/jeweler/release.rb
CHANGED
@@ -22,7 +22,10 @@ class Jeweler
|
|
22
22
|
|
23
23
|
protected
|
24
24
|
def any_pending_changes?
|
25
|
-
|
25
|
+
unless ENV['JEWELER_DEBUG'].nil? || ENV['JEWELER_DEBUG'].squeeze == ''
|
26
|
+
require 'ruby-debug'; breakpoint
|
27
|
+
end
|
28
|
+
!(@repo.status.added.empty? && @repo.status.deleted.empty? && @repo.status.changed.empty?)
|
26
29
|
end
|
27
30
|
end
|
28
31
|
end
|
@@ -27,7 +27,7 @@ class JewelerTest < Test::Unit::TestCase
|
|
27
27
|
|
28
28
|
context "given a nil github repo name" do
|
29
29
|
setup do
|
30
|
-
@block = lambda { Jeweler::Generator.new(nil
|
30
|
+
@block = lambda { Jeweler::Generator.new(nil) }
|
31
31
|
end
|
32
32
|
|
33
33
|
should "raise an error" do
|
@@ -163,7 +163,7 @@ class JewelerTest < Test::Unit::TestCase
|
|
163
163
|
|
164
164
|
context "for technicalpickles's the-perfect-gem repo and working directory 'tmp'" do
|
165
165
|
setup do
|
166
|
-
@generator = Jeweler::Generator.new('the-perfect-gem', @tmp_dir)
|
166
|
+
@generator = Jeweler::Generator.new('the-perfect-gem', :directory => @tmp_dir)
|
167
167
|
end
|
168
168
|
|
169
169
|
should "use tmp for target directory" do
|
@@ -307,9 +307,9 @@ class JewelerTest < Test::Unit::TestCase
|
|
307
307
|
end
|
308
308
|
end
|
309
309
|
|
310
|
-
context "running
|
310
|
+
context "running bacon" do
|
311
311
|
setup do
|
312
|
-
@generator.
|
312
|
+
@generator.test_style = :bacon
|
313
313
|
@generator.run
|
314
314
|
end
|
315
315
|
|
data/test/jeweler_test.rb
CHANGED
@@ -5,6 +5,7 @@ class JewelerTest < Test::Unit::TestCase
|
|
5
5
|
def setup
|
6
6
|
@now = Time.now
|
7
7
|
Time.stubs(:now).returns(@now)
|
8
|
+
FileUtils.rm_rf("#{File.dirname(__FILE__)}/tmp")
|
8
9
|
end
|
9
10
|
|
10
11
|
def teardown
|
@@ -23,43 +24,6 @@ class JewelerTest < Test::Unit::TestCase
|
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
|
-
class << self
|
27
|
-
def should_have_major_version(version)
|
28
|
-
should "have major version of #{version}" do
|
29
|
-
assert_equal version, @jeweler.major_version
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def should_have_minor_version(version)
|
34
|
-
should "have minor version of #{version}" do
|
35
|
-
assert_equal version, @jeweler.minor_version
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def should_have_patch_version(version)
|
40
|
-
should "have patch version of #{version}" do
|
41
|
-
assert_equal version, @jeweler.patch_version
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def should_be_version(version)
|
46
|
-
should "be version #{version}" do
|
47
|
-
assert_equal version, @jeweler.version
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def should_bump_version(major, minor, patch)
|
52
|
-
version = "#{major}.#{minor}.#{patch}"
|
53
|
-
should_have_major_version major
|
54
|
-
should_have_minor_version minor
|
55
|
-
should_have_patch_version patch
|
56
|
-
should_be_version version
|
57
|
-
should "output the new version, #{version}" do
|
58
|
-
assert_match version, @output
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
27
|
context "A jeweler without a VERSION.yml" do
|
64
28
|
setup do
|
65
29
|
FileUtils.mkdir_p(tmp_dir)
|
@@ -124,7 +88,6 @@ class JewelerTest < Test::Unit::TestCase
|
|
124
88
|
assert_match 'bar.gemspec', @output
|
125
89
|
end
|
126
90
|
|
127
|
-
|
128
91
|
context "re-reading the gemspec" do
|
129
92
|
setup do
|
130
93
|
gemspec_path = File.join(tmp_dir, 'bar.gemspec')
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class Test::Unit::TestCase
|
2
|
+
class << self
|
3
|
+
def should_have_major_version(version)
|
4
|
+
should "have major version of #{version}" do
|
5
|
+
assert_equal version, @jeweler.major_version
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def should_have_minor_version(version)
|
10
|
+
should "have minor version of #{version}" do
|
11
|
+
assert_equal version, @jeweler.minor_version
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def should_have_patch_version(version)
|
16
|
+
should "have patch version of #{version}" do
|
17
|
+
assert_equal version, @jeweler.patch_version
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def should_be_version(version)
|
22
|
+
should "be version #{version}" do
|
23
|
+
assert_equal version, @jeweler.version
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def should_bump_version(major, minor, patch)
|
28
|
+
version = "#{major}.#{minor}.#{patch}"
|
29
|
+
should_have_major_version major
|
30
|
+
should_have_minor_version minor
|
31
|
+
should_have_patch_version patch
|
32
|
+
should_be_version version
|
33
|
+
should "output the new version, #{version}" do
|
34
|
+
assert_match version, @output
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -8,14 +8,16 @@ require 'ruby-debug'
|
|
8
8
|
gem 'mocha'
|
9
9
|
require 'mocha'
|
10
10
|
|
11
|
+
require File.dirname(__FILE__) + '/shoulda_macros/jeweler_macros'
|
12
|
+
|
11
13
|
# Use vendored gem because of limited gem availability on runcoderun
|
12
14
|
# This is loosely based on 'vendor everything'.
|
13
15
|
Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', '**')].each do |dir|
|
14
16
|
lib = "#{dir}/lib"
|
15
17
|
$LOAD_PATH.unshift(lib) if File.directory?(lib)
|
16
18
|
end
|
17
|
-
require 'output_catcher'
|
18
19
|
|
20
|
+
require 'output_catcher'
|
19
21
|
require 'time'
|
20
22
|
|
21
23
|
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
@@ -28,8 +30,10 @@ class FileList
|
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
31
|
-
|
33
|
+
TMP_DIR = File.join(File.dirname(__FILE__), 'tmp')
|
34
|
+
FileUtils.rm_f(TMP_DIR) # GAH, dirty hax. Somewhere isn't tearing up correctly, so do some cleanup first
|
32
35
|
|
36
|
+
class Test::Unit::TestCase
|
33
37
|
def catch_out(&block)
|
34
38
|
OutputCatcher.catch_out do
|
35
39
|
block.call
|
@@ -43,4 +47,4 @@ class Test::Unit::TestCase
|
|
43
47
|
def tmp_dir
|
44
48
|
File.join(File.dirname(__FILE__), 'tmp')
|
45
49
|
end
|
46
|
-
end
|
50
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: namelessjon-jeweler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Nichols
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-11-
|
12
|
+
date: 2008-11-18 00:00:00 -08:00
|
13
13
|
default_executable: jeweler
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -30,36 +30,38 @@ extensions: []
|
|
30
30
|
extra_rdoc_files: []
|
31
31
|
|
32
32
|
files:
|
33
|
-
- README.markdown
|
34
33
|
- Rakefile
|
34
|
+
- README.markdown
|
35
35
|
- TODO
|
36
36
|
- VERSION.yml
|
37
37
|
- bin/jeweler
|
38
|
-
- lib/jeweler.rb
|
39
38
|
- lib/jeweler
|
40
39
|
- lib/jeweler/bumping.rb
|
41
40
|
- lib/jeweler/errors.rb
|
42
41
|
- lib/jeweler/gemspec.rb
|
42
|
+
- lib/jeweler/generator.rb
|
43
43
|
- lib/jeweler/release.rb
|
44
|
+
- lib/jeweler/tasks.rb
|
44
45
|
- lib/jeweler/templates
|
45
46
|
- lib/jeweler/templates/LICENSE
|
47
|
+
- lib/jeweler/templates/Rakefile
|
46
48
|
- lib/jeweler/templates/README
|
49
|
+
- lib/jeweler/templates/spec
|
50
|
+
- lib/jeweler/templates/spec/flunking_spec.rb
|
51
|
+
- lib/jeweler/templates/spec/spec_helper.rb
|
47
52
|
- lib/jeweler/templates/test
|
48
53
|
- lib/jeweler/templates/test/flunking_test.rb
|
49
54
|
- lib/jeweler/templates/test/test_helper.rb
|
50
|
-
- lib/jeweler/templates/spec
|
51
|
-
- lib/jeweler/templates/spec/spec_helper.rb
|
52
|
-
- lib/jeweler/templates/spec/flunking_spec.rb
|
53
|
-
- lib/jeweler/templates/Rakefile
|
54
55
|
- lib/jeweler/versioning.rb
|
55
|
-
- lib/jeweler
|
56
|
-
- lib/jeweler/tasks.rb
|
56
|
+
- lib/jeweler.rb
|
57
57
|
- test/fixtures
|
58
58
|
- test/fixtures/bar
|
59
59
|
- test/fixtures/bar/VERSION.yml
|
60
|
+
- test/jeweler_generator_test.rb
|
60
61
|
- test/jeweler_test.rb
|
62
|
+
- test/shoulda_macros
|
63
|
+
- test/shoulda_macros/jeweler_macros.rb
|
61
64
|
- test/test_helper.rb
|
62
|
-
- test/jeweler_generator_test.rb
|
63
65
|
- lib/jeweler/templates/.gitignore
|
64
66
|
has_rdoc: false
|
65
67
|
homepage: http://github.com/technicalpickles/jeweler
|