gem-this 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +8 -5
  2. data/lib/gem_this.rb +4 -2
  3. data/test/gem_this_test.rb +20 -0
  4. metadata +4 -4
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ spec = Gem::Specification.new do |s|
20
20
 
21
21
  # Change these as appropriate
22
22
  s.name = "gem-this"
23
- s.version = "0.3.5"
23
+ s.version = "0.3.6"
24
24
  s.summary = "Make existing code into a gem, without any fuss."
25
25
  s.author = "James Adam"
26
26
  s.email = "james@lazyatom.com"
@@ -80,18 +80,21 @@ task :clean => [:clobber_rdoc, :clobber_package] do
80
80
  end
81
81
 
82
82
  desc 'Tag the repository in git with gem version number'
83
- task :tag => [:gemspec, :package] do
84
- if `git diff --cached`.empty?
83
+ task :tag do
84
+ changed_files = `git diff --cached --name-only`.split("\n") + `git diff --name-only`.split("\n")
85
+ if changed_files == ['Rakefile']
86
+ Rake::Task["package"].invoke
87
+
85
88
  if `git tag`.split("\n").include?("v#{spec.version}")
86
89
  raise "Version #{spec.version} has already been released"
87
90
  end
88
- `git add #{File.expand_path("../#{spec.name}.gemspec", __FILE__)}`
91
+ `git add #{File.expand_path("../#{spec.name}.gemspec", __FILE__)} Rakefile`
89
92
  `git commit -m "Released version #{spec.version}"`
90
93
  `git tag v#{spec.version}`
91
94
  `git push --tags`
92
95
  `git push`
93
96
  else
94
- raise "Unstaged changes still waiting to be committed"
97
+ raise "Repository contains uncommitted changes; either commit or stash."
95
98
  end
96
99
  end
97
100
 
data/lib/gem_this.rb CHANGED
@@ -9,7 +9,7 @@ class GemThis
9
9
  class << self
10
10
  attr_accessor :custom_task_file
11
11
  end
12
- self.custom_task_file = File.expand_path("~/.gem-this")
12
+ self.custom_task_file = ENV['HOME'] && File.expand_path("~/.gem-this")
13
13
 
14
14
  attr_reader :name, :debug
15
15
 
@@ -23,7 +23,9 @@ class GemThis
23
23
  def create_rakefile
24
24
  template = ERB.new File.read(File.join(File.dirname(__FILE__), '..', 'Rakefile.erb')), nil, '<>'
25
25
  rakefile = template.result(binding)
26
- rakefile += "\n" + File.read(self.class.custom_task_file) if File.exist?(self.class.custom_task_file)
26
+ if self.class.custom_task_file && File.exist?(self.class.custom_task_file)
27
+ rakefile += "\n" + File.read(self.class.custom_task_file)
28
+ end
27
29
 
28
30
  if debug
29
31
  puts rakefile
@@ -110,4 +110,24 @@ end
110
110
  assert_rake_task :custom_task
111
111
  end
112
112
  end
113
+
114
+ context "When the user has no .gem-this file specified" do
115
+ setup do
116
+ GemThis.custom_task_file = nil
117
+ end
118
+
119
+ should "not raise exception when building gem" do
120
+ assert_nothing_raised { build_gem {} }
121
+ end
122
+ end
123
+
124
+ context "When the specified .gem-this file does not exist" do
125
+ setup do
126
+ GemThis.custom_task_file = "hopefully/this/file/doesnt/exist"
127
+ end
128
+
129
+ should "not raise exception when building gem" do
130
+ assert_nothing_raised { build_gem {} }
131
+ end
132
+ end
113
133
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-this
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 5
10
- version: 0.3.5
9
+ - 6
10
+ version: 0.3.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Adam
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-21 00:00:00 +00:00
18
+ date: 2011-01-16 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency