dima-jeweler 0.9.2

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.
Files changed (67) hide show
  1. data/ChangeLog.markdown +58 -0
  2. data/LICENSE +20 -0
  3. data/README.markdown +103 -0
  4. data/Rakefile +61 -0
  5. data/TODO +11 -0
  6. data/VERSION.yml +4 -0
  7. data/bin/jeweler +8 -0
  8. data/lib/jeweler.rb +161 -0
  9. data/lib/jeweler/commands.rb +11 -0
  10. data/lib/jeweler/commands/build_gem.rb +22 -0
  11. data/lib/jeweler/commands/install_gem.rb +19 -0
  12. data/lib/jeweler/commands/release.rb +46 -0
  13. data/lib/jeweler/commands/release_to_rubyforge.rb +28 -0
  14. data/lib/jeweler/commands/validate_gemspec.rb +21 -0
  15. data/lib/jeweler/commands/version/base.rb +30 -0
  16. data/lib/jeweler/commands/version/bump_major.rb +13 -0
  17. data/lib/jeweler/commands/version/bump_minor.rb +12 -0
  18. data/lib/jeweler/commands/version/bump_patch.rb +14 -0
  19. data/lib/jeweler/commands/version/write.rb +12 -0
  20. data/lib/jeweler/commands/write_gemspec.rb +26 -0
  21. data/lib/jeweler/errors.rb +8 -0
  22. data/lib/jeweler/gemspec_helper.rb +51 -0
  23. data/lib/jeweler/generator.rb +345 -0
  24. data/lib/jeweler/generator/application.rb +45 -0
  25. data/lib/jeweler/generator/options.rb +64 -0
  26. data/lib/jeweler/tasks.rb +102 -0
  27. data/lib/jeweler/templates/.gitignore +5 -0
  28. data/lib/jeweler/templates/LICENSE +20 -0
  29. data/lib/jeweler/templates/README.rdoc +7 -0
  30. data/lib/jeweler/templates/Rakefile +116 -0
  31. data/lib/jeweler/templates/bacon/flunking.rb +7 -0
  32. data/lib/jeweler/templates/bacon/helper.rb +8 -0
  33. data/lib/jeweler/templates/features/default.feature +9 -0
  34. data/lib/jeweler/templates/features/support/env.rb +11 -0
  35. data/lib/jeweler/templates/micronaut/flunking.rb +7 -0
  36. data/lib/jeweler/templates/micronaut/helper.rb +17 -0
  37. data/lib/jeweler/templates/minitest/flunking.rb +7 -0
  38. data/lib/jeweler/templates/minitest/helper.rb +11 -0
  39. data/lib/jeweler/templates/rspec/flunking.rb +7 -0
  40. data/lib/jeweler/templates/rspec/helper.rb +9 -0
  41. data/lib/jeweler/templates/shoulda/flunking.rb +7 -0
  42. data/lib/jeweler/templates/shoulda/helper.rb +10 -0
  43. data/lib/jeweler/templates/testunit/flunking.rb +7 -0
  44. data/lib/jeweler/templates/testunit/helper.rb +9 -0
  45. data/lib/jeweler/version_helper.rb +83 -0
  46. data/test/fixtures/bar/VERSION.yml +4 -0
  47. data/test/geminstaller.yml +12 -0
  48. data/test/generators/initialization_test.rb +146 -0
  49. data/test/jeweler/commands/test_build_gem.rb +53 -0
  50. data/test/jeweler/commands/test_install_gem.rb +0 -0
  51. data/test/jeweler/commands/test_release.rb +150 -0
  52. data/test/jeweler/commands/test_release_to_rubyforge.rb +141 -0
  53. data/test/jeweler/commands/test_write_gemspec.rb +58 -0
  54. data/test/jeweler/commands/version/test_bump_major.rb +21 -0
  55. data/test/jeweler/commands/version/test_bump_minor.rb +19 -0
  56. data/test/jeweler/commands/version/test_bump_patch.rb +20 -0
  57. data/test/jeweler/commands/version/test_write.rb +23 -0
  58. data/test/shoulda_macros/jeweler_macros.rb +35 -0
  59. data/test/test_application.rb +109 -0
  60. data/test/test_gemspec_helper.rb +36 -0
  61. data/test/test_generator.rb +179 -0
  62. data/test/test_helper.rb +51 -0
  63. data/test/test_jeweler.rb +136 -0
  64. data/test/test_options.rb +90 -0
  65. data/test/test_tasks.rb +40 -0
  66. data/test/test_version_helper.rb +115 -0
  67. metadata +152 -0
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'mini/test'
3
+
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ require '<%= file_name_prefix %>'
7
+
8
+ class Mini::Test::TestCase
9
+ end
10
+
11
+ Mini::Test.autorun
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe "<%= constant_name %>" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec'
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ require '<%= file_name_prefix %>'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class <%= constant_name %>Test < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require '<%= file_name_prefix %>'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class <%= constant_name %>Test < Test::Unit::TestCase
4
+ def test_something_for_real
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ require '<%= file_name_prefix %>'
7
+
8
+ class Test::Unit::TestCase
9
+ end
@@ -0,0 +1,83 @@
1
+ require 'yaml'
2
+
3
+ class Jeweler
4
+ class VersionHelper
5
+ attr_accessor :base_dir
6
+ attr_reader :major, :minor, :patch
7
+
8
+ def initialize(base_dir)
9
+ self.base_dir = base_dir
10
+
11
+ if File.exists?(yaml_path)
12
+ parse_yaml
13
+ end
14
+ end
15
+
16
+ def bump_major
17
+ @major += 1
18
+ @minor = 0
19
+ @patch = 0
20
+ end
21
+
22
+ def bump_minor
23
+ @minor += 1
24
+ @patch = 0
25
+ end
26
+
27
+ def bump_patch
28
+ @patch += 1
29
+ end
30
+
31
+ def update_to(major, minor, patch)
32
+ @major = major
33
+ @minor = minor
34
+ @patch = patch
35
+ end
36
+
37
+ def write
38
+ File.open(yaml_path, 'w+') do |f|
39
+ YAML.dump(self.to_hash, f)
40
+ end
41
+ end
42
+
43
+ def to_s
44
+ "#{major}.#{minor}.#{patch}"
45
+ end
46
+
47
+ def to_hash
48
+ {
49
+ :major => major,
50
+ :minor => minor,
51
+ :patch => patch
52
+ }
53
+ end
54
+
55
+ def refresh
56
+ parse_yaml
57
+ end
58
+
59
+ def yaml_path
60
+ denormalized_path = File.join(@base_dir, 'VERSION.yml')
61
+ absolute_path = File.expand_path(denormalized_path)
62
+ absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
63
+ end
64
+
65
+ protected
66
+
67
+ def parse_yaml
68
+ yaml = read_yaml
69
+ @major = (yaml['major'] || yaml[:major]).to_i
70
+ @minor = (yaml['minor'] || yaml[:minor]).to_i
71
+ @patch = (yaml['patch'] || yaml[:patch]).to_i
72
+ end
73
+
74
+ def read_yaml
75
+ if File.exists?(yaml_path)
76
+ YAML.load_file(yaml_path)
77
+ else
78
+ raise VersionYmlError, "#{yaml_path} does not exist!"
79
+ end
80
+ end
81
+
82
+ end
83
+ end
@@ -0,0 +1,4 @@
1
+ ---
2
+ major: 1
3
+ minor: 5
4
+ patch: 2
@@ -0,0 +1,12 @@
1
+ # Dependencies required to run the test suite
2
+ gems:
3
+ - name: rspec
4
+ version: '~> 1.1.12'
5
+ - name: Shoulda
6
+ version: '~> 1.2.0'
7
+ - name: ruby-debug
8
+ version: '~> 0.10.3'
9
+ - name: rr
10
+ version: '~> 0.7.1'
11
+ - name: mhennemeyer-output_catcher
12
+ version: '~> 1.0.1'
@@ -0,0 +1,146 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class JewelerGeneratorInitializerTest < Test::Unit::TestCase
4
+ context "given a nil github repo name" do
5
+ setup do
6
+ @block = lambda { Jeweler::Generator.new(nil) }
7
+ end
8
+
9
+ should "raise an error" do
10
+ assert_raise Jeweler::NoGitHubRepoNameGiven do
11
+ @block.call
12
+ end
13
+ end
14
+ end
15
+
16
+ context "without git user's name set" do
17
+ setup do
18
+ Jeweler::Generator.any_instance.stubs(:read_git_config).returns({'user.email' => 'bar@example.com'})
19
+ end
20
+
21
+ context "instantiating new generator" do
22
+ setup do
23
+ @block = lambda { Jeweler::Generator.new('the-perfect-gem')}
24
+ end
25
+
26
+ should "raise no git user name exception" do
27
+ assert_raise Jeweler::NoGitUserName do
28
+ @block.call
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ context "without git user's email set" do
35
+ setup do
36
+ Jeweler::Generator.any_instance.stubs(:read_git_config).returns({'user.name' => 'foo'})
37
+ end
38
+
39
+ context "instantiating new generator" do
40
+ setup do
41
+ @block = lambda { Jeweler::Generator.new('the-perfect-gem')}
42
+ end
43
+
44
+ should "raise no git user name exception" do
45
+ assert_raise Jeweler::NoGitUserEmail do
46
+ @block.call
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ context "without github username set" do
53
+ setup do
54
+ Jeweler::Generator.any_instance.stubs(:read_git_config).
55
+ returns({'user.email' => 'bar@example.com', 'user.name' => 'foo'})
56
+ end
57
+
58
+ context "instantiating new generator" do
59
+ setup do
60
+ @block = lambda { Jeweler::Generator.new('the-perfect-gem')}
61
+ end
62
+
63
+ should "raise no github user exception" do
64
+ assert_raise Jeweler::NoGitHubUser do
65
+ @block.call
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ context "without github token set" do
72
+ setup do
73
+ Jeweler::Generator.any_instance.stubs(:read_git_config).
74
+ returns({'user.email' => 'bar@example.com', 'user.name' => 'foo', 'github.user' => 'technicalpickles'})
75
+ end
76
+
77
+ context "instantiating new generator" do
78
+ setup do
79
+ @block = lambda { Jeweler::Generator.new('the-perfect-gem')}
80
+ end
81
+
82
+ should "raise no github user exception" do
83
+ assert_raise Jeweler::NoGitHubToken do
84
+ @block.call
85
+ end
86
+ end
87
+ end
88
+ end
89
+
90
+ context "with valid git user configuration" do
91
+ setup do
92
+ Jeweler::Generator.any_instance.stubs(:read_git_config).
93
+ returns({'user.name' => 'foo', 'user.email' => 'bar@example.com', 'github.user' => 'technicalpickles', 'github.token' => 'zomgtoken'})
94
+ end
95
+
96
+ context "for technicalpickle's the-perfect-gem repository" do
97
+ setup do
98
+ @generator = Jeweler::Generator.new('the-perfect-gem')
99
+ end
100
+
101
+ should "assign 'foo' to user's name" do
102
+ assert_equal 'foo', @generator.user_name
103
+ end
104
+
105
+ should "assign 'bar@example.com to user's email" do
106
+ assert_equal 'bar@example.com', @generator.user_email
107
+ end
108
+
109
+ should "assign github remote" do
110
+ assert_equal 'git@github.com:technicalpickles/the-perfect-gem.git', @generator.github_remote
111
+ end
112
+
113
+ should "determine github username as technicalpickles" do
114
+ assert_equal 'technicalpickles', @generator.github_username
115
+ end
116
+
117
+ should "determine github repository name as the-perfect-gem" do
118
+ assert_equal 'the-perfect-gem', @generator.github_repo_name
119
+ end
120
+
121
+ should "determine github url as http://github.com/technicalpickles/the-perfect-gem" do
122
+ assert_equal 'http://github.com/technicalpickles/the-perfect-gem', @generator.github_url
123
+ end
124
+
125
+ should "determine target directory as the same as the github repository name" do
126
+ assert_equal @generator.github_repo_name, @generator.target_dir
127
+ end
128
+
129
+ should "determine lib directory as being inside the target directory" do
130
+ assert_equal File.join(@generator.target_dir, 'lib'), @generator.lib_dir
131
+ end
132
+
133
+ should "determine test directory as being inside the target directory" do
134
+ assert_equal File.join(@generator.target_dir, 'test'), @generator.test_dir
135
+ end
136
+
137
+ should "determine constant name as ThePerfectGem" do
138
+ assert_equal 'ThePerfectGem', @generator.constant_name
139
+ end
140
+
141
+ should "determine file name prefix as the_perfect_gem" do
142
+ assert_equal 'the_perfect_gem', @generator.file_name_prefix
143
+ end
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,53 @@
1
+ require 'test_helper'
2
+
3
+ class Jeweler
4
+ module Commands
5
+ class TestBuildGem < Test::Unit::TestCase
6
+
7
+ context "after running" do
8
+ setup do
9
+ @gemspec = Object.new
10
+ stub(@gemspec).file_name { 'zomg-1.2.3.gem' }
11
+
12
+ @gemspec_helper = Object.new
13
+ stub(@gemspec_helper).parse { @gemspec }
14
+
15
+ @builder = Object.new
16
+ stub(Gem::Builder).new { @builder }
17
+ stub(@builder).build { 'zomg-1.2.3.gem' }
18
+
19
+ @file_utils = Object.new
20
+ stub(@file_utils).mkdir_p './pkg'
21
+ stub(@file_utils).mv './zomg-1.2.3.gem', './pkg'
22
+
23
+ @base_dir = '.'
24
+
25
+ @command = Jeweler::Commands::BuildGem.new
26
+ @command.base_dir = @base_dir
27
+ @command.file_utils = @file_utils
28
+ @command.gemspec_helper = @gemspec_helper
29
+
30
+ @command.run
31
+ end
32
+
33
+ should "call gemspec helper's parse" do
34
+ assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.parse }
35
+ end
36
+
37
+ should "build from parsed gemspec" do
38
+ assert_received(Gem::Builder) {|builder_class| builder_class.new(@gemspec) }
39
+ assert_received(@builder) {|builder| builder.build }
40
+ end
41
+
42
+ should 'make package directory' do
43
+ assert_received(@file_utils) {|file_utils| file_utils.mkdir_p './pkg'}
44
+ end
45
+
46
+ should 'move built gem into package directory' do
47
+ assert_received(@file_utils) {|file_utils| file_utils.mv './zomg-1.2.3.gem', './pkg'}
48
+ end
49
+ end
50
+
51
+ end
52
+ end
53
+ end
File without changes
@@ -0,0 +1,150 @@
1
+ require 'test_helper'
2
+
3
+ class Jeweler
4
+ module Commands
5
+ class TestRelease < Test::Unit::TestCase
6
+
7
+ context "with added files" do
8
+ setup do
9
+ @repo = Object.new
10
+ stub(@repo).checkout(anything)
11
+
12
+ status = Object.new
13
+ stub(status).added { ['README'] }
14
+ stub(status).deleted { [] }
15
+ stub(status).changed { [] }
16
+ stub(@repo).status { status }
17
+
18
+ @command = Jeweler::Commands::Release.new
19
+ @command.output = @output
20
+ @command.repo = @repo
21
+ @command.gemspec_helper = @gemspec_helper
22
+ @command.version = '1.2.3'
23
+ end
24
+
25
+ should 'raise error' do
26
+ assert_raises RuntimeError, /try commiting/i do
27
+ @command.run
28
+ end
29
+ end
30
+ end
31
+
32
+ context "with deleted files" do
33
+ setup do
34
+ @repo = Object.new
35
+ stub(@repo).checkout(anything)
36
+
37
+ status = Object.new
38
+ stub(status).added { [] }
39
+ stub(status).deleted { ['README'] }
40
+ stub(status).changed { [] }
41
+ stub(@repo).status { status }
42
+
43
+ @command = Jeweler::Commands::Release.new
44
+ @command.output = @output
45
+ @command.repo = @repo
46
+ @command.gemspec_helper = @gemspec_helper
47
+ @command.version = '1.2.3'
48
+ @command.base_dir = '.'
49
+ end
50
+
51
+ should 'raise error' do
52
+ assert_raises RuntimeError, /try commiting/i do
53
+ @command.run
54
+ end
55
+ end
56
+ end
57
+
58
+ context "with changed files" do
59
+ setup do
60
+ @repo = Object.new
61
+ stub(@repo).checkout(anything)
62
+
63
+ status = Object.new
64
+ stub(status).added { [] }
65
+ stub(status).deleted { [] }
66
+ stub(status).changed { ['README'] }
67
+ stub(@repo).status { status }
68
+
69
+ @command = Jeweler::Commands::Release.new
70
+ @command.output = @output
71
+ @command.repo = @repo
72
+ @command.gemspec_helper = @gemspec_helper
73
+ @command.version = '1.2.3'
74
+ end
75
+
76
+ should 'raise error' do
77
+ assert_raises RuntimeError, /try commiting/i do
78
+ @command.run
79
+ end
80
+ end
81
+ end
82
+
83
+ context "after running without pending changes" do
84
+ setup do
85
+ @repo = Object.new
86
+ stub(@repo).checkout(anything)
87
+ stub(@repo).add(anything)
88
+ stub(@repo).commit(anything)
89
+ stub(@repo).push
90
+ stub(@repo).push(anything)
91
+ stub(@repo).add_tag(anything)
92
+
93
+ @gemspec_helper = Object.new
94
+ stub(@gemspec_helper).write
95
+ stub(@gemspec_helper).path {'zomg.gemspec'}
96
+ stub(@gemspec_helper).update_version('1.2.3')
97
+
98
+ status = Object.new
99
+ stub(status).added { [] }
100
+ stub(status).deleted { [] }
101
+ stub(status).changed { [] }
102
+ stub(@repo).status { status }
103
+
104
+ @output = StringIO.new
105
+
106
+ @command = Jeweler::Commands::Release.new
107
+ @command.output = @output
108
+ @command.repo = @repo
109
+ @command.gemspec_helper = @gemspec_helper
110
+ @command.version = '1.2.3'
111
+
112
+ @command.run
113
+ end
114
+
115
+ should "checkout master" do
116
+ assert_received(@repo) {|repo| repo.checkout('master') }
117
+ end
118
+
119
+ should "refresh gemspec version" do
120
+ assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.update_version('1.2.3') }
121
+ end
122
+
123
+ should "write gemspec" do
124
+ assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.write }
125
+
126
+ end
127
+
128
+ should "add gemspec to repository" do
129
+ assert_received(@repo) {|repo| repo.add('zomg.gemspec') }
130
+ end
131
+
132
+ should "commit with commit message including version" do
133
+ assert_received(@repo) {|repo| repo.commit("Regenerated gemspec for version 1.2.3") }
134
+ end
135
+
136
+ should "push repository" do
137
+ assert_received(@repo) {|repo| repo.push }
138
+ end
139
+
140
+ should "tag release" do
141
+ assert_received(@repo) {|repo| repo.add_tag("v1.2.3")}
142
+ end
143
+
144
+ should "push tag to repository" do
145
+ assert_received(@repo) {|repo| repo.push('origin', 'v1.2.3')}
146
+ end
147
+ end
148
+ end
149
+ end
150
+ end