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,36 @@
1
+ class Bueller
2
+ module Commands
3
+ class InstallGem
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
+ bueller.output = $stdout
15
+ end
16
+
17
+ def output
18
+ bueller.output
19
+ end
20
+ def gemspec_helper
21
+ bueller.gemspec_helper
22
+ end
23
+
24
+ def run
25
+ command = "#{gem_command} install #{gemspec_helper.gem_path}"
26
+ output.puts "Executing #{command.inspect}:"
27
+
28
+ sh command
29
+ end
30
+
31
+ def gem_command
32
+ "bundle exec gem"
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,41 @@
1
+ class Bueller
2
+ module Commands
3
+ class ReleaseToGithub
4
+ def self.run_for(bueller, attributes = {})
5
+ command = new bueller, attributes
6
+ command.run
7
+ command
8
+ end
9
+
10
+ attr_accessor :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
+
31
+ output.puts "Pushing master to origin"
32
+ repo.push
33
+ end
34
+
35
+ def clean_staging_area?
36
+ status = repo.status
37
+ status.added.empty? && status.deleted.empty? && status.changed.empty?
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,26 @@
1
+ class Bueller
2
+ module Commands
3
+ class ReleaseToRubygems
4
+ attr_reader :bueller
5
+
6
+ def initialize(bueller)
7
+ @bueller = bueller
8
+ end
9
+
10
+ def gemspec_helper; bueller.gemspec_helper; end
11
+ def version; bueller.version; end
12
+
13
+ def run
14
+ command = "gem push #{gemspec_helper.gem_path}"
15
+ $stdout.puts "Executing #{command.inspect}:"
16
+ sh command
17
+ end
18
+
19
+ def self.run_for(bueller)
20
+ command = new bueller
21
+ command.run
22
+ command
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,36 @@
1
+ require 'pathname'
2
+
3
+ class Bueller
4
+ module Commands
5
+ module Version
6
+ class Base
7
+ def self.run_for(bueller)
8
+ command = new bueller
9
+ command.run
10
+ command
11
+ end
12
+
13
+ attr_accessor :version_helper, :gemspec
14
+ attr_reader :bueller
15
+
16
+ def initialize(bueller)
17
+ @bueller = bueller
18
+ end
19
+
20
+ def version_helper; bueller.version_helper; end
21
+ def gemspec_helper; bueller.gemspec_helper; end
22
+
23
+ def run
24
+ update_version
25
+
26
+ gemspec_helper.update_version version_helper.to_s
27
+ gemspec_helper.write
28
+ end
29
+
30
+ def update_version
31
+ raise "Subclasses should implement this"
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,11 @@
1
+ class Bueller
2
+ module Commands
3
+ module Version
4
+ class BumpMajor < Base
5
+ def update_version
6
+ version_helper.bump_major
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ class Bueller
2
+ module Commands
3
+ module Version
4
+ class BumpMinor < Base
5
+
6
+ def update_version
7
+ self.version_helper.bump_minor
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ class Bueller
2
+ module Commands
3
+ module Version
4
+ class BumpPatch < Base
5
+
6
+ def update_version
7
+ self.version_helper.bump_patch
8
+ end
9
+
10
+ end
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,21 @@
1
+ class Bueller
2
+ module Commands
3
+ module Version
4
+ class Write < Base
5
+ def self.run_for(bueller, major, minor, patch, build)
6
+ command = new bueller
7
+ command.major = major
8
+ command.minor = minor
9
+ command.patch = patch
10
+ command.build = build
11
+ command.run
12
+ end
13
+
14
+ attr_accessor :major, :minor, :patch, :build
15
+ def update_version
16
+ version_helper.update_to major, minor, patch, build
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ class Bueller
2
+ module Commands
3
+ class WriteGemspec
4
+ attr_accessor :base_dir, :output, :gemspec_helper, :version_helper
5
+
6
+ def initialize(bueller)
7
+ self.output = $stdout
8
+ self.base_dir = bueller.base_dir
9
+ self.output = bueller.output
10
+ self.gemspec_helper = bueller.gemspec_helper
11
+ self.version_helper = bueller.version_helper
12
+ end
13
+
14
+ def run
15
+ gemspec_helper.update_version version_helper.to_s
16
+ gemspec_helper.set_date
17
+ gemspec_helper.write
18
+
19
+ output.puts "Generated: #{gemspec_helper.path}"
20
+ end
21
+
22
+ def self.run_for(bueller)
23
+ command = new(bueller)
24
+ command.run
25
+ command
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ class Bueller
2
+ module Commands
3
+ autoload :BuildGem, 'bueller/commands/build_gem'
4
+ autoload :InstallGem, 'bueller/commands/install_gem'
5
+ autoload :GitTagRelease, 'bueller/commands/git_tag_release'
6
+ autoload :ReleaseToGithub, 'bueller/commands/release_to_github'
7
+ autoload :ReleaseToRubygems, 'bueller/commands/release_to_rubygems'
8
+ autoload :WriteGemspec, 'bueller/commands/write_gemspec'
9
+
10
+ module Version
11
+ autoload :Base, 'bueller/commands/version/base'
12
+ autoload :BumpMajor, 'bueller/commands/version/bump_major'
13
+ autoload :BumpMinor, 'bueller/commands/version/bump_minor'
14
+ autoload :BumpPatch, 'bueller/commands/version/bump_patch'
15
+ autoload :Write, 'bueller/commands/version/write'
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ class Bueller
2
+ # Gemspec related error
3
+ class GemspecError < StandardError
4
+ end
5
+
6
+ class VersionYmlError < StandardError
7
+ end
8
+ end
@@ -0,0 +1,83 @@
1
+ class Bueller
2
+ class GemSpecHelper
3
+ class VersionMissing < StandardError; end
4
+ class NoGemspecFound < StandardError; end
5
+
6
+ attr_accessor :spec, :spec_source, :base_dir, :errors
7
+
8
+ def errors
9
+ @errors ||= []
10
+ end
11
+
12
+ def initialize(base_dir = nil)
13
+ self.base_dir = base_dir || ''
14
+ end
15
+
16
+ def valid?
17
+ begin
18
+ reload_spec
19
+ spec
20
+ rescue => e
21
+ errors << "could not eval gemspec: #{e}"
22
+ return false
23
+ end
24
+
25
+ begin
26
+ spec.validate
27
+ rescue => e
28
+ errors << "gemspec is invalid: #{e}"
29
+ return false
30
+ end
31
+
32
+ true
33
+ end
34
+
35
+ def write
36
+ File.open(path, 'w') do |f|
37
+ f.puts spec_source
38
+ end
39
+ end
40
+
41
+ def path
42
+ denormalized_path = Dir.glob(File.join(base_dir, '*.gemspec')).first
43
+ raise NoGemspecFound, "No gemspec found in #{base_dir}" if denormalized_path.nil?
44
+ absolute_path = File.expand_path(denormalized_path)
45
+ absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
46
+ end
47
+
48
+ def spec_source
49
+ @spec_source ||= File.read(path)
50
+ end
51
+
52
+ def reload_spec
53
+ @spec = nil
54
+ end
55
+
56
+ def spec
57
+ @spec ||= eval(spec_source)
58
+ end
59
+
60
+ def gem_path
61
+ File.join(base_dir, 'pkg', spec.file_name)
62
+ end
63
+
64
+ def update_version(version)
65
+ raise VersionMissing unless has_version?
66
+ spec_source.sub! /\.version\s*=\s*.*/, %Q{.version = "#{version}"}
67
+ reload_spec
68
+ end
69
+
70
+ def set_date
71
+ spec_source.sub! /\.date\s*=\s*.*/, %Q{.date = "#{Time.now.strftime('%Y-%m-%d')}"}
72
+ reload_spec
73
+ end
74
+
75
+ def has_version?
76
+ !spec.version.nil?
77
+ end
78
+
79
+ def version
80
+ spec.version
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,51 @@
1
+ class Bueller
2
+ class Generator
3
+ class Application
4
+ class << self
5
+ def run!(*arguments)
6
+ env_opts = if ENV['BUELLER_OPTS']
7
+ Bueller::Generator::Options.new(ENV['BUELLER_OPTS'].split(' '))
8
+ end
9
+ options = Bueller::Generator::Options.new(arguments)
10
+ options = options.merge(env_opts) if env_opts
11
+
12
+ if options[:invalid_argument]
13
+ $stderr.puts options[:invalid_argument]
14
+ options[:show_help] = true
15
+ end
16
+
17
+ if options[:show_help]
18
+ $stderr.puts options.opts
19
+ return 1
20
+ end
21
+
22
+ if options[:project_name].nil? || options[:project_name].squeeze.strip == ""
23
+ $stderr.puts options.opts
24
+ return 1
25
+ end
26
+
27
+ begin
28
+ Bueller::Generator.run(options)
29
+ return 0
30
+ rescue Bueller::NoGitUserName
31
+ $stderr.puts %Q{No user.name found in ~/.gitconfig. Please tell git about yourself (see http://help.github.com/git-email-settings/ for details). For example: git config --global user.name "mad voo"}
32
+ return 1
33
+ rescue Bueller::NoGitUserEmail
34
+ $stderr.puts %Q{No user.email found in ~/.gitconfig. Please tell git about yourself (see http://help.github.com/git-email-settings/ for details). For example: git config --global user.email mad.vooo@gmail.com}
35
+ return 1
36
+ rescue Bueller::NoGitHubUser
37
+ $stderr.puts %Q{No github.user found in ~/.gitconfig. Please tell git about your GitHub account (see http://github.com/blog/180-local-github-config for details). For example: git config --global github.user defunkt}
38
+ return 1
39
+ rescue Bueller::NoGitHubToken
40
+ $stderr.puts %Q{No github.token found in ~/.gitconfig. Please tell git about your GitHub account (see http://github.com/blog/180-local-github-config for details). For example: git config --global github.token 6ef8395fecf207165f1a82178ae1b984}
41
+ return 1
42
+ rescue Bueller::FileInTheWay
43
+ $stderr.puts "The directory #{options[:project_name]} already exists. Maybe move it out of the way before continuing?"
44
+ return 1
45
+ end
46
+ end
47
+ end
48
+
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,43 @@
1
+ class Bueller
2
+ class Generator
3
+ module BaconMixin
4
+
5
+ def self.extended(generator)
6
+ generator.development_dependencies << 'bacon'
7
+ end
8
+
9
+ def default_task
10
+ 'spec'
11
+ end
12
+
13
+ def feature_support_require
14
+ 'test/unit/assertions'
15
+ end
16
+
17
+ def feature_support_extend
18
+ 'Test::Unit::Assertions' # NOTE can't use bacon inside of cucumber actually
19
+ end
20
+
21
+ def test_dir
22
+ 'spec'
23
+ end
24
+
25
+ def test_task
26
+ 'spec'
27
+ end
28
+
29
+ def test_pattern
30
+ 'spec/**/*_spec.rb'
31
+ end
32
+
33
+ def test_filename
34
+ "#{require_name}_spec.rb"
35
+ end
36
+
37
+ def test_helper_filename
38
+ "spec_helper.rb"
39
+ end
40
+
41
+ end
42
+ end
43
+ end