tumbler 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.0.14
2
+
3
+ * Remove sudo on gem install. You have to sudo it yourself if you want that behaviour. (Joshua Hull, 1a244cc)
4
+ * More informative output (Joshua Hull, cb09263)
5
+
1
6
  == 0.0.13
2
7
 
3
8
  * Tidier pathing and building. (Joshua Hull, 21a9017)
@@ -6,6 +6,7 @@ Callsite.activate_kernel_dir_methods
6
6
 
7
7
  $LOAD_PATH << __DIR__
8
8
 
9
+ require 'tumbler/informer'
9
10
  require 'tumbler/runner'
10
11
  require 'tumbler/updater'
11
12
  require 'tumbler/rake_tasks'
@@ -1,7 +1,8 @@
1
1
  module Tumbler
2
2
  class Gem
3
3
  include Runner
4
-
4
+ include Informer
5
+
5
6
  def initialize(manager)
6
7
  @manager = manager
7
8
  end
@@ -20,12 +21,16 @@ module Tumbler
20
21
 
21
22
  def push
22
23
  build
23
- sh("gem push #{built_gem_path}")
24
+ inform "Pushing #{built_gem_path}" do
25
+ sh("gem push #{built_gem_path}")
26
+ end
24
27
  end
25
28
 
26
29
  def install
27
30
  build
28
- exec("sudo gem install #{built_gem_path}")
31
+ inform "Installing #{built_gem_path}" do
32
+ exec("gem install #{built_gem_path}")
33
+ end
29
34
  end
30
35
 
31
36
  def spec_path
@@ -33,11 +38,13 @@ module Tumbler
33
38
  end
34
39
 
35
40
  def build
36
- sh("bundle exec gem build #{spec_path}")
37
- Dir.chdir(base) {
38
- FileUtils.mkdir_p('pkg')
39
- FileUtils.mv(built_gem_base, 'pkg')
40
- }
41
+ inform "Building #{built_gem_path}" do
42
+ sh("bundle exec gem build #{spec_path}")
43
+ Dir.chdir(base) {
44
+ FileUtils.mkdir_p('pkg')
45
+ FileUtils.mv(built_gem_base, 'pkg')
46
+ }
47
+ end
41
48
  end
42
49
  end
43
50
  end
@@ -0,0 +1,18 @@
1
+ $informer_indent = 0
2
+
3
+ module Tumbler
4
+ module Informer
5
+ def inform(msg, &block)
6
+ $stderr.puts (' ' * $informer_indent << msg)
7
+ $informer_indent += 1
8
+ begin
9
+ block.call if block
10
+ rescue Exception
11
+ $stderr.puts " #{msg} failed!"
12
+ raise
13
+ ensure
14
+ $informer_indent -= 1
15
+ end
16
+ end
17
+ end
18
+ end
@@ -4,6 +4,7 @@ require 'tumbler/manager/version'
4
4
  module Tumbler
5
5
  class Manager
6
6
  include Runner
7
+ include Informer
7
8
 
8
9
  Change = Struct.new(:hash, :author, :summary)
9
10
 
@@ -68,25 +69,31 @@ module Tumbler
68
69
 
69
70
  def bump_and_commit(field)
70
71
  guard_clean
71
- @changelog.update if @changelog
72
- bump(field)
73
- @changelog.write_version_header if @changelog
72
+ inform "Bumping & committing" do
73
+ @changelog.update if @changelog
74
+ bump(field)
75
+ @changelog.write_version_header if @changelog
76
+ end
74
77
  end
75
78
 
76
79
  def tag_and_push
77
- @changelog.commit if @changelog && !clean?
78
- guard_clean
79
- guard_already_tagged
80
- tag
81
- push
82
- @gem.push
80
+ inform "Tagging & pushing" do
81
+ @changelog.commit if @changelog && !clean?
82
+ guard_clean
83
+ guard_already_tagged
84
+ tag
85
+ push
86
+ @gem.push
87
+ end
83
88
  end
84
89
 
85
90
  def bump_and_push(field)
86
- revert_on_error {
87
- bump_and_commit(field)
88
- tag_and_push
89
- }
91
+ inform "Bumping & pushing" do
92
+ revert_on_error do
93
+ bump_and_commit(field)
94
+ tag_and_push
95
+ end
96
+ end
90
97
  end
91
98
 
92
99
  def current_revision
@@ -98,6 +105,7 @@ module Tumbler
98
105
  begin
99
106
  yield
100
107
  rescue
108
+ inform "Undoing commit"
101
109
  sh "git reset --hard #{current_ref}"
102
110
  raise
103
111
  end
@@ -113,8 +121,10 @@ module Tumbler
113
121
 
114
122
  def bump(level)
115
123
  from = @version.to_s
116
- @version.bump(level)
117
- @version.commit(from)
124
+ inform "Bumping from #{from} by #{level}" do
125
+ @version.bump(level)
126
+ @version.commit(from)
127
+ end
118
128
  end
119
129
 
120
130
  def clean?
@@ -122,16 +132,16 @@ module Tumbler
122
132
  end
123
133
 
124
134
  def push
125
- sh "git push --all"
126
- sh "git push --tags"
135
+ inform "Pushing commit & tags" do
136
+ sh "git push --all"
137
+ sh "git push --tags"
138
+ end
127
139
  end
128
140
 
129
141
  def tag
130
- sh "git tag #{@version.to_s}"
131
- end
132
-
133
- def commit(msg)
134
- sh "git commit #{@version.basefile} -m'#{msg}'"
142
+ inform "Tagging version #{@version.to_s}" do
143
+ sh "git tag #{@version.to_s}"
144
+ end
135
145
  end
136
146
 
137
147
  def tags
@@ -5,6 +5,7 @@ module Tumbler
5
5
  class Manager
6
6
  class Changelog
7
7
  include Runner
8
+ include Informer
8
9
 
9
10
  DEFAULT_FILE = 'CHANGELOG'
10
11
 
@@ -21,12 +22,14 @@ module Tumbler
21
22
  end
22
23
 
23
24
  def write_version_header
24
- prepend "== #{@manager.version}\n\n"
25
+ inform "Writing version header to `#{@basefile}'" do
26
+ prepend "== #{@manager.version}\n\n"
27
+ end
25
28
  end
26
29
 
27
30
  def prepend(data)
28
31
  if @manager.noop
29
- @manager.dry "Prepending #{data} to #{@basefile}"
32
+ @manager.dry "Prepending #{data} to `#{@basefile}'"
30
33
  else
31
34
  Tempfile.open('changelog') do |tmp|
32
35
  tmp.puts data
@@ -44,8 +47,10 @@ module Tumbler
44
47
 
45
48
  def update
46
49
  ensure_existence
47
- prepend("\n")
48
- prepend(@manager.latest_changes.inject('') { |changes, change| changes << "* #{change.summary} (#{change.author}, #{change.hash})\n" })
50
+ inform "Updating `#{@basefile}' with latest changes" do
51
+ prepend("\n")
52
+ prepend(@manager.latest_changes.inject('') { |changes, change| changes << "* #{change.summary} (#{change.author}, #{change.hash})\n" })
53
+ end
49
54
  end
50
55
 
51
56
  def ensure_existence
@@ -2,6 +2,7 @@ module Tumbler
2
2
  class Manager
3
3
  class Version
4
4
  include Runner
5
+ include Informer
5
6
 
6
7
  attr_reader :file, :basefile, :field_names
7
8
 
@@ -45,17 +46,21 @@ module Tumbler
45
46
  end
46
47
 
47
48
  def bump(level)
48
- if @manager.noop
49
- @manager.dry "Bumping version to #{bump(level).to_s}"
50
- else
51
- new_file = generate_with_new(@version.bump(level).to_s)
52
- File.open(file, 'w') {|f| f << new_file }
53
- reload
49
+ inform "Bumping version to #{@version.bump(level).to_s}" do
50
+ if @manager.noop
51
+ @manager.dry "Bumping version to #{@version.bump(level).to_s}"
52
+ else
53
+ new_file = generate_with_new(@version.bump(level).to_s)
54
+ File.open(file, 'w') {|f| f << new_file }
55
+ reload
56
+ end
54
57
  end
55
58
  end
56
59
 
57
60
  def commit(from)
58
- sh "git commit #{@basefile} -m'Bumped version from #{from} to #{to_s}'"
61
+ inform "Committing version `#{@basefile}'" do
62
+ sh "git commit #{@basefile} -m'Bumped version from #{from} to #{to_s}'"
63
+ end
59
64
  end
60
65
 
61
66
  def base
@@ -1,3 +1,3 @@
1
1
  module Tumbler
2
- VERSION = '0.0.13'
2
+ VERSION = '0.0.14'
3
3
  end
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: 5
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 13
10
- version: 0.0.13
9
+ - 14
10
+ version: 0.0.14
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joshua Hull
@@ -186,6 +186,7 @@ files:
186
186
  - lib/tumbler/gemspec.rb
187
187
  - lib/tumbler/gemspec_helper.rb
188
188
  - lib/tumbler/generate.rb
189
+ - lib/tumbler/informer.rb
189
190
  - lib/tumbler/manager.rb
190
191
  - lib/tumbler/manager/changelog.rb
191
192
  - lib/tumbler/manager/version.rb