tumbler 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  .bundle
2
- pkg/*
2
+ pkg/*
3
+ Gemfile.lock
data/CHANGELOG CHANGED
@@ -1,3 +1,31 @@
1
+ == 0.0.12
2
+
3
+ * Having a default require for the version file is probably a reasonable default. (Joshua Hull, 6afc0be)
4
+ * Remove spec completely and update rakefile (Arthur Chiu, a99fbb4)
5
+ * Converted version_test (Arthur Chiu, 2b6c300)
6
+ * Convert task_test (Arthur Chiu, 73ccc19)
7
+ * Updated teststrap and converted changelog_test (Arthur Chiu, a05e105)
8
+ * Merged in bin_tumbler tests into cli_test (Arthur Chiu, 016ee16)
9
+ * Generate test conversion (Arthur Chiu, 622a9cf)
10
+ * Converted updater_test (Arthur Chiu, 0548e72)
11
+ * Change to DotMatrix, addd gemspec test (Arthur Chiu, c50705c)
12
+ * Initial changes to riot (Arthur Chiu, 321683b)
13
+ * What did dev say to the cli options parser? you're such a thor. (Arthur Chiu, 0a428eb)
14
+ * Remove gemfile.lock (Arthur Chiu, 9c94f67)
15
+ * Added a section to readme to explain differences from Jeweler (I will flesh it out soon) (Nathan Esquenazi, 0bba249)
16
+ * Fixes summary and description to be different to prevent warning (Nathan Esquenazi, 9ea80a0)
17
+ * remove specification_version (set automatically when the gemspec is 'packaged') (Nathan Esquenazi, ad69939)
18
+ * Cleanup and refactor into a copy_template method (Nathan Esquenazi, e8e9033)
19
+ * Remove generate_xxx methods and render directly in write methods (Nathan Esquenazi, 759d0fe)
20
+ * Cleaned up spec. (Joshua Hull, 4231be6)
21
+ * Require version file by default (Joshua Hull, 6c599a9)
22
+ * Removed require in gem lib file (Arthur Chiu, d26adee)
23
+ * Added gem lib file (Arthur Chiu, a953012)
24
+ * Add test to check mygem directory and mygem.rb (Arthur Chiu, f4ee058)
25
+ * Use /test for spec files. (Joshua Hull, ef67ebd)
26
+ * Don't commit CHANGELOG after first part of two part deploy. (Joshua Hull, a0e96aa)
27
+ * Add correct summary/description to gem (Joshua Hull, 573ecf2)
28
+
1
29
  == 0.0.11
2
30
 
3
31
  * Use custom matcher for searching in file. (Joshua Hull, 8d16801)
data/Gemfile CHANGED
@@ -4,10 +4,12 @@ gem 'callsite'
4
4
  gem 'versionomy'
5
5
  gem 'bundler'
6
6
  gem 'json'
7
+ gem 'thor', :require => 'thor/group'
7
8
 
8
9
  group :development do
9
10
  gem 'rake'
10
- gem 'rspec'
11
+ gem 'riot'
11
12
  gem 'fakeweb'
12
13
  gem 'mocha'
14
+ gem 'blockenspiel'
13
15
  end
data/README.rdoc CHANGED
@@ -116,4 +116,8 @@ and that does it! Your gem is now released onto the world.
116
116
 
117
117
  == What's next?
118
118
 
119
- I'm sure there are bugs and other common workflows that I will add and/or document, but basically, I just wanna type a lot less when I bump a gem, and get more things done.
119
+ I'm sure there are bugs and other common workflows that I will add and/or document, but basically, I just wanna type a lot less when I bump a gem, and get more things done.
120
+
121
+ == How is this different from Jeweler?
122
+
123
+ Clearly worth explaining briefly how this gem differs from Jeweler to help people to understand why they might want to use this instead. Will flesh this section out very soon. Dynamic gemspec, better version practice, closer integration to git, et. al
data/Rakefile CHANGED
@@ -2,14 +2,13 @@ $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
2
2
  require 'tumbler'
3
3
  Tumbler.use_rake_tasks
4
4
 
5
- task 'tumbler:preflight' do
6
- Rake::Task["spec"].invoke
7
- end
5
+ # task 'tumbler:preflight' do
6
+ # Rake::Task["spec"].invoke
7
+ # end
8
8
 
9
- require 'spec'
10
- require 'spec/rake/spectask'
11
- Spec::Rake::SpecTask.new(:spec) do |t|
12
- t.spec_opts ||= []
13
- t.spec_opts << "--options" << "spec/spec.opts"
14
- t.spec_files = FileList['spec/**/*_spec.rb']
15
- end
9
+ require 'rake/testtask'
10
+ Rake::TestTask.new(:test) do |test|
11
+ test.libs << 'lib' << 'test'
12
+ test.pattern = 'test/**/*_test.rb'
13
+ test.verbose = true
14
+ end
data/Tumbler CHANGED
@@ -1,4 +1,3 @@
1
1
  gem_name 'tumbler'
2
-
3
2
  version_file 'lib/tumbler/version.rb'
4
3
  changelog_file 'CHANGELOG'
data/bin/tumbler CHANGED
@@ -1,8 +1,7 @@
1
- #!/usr/env ruby
1
+ #!/usr/bin/env ruby
2
2
 
3
3
  require 'fileutils'
4
-
5
4
  $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
6
5
  require 'tumbler'
7
6
 
8
- Tumbler::CLI.run(ARGV)
7
+ Tumbler::Cli.start(ARGV)
@@ -18,13 +18,8 @@ Gem::Specification.new do |s|
18
18
  s.require_paths = ["lib"]
19
19
  s.rubygems_version = %q{1.3.7}
20
20
  s.summary = %q{This is awesome.}
21
- s.test_files = `git ls-files spec`.split("\n")
21
+ s.test_files = Tumbler::Gemspec.files(/^test/)
22
22
 
23
23
  # dependencies
24
24
  Tumbler::Gemspec.inject_dependencies(s)
25
-
26
- if s.respond_to? :specification_version then
27
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
28
- s.specification_version = 3
29
- end
30
25
  end
@@ -0,0 +1,4 @@
1
+ require '<%= name %>/version'
2
+
3
+ module <%=constant_name %> #:nodoc
4
+ end
data/lib/tumbler/cli.rb CHANGED
@@ -1,69 +1,27 @@
1
- require 'optparse'
1
+ require 'thor/group'
2
2
 
3
3
  module Tumbler
4
- class CLI
5
- def self.run(args)
6
- CLI.new(args).run
7
- end
8
-
9
- def initialize(args)
10
- @options = {
11
- :changelog => Manager::Changelog::DEFAULT_FILE,
12
- }
13
- parser.parse!(args)
14
- end
15
-
16
- def parser
17
- OptionParser.new do |opts|
18
- opts.banner = "Usage: tumbler name [options]"
19
-
20
- opts.separator ""
21
- opts.separator "Options:"
22
-
23
- opts.on("-cVALUE", "--changelog=VALUE", "Set changelog file") do |v|
24
- @options[:changelog] = v
25
- end
26
-
27
- opts.on("-u", "--update", "Update existing application") do |v|
28
- @options[:update] = nil
29
- end
4
+ class Cli < Thor::Group
5
+ include Thor::Actions
30
6
 
31
- opts.on("-nc", "--no-changelog", "Disable changelog") do |v|
32
- @options[:changelog] = nil
33
- end
7
+ def self.banner; "tumbler name [options]"; end
34
8
 
35
- opts.on("-vVALUE", "--version=VALUE", "Set version file") do |v|
36
- @options[:version] = v
37
- end
9
+ desc "Generates a new gem project"
38
10
 
39
- opts.on("-nv", "--no-version", "Disable version") do |v|
40
- @options[:version] = nil
41
- end
11
+ argument :name, :desc => "name of your awesome gem"
42
12
 
43
- opts.on("-vNAME", "--name=NAME", "Set gem name") do |v|
44
- @options[:name] = v
45
- end
46
-
47
- opts.on_tail("-h", "--help", "Show this help message.") { puts opts; exit }
13
+ class_option :changelog, :desc => 'Set the CHANGELOG file', :aliases => '-c', :default => nil, :type => :string
14
+ class_option :update, :desc => 'Update existing application', :aliases => '-u', :default => false, :type => :boolean
15
+ class_option :version, :desc => 'Set the version number', :aliases => '-v', :default => nil, :type => :string
16
+ class_option :root, :desc => 'set root path', :aliases => '-r', :default => '.', :type => :string
17
+ def setup_gem
18
+ path = File.join options[:root], name
19
+ case
20
+ when options[:update] then Tumbler::Updater.new(path, options).update
21
+ when File.exist?(path) then raise("Directory path #{path} already exists!")
22
+ else FileUtils.mkdir_p(path) ; Tumbler::Generate.app(path, name, options).write
48
23
  end
24
+ say "Gem #{name} successfully generated!", :green
49
25
  end
50
-
51
- def run
52
- app_name = ARGV.first
53
-
54
- if app_name.nil?
55
- raise 'You must supply an application name.'
56
- elsif @options.key?(:update)
57
- Tumbler::Updater.new(app_name, @options).update
58
- elsif File.exist?(app_name)
59
- raise "There is already a directory named #{app_name}"
60
- else
61
- FileUtils.mkdir_p(app_name)
62
- Tumbler::Generate.app(app_name, app_name, @options).write
63
- end
64
-
65
- puts "Gem '#{app_name}' generated successfully!"
66
- end
67
-
68
26
  end
69
- end
27
+ end
@@ -24,7 +24,7 @@ module Tumbler
24
24
  generator
25
25
  end
26
26
 
27
- attr_reader :development_dependencies, :dependencies, :base
27
+ attr_reader :development_dependencies, :dependencies, :base, :name
28
28
  attr_accessor :version, :changelog
29
29
 
30
30
  def initialize(dir, name)
@@ -46,6 +46,7 @@ module Tumbler
46
46
  write_gemspec
47
47
  write_gemfile
48
48
  write_version(@version)
49
+ write_file
49
50
  write_changelog
50
51
  write_rakefile
51
52
  write_tumbler_config
@@ -63,38 +64,49 @@ module Tumbler
63
64
  def gemfile_file
64
65
  File.join(@base, 'Gemfile')
65
66
  end
67
+
68
+ def gemspec_file
69
+ File.join(@base, "#{@name}.gemspec")
70
+ end
66
71
 
67
72
  def config_file
68
73
  File.join(@base, 'Tumbler')
69
74
  end
70
75
 
71
- def write_version(version)
72
- FileUtils.mkdir_p(File.dirname(version_path))
73
- File.open(version_path, 'w') {|f| f << generate_version(version) }
74
- end
75
-
76
76
  def version_path
77
77
  File.join(@base, 'lib', @name, 'version.rb')
78
78
  end
79
79
 
80
- def write_gemfile
81
- File.open(gemfile_file, 'w') {|f| f << generate_gemfile }
80
+ def rb_path
81
+ File.join(@base, 'lib', "#{@name}.rb")
82
82
  end
83
-
83
+
84
+ def write_changelog
85
+ File.open(File.join(@base, @changelog), 'w') {|f| f << '' } if @changelog
86
+ end
87
+
84
88
  def write_rakefile
85
89
  FileUtils.cp(template_path('Rakefile'), @base)
86
90
  end
87
91
 
88
- def write_gemspec
89
- File.open(File.join(@base, "#{@name}.gemspec"), 'w') {|f| f << generate_gemspec }
92
+ def write_file
93
+ copy_template('generic.rb.erb', :to => rb_path)
94
+ end
95
+
96
+ def write_version(version)
97
+ copy_template('version.rb.erb', :to => version_path, :binding => binding)
90
98
  end
91
99
 
92
- def write_changelog
93
- File.open(File.join(@base, @changelog), 'w') {|f| f << '' } if @changelog
100
+ def write_gemfile
101
+ copy_template('Gemfile.erb', :to => gemfile_file)
102
+ end
103
+
104
+ def write_gemspec
105
+ copy_template('generic.gemspec.erb', :to => gemspec_file)
94
106
  end
95
107
 
96
108
  def write_tumbler_config
97
- File.open(config_file, 'w') {|f| f << generate_tumbler_conf}
109
+ copy_template('Tumbler.erb', :to => config_file)
98
110
  end
99
111
 
100
112
  def git_email
@@ -113,25 +125,12 @@ module Tumbler
113
125
  File.join(File.dirname(__FILE__), '..', 'template', path)
114
126
  end
115
127
 
116
- def generate_tumbler_conf
117
- render_erb('Tumbler.erb')
118
- end
119
-
120
- def generate_gemfile
121
- render_erb('Gemfile.erb')
122
- end
123
-
124
- def generate_version(version)
125
- render_erb('version.rb.erb', binding)
126
- end
127
-
128
- def generate_gemspec
129
- render_erb('generic.gemspec.erb')
130
- end
131
-
132
- def render_erb(file, local_binding=binding)
133
- template = ERB.new(File.read(template_path(file)), 0, '<>')
134
- template.result(local_binding)
128
+ # copy_template('generic.rb.erb', :to => '/path/to/file')
129
+ def copy_template(template_file, options={})
130
+ FileUtils.mkdir_p(File.dirname(options[:to]))
131
+ template = ERB.new(File.read(template_path(template_file)), 0, '<>')
132
+ contents = template.result(options[:binding] || binding)
133
+ File.open(options[:to], 'w') {|f| f << contents }
135
134
  end
136
135
  end
137
136
  end
@@ -70,13 +70,11 @@ module Tumbler
70
70
  guard_clean
71
71
  @changelog.update if @changelog
72
72
  bump(field)
73
- if @changelog
74
- @changelog.write_version_header
75
- @changelog.commit
76
- end
73
+ @changelog.write_version_header if @changelog
77
74
  end
78
75
 
79
76
  def tag_and_push
77
+ @changelog.commit if @changelog && !clean?
80
78
  guard_clean
81
79
  guard_already_tagged
82
80
  tag
@@ -1,3 +1,3 @@
1
1
  module Tumbler
2
- VERSION = '0.0.11'
2
+ VERSION = '0.0.12'
3
3
  end
@@ -0,0 +1,59 @@
1
+ require File.join(File.dirname(__FILE__),'teststrap')
2
+
3
+ context "Manager::Changelog" do
4
+ setup { $".delete "tumbler/gemspec.rb" }
5
+ teardown { $".delete "tumbler/gemspec.rb" } # we need to delete this so each gemspec can be generated fresh
6
+
7
+ context "generates changelog" do
8
+ setup { @tumbler, @dir, @test_dir = create_app('test') }
9
+ teardown { FileUtils.rm_rf @dir ; FileUtils.rm_rf @test_dir }
10
+ setup do
11
+ @tumbler.sh 'touch file1'
12
+ @tumbler.sh 'git add file1'
13
+ @tumbler.sh 'git commit file1 -m"added file1"'
14
+ @tumbler.sh 'touch file2'
15
+ @tumbler.sh 'git add file2'
16
+ @tumbler.sh 'git commit file2 -m"added file2"'
17
+ Tumbler::Gem.any_instance.stubs(:push).once.returns(true)
18
+ @tumbler.bump_and_push(:tiny)
19
+ @tumbler
20
+ end
21
+ asserts("correct version") { topic.version.to_s }.equals '0.0.1'
22
+ asserts("adds to changelog file") { File.read(topic.changelog.file) }.matches %r{== 0\.0\.1\s+\* added file2 \(.*?, [a-f0-9]{7}\)\s+\* added file1 \(.*?, [a-f0-9]{7}\)}
23
+ end
24
+
25
+ context "should not perform any changelog activity when the option isn't specified" do
26
+ setup { @tumbler, @dir, @test_dir = create_app('test', :changelog => nil) }
27
+ teardown { FileUtils.rm_rf @dir ; FileUtils.rm_rf @test_dir }
28
+ setup do
29
+ @tumbler.sh 'touch file1'
30
+ @tumbler.sh 'git add file1'
31
+ @tumbler.sh 'git commit file1 -m"added file1"'
32
+ @tumbler.sh 'touch file2'
33
+ @tumbler.sh 'git add file2'
34
+ @tumbler.sh 'git commit file2 -m"added file2"'
35
+ Tumbler::Gem.any_instance.stubs(:push).once.returns(true)
36
+ @tumbler.bump_and_push(:tiny)
37
+ @tumbler
38
+ end
39
+ asserts("correct version") { topic.version.to_s }.equals '0.0.1'
40
+ asserts("CHANGELOG exist") { File.exist?(File.join(topic.base, 'CHANGELOG')) }.not!
41
+ end
42
+
43
+ context "should rollback the entire set of commits when the remote is unreachable" do
44
+ setup { @tumbler, @dir, @test_dir = create_app('test', :changelog => nil,:remote => 'ssh://ijustmadethisupisadomain.com/what_you_say.git') }
45
+ teardown { FileUtils.rm_rf @dir ; FileUtils.rm_rf @test_dir }
46
+ setup do
47
+ @tumbler.sh 'touch file1'
48
+ @tumbler.sh 'git add file1'
49
+ @tumbler.sh 'git commit file1 -m"added file1"'
50
+ @tumbler.sh 'touch file2'
51
+ @tumbler.sh 'git add file2'
52
+ @tumbler.sh 'git commit file2 -m"added file2"'
53
+ @current_rev = @tumbler.current_revision
54
+ @tumbler
55
+ end
56
+ asserts("raises error") { topic.bump_and_push(:tiny) }.raises RuntimeError
57
+ asserts("commit revision") { @tumbler.sh('git log').split(/\n/)[0] == "commit #{@current_rev}" }
58
+ end
59
+ end
data/test/cli_test.rb ADDED
@@ -0,0 +1,68 @@
1
+ require File.join(File.dirname(__FILE__),'teststrap')
2
+
3
+ context "Cli" do
4
+ setup { @test_dir = temp_dir('test') }
5
+ setup { FileUtils.rm_rf @test_dir }
6
+ teardown { FileUtils.rm_rf @test_dir }
7
+
8
+ context "shows the help" do
9
+ setup { capture(:stdout) { Tumbler::Cli.start(['-h']) } }
10
+ asserts_topic.matches %r{tumbler name \[options\]}
11
+ asserts_topic.matches %r{Update existing application}
12
+ asserts_topic.matches %r{Set the version number}
13
+ asserts_topic.matches %r{Set the CHANGELOG file}
14
+ asserts_topic.matches %r{set root path}
15
+ end
16
+
17
+ context "generates" do
18
+ context "the app" do
19
+ setup do
20
+ capture(:stdout) { Tumbler::Cli.start(['test_gem',"-r=#{@test_dir}"]) }
21
+ Tumbler.load(File.join(@test_dir, 'test_gem'))
22
+ end
23
+ asserts("$?") { $? }.equals 0
24
+ asserts("version") { topic.version.to_s }.equals '0.0.0'
25
+ asserts("tumbler") { topic.bundler.dependencies.first.name }.equals 'tumbler'
26
+ asserts(">=0") { topic.bundler.dependencies.first.requirements_list }.equals ['>= 0']
27
+ asserts("development") { topic.bundler.dependencies.first.groups }.equals [:development]
28
+ end
29
+
30
+ context "at designated root" do
31
+ setup { capture(:stdout) { Tumbler::Cli.start(['agem', "-r=#{@test_dir}"]) } }
32
+ asserts_topic.matches %r{agem successfully generated!}
33
+ asserts("in the right path") { File.exists? File.join(@test_dir,'agem') }
34
+ end
35
+
36
+ end
37
+
38
+ context "upgrades" do
39
+ setup { capture(:stdout) { Tumbler::Cli.start(['rails', "-r=#{@test_dir}"]) } }
40
+
41
+ context "does nothing on a normal existing tumbler app" do
42
+ setup do
43
+ @tumbler = Tumbler.load(File.join(@test_dir, 'rails'))
44
+ @version = File.read @tumbler.version.file
45
+ @changelog = File.read @tumbler.changelog.file
46
+ @gemfile = File.read @tumbler.gemfile_path
47
+ @gemspec = File.read @tumbler.gemspec_path
48
+ end
49
+ setup { capture(:stdout) { Tumbler::Cli.start(['rails', '-u', "-r=#{@test_dir}"]) } }
50
+ asserts("$?") { $? }.equals 0
51
+ asserts("version") { File.read(@tumbler.version.file) == @version }
52
+ asserts("changelog") { File.read(@tumbler.changelog.file) == @changelog }
53
+ asserts("gemfile") { File.read(@tumbler.gemfile_path) == @gemfile }
54
+ asserts("gemspec") { File.read(@tumbler.gemspec_path) == @gemspec }
55
+ end
56
+
57
+ context "should not work if the directory and gemspec mismatch and you don't supply a name" do
58
+ setup do
59
+ FileUtils.mv("#{@test_dir}/rails/rails.gemspec", "#{@test_dir}/rails/notrails.gemspec")
60
+ end
61
+ asserts "exit status" do
62
+ capture(:stdout) { Tumbler::Cli.start(['rails', '-u',"-r=#{@test_dir}"]) }
63
+ end.raises RuntimeError
64
+ end
65
+ end
66
+
67
+
68
+ end