gem-this 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
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.4"
23
+ s.version = "0.3.5"
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"
@@ -94,3 +94,8 @@ task :tag => [:gemspec, :package] do
94
94
  raise "Unstaged changes still waiting to be committed"
95
95
  end
96
96
  end
97
+
98
+ desc "Tag and publish the gem to rubygems.org"
99
+ task :publish => :tag do
100
+ `gem push pkg/#{spec.name}-#{spec.version}.gem`
101
+ end
data/Readme.markdown CHANGED
@@ -40,8 +40,6 @@ When you run `gem-this`, it will create a new `Rakefile` in your project directo
40
40
  rake rdoc # Build the rdoc HTML Files
41
41
  rake repackage # Force a rebuild of the package files
42
42
  rake rerdoc # Force a rebuild of the RDOC files
43
- rake rubyforge:release # Release gem and RDoc documentation to RubyForge
44
- rake rubyforge:release:docs # Publish RDoc to RubyForge.
45
43
 
46
44
 
47
45
  The simplest thing to do next is simply run `rake package`:
@@ -65,6 +63,37 @@ For the most part, `gem-this` simply sets up a good base for you to customise yo
65
63
  Don't worry; you'll be fine.
66
64
 
67
65
 
66
+ Advanced usage!
67
+ ---------------
68
+
69
+ If you have developed some custom tasks that you find yourself using again and again, and want them to be made available for any new gems you create, now you can! Just drop your tasks into `~/.gem-this`, and they will be automatically copied into any Rakefiles that gem-this generates.
70
+
71
+ For example, this is what is in *my* `.gem-this` file:
72
+
73
+ desc 'Tag the repository in git with gem version number'
74
+ task :tag => [:gemspec, :package] do
75
+ if `git diff --cached`.empty?
76
+ if `git tag`.split("\n").include?("v#{spec.version}")
77
+ raise "Version #{spec.version} has already been released"
78
+ end
79
+ `git add #{File.expand_path("../#{spec.name}.gemspec", __FILE__)}`
80
+ `git commit -m "Released version #{spec.version}"`
81
+ `git tag v#{spec.version}`
82
+ `git push --tags`
83
+ `git push`
84
+ else
85
+ raise "Unstaged changes still waiting to be committed"
86
+ end
87
+ end
88
+
89
+ desc "Tag and publish the gem to rubygems.org"
90
+ task :publish => :tag do
91
+ `gem push pkg/#{spec.name}-#{spec.version}.gem`
92
+ end
93
+
94
+ Your workflow is in your hands. Enjoy!
95
+
96
+
68
97
  Thanks
69
98
  ======
70
99
 
data/lib/gem_this.rb CHANGED
@@ -6,6 +6,11 @@ class GemThis
6
6
  SUMMARY = "Creates a Rakefile suitable for turning the current project into a gem."
7
7
  DEBUG_MESSAGE = "debug, only prints out the generated Rakefile."
8
8
 
9
+ class << self
10
+ attr_accessor :custom_task_file
11
+ end
12
+ self.custom_task_file = File.expand_path("~/.gem-this")
13
+
9
14
  attr_reader :name, :debug
10
15
 
11
16
  def initialize(name, options={})
@@ -18,6 +23,7 @@ class GemThis
18
23
  def create_rakefile
19
24
  template = ERB.new File.read(File.join(File.dirname(__FILE__), '..', 'Rakefile.erb')), nil, '<>'
20
25
  rakefile = template.result(binding)
26
+ rakefile += "\n" + File.read(self.class.custom_task_file) if File.exist?(self.class.custom_task_file)
21
27
 
22
28
  if debug
23
29
  puts rakefile
@@ -92,4 +92,22 @@ class GemThisTest < Test::Unit::TestCase
92
92
  end
93
93
  end
94
94
  end
95
+
96
+ context "When the user has a .gem-this file" do
97
+ setup do
98
+ create_gem_this_file %{
99
+ desc "Something for my gems"
100
+ task :custom_task do
101
+ end
102
+ }
103
+ build_gem do
104
+ touch "README"
105
+ touch "lib/thing.rb"
106
+ end
107
+ end
108
+
109
+ should "include custom tasks in the Rakefile" do
110
+ assert_rake_task :custom_task
111
+ end
112
+ end
95
113
  end
data/test/test_helper.rb CHANGED
@@ -59,11 +59,12 @@ class Test::Unit::TestCase
59
59
 
60
60
  def assert_rake_task(task)
61
61
  tasks = in_gem { `rake -T`.split("\n").map { |line| line.split[1] } }
62
- assert tasks.include?(task.to_s), tasks.inspect
62
+ assert tasks.include?(task.to_s), "#{tasks.inspect} did not include #{task}"
63
63
  end
64
64
 
65
65
  def assert_default_rake_task_dependencies_contains(task)
66
66
  in_gem {
67
+ load 'RakeFile'
67
68
  assert prerequisites_for('default').include?(task.to_s), prerequisites_for('default').inspect
68
69
  }
69
70
  end
@@ -77,8 +78,7 @@ class Test::Unit::TestCase
77
78
  def in_gem(&block)
78
79
  result = nil
79
80
  FileUtils.cd(@gem.gem_path) do
80
- load 'RakeFile'
81
- result = block.call
81
+ result = yield
82
82
  end
83
83
  result
84
84
  end
@@ -95,6 +95,13 @@ class Test::Unit::TestCase
95
95
  in_gem { YAML.load(`gem specification #{@gem.path_to_gem}`) }
96
96
  end
97
97
 
98
+ def create_gem_this_file(content)
99
+ t = Tempfile.new('gem-this-task-file')
100
+ t.puts content
101
+ t.close
102
+ GemThis.custom_task_file = t.path
103
+ end
104
+
98
105
  private
99
106
  def find_task(task_name)
100
107
  @tasks ||= Rake.application.tasks
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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
9
+ - 5
10
+ version: 0.3.5
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-19 00:00:00 +00:00
18
+ date: 2010-11-21 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency