sr-mg 0.0.1 → 0.0.2

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.mkd +51 -0
  2. data/lib/mg.rb +38 -32
  3. data/test/mg_test.rb +13 -12
  4. metadata +4 -3
@@ -0,0 +1,51 @@
1
+ mg
2
+ ==
3
+
4
+ A a minimalist way to create [gems](http://rubygems.org) and publish
5
+ them to [Rubyforge](http://rubyforge.org) using
6
+ [Rake](http://rake.rubyforge.org).
7
+
8
+ Usage
9
+ -----
10
+
11
+ In your Rakefile:
12
+
13
+ require "mg"
14
+
15
+ MG.new("foo.gemspec")
16
+
17
+ The following tasks are now available:
18
+
19
+ rake install
20
+ Build and install as local gem
21
+
22
+ rake package
23
+ Build gem tarball into dist/
24
+
25
+ rake rubyforge
26
+ Publish the current release on Rubyforge
27
+
28
+ rake rubyforge:gem
29
+ Publish gem and tarball to rubyforge
30
+
31
+ rake rubyforge:git
32
+ Push to gitosis@rubyforge.org:foo.git
33
+
34
+ Licence
35
+ -------
36
+
37
+ Written by [Ryan Tomayko](http://tomayko.com/about), extracted
38
+ by [Simon Rozet](http://atonie.org).
39
+
40
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
41
+ Version 2, December 2004
42
+
43
+ Copyright (C) 2009 Ryan Tomayko and Simon Rozet
44
+ Everyone is permitted to copy and distribute verbatim or modified
45
+ copies of this license document, and changing it is allowed as long
46
+ as the name is changed.
47
+
48
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
49
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
50
+
51
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
data/lib/mg.rb CHANGED
@@ -11,22 +11,26 @@ class MG < Rake::TaskLib
11
11
  define_tasks
12
12
  end
13
13
 
14
- private
15
- # Load the gemspec using the same limitations as github
16
- def spec
17
- @spec ||= begin
18
- require "rubygems/specification"
19
- data = File.read(gemspec)
20
- spec = nil
21
- Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
22
- spec
23
- end
24
- end
14
+ def name
15
+ spec.name
16
+ end
17
+
18
+ def group
19
+ spec.rubyforge_project
20
+ end
25
21
 
26
- def name
27
- spec.name
22
+ # Load the gemspec using the same limitations as github
23
+ def spec
24
+ @spec ||= begin
25
+ require "rubygems/specification"
26
+ data = File.read(gemspec)
27
+ spec = nil
28
+ Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
29
+ spec
28
30
  end
31
+ end
29
32
 
33
+ private
30
34
  def package(ext="")
31
35
  "dist/#{spec.name}-#{spec.version}" + ext
32
36
  end
@@ -40,25 +44,6 @@ class MG < Rake::TaskLib
40
44
  sh "gem install #{package(".gem")}"
41
45
  end
42
46
 
43
- desc "Publish the current release on Rubyforge"
44
- task :rubyforge => ["rubyforge:gem", "rubyforge:tarball", "rubyforge:git"]
45
-
46
- namespace :rubyforge do
47
- desc "Publish gem and tarball to rubyforge"
48
- task :gem => package(".gem") do
49
- sh "rubyforge add_release #{name} #{name} #{spec.version} #{package('.gem')}"
50
- end
51
-
52
- task :tarball => package(".tar.gz") do
53
- sh "rubyforge add_file #{name} #{name} #{spec.version} #{package('.tar.gz')}"
54
- end
55
-
56
- desc "Push to gitosis@rubyforge.org:#{name}.git"
57
- task :git do
58
- sh "git push gitosis@rubyforge.org:#{name}.git master"
59
- end
60
- end
61
-
62
47
  desc "Build gem tarball into dist/"
63
48
  task :package => %w(.gem .tar.gz).map { |ext| package(ext) }
64
49
 
@@ -75,5 +60,26 @@ class MG < Rake::TaskLib
75
60
  sh "gem build #{name}.gemspec"
76
61
  mv File.basename(f.name), f.name
77
62
  end
63
+
64
+ if group
65
+ desc "Publish the current release on Rubyforge"
66
+ task :rubyforge => ["rubyforge:gem", "rubyforge:tarball", "rubyforge:git"]
67
+
68
+ namespace :rubyforge do
69
+ desc "Publish gem and tarball to rubyforge"
70
+ task :gem => package(".gem") do
71
+ sh "rubyforge add_release #{group} #{name} #{spec.version} #{package('.gem')}"
72
+ end
73
+
74
+ task :tarball => package(".tar.gz") do
75
+ sh "rubyforge add_file #{group} #{name} #{spec.version} #{package('.tar.gz')}"
76
+ end
77
+
78
+ desc "Push to gitosis@rubyforge.org:#{name}.git"
79
+ task :git do
80
+ sh "git push gitosis@rubyforge.org:#{name}.git master"
81
+ end
82
+ end
83
+ end
78
84
  end
79
85
  end
@@ -2,25 +2,26 @@ require "test/unit"
2
2
  require File.dirname(__FILE__) + "/../lib/mg"
3
3
 
4
4
  class MGTest < Test::Unit::TestCase
5
- include Rake
6
-
7
5
  def setup
8
- @mg = MG.new(File.dirname(__FILE__) + "/../mg.gemspec")
6
+ MG.new(File.dirname(__FILE__) + "/../mg.gemspec")
9
7
  end
10
8
 
11
9
  def test_tasks
12
- assert_task_defined :install
13
- assert_task_defined :rubyforge
14
- assert_task_defined :package
15
- assert_task_defined "dist/mg-0.0.1.gem"
16
- assert_task_defined "dist/mg-0.0.1.tar.gz"
10
+ assert task_defined?(:install)
11
+ assert task_defined?(:package)
12
+ assert task_defined?("dist/mg-0.0.2.gem")
13
+ assert task_defined?("dist/mg-0.0.2.tar.gz")
14
+ assert ! task_defined?(:rubyforge)
15
+ end
17
16
 
18
- assert_equal ["rubyforge:gem", "rubyforge:tarball", "rubyforge:git"],
19
- Task["rubyforge"].prerequisites
17
+ def test_with_rubyforge_project
18
+ # TODO assert_task_defined :rubyforge
19
+ # TODO assert_equal ["rubyforge:gem", "rubyforge:tarball", "rubyforge:git"],
20
+ # TODO Rake::Task["rubyforge"].prerequisites
20
21
  end
21
22
 
22
23
  private
23
- def assert_task_defined(task_name)
24
- assert Task.task_defined?(task_name)
24
+ def task_defined?(task_name)
25
+ Rake::Task.task_defined?(task_name)
25
26
  end
26
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sr-mg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Rozet
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-16 00:00:00 -07:00
12
+ date: 2009-03-18 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -31,6 +31,7 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
 
33
33
  files:
34
+ - README.mkd
34
35
  - lib/mg.rb
35
36
  - test/mg_test.rb
36
37
  has_rdoc: false
@@ -58,6 +59,6 @@ rubyforge_project:
58
59
  rubygems_version: 1.2.0
59
60
  signing_key:
60
61
  specification_version: 2
61
- summary: Minimalistic Gem
62
+ summary: Minimalist Gem
62
63
  test_files:
63
64
  - test/mg_test.rb