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,58 @@
1
+ # jeweler x.y.z
2
+
3
+ * Tasks:
4
+ * Fixed populating default spec's extra_rdoc_files
5
+ * Removed redudant gem building/installing tasks. Use rake build and rake install
6
+ * Generator:
7
+ * Added support for micronaut
8
+ * Generate nicer block variable names in Rakefile
9
+ * Cucumber generation now places steps in features/step_features, to follow cucumber standards
10
+
11
+ * shoulda and test/unit test_helpers no longers require mocha
12
+ * Rakefile uses more readable block variable names
13
+ * .gitignore now includes pkg and coverage directories
14
+ * Avoid puts'ing in Rakefile when LoadError occurs. Instead, define a task that aborts with instructions to install.
15
+ * Cucumber is now optional. Generate stories using --cucumber
16
+ * Bacon's 'test' task is now 'spec'
17
+ * Generate README.rdoc instead of just a plain text README
18
+ * Updated year in README.rdoc and COPYRIGHT to be based on the current year instead of hardcoded
19
+
20
+ # jeweler 0.8.1 2009-02-03
21
+
22
+ * Fixed minitest generator
23
+
24
+ # jeweler 0.8.0 2009-02-03
25
+
26
+ * Generator:
27
+ * Supports these new testing frameworks:
28
+ * test/unit
29
+ * minitest
30
+ * rspec
31
+ * Added support for cucumber
32
+ * Creating a new gem is now more verbose, and will show files/directories created
33
+ * Binaries will now be automatically detected in 'bin'
34
+
35
+ # jeweler 0.7.2 2009-01-29
36
+
37
+ * Added rake task 'version:bump' which is shorthand for 'version:bump:patch'
38
+ * Generated projects no longer assume RCov is installed.
39
+
40
+ # jeweler 0.7.1 2009-01-26
41
+
42
+ * Fixed yaml not being required
43
+ * Automatically add files in bin as executables in gemspec
44
+
45
+ # jeweler 0.7.0 2009-01-19
46
+
47
+ * Added support to generator for specifying a description
48
+ * Condensed README.markdown to be less novel-like
49
+ * RDoc is now included in your gemspec
50
+ * Rescue errors that raise in the generator, and display better error message, and exit with a non-zero exit status
51
+
52
+ # jeweler 0.6.5 2009-01-14
53
+
54
+ * `jeweler --create-repo foo` now enables gem creation in addition to creating the repository
55
+
56
+ # jeweler 0.6.4 2009-01-13
57
+
58
+ * Added tasks `build` and `install` as shortcuts for `gem:build` and `gem:install`
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Josh Nichols
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,103 @@
1
+ # Jeweler: Craft the perfect RubyGem
2
+
3
+ Jeweler provides two things:
4
+
5
+ * Rake tasks for managing gems and versioning of a <a href="http://github.com">GitHub</a> project
6
+ * A generator for creating kickstarting a new project
7
+
8
+ ## Installing
9
+
10
+ # Run the following if you haven't done so before:
11
+ gem sources -a http://gems.github.com
12
+ # Install the gem:
13
+ sudo gem install technicalpickles-jeweler
14
+
15
+ ## Using in an existing project
16
+
17
+ It's easy to get up and running. Update your instantiate a `Jeweler::Tasks`, and give it a block with details about your project.
18
+
19
+ begin
20
+ require 'jeweler'
21
+ Jeweler::Tasks.new do |s|
22
+ s.name = "the-perfect-gem"
23
+ s.summary = "TODO"
24
+ s.email = "josh@technicalpickles.com"
25
+ s.homepage = "http://github.com/technicalpickles/the-perfect-gem"
26
+ s.description = "TODO"
27
+ s.authors = ["Josh Nichols"]
28
+ end
29
+ rescue LoadError
30
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
31
+ end
32
+
33
+ In this example, `s` is a Gem::Specification object. See the [GemSpec reference](http://www.rubygems.org/read/chapter/20) for values of interest.
34
+
35
+ ## Using to start a new project
36
+
37
+ Jeweler provides a generator. It requires you to [setup your name and email for git](http://github.com/guides/tell-git-your-user-name-and-email-address) and [your username and token for GitHub](http://github.com/guides/local-github-config).
38
+
39
+ jeweler the-perfect-gem
40
+
41
+ This will prepare a project in the 'the-perfect-gem' directory, setup to use Jeweler.
42
+
43
+ It supports a number of options:
44
+
45
+ * --create-repo: in addition to preparing a project, it create an repo up on GitHub and enable RubyGem generation
46
+ * --testunit: generate test_helper.rb and test ready for test/unit
47
+ * --minitest: generate test_helper.rb and test ready for minitest
48
+ * --shoulda: generate test_helper.rb and test ready for shoulda (this is the default)
49
+ * --rspec: generate spec_helper.rb and spec ready for rspec
50
+ * --bacon: generate spec_helper.rb and spec ready for bacon
51
+
52
+ ## Gemspec
53
+
54
+ Jeweler handles generating a gemspec file for your project:
55
+
56
+ rake gemspec
57
+
58
+ This creates a gemspec for your project. It's based on the info you give `Jeweler::Tasks`, the current version of your project, and some defaults that Jeweler provides.
59
+
60
+ ## Gem
61
+
62
+ Jeweler gives you tasks for building and installing your gem:
63
+
64
+ rake build
65
+ rake install
66
+
67
+ ## Versioning
68
+
69
+ Jeweler tracks the version of your project. It assumes you will be using a version in the format `x.y.z`. `x` is the 'major' version, `y` is the 'minor' version, and `z` is the patch version.
70
+
71
+ Initially, your project starts out at 0.0.0. Jeweler provides Rake tasks for bumping the version:
72
+
73
+ rake version:bump:major
74
+ rake version:bump:minor
75
+ rake version:bump:patch
76
+
77
+ ## Releasing
78
+
79
+ Jeweler handles releasing your gem into the wild:
80
+
81
+ rake release
82
+
83
+ It does the following for you:
84
+
85
+ * Regenerate the gemspec to the latest version of your project
86
+ * Push to GitHub (which results in a gem being build)
87
+ * Tag the version and push to GitHub
88
+
89
+ Jeweler also handles releasing your gem to RubyForge. Assuming you've configured ~/.ruby_forge properly and included :rubyforge_project in your Jeweler::Tasks block, the following will release your gem to RubyForge:
90
+
91
+ rake rubyforge:release:gem
92
+
93
+ ## Workflow
94
+
95
+ * Hack, commit, hack, commit, etc, etc
96
+ * `rake version:bump:patch release` to do the actual version bump and release
97
+ * Have a delicious scotch
98
+ * Go to [Has My Gem Built Yet](http://hasmygembuiltyet.org) and wait for your gem to be built
99
+
100
+ ## Links
101
+
102
+ * [Bugs](http://technicalpickles.lighthouseapp.com/projects/23560-jeweler/overview)
103
+ * [Donate](http://pledgie.org/campaigns/2604)
data/Rakefile ADDED
@@ -0,0 +1,61 @@
1
+ require 'rake'
2
+
3
+ $LOAD_PATH.unshift('lib')
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "jeweler"
9
+ gem.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
10
+ gem.email = "josh@technicalpickles.com"
11
+ gem.homepage = "http://github.com/technicalpickles/jeweler"
12
+ gem.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
13
+ gem.authors = ["Josh Nichols"]
14
+ gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore']
15
+ gem.add_dependency 'schacon-git'
16
+ end
17
+ rescue LoadError
18
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
19
+ end
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.pattern = 'test/**/test_*.rb'
24
+ test.libs << 'test'
25
+ end
26
+
27
+ require 'rake/rdoctask'
28
+ Rake::RDocTask.new do |rdoc|
29
+ rdoc.rdoc_dir = 'rdoc'
30
+ rdoc.title = 'jeweler'
31
+ rdoc.options << '--line-numbers' << '--inline-source'
32
+ rdoc.rdoc_files.include('README.markdown')
33
+ rdoc.rdoc_files.include('lib/**/*.rb')
34
+ end
35
+
36
+ begin
37
+ require 'rcov/rcovtask'
38
+ Rcov::RcovTask.new(:rcov) do |rcov|
39
+ rcov.libs << 'test'
40
+ rcov.pattern = 'test/**/test_*.rb'
41
+ end
42
+ rescue LoadError
43
+ task :rcov do
44
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
45
+ end
46
+ end
47
+
48
+ begin
49
+ require 'cucumber/rake/task'
50
+ Cucumber::Rake::Task.new(:features)
51
+ rescue LoadError
52
+ task :features do
53
+ abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
54
+ end
55
+ end
56
+
57
+ if ENV["RUN_CODE_RUN"] == "true"
58
+ task :default => [:test, :features]
59
+ else
60
+ task :default => :test
61
+ end
data/TODO ADDED
@@ -0,0 +1,11 @@
1
+ * use some sort of logger instead of stdout and stderr
2
+ * jeweler --delete-repo
3
+ * output gemspec as yaml
4
+ * move interactions with github into separate class
5
+ * use Net::HTTP.post_form instead of `` for enabling gem creation
6
+ * Generators
7
+ * Rails generator for making a plugin that's Jeweler enabled
8
+ * Change generated test filename (test_foo not foo_test)
9
+ * Releasing
10
+ * Have a way to check if the gem is built yet
11
+ * Option for enabling
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 9
4
+ :patch: 2
data/bin/jeweler ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'optparse'
4
+
5
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
6
+ require 'jeweler'
7
+
8
+ Jeweler::Generator::Application.run!(*ARGV)
data/lib/jeweler.rb ADDED
@@ -0,0 +1,161 @@
1
+ require 'date'
2
+ require 'rubygems/builder'
3
+ require 'rubyforge'
4
+
5
+ require 'jeweler/version_helper'
6
+ require 'jeweler/gemspec_helper'
7
+ require 'jeweler/errors'
8
+ require 'jeweler/generator'
9
+ require 'jeweler/generator/options'
10
+ require 'jeweler/generator/application'
11
+
12
+ require 'jeweler/commands'
13
+
14
+ require 'jeweler/tasks'
15
+
16
+ # A Jeweler helps you craft the perfect Rubygem. Give him a gemspec, and he takes care of the rest.
17
+ class Jeweler
18
+
19
+ attr_reader :gemspec, :gemspec_helper
20
+ attr_accessor :base_dir, :output
21
+
22
+ def initialize(gemspec, base_dir = '.')
23
+ raise(GemspecError, "Can't create a Jeweler with a nil gemspec") if gemspec.nil?
24
+
25
+ @base_dir = base_dir
26
+ @gemspec = fill_in_gemspec_defaults(gemspec)
27
+ @repo = Git.open(base_dir) if in_git_repo?
28
+ @version_helper = Jeweler::VersionHelper.new(@base_dir)
29
+ @output = $stdout
30
+ @gemspec_helper = GemSpecHelper.new(@gemspec,base_dir)
31
+ end
32
+
33
+ # Major version, as defined by the gemspec's Version module.
34
+ # For 1.5.3, this would return 1.
35
+ def major_version
36
+ @version_helper.major
37
+ end
38
+
39
+ # Minor version, as defined by the gemspec's Version module.
40
+ # For 1.5.3, this would return 5.
41
+ def minor_version
42
+ @version_helper.minor
43
+ end
44
+
45
+ # Patch version, as defined by the gemspec's Version module.
46
+ # For 1.5.3, this would return 5.
47
+ def patch_version
48
+ @version_helper.patch
49
+ end
50
+
51
+ # Human readable version, which is used in the gemspec.
52
+ def version
53
+ @version_helper.to_s
54
+ end
55
+
56
+ # Writes out the gemspec
57
+ def write_gemspec
58
+ build_command(Jeweler::Commands::WriteGemspec).run
59
+ end
60
+
61
+ # Validates the project's gemspec from disk in an environment similar to how
62
+ # GitHub would build from it. See http://gist.github.com/16215
63
+ def validate_gemspec
64
+ build_command(Jeweler::Commands::ValidateGemspec).run
65
+ end
66
+
67
+ # is the project's gemspec from disk valid?
68
+ def valid_gemspec?
69
+ gemspec_helper.valid?
70
+ end
71
+
72
+ def build_gem
73
+ build_command(Jeweler::Commands::BuildGem).run
74
+ end
75
+
76
+ def install_gem
77
+ build_command(Jeweler::Commands::InstallGem).run
78
+ end
79
+
80
+ # Bumps the patch version.
81
+ #
82
+ # 1.5.1 -> 1.5.2
83
+ def bump_patch_version(options = {})
84
+ build_command(Jeweler::Commands::Version::BumpPatch).run
85
+ end
86
+
87
+ # Bumps the minor version.
88
+ #
89
+ # 1.5.1 -> 1.6.0
90
+ def bump_minor_version(options = {})
91
+ build_command(Jeweler::Commands::Version::BumpMinor).run
92
+ end
93
+
94
+ # Bumps the major version.
95
+ #
96
+ # 1.5.1 -> 2.0.0
97
+ def bump_major_version(options = {})
98
+ build_command(Jeweler::Commands::Version::BumpMajor).run
99
+ end
100
+
101
+ # Bumps the version, to the specific major/minor/patch version, writing out the appropriate version.rb, and then reloads it.
102
+ def write_version(major, minor, patch, options = {})
103
+ command = build_command(Jeweler::Commands::Version::Write)
104
+ command.major = major
105
+ command.minor = minor
106
+ command.patch = patch
107
+
108
+ command.run
109
+ end
110
+
111
+ def release
112
+ build_command(Jeweler::Commands::Release).run
113
+ end
114
+
115
+ def release_gem_to_rubyforge
116
+ build_command(Jeweler::Commands::ReleaseToRubyforge).run
117
+ end
118
+
119
+ protected
120
+
121
+ def build_command(command_class)
122
+ command = command_class.new
123
+ command.repo = @repo if command.respond_to?(:repo=)
124
+ command.version_helper = @version_helper if command.respond_to?(:version_helper=)
125
+ command.gemspec = @gemspec if command.respond_to?(:gemspec=)
126
+ command.commit = true if command.respond_to?(:commit=)
127
+ command.version = self.version if command.respond_to?(:version=)
128
+ command.output = output if command.respond_to?(:output=)
129
+ command.base_dir = @base_dir if command.respond_to?(:base_dir=)
130
+ command.gemspec_helper = GemSpecHelper.new(@gemspec, @base_dir) if command.respond_to?(:gemspec_helper)
131
+ command.ruby_forge = RubyForge.new if command.respond_to?(:ruby_forge=)
132
+
133
+ command
134
+ end
135
+
136
+ def in_git_repo?
137
+ File.exists?(File.join(self.base_dir, '.git'))
138
+ end
139
+
140
+ def fill_in_gemspec_defaults(gemspec)
141
+ if gemspec.files.nil? || gemspec.files.empty?
142
+ gemspec.files = FileList["[A-Z]*.*", "{bin,generators,lib,test,spec}/**/*"]
143
+ end
144
+
145
+ if gemspec.executables.nil? || gemspec.executables.empty?
146
+ gemspec.executables = Dir["#{@base_dir}/bin/*"].map do |f|
147
+ File.basename(f)
148
+ end
149
+ end
150
+
151
+ gemspec.has_rdoc = true
152
+ gemspec.rdoc_options << '--inline-source' << '--charset=UTF-8'
153
+
154
+ if gemspec.extra_rdoc_files.nil? || gemspec.extra_rdoc_files.empty?
155
+ gemspec.extra_rdoc_files = FileList["README*", "ChangeLog*", "LICENSE*"]
156
+ end
157
+
158
+ gemspec
159
+ end
160
+ end
161
+
@@ -0,0 +1,11 @@
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/validate_gemspec'
6
+ require 'jeweler/commands/write_gemspec'
7
+ require 'jeweler/commands/version/base'
8
+ require 'jeweler/commands/version/bump_major'
9
+ require 'jeweler/commands/version/bump_minor'
10
+ require 'jeweler/commands/version/bump_patch'
11
+ require 'jeweler/commands/version/write'