gemesis 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +46 -7
  2. data/bin/collect_gems +48 -0
  3. data/lib/gemesis/rake.rb +44 -2
  4. metadata +12 -6
@@ -2,16 +2,55 @@
2
2
 
3
3
  This is a gem that provides some simple rake tasks for managing a rubygem.
4
4
 
5
- == usage
5
+ == creating a gem
6
+
7
+ === create a gem specification file called gemspec
8
+
9
+ For example:
10
+
11
+ Gem::Specification.new do |s|
12
+ s.name = 'gemesis'
13
+ s.version = '0.0.4'
14
+ s.summary = 'some lightweight utilities to assist in managing a rubygem'
15
+ s.authors << 'Mark Ryall'
16
+ s.email = 'mark@ryall.name'
17
+ s.homepage = %q{http://github.com/markryall/gemesis}
18
+ s.files = Dir['bin/*'] + Dir['lib/**/*'] + ['README.rdoc', 'MIT-LICENSE']
19
+ s.executables << 'collect_gems'
20
+ end
21
+
22
+ Make sure the version line is formatted as indicated - the major, minor and patch tasks will not work otherwise.
23
+
24
+ === initialise a git or mercurial repository
25
+
26
+ hg/git init
6
27
 
7
- Create a gem specification file called gemspec, initialise a git or mercurial repository and create Rakefile containing:
28
+ === create Rakefile
8
29
 
9
- <tt>
10
- require 'gemesis/rake'
11
- </tt>
30
+ require 'gemesis/rake'
12
31
 
13
- This will add five rake tasks in a gem namespace: push, build, install, uninstall and reinstall
32
+ == usage
33
+
34
+ This will add the following rake tasks in a gem namespace:
35
+
36
+ * release - push, then increments version in gemspec
37
+ * push - builds the gem, pushes to rubyforge and
38
+ * build - builds the gem file
39
+ * install - installs the gem file
40
+ * uninstall - uninstalls the gem
41
+ * reinstall - uninstalls and installs the gem
42
+ * major - increments the major version number
43
+ * minor - increments the minor version number
44
+ * patch - increments the patch number
14
45
 
15
46
  To run gem installation or uninstallation with sudo - set an environment variable SUDO to sudo
16
47
 
17
- Note that push will create a repository tag so it is recommended you increment the gem version and commit all changes prior to executing a push.
48
+ Note that push will create a repository tag so it is recommended you increment the gem version and commit all changes prior to executing a push.
49
+
50
+ Refer to http://semver.org/ for some sensible tips on versioning.
51
+
52
+ == collect_gems
53
+
54
+ If you checkout any gem that uses gemesis (or has a gem specification file caled gemspec), you can use the collect_gems executable to install all necessary runtime and development depencies.
55
+
56
+ collect_gems was completely stolen from http://github.com/mdub/gem_collector
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ module GemCollector
6
+ extend self
7
+
8
+ # Shadow Kernel#gem, extending it to auto-install missing gems
9
+ def gem(name, *version_requirements)
10
+ dependency = Gem::Dependency.new(name, *version_requirements)
11
+ if Gem.source_index.search(dependency).empty?
12
+ puts "Installing #{dependency}"
13
+ `gem install #{name} --version \"#{version_requirements.first}\"`
14
+ else
15
+ puts "#{dependency} is already installed"
16
+ end
17
+ end
18
+
19
+ def eval_block &block
20
+ instance_eval &block
21
+ end
22
+
23
+ def eval(*args)
24
+ instance_eval(*args)
25
+ end
26
+
27
+ def load(file)
28
+ puts "loading #{file}"
29
+ eval(File.read(file), file)
30
+ end
31
+ end
32
+
33
+ path = ARGV.shift
34
+ path ||= 'Gemfile'
35
+ if File.exist? path
36
+ puts "Loading dependencies specified in #{File.expand_path(path)}"
37
+ GemCollector.load path
38
+ else
39
+ puts "Did not find a file called #{path} to load"
40
+ end
41
+ if File.exist? 'gemspec'
42
+ puts "Loading dependencies specified in #{File.expand_path('gemspec')}"
43
+ Gem::Specification.load('gemspec').dependencies.each do |dep|
44
+ GemCollector.eval_block { gem dep.name, dep.requirement }
45
+ end
46
+ else
47
+ puts "Did not find a gemspec file to load"
48
+ end
@@ -3,7 +3,13 @@ namespace :gem do
3
3
  vcs = 'git' if File.exist?('.git')
4
4
  vcs = 'hg' if File.exist?('.hg')
5
5
 
6
- raise 'gemesis requires a git or mercurial repository' unless vcs
6
+ desc "release new #{spec.name} - push then increment patch"
7
+ task :release => [:push, :patch] do
8
+ if vcs
9
+ sh "#{vcs} add gemspec"
10
+ sh "#{vcs} commit -m \"bumped version for next release\""
11
+ end
12
+ end
7
13
 
8
14
  desc "push new #{spec.name} release and #{vcs} tag"
9
15
  task :push => :build do
@@ -28,4 +34,40 @@ namespace :gem do
28
34
 
29
35
  desc "reinstall #{spec.name} locally"
30
36
  task :reinstall => [:uninstall, :install]
31
- end
37
+
38
+ def bump
39
+ FileUtils.mv 'gemspec', 'gemspec.tmp'
40
+
41
+ File.open('gemspec','w') do |io_out|
42
+ File.open('gemspec.tmp') do |io_in|
43
+ io_in.each do |line|
44
+ line.chomp!
45
+ if line =~ /version = '(\d+)\.(\d+)\.(\d+)'/
46
+ versions = [$1.to_i,$2.to_i,$3.to_i]
47
+ yield versions
48
+ io_out.puts " s.version = '#{versions.join('.')}'"
49
+ else
50
+ io_out.puts line
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ FileUtils.rm 'gemspec.tmp'
57
+ end
58
+
59
+ desc "bump major version"
60
+ task :major do
61
+ bump {|versions| versions[0] += 1}
62
+ end
63
+
64
+ desc "bump minor version"
65
+ task :minor do
66
+ bump {|versions| versions[1] += 1}
67
+ end
68
+
69
+ desc "bump patch version"
70
+ task :patch do
71
+ bump {|versions| versions[2] += 1}
72
+ end
73
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemesis
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 3
9
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - Mark Ryall
@@ -14,19 +15,20 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-04-11 00:00:00 +10:00
18
+ date: 2010-10-24 00:00:00 +10:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
21
22
  description:
22
23
  email: mark@ryall.name
23
- executables: []
24
-
24
+ executables:
25
+ - collect_gems
25
26
  extensions: []
26
27
 
27
28
  extra_rdoc_files: []
28
29
 
29
30
  files:
31
+ - bin/collect_gems
30
32
  - lib/gemesis/rake.rb
31
33
  - README.rdoc
32
34
  - MIT-LICENSE
@@ -40,23 +42,27 @@ rdoc_options: []
40
42
  require_paths:
41
43
  - lib
42
44
  required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
43
46
  requirements:
44
47
  - - ">="
45
48
  - !ruby/object:Gem::Version
49
+ hash: 3
46
50
  segments:
47
51
  - 0
48
52
  version: "0"
49
53
  required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
50
55
  requirements:
51
56
  - - ">="
52
57
  - !ruby/object:Gem::Version
58
+ hash: 3
53
59
  segments:
54
60
  - 0
55
61
  version: "0"
56
62
  requirements: []
57
63
 
58
64
  rubyforge_project:
59
- rubygems_version: 1.3.6
65
+ rubygems_version: 1.3.7
60
66
  signing_key:
61
67
  specification_version: 3
62
68
  summary: some lightweight utilities to assist in managing a rubygem