tumbler 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ == 0.0.15
2
+
3
+ * Nicer output for generation and updating (Joshua Hull, ef03bbe)
4
+ * Version constant can either be Version or VERSION (Joshua Hull, f5cf74e)
5
+ * Make automatic case first. (Joshua Hull, db6454d)
6
+ * Explain tumbler task namespacing (Joshua Hull, b39c0e2)
7
+ * Update description/summary. (Joshua Hull, a972fd1)
8
+ * Allow color to be enabled/disabled (Joshua Hull, 1e5f5ba)
9
+ * Add colorful output (Joshua Hull, d626d17)
10
+
1
11
  == 0.0.14
2
12
 
3
13
  * Remove sudo on gem install. You have to sudo it yourself if you want that behaviour. (Joshua Hull, 1a244cc)
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gem 'versionomy'
5
5
  gem 'bundler'
6
6
  gem 'json'
7
7
  gem 'thor', :require => 'thor/group'
8
+ gem 'rainbow'
8
9
 
9
10
  group :development do
10
11
  gem 'rake'
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Tumbler
2
2
 
3
- Let's make gem development fun and remove all the repetition! Tumbler provides support for common gem management tasks which helps you spend less time dealing with gem releases and more time focusing on your gem functionality!
3
+ Let's make gem development fun! Tumbler provides common gem management tasks using a common set of 'best practices' out of the box.
4
4
 
5
5
  == Gem Guidelines
6
6
 
@@ -27,7 +27,17 @@ This will generate a skeleton of your gem that you can then easily configure and
27
27
 
28
28
  If you have a pre-existing gem which could benefit from Tumbler, you have to a do a few things. Note that if you are generating a new gem using the tumbler command, this will be done for you automatically.
29
29
 
30
- For existing projects, you need to instruct Tumbler to manage the gem tasks. This is all handled by a file at the root of your project called <tt>Tumbler</tt>. A typical <tt>Tumbler</tt> file should look something like the following:
30
+ ==== Automatically
31
+
32
+ To automatically setup your project to use tumbler, simply execute:
33
+
34
+ tumbler . -u --name gem_name
35
+
36
+ From inside the gem's root directory and this will take care of all the details for you. When it's done updating your gem, review and commit the changes.
37
+
38
+ ==== Manually
39
+
40
+ Alternatively, for existing projects, you can set up all the bits needed to make Tumbler work with your gem. This is all handled by a file at the root of your project called <tt>Tumbler</tt>. A typical <tt>Tumbler</tt> file should look something like the following:
31
41
 
32
42
  # Names your gem
33
43
  gem_name 'my_awesome_gem'
@@ -40,7 +50,7 @@ For existing projects, you need to instruct Tumbler to manage the gem tasks. Thi
40
50
 
41
51
  Your version number can be anything parsable by Versionomy. The changelog will be automatically updated when a new version is released.
42
52
 
43
- The version file should have a constant <tt>VERSION</tt> which is set to the current version for your gem. A typical version file might look like the following:
53
+ The version file should have a constant <tt>VERSION</tt> or <tt>Version</tt> which is set to the current version for your gem. A typical version file might look like the following:
44
54
 
45
55
  # lib/awesome_gem/version.rb
46
56
  module AwesomeGem #:nodoc
@@ -52,11 +62,9 @@ Next, in your +Rakefile+, add the following to get access to Tumbler tasks:
52
62
  require 'tumbler'
53
63
  Tumbler.use_rake_tasks
54
64
 
55
- Alternatively, you can have Tumbler do all this work for you. If you install Tumbler into your system gems, you can simply execute:
65
+ If you'd prefer to have the tumbler tasks namespaced, provide use_rake_tasks with a string. For example:
56
66
 
57
- tumbler . -u --name gem_name
58
-
59
- From inside the gem's root directory and this will take care of all these details for you.
67
+ Tumbler.use_rake_tasks('tumbler')
60
68
 
61
69
  === Available Rake Tasks
62
70
 
@@ -88,12 +96,13 @@ If you do the following,
88
96
 
89
97
  you will bump the version, tag it in git, regenerate the changelog from your git commits and push the whole thing to rubygems and your remote.
90
98
 
91
- If you prefer you can do it in two steps (which give you a chance to edit the generated changelog)
99
+ If you prefer you can do it in two steps (which gives you a chance to edit the generated changelog)
92
100
 
93
101
  rake version:(tiny|minor|major):bump
94
- rake version:push
102
+
103
+ At this point, edit your changelog to reflect whatever comments or formatting you'd like. When you're done, run the following
95
104
 
96
- This will give you the chance to review the changelog and do anything else you'd like before taking the final release plunge.
105
+ rake version:push
97
106
 
98
107
  === Common Workflow
99
108
 
@@ -1,5 +1,7 @@
1
1
  gem_name <%= @name.inspect %>
2
2
 
3
+ use_color true
4
+
3
5
  <% if @version %>
4
6
  version_file 'lib/<%= @name %>/version.rb'
5
7
  <% end %>
data/lib/tumbler.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'callsite'
2
2
  require 'versionomy'
3
3
  require 'bundler'
4
+ require 'rainbow'
4
5
 
5
6
  Callsite.activate_kernel_dir_methods
6
7
 
@@ -5,6 +5,7 @@ module Tumbler
5
5
  class Generate
6
6
 
7
7
  include Runner
8
+ include Informer
8
9
 
9
10
  def self.app(dir, name, opts = {})
10
11
  generator = Generate.new(dir, name)
@@ -43,18 +44,21 @@ module Tumbler
43
44
  end
44
45
 
45
46
  def write
46
- write_gemspec
47
- write_gemfile
48
- write_version(@version)
49
- write_file
50
- write_changelog
51
- write_rakefile
52
- write_tumbler_config
53
- sh 'git init'
54
- initial_commit
47
+ inform "Generating gem #{name}" do
48
+ write_gemspec
49
+ write_gemfile
50
+ write_version(@version)
51
+ write_file
52
+ write_changelog
53
+ write_rakefile
54
+ write_tumbler_config
55
+ sh 'git init'
56
+ initial_commit
57
+ end
55
58
  end
56
59
 
57
60
  def initial_commit
61
+ inform "Performing initial commit"
58
62
  sh 'git init'
59
63
  sh 'git add .'
60
64
  sh 'git commit -a -m"Initial commit"'
@@ -82,10 +86,12 @@ module Tumbler
82
86
  end
83
87
 
84
88
  def write_changelog
89
+ inform "Writing changelog file"
85
90
  File.open(File.join(@base, @changelog), 'w') {|f| f << '' } if @changelog
86
91
  end
87
92
 
88
93
  def write_rakefile
94
+ inform "Writing Rakefile"
89
95
  FileUtils.cp(template_path('Rakefile'), @base)
90
96
  end
91
97
 
@@ -94,18 +100,22 @@ module Tumbler
94
100
  end
95
101
 
96
102
  def write_version(version)
103
+ inform "Writing version file"
97
104
  copy_template('version.rb.erb', :to => version_path, :binding => binding)
98
105
  end
99
106
 
100
107
  def write_gemfile
108
+ inform "Writing Gemfile"
101
109
  copy_template('Gemfile.erb', :to => gemfile_file)
102
110
  end
103
111
 
104
112
  def write_gemspec
113
+ inform "Writing #{name}.gemspec"
105
114
  copy_template('generic.gemspec.erb', :to => gemspec_file)
106
115
  end
107
116
 
108
117
  def write_tumbler_config
118
+ inform "Writing Tumbler config"
109
119
  copy_template('Tumbler.erb', :to => config_file)
110
120
  end
111
121
 
@@ -2,13 +2,16 @@ $informer_indent = 0
2
2
 
3
3
  module Tumbler
4
4
  module Informer
5
+
6
+ Colors = [:green, :cyan, :blue, :magenta]
7
+
5
8
  def inform(msg, &block)
6
- $stderr.puts (' ' * $informer_indent << msg)
9
+ $stderr.puts (' ' * $informer_indent << msg.color(Colors[$informer_indent % Colors.size]))
7
10
  $informer_indent += 1
8
11
  begin
9
12
  block.call if block
10
13
  rescue Exception
11
- $stderr.puts " #{msg} failed!"
14
+ $stderr.puts "#{msg} failed!".color(:red)
12
15
  raise
13
16
  ensure
14
17
  $informer_indent -= 1
@@ -51,6 +51,10 @@ module Tumbler
51
51
  @version
52
52
  end
53
53
 
54
+ def use_color(state = true)
55
+ Sickill::Rainbow.enabled = state
56
+ end
57
+
54
58
  def use_gem(&block)
55
59
  @gem.instance_eval(block)
56
60
  end
@@ -4,6 +4,9 @@ require 'json'
4
4
 
5
5
  module Tumbler
6
6
  class Updater
7
+
8
+ include Informer
9
+
7
10
  def initialize(dir, opts = nil)
8
11
  @dir = dir
9
12
  @name = opts && opts[:name] || File.basename(File.expand_path(dir))
@@ -11,56 +14,68 @@ module Tumbler
11
14
  end
12
15
 
13
16
  def update
14
- upgrade_deps
15
- upgrade_version
16
- upgrade_changelog
17
- upgrade_rakefile
18
- upgrade_tumbler_config
17
+ inform "Updating gem '#{@name}' at #{@dir}" do
18
+ upgrade_deps
19
+ upgrade_version
20
+ upgrade_changelog
21
+ upgrade_rakefile
22
+ upgrade_tumbler_config
23
+ end
19
24
  end
20
25
 
21
26
  def upgrade_tumbler_config
22
- unless File.exist?(tumbler_config_path)
23
- Tumbler::Generate.app(@dir, @name).write_tumbler_config
27
+ inform "Examining Tumbler config" do
28
+ unless File.exist?(tumbler_config_path)
29
+ Tumbler::Generate.app(@dir, @name).write_tumbler_config
30
+ end
24
31
  end
25
32
  end
26
33
 
27
34
  def upgrade_deps
28
- if File.exist?(gemfile_path)
29
- gemspec = File.read(gemspec_path)
30
- unless gemspec[/add_bundler_dependencies/] || gemspec[/inject_dependencies/]
31
- @tainted_gemspec = true
32
- File.open(gemspec_path, 'a') do |g|
33
- g << <<-HERE_DOC
34
- raise # (see below)
35
+ inform "Examining dependency management" do
36
+ if File.exist?(gemfile_path)
37
+ gemspec = File.read(gemspec_path)
38
+ unless gemspec[/add_bundler_dependencies/] || gemspec[/inject_dependencies/]
39
+ @tainted_gemspec = true
40
+ File.open(gemspec_path, 'a') do |g|
41
+ g << <<-HERE_DOC
42
+ raise # (see below)
35
43
 
36
- # You probably want to use inject the dependencies using either
37
- # add_bundler_depenedencies or Tumbler::Gemspec.inject_dependencies(spec) (where spec is your Gemspec)
38
- HERE_DOC
44
+ # You probably want to use inject the dependencies using either
45
+ # add_bundler_depenedencies or Tumbler::Gemspec.inject_dependencies(spec) (where spec is your Gemspec)
46
+ HERE_DOC
47
+ end
39
48
  end
40
49
  end
41
50
  end
42
51
  end
43
52
 
44
53
  def upgrade_version
45
- unless File.exists?(version_path)
46
- # go to rubygems and get it
47
- gem_data = JSON.parse(Net::HTTP.get(URI.parse("http://rubygems.org/api/v1/gems/#{URI.escape(@name)}.json")))
48
- version = gem_data['version']
49
- Tumbler::Generate.app(@dir, @name).write_version(version)
54
+ inform "Examining version tracking" do
55
+ unless File.exists?(version_path)
56
+ # go to rubygems and get it
57
+ gem_data = JSON.parse(Net::HTTP.get(URI.parse("http://rubygems.org/api/v1/gems/#{URI.escape(@name)}.json")))
58
+ version = gem_data['version']
59
+ Tumbler::Generate.app(@dir, @name).write_version(version)
60
+ end
50
61
  end
51
62
  end
52
63
 
53
64
  def upgrade_changelog
54
- unless File.exists?(changelog_path)
55
- Tumbler::Generate.app(@dir, @name).write_changelog
65
+ inform "Examining changelog" do
66
+ unless File.exists?(changelog_path)
67
+ Tumbler::Generate.app(@dir, @name).write_changelog
68
+ end
56
69
  end
57
70
  end
58
71
 
59
72
  def upgrade_rakefile
60
- create_rakefile and return if !File.exist?(rakefile_path)
61
- rakefile = File.read(rakefile_path)
62
- if rakefile !~ /Tumbler.use_rake_tasks/
63
- File.open(rakefile_path, 'a') {|f| f.puts "\n\n# automatically added Tumbler tasks\n\nrequire 'tumbler'\nTumbler.use_rake_tasks"}
73
+ inform "Examining Rakefile" do
74
+ create_rakefile and return if !File.exist?(rakefile_path)
75
+ rakefile = File.read(rakefile_path)
76
+ if rakefile !~ /Tumbler.use_rake_tasks/
77
+ File.open(rakefile_path, 'a') {|f| f.puts "\n\n# automatically added Tumbler tasks\n\nrequire 'tumbler'\nTumbler.use_rake_tasks"}
78
+ end
64
79
  end
65
80
  end
66
81
 
@@ -1,3 +1,3 @@
1
1
  module Tumbler
2
- VERSION = '0.0.14'
2
+ VERSION = '0.0.15'
3
3
  end
data/tumbler.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.rubyforge_project = Tumbler::Gemspec.name
11
11
  s.authors = ["Joshua Hull"]
12
12
  s.date = Tumbler::Gemspec.date
13
- s.description = "Let's make gem development fun and remove all the repetition! Tumbler provides support for common gem management tasks which helps you spend less time dealing with gem releases and more time focusing on your gem functionality!"
13
+ s.description = "Let's make gem development fun! Tumbler provides common gem management tasks using a common set of 'best practices' out of the box."
14
14
  s.summary = "Common gem generation and management tasks"
15
15
  s.email = %q{joshbuddy@gmail.com}
16
16
  s.extra_rdoc_files = Tumbler::Gemspec.files('README.rdoc')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tumbler
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 14
10
- version: 0.0.14
9
+ - 15
10
+ version: 0.0.15
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joshua Hull
@@ -100,8 +100,8 @@ dependencies:
100
100
  - 0
101
101
  version: "0"
102
102
  requirement: *id006
103
- type: :development
104
- name: rake
103
+ type: :runtime
104
+ name: rainbow
105
105
  - !ruby/object:Gem::Dependency
106
106
  prerelease: false
107
107
  version_requirements: &id007 !ruby/object:Gem::Requirement
@@ -115,7 +115,7 @@ dependencies:
115
115
  version: "0"
116
116
  requirement: *id007
117
117
  type: :development
118
- name: riot
118
+ name: rake
119
119
  - !ruby/object:Gem::Dependency
120
120
  prerelease: false
121
121
  version_requirements: &id008 !ruby/object:Gem::Requirement
@@ -129,7 +129,7 @@ dependencies:
129
129
  version: "0"
130
130
  requirement: *id008
131
131
  type: :development
132
- name: fakeweb
132
+ name: riot
133
133
  - !ruby/object:Gem::Dependency
134
134
  prerelease: false
135
135
  version_requirements: &id009 !ruby/object:Gem::Requirement
@@ -143,7 +143,7 @@ dependencies:
143
143
  version: "0"
144
144
  requirement: *id009
145
145
  type: :development
146
- name: mocha
146
+ name: fakeweb
147
147
  - !ruby/object:Gem::Dependency
148
148
  prerelease: false
149
149
  version_requirements: &id010 !ruby/object:Gem::Requirement
@@ -157,8 +157,22 @@ dependencies:
157
157
  version: "0"
158
158
  requirement: *id010
159
159
  type: :development
160
+ name: mocha
161
+ - !ruby/object:Gem::Dependency
162
+ prerelease: false
163
+ version_requirements: &id011 !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ hash: 3
169
+ segments:
170
+ - 0
171
+ version: "0"
172
+ requirement: *id011
173
+ type: :development
160
174
  name: blockenspiel
161
- description: Let's make gem development fun and remove all the repetition! Tumbler provides support for common gem management tasks which helps you spend less time dealing with gem releases and more time focusing on your gem functionality!
175
+ description: Let's make gem development fun! Tumbler provides common gem management tasks using a common set of 'best practices' out of the box.
162
176
  email: joshbuddy@gmail.com
163
177
  executables:
164
178
  - tumbler