bueller 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/ChangeLog.markdown +141 -0
  2. data/LICENSE +20 -0
  3. data/README.markdown +182 -0
  4. data/bin/bueller +5 -0
  5. data/lib/bueller/commands/build_gem.rb +50 -0
  6. data/lib/bueller/commands/git_tag_release.rb +63 -0
  7. data/lib/bueller/commands/install_gem.rb +36 -0
  8. data/lib/bueller/commands/release_to_github.rb +41 -0
  9. data/lib/bueller/commands/release_to_rubygems.rb +26 -0
  10. data/lib/bueller/commands/version/base.rb +36 -0
  11. data/lib/bueller/commands/version/bump_major.rb +11 -0
  12. data/lib/bueller/commands/version/bump_minor.rb +12 -0
  13. data/lib/bueller/commands/version/bump_patch.rb +14 -0
  14. data/lib/bueller/commands/version/write.rb +21 -0
  15. data/lib/bueller/commands/write_gemspec.rb +29 -0
  16. data/lib/bueller/commands.rb +18 -0
  17. data/lib/bueller/errors.rb +8 -0
  18. data/lib/bueller/gemspec_helper.rb +83 -0
  19. data/lib/bueller/generator/application.rb +51 -0
  20. data/lib/bueller/generator/bacon_mixin.rb +43 -0
  21. data/lib/bueller/generator/github_mixin.rb +29 -0
  22. data/lib/bueller/generator/micronaut_mixin.rb +41 -0
  23. data/lib/bueller/generator/minitest_mixin.rb +42 -0
  24. data/lib/bueller/generator/options.rb +154 -0
  25. data/lib/bueller/generator/rdoc_mixin.rb +9 -0
  26. data/lib/bueller/generator/riot_mixin.rb +42 -0
  27. data/lib/bueller/generator/rspec_mixin.rb +50 -0
  28. data/lib/bueller/generator/shindo_mixin.rb +44 -0
  29. data/lib/bueller/generator/shoulda_mixin.rb +42 -0
  30. data/lib/bueller/generator/testspec_mixin.rb +42 -0
  31. data/lib/bueller/generator/testunit_mixin.rb +39 -0
  32. data/lib/bueller/generator/yard_mixin.rb +14 -0
  33. data/lib/bueller/generator.rb +291 -0
  34. data/lib/bueller/rubyforge_tasks.rb +88 -0
  35. data/lib/bueller/tasks.rb +133 -0
  36. data/lib/bueller/templates/.document +11 -0
  37. data/lib/bueller/templates/.gitignore +40 -0
  38. data/lib/bueller/templates/Gemfile +1 -0
  39. data/lib/bueller/templates/LICENSE +20 -0
  40. data/lib/bueller/templates/README.rdoc +17 -0
  41. data/lib/bueller/templates/Rakefile +20 -0
  42. data/lib/bueller/templates/bacon/flunking.rb +7 -0
  43. data/lib/bueller/templates/bacon/helper.rb +8 -0
  44. data/lib/bueller/templates/bueller_tasks.erb +10 -0
  45. data/lib/bueller/templates/features/default.feature +9 -0
  46. data/lib/bueller/templates/features/support/env.rb +16 -0
  47. data/lib/bueller/templates/gemspec +27 -0
  48. data/lib/bueller/templates/micronaut/flunking.rb +7 -0
  49. data/lib/bueller/templates/micronaut/helper.rb +17 -0
  50. data/lib/bueller/templates/minitest/flunking.rb +7 -0
  51. data/lib/bueller/templates/minitest/helper.rb +11 -0
  52. data/lib/bueller/templates/other_tasks.erb +84 -0
  53. data/lib/bueller/templates/riot/flunking.rb +11 -0
  54. data/lib/bueller/templates/riot/helper.rb +3 -0
  55. data/lib/bueller/templates/rspec/.rspec +1 -0
  56. data/lib/bueller/templates/rspec/flunking.rb +7 -0
  57. data/lib/bueller/templates/rspec/helper.rb +19 -0
  58. data/lib/bueller/templates/shindo/flunking.rb +8 -0
  59. data/lib/bueller/templates/shindo/helper.rb +5 -0
  60. data/lib/bueller/templates/shoulda/flunking.rb +7 -0
  61. data/lib/bueller/templates/shoulda/helper.rb +10 -0
  62. data/lib/bueller/templates/testspec/flunking.rb +7 -0
  63. data/lib/bueller/templates/testspec/helper.rb +7 -0
  64. data/lib/bueller/templates/testunit/flunking.rb +7 -0
  65. data/lib/bueller/templates/testunit/helper.rb +9 -0
  66. data/lib/bueller/version_helper.rb +59 -0
  67. data/lib/bueller.rb +139 -0
  68. data/spec/bueller/commands/build_gem_spec.rb +38 -0
  69. data/spec/bueller/commands/git_tag_release_spec.rb +79 -0
  70. data/spec/bueller/commands/install_gem_spec.rb +11 -0
  71. data/spec/bueller/commands/release_to_github_spec.rb +54 -0
  72. data/spec/bueller/commands/release_to_rubygems_spec.rb +15 -0
  73. data/spec/bueller/commands/version/bump_major_spec.rb +12 -0
  74. data/spec/bueller/commands/version/bump_minor_spec.rb +12 -0
  75. data/spec/bueller/commands/version/bump_patch_spec.rb +12 -0
  76. data/spec/bueller/commands/write_gemspec_spec.rb +32 -0
  77. data/spec/bueller/gemspec_helper_spec.rb +55 -0
  78. data/spec/bueller/generator/application_spec.rb +67 -0
  79. data/spec/bueller/generator/options_spec.rb +206 -0
  80. data/spec/bueller/generator_mixins_spec.rb +23 -0
  81. data/spec/bueller/generator_spec.rb +274 -0
  82. data/spec/bueller/tasks_spec.rb +29 -0
  83. data/spec/bueller/version_helper_spec.rb +57 -0
  84. data/spec/bueller_spec.rb +94 -0
  85. data/spec/fixtures/bar/bar.gemspec +41 -0
  86. data/spec/fixtures/bar/bin/foo_the_ultimate_bin +1 -0
  87. data/spec/fixtures/bar/hey_include_me_in_gemspec +0 -0
  88. data/spec/fixtures/bar/lib/foo_the_ultimate_lib.rb +1 -0
  89. data/spec/fixtures/existing-project/LICENSE +20 -0
  90. data/spec/fixtures/existing-project/README.rdoc +7 -0
  91. data/spec/fixtures/existing-project/Rakefile +69 -0
  92. data/spec/fixtures/existing-project/existing-project.gemspec +20 -0
  93. data/spec/fixtures/existing-project/lib/existing_project_with_version.rb +0 -0
  94. data/spec/fixtures/existing-project/test/existing_project_with_version_test.rb +7 -0
  95. data/spec/fixtures/existing-project/test/test_helper.rb +10 -0
  96. data/spec/fixtures/existing-project-with-version-constant/LICENSE +20 -0
  97. data/spec/fixtures/existing-project-with-version-constant/README.rdoc +7 -0
  98. data/spec/fixtures/existing-project-with-version-constant/Rakefile +69 -0
  99. data/spec/fixtures/existing-project-with-version-constant/existing-project-with-version.gemspec +19 -0
  100. data/spec/fixtures/existing-project-with-version-constant/lib/existing_project_with_version.rb +0 -0
  101. data/spec/fixtures/existing-project-with-version-constant/test/existing_project_with_version_test.rb +7 -0
  102. data/spec/fixtures/existing-project-with-version-constant/test/test_helper.rb +10 -0
  103. data/spec/spec_helper.rb +11 -0
  104. data/spec/support/application.rb +28 -0
  105. data/spec/support/file_system.rb +24 -0
  106. data/spec/support/gemspec.rb +28 -0
  107. data/spec/support/git.rb +19 -0
  108. data/spec/support/have_version.rb +18 -0
  109. metadata +381 -0
@@ -0,0 +1,141 @@
1
+ # bueller 1.4.0 2009-11-19
2
+
3
+ * Generator now adds gemcutter support by default. Disable it with --no-gemcutter
4
+ * Generator now creates a reek task that works with the latest reek. If you have a previously generated project using it, you may need to change the require line to: require 'reek/adapters/rake_task'
5
+ * Generator now exits with the correct exit code
6
+ * `rake install` no longer uses `sudo` to install. If your ruby configuration needs sudo to install, use `sudo rake install` instead.
7
+ * `rake install` now correctly installs dependencies as well
8
+ * `rake install` should correctly figure out which `gem` binary to invoke now
9
+ * `rake build` now will regenerate the gemspec as well
10
+ * `rake gemspec` now eliminates duplicates for gemspec.files, gemspec.rdoc_files, etc
11
+ * `rake gemspec` now automatically populates gemspec.extensions with any extconf.rb files you have in `ext`
12
+ * Releasing to Rubyforge is now deprecated in favor of Gemcutter.
13
+
14
+ # bueller 1.3.0
15
+
16
+ * Now supports an additional version type, build. This can be used to add a fourth segment of the version that's arbitrary. One example use is having prereleases.
17
+ * Jeweler now lazily loads, to avoid causing side-effects when running other rake tasks
18
+ * Version can now be set explicitly on the gemspec, rather than relying on a VERSION file
19
+ * Rubyforge and Gemcutter support now hooks into `rake release`
20
+ * `rake build` now uses an in-memory copy of the gemspec, rather than the filesystem persisted one
21
+ * Rubyforge support no longer forces the uploading of documentation
22
+ * Generator:
23
+ * Allow arbitrary homepage and git remotes, to decouple a bit from GitHub
24
+ * Support for the riot testing framework: http://github.com/thumblemonks/riot/
25
+ * Support for test/spec
26
+ * .gitignore now ignores emacs temporary files
27
+ * rspec support now creates a spec.opts with support for color and other stuff
28
+ * Updated minitest support (formally miniunit)
29
+ * Improved support for autotest
30
+
31
+ # bueller 1.2.0 2009-08-06
32
+ * Generator now adds development dependencies appropriate to your testing framework
33
+ * Added check_dependencies tasks for verifying gem dependencies are installed
34
+ * Fixed typo in generated yard task
35
+ * Fixed generator from having a lot of extra newlines
36
+
37
+ # bueller 1.1.0 2009-08-05
38
+
39
+ * Support for generating a project that uses yard instead of rdoc
40
+ * Generated gemspec now includes comments about it being generated by bueller
41
+ * Only use sudo for installing on non-windows platforms [#1]
42
+ * Fixed rake release to be repeatable on the same version [#16]
43
+ * Fixed rake rubyforge:setup to not create duplicate packages
44
+ * Use a more recent version of ruby-git
45
+ * Fixes various issues with reading values out of ~/.gitconfig [#26] [#21] [#19]
46
+ * Experimenting with a rake task to check development time dependencies [#22]
47
+ * Fixed generated rdoc task to load from VERSION instead of VERSION.yml
48
+
49
+ # bueller 1.0.2 2009-07-29
50
+
51
+ * Don't include git ignored files for default gemspec's files and test_files
52
+ * Fixed rspec generator to allow specs to be run directly
53
+ * Removed misleading docstring for version_required rake task [#17]
54
+ * Includes some notes about contributed in generated README
55
+ * Added support for generating a project to use reek and roodi
56
+
57
+ # bueller 1.0.1 2009-05-15
58
+
59
+ # bueller 0.11.1
60
+
61
+ * Lots of internal refactorings to how project generation happens
62
+ * Fixed missing dependency on rubyforge
63
+ * Depend on a recent version of schacon-git which works on ruby 1.9
64
+ * Updated cucumber support for 0.3.x
65
+ * Tested on Ruby 1.9
66
+
67
+ # bueller 0.11.0 2009-04-05
68
+
69
+ * generator will respect JEWELER_OPTS, as a way to provide default options
70
+ (pat-maddox)
71
+ * Include 'examples' and 'rails' directories by default in gemspec files
72
+ * generated gemspec now will only include files (not directories). also, they are listed one per line, and sorted.
73
+ * Jeweler::Tasks's intializer has been improved:
74
+ * You can now pass it an existing gemspec (othewise a new one will be created)
75
+ * Jeweler sets its defaults before yielding the gemspec to you. This allows you to append to its defaults, so you aren't forced to entirely overwrite them just to add one value.
76
+ * Managing a gemspec's files, test_files, and extra_rdoc_files is now more flexible. They are now wrapped in a FileList, so you can easily 'include' or 'exclude' patterns.
77
+
78
+ # bueller 0.10.2 2009-03-26
79
+
80
+ * 'rake install' now will 'rake build' first
81
+ * Support for releasing to RubyForge, thanks to jtrupiano
82
+ * Steps towards Ruby 1.9 support, thanks to rsanheim
83
+
84
+ # bueller 0.9.1 2009-03-05
85
+
86
+ * Tasks:
87
+ * Fixed populating default spec's extra_rdoc_files
88
+ * Removed redundant gem building/installing tasks. Use rake build and rake install
89
+ * Generator:
90
+ * Added support for micronaut
91
+ * Generate nicer block variable names in Rakefile
92
+ * Cucumber generation now places steps in features/step_features, to follow cucumber standards
93
+
94
+ * shoulda and test/unit test_helpers no longer require mocha
95
+ * Rakefile uses more readable block variable names
96
+ * .gitignore now includes pkg and coverage directories
97
+ * Avoid puts'ing in Rakefile when LoadError occurs. Instead, define a task that aborts with instructions to install.
98
+ * Cucumber is now optional. Generate stories using --cucumber
99
+ * Bacon's 'test' task is now 'spec'
100
+ * Generate README.rdoc instead of just a plain text README
101
+ * Updated year in README.rdoc and COPYRIGHT to be based on the current year instead of hardcoded
102
+
103
+ # bueller 0.8.1 2009-02-03
104
+
105
+ * Fixed minitest generator
106
+
107
+ # bueller 0.8.0 2009-02-03
108
+
109
+ * Generator:
110
+ * Supports these new testing frameworks:
111
+ * test/unit
112
+ * minitest
113
+ * rspec
114
+ * Added support for cucumber
115
+ * Creating a new gem is now more verbose, and will show files/directories created
116
+ * Binaries will now be automatically detected in 'bin'
117
+
118
+ # bueller 0.7.2 2009-01-29
119
+
120
+ * Added rake task 'version:bump' which is shorthand for 'version:bump:patch'
121
+ * Generated projects no longer assume RCov is installed.
122
+
123
+ # bueller 0.7.1 2009-01-26
124
+
125
+ * Fixed yaml not being required
126
+ * Automatically add files in bin as executables in gemspec
127
+
128
+ # bueller 0.7.0 2009-01-19
129
+
130
+ * Added support to generator for specifying a description
131
+ * Condensed README.markdown to be less novel-like
132
+ * RDoc is now included in your gemspec
133
+ * Rescue errors that raise in the generator, and display better error message, and exit with a non-zero exit status
134
+
135
+ # bueller 0.6.5 2009-01-14
136
+
137
+ * `bueller --create-repo foo` now enables gem creation in addition to creating the repository
138
+
139
+ # bueller 0.6.4 2009-01-13
140
+
141
+ * 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,182 @@
1
+ # Bueller: Craft the absolute perfect RubyGem
2
+
3
+ Bueller 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
+ ## Quick Links
9
+
10
+ * [Wiki](http://wiki.github.com/dkastner/bueller)
11
+ * [Bugs](http://github.com/dkastner/bueller/issues)
12
+
13
+ ## Installing
14
+
15
+ # Install the gem:
16
+ gem install bueller
17
+
18
+ ## Using in an existing project
19
+
20
+ Since bueller uses your existing gemspec, simply add the bueller tasks to your Rakefile:
21
+
22
+ begin
23
+ require 'bueller'
24
+ Bueller::Tasks.new
25
+ rescue LoadError
26
+ puts "Bueller not available. Install it with: gem install bueller"
27
+ end
28
+
29
+ ## Using to start a new project
30
+
31
+ Bueller provides a generator. It requires you to [setup your name and email for git](http://help.github.com/git-email-settings/) and [your username and token for GitHub](http://github.com/guides/local-github-config).
32
+
33
+ bueller the-perfect-gem
34
+
35
+ This will prepare a project in the 'the-perfect-gem' directory, setup to use Bueller.
36
+
37
+ It supports a number of options. Here's a taste, but `bueller --help` will give you the most up-to-date listing:
38
+
39
+ * --create-repo: in addition to preparing a project, it create an repo up on GitHub and enable RubyGem generation
40
+ * --testunit: generate test_helper.rb and test ready for test/unit
41
+ * --minitest: generate test_helper.rb and test ready for minitest
42
+ * --shoulda: generate test_helper.rb and test ready for shoulda
43
+ * --rspec: generate spec_helper.rb and spec ready for rspec (this is the default)
44
+ * --bacon: generate spec_helper.rb and spec ready for bacon
45
+ * --gemcutter: setup releasing to gemcutter
46
+ * --rubyforge: setup releasing to rubyforge
47
+
48
+ ### Default options
49
+
50
+ Bueller respects the BUELLER_OPTS environment variable. Want to always use Test::Unit, and you're using bash? Add this to ~/.bashrc:
51
+
52
+ export BUELLER_OPTS="--testunit"
53
+
54
+ ## Gemspec
55
+
56
+ Bueller leaves the task of defining a clean gemspec to you. However, it does offer a method to bump version numbers via rake tasks.
57
+
58
+ rake version:bump:minor
59
+
60
+ When starting from scratch, bueller will create a skeleton gemspec for you.
61
+
62
+ ## Gem
63
+
64
+ Bueller gives you tasks for building and installing your gem.
65
+
66
+ rake install
67
+
68
+ To build the gem (which will end up in `pkg`), run:
69
+
70
+ rake build
71
+
72
+ To install the gem (and build if necessary), i.e. using gem install, run:
73
+
74
+ rake install
75
+
76
+ Note, this does not use `sudo` to install it, so if your ruby setup needs that, you should prefix it with sudo:
77
+
78
+ sudo rake install
79
+
80
+ ## Versioning
81
+
82
+ Bueller 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.
83
+
84
+ Initially, your project starts out at 0.0.0. Bueller provides Rake tasks for bumping the version:
85
+
86
+ rake version:bump:major
87
+ rake version:bump:minor
88
+ rake version:bump:patch
89
+
90
+ You can also programmatically set the version if you wish. Typically, you use this to have a module with the version info so clients can access it. The only downside here is you no longer can use the version:bump tasks.
91
+
92
+ Gem::Specification.new do |s|
93
+ s.version = MyProject::VERSION
94
+ # more stuff
95
+ end
96
+
97
+ ### Prerelease versioning
98
+
99
+ Major, minor, and patch versions have a distant cousin: build. You can use this to add an arbitrary (or you know, regular type) version. This is particularly useful for prereleases.
100
+
101
+ You have two ways of doing this:
102
+
103
+ * Use `version:write` and specify `BUILD=pre1`
104
+
105
+ Bueller does not provide a `version:bump:build` because the build version can really be anything, so it's hard to know what should be the next bump.
106
+
107
+ ## Releasing
108
+
109
+ Bueller handles releasing your gem into the wild:
110
+
111
+ rake release
112
+
113
+ It does the following for you:
114
+
115
+ * git pushes to origin/master branch
116
+ * git tags the version and pushes to the origin remote
117
+
118
+ As is though, it doesn't actually get your gem anywhere. To do that, you'll need to use rubyforge or gemcutter.
119
+
120
+ ### Releasing to Gemcutter
121
+
122
+ Bueller can also handle releasing to [Gemcutter](http://gemcutter.org). There are a few steps you need to do before doing any Gemcutter releases with Bueller:
123
+
124
+ * [Create an account on Gemcutter](http://gemcutter.org/sign_up)
125
+ * Install the Gemcutter gem: gem install gemcutter
126
+ * Run 'gem tumble' to set up RubyGems to use gemcutter as the default source if you haven't already
127
+ * Update your Rakefile to make an instance of `Bueller::GemcutterTasks`
128
+
129
+
130
+ A Rakefile setup for gemcutter would include something like this:
131
+
132
+ begin
133
+ require 'bueller'
134
+ Bueller::Tasks.new
135
+ Bueller::GemcutterTasks.new
136
+ rescue LoadError
137
+ puts "Bueller (or a dependency) not available. Install it with: gem install bueller"
138
+ end
139
+
140
+
141
+ After you have configured this, `rake release` will now also release to Gemcutter.
142
+
143
+ If you need to release it without the rest of the release task, you can run:
144
+
145
+ $ rake gemcutter:release
146
+
147
+ ### Releasing to RubyForge
148
+
149
+ Bueller can also handle releasing to [RubyForge](http://rubyforge.org). There are a few steps you need to do before doing any RubyForge releases with Bueller:
150
+
151
+ * [Create an account on RubyForge](http://rubyforge.org/account/register.php)
152
+ * Request a project on RubyForge.
153
+ * Install the RubyForge gem: gem install rubyforge
154
+ * Run 'rubyforge setup' and fill in your username and password for RubyForge
155
+ * Run 'rubyforge config' to pull down information about your projects
156
+ * Run 'rubyforge login' to make sure you are able to login
157
+ * In Bueller::Tasks, you must set `rubyforge_project` to the project you just created
158
+ * Add Bueller::RubyforgeTasks to bring in the appropriate tasks.
159
+ * Note, using `bueller --rubyforge` when generating the project does this for you automatically.
160
+
161
+ A gemspec setup for rubyforge would include something like this:
162
+
163
+ Gem::Specification.new do |s|
164
+ # ommitted for brevity
165
+ gemspec.rubyforge_project = 'the-perfect-gem' # This line would be new
166
+ end
167
+
168
+ Now you must initially create a 'package' for your gem in your RubyForge 'project':
169
+
170
+ $ rake rubyforge:setup
171
+
172
+ After you have configured this, `rake release` will now also release to RubyForge.
173
+
174
+ If you need to release it without the rest of the release task, you can run:
175
+
176
+ $ rake rubyforge:release
177
+
178
+ ## Development and Release Workflow
179
+
180
+ * Hack, commit, hack, commit, etc, etc
181
+ * `rake version:bump:patch release` to do the actual version bump and release
182
+ * Have a delicious beverage (I suggest port)
data/bin/bueller ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ require 'bueller/generator'
4
+
5
+ exit Bueller::Generator::Application.run!(*ARGV)
@@ -0,0 +1,50 @@
1
+ class Bueller
2
+ module Commands
3
+ class BuildGem
4
+ def self.run_for(bueller)
5
+ command = new bueller
6
+ command.run
7
+ command
8
+ end
9
+
10
+ attr_reader :bueller
11
+
12
+ def initialize(bueller)
13
+ @bueller = bueller
14
+ end
15
+
16
+ def base_dir
17
+ bueller.base_dir
18
+ end
19
+ def gemspec_helper
20
+ bueller.gemspec_helper
21
+ end
22
+ def version_helper
23
+ bueller.version_helper
24
+ end
25
+
26
+ def run
27
+ make_package_directory
28
+ move_gem_file
29
+ end
30
+
31
+ def pkg_dir
32
+ @pkg_dir ||= File.join(base_dir, 'pkg')
33
+ end
34
+
35
+ def make_package_directory
36
+ FileUtils.mkdir_p pkg_dir
37
+ end
38
+
39
+ def build_gem
40
+ Gem::Builder.new(gemspec_helper.spec).build
41
+ end
42
+
43
+ def move_gem_file
44
+ gem_file_name = build_gem
45
+ gem_file_path = File.join(base_dir, gem_file_name)
46
+ FileUtils.mv gem_file_path, pkg_dir
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,63 @@
1
+ class Bueller
2
+ module Commands
3
+ class GitTagRelease
4
+ def self.run_for(bueller)
5
+ command = new bueller
6
+ command.run
7
+ command
8
+ end
9
+
10
+ attr_accessor :repo, :output
11
+ attr_reader :bueller
12
+
13
+ def initialize(bueller, attributes = {})
14
+ self.output = $stdout
15
+ @bueller = bueller
16
+
17
+ attributes.each_pair do |key, value|
18
+ send("#{key}=", value)
19
+ end
20
+ end
21
+
22
+ def base_dir; bueller.base_dir; end
23
+ def version; bueller.version; end
24
+ def repo; bueller.repo; end
25
+
26
+ def run
27
+ raise "Hey buddy, try committing them files first" unless clean_staging_area?
28
+
29
+ repo.checkout('master')
30
+ repo.push
31
+
32
+ unless release_tagged?
33
+ output.puts "Tagging #{release_tag}"
34
+ repo.add_tag(release_tag)
35
+
36
+ output.puts "Pushing #{release_tag} to origin"
37
+ repo.push('origin', release_tag)
38
+ end
39
+ end
40
+
41
+ def clean_staging_area?
42
+ status.added.empty? && status.deleted.empty? && status.changed.empty?
43
+ end
44
+
45
+ def status
46
+ repo.status
47
+ end
48
+
49
+ def release_tag
50
+ "v#{version}"
51
+ end
52
+
53
+ def release_tagged?
54
+ begin
55
+ repo.tag(release_tag)
56
+ false
57
+ rescue
58
+ true
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end