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 +10 -0
- data/Gemfile +1 -0
- data/README.rdoc +19 -10
- data/lib/template/Tumbler.erb +2 -0
- data/lib/tumbler.rb +1 -0
- data/lib/tumbler/generate.rb +19 -9
- data/lib/tumbler/informer.rb +5 -2
- data/lib/tumbler/manager.rb +4 -0
- data/lib/tumbler/updater.rb +43 -28
- data/lib/tumbler/version.rb +1 -1
- data/tumbler.gemspec +1 -1
- metadata +23 -9
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
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Tumbler
|
2
2
|
|
3
|
-
Let's make gem development fun
|
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
|
-
|
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
|
-
|
65
|
+
If you'd prefer to have the tumbler tasks namespaced, provide use_rake_tasks with a string. For example:
|
56
66
|
|
57
|
-
tumbler
|
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
|
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
|
-
|
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
|
-
|
105
|
+
rake version:push
|
97
106
|
|
98
107
|
=== Common Workflow
|
99
108
|
|
data/lib/template/Tumbler.erb
CHANGED
data/lib/tumbler.rb
CHANGED
data/lib/tumbler/generate.rb
CHANGED
@@ -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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
|
data/lib/tumbler/informer.rb
CHANGED
@@ -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 "
|
14
|
+
$stderr.puts "#{msg} failed!".color(:red)
|
12
15
|
raise
|
13
16
|
ensure
|
14
17
|
$informer_indent -= 1
|
data/lib/tumbler/manager.rb
CHANGED
data/lib/tumbler/updater.rb
CHANGED
@@ -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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
23
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
55
|
-
|
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
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
|
data/lib/tumbler/version.rb
CHANGED
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
|
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:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
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: :
|
104
|
-
name:
|
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:
|
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:
|
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:
|
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
|
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
|