ritual 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.2.0 2011-02-08
2
+
3
+ * Extension support.
4
+
1
5
  == 0.1.1 2011-01-21
2
6
 
3
7
  * Support custom code in version file. Only the "VERSION =" line is
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 George Ogata
1
+ Copyright (c) George Ogata
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.markdown CHANGED
@@ -1,48 +1,110 @@
1
1
  # Ritual
2
2
 
3
- Adds tasks and helpers to your Rakefile to manage releases.
3
+ Sweet, simple Rakefiles for your gem.
4
4
 
5
- Much more lightweight than [Jeweler][jeweler] or [Newgem][newgem]. Way less
6
- flexible, as it's only geared towards my workflow so far.
5
+ Picks up where Bundler leaves off, reducing the entire release ritual
6
+ to a single command.
7
7
 
8
- Like the idea? Feel free to fork and send patches!
8
+ ## Example
9
9
 
10
- [jeweler]: http://github.com/technicalpickles/jeweler
11
- [newgem]: http://github.com/drnic/newgem
10
+ For a plain ruby gem (no extensions), this is usually enough for your
11
+ `Rakefile`:
12
12
 
13
- ## Usage
13
+ require 'ritual'
14
14
 
15
- In `Rakefile`:
15
+ To release a new patch version of your gem:
16
16
 
17
- gem 'ritual'
18
- require 'ritual'
17
+ rake patch release
18
+
19
+ The `release` task just runs these tasks:
20
+
21
+ rake repo:bump # Bump and commit the version file and changelog.
22
+ rake repo:tag # Tag the release with the current version.
23
+ rake repo:push # Push updates upstream.
24
+ rake gem:build # Build the gem.
25
+ rake gem:push # Push the gem to the gem server.
19
26
 
20
- Adds some shortcuts:
27
+ Select which component to bump with one of these:
21
28
 
22
- * `cucumber_task(*args, &block)`: Define a Cucumber task. Noop if
23
- Cucumber cannot be loaded.
24
- * `spec_task(*args, &block)`: Define an RSpec task. Noop if RSpec
25
- cannot be loaded.
26
- * `rdoc_task(*args, &block)`: Define an rdoc task.
29
+ rake patch # Select a patch version bump.
30
+ rake minor # Select a minor version bump.
31
+ rake major # Select a major version bump.
27
32
 
28
- And some tasks:
33
+ For example:
29
34
 
30
- * `rake major release`
31
- * `rake minor release`
32
- * `rake patch release`
33
- * Perform the release ritual:
34
- * Bump the major/minor/patch version. This is defined in
35
- `lib/<library-name>/version.rb.`
36
- * Tag the release in git.
37
- * Push the git repo to origin.
38
- * Build the gem from the gemspec.
39
- * Push the gem to Gemcutter.
35
+ * `rake patch release` will bump 1.2.3 to 1.2.4 and release.
36
+ * `rake minor release` will bump 1.2.3 to 1.3.0 and release.
37
+ * `rake major release` will bump 1.2.3 to 2.0.0 and release.
38
+
39
+ "Release early, release often" has never been so easy!
40
+
41
+ ## Gemspec
40
42
 
41
43
  You [maintain the gemspec directly][using-gemspecs-as-intended], rather than via
42
44
  a wrapper like Jeweler or Hoe.
43
45
 
44
46
  [using-gemspecs-as-intended]: http://yehudakatz.com/2010/04/02/using-gemspecs-as-intended
45
47
 
48
+ ## Extensions
49
+
50
+ Use `extension` to define an extension-building task. Use one of two
51
+ conventions.
52
+
53
+ ### Unnamed extensions
54
+
55
+ If you only need a single extension, say if you're simply wrapping a C
56
+ library, then use an unnamed extension. In your Rakefile, do:
57
+
58
+ extension
59
+
60
+ This defines a task `ext` to build your extension. Source files live
61
+ in `ext/`, and the extension is named after the gem.
62
+
63
+ So if the gem is `my_gem`, then Ritual configures your extension with
64
+ `ext/extconf.rb`, runs `make`, and installs `ext/my_gem.DLEXT` to
65
+ `lib/my_gem/my_gem.DLEXT`. (`DLEXT` is the shared library extension,
66
+ which varies from system to system.) `extconf.rb` should contain:
67
+
68
+ create_makefile "my_gem"
69
+
70
+ And the extension entry point is `Init_my_gem`.
71
+
72
+ ### Named extensions
73
+
74
+ If you need more than one extension, you better name them. Do:
75
+
76
+ extension :my_ext
77
+
78
+ The task is named `ext:my_ext`. Source files live in
79
+ `ext/my_ext/`. Ritual configures the extension with
80
+ `ext/my_ext/extconf.rb`, and installs `ext/my_ext/my_gem.DLEXT` to
81
+ `lib/my_gem/my_ext.DLEXT`. `extconf.rb`, should contain:
82
+
83
+ create_makefile "my_gem/my_ext"
84
+
85
+ And the extension entry point is `Init_my_ext`.
86
+
87
+ ### Customizing
88
+
89
+ Both `extension` calls above can take options:
90
+
91
+ * `:build_as` - The path of the shared library that gets built.
92
+ * `:install_as` - The path the shared library is installed to.
93
+
94
+ Both are relative to the Rakefile's directory, and should omit the
95
+ shared library extension.
96
+
97
+ ### JRuby extensions
98
+
99
+ JRuby doesn't support extensions in the traditional sense (using
100
+ `mkmf`). Instead, you typically build a `.jar` which is packaged into
101
+ the gem.
102
+
103
+ To build a JRuby extension, pass `:type => :jruby` to
104
+ `extension`. JRuby extensions can be named or unnamed, as above. All
105
+ `.java` files are fed to `javac` simultanously to build the `.jar`,
106
+ which is bundled into the gem by `gem:build`.
107
+
46
108
  ## Note on Patches/Pull Requests
47
109
 
48
110
  * Bug reports: http://github.com/oggy/ritual/issues
@@ -53,4 +115,4 @@ a wrapper like Jeweler or Hoe.
53
115
 
54
116
  ## Copyright
55
117
 
56
- Copyright (c) 2010 George Ogata. See LICENSE for details.
118
+ Copyright (c) George Ogata. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,4 +1,2 @@
1
1
  $:.unshift File.expand_path('lib', File.dirname(__FILE__))
2
2
  require 'ritual'
3
-
4
- spec_task :spec
@@ -0,0 +1,56 @@
1
+ module Ritual
2
+ module Extension
3
+ class Base
4
+ DLEXT = Config::CONFIG['DLEXT']
5
+
6
+ def initialize(name, params={})
7
+ @name = name ? name.to_sym : nil
8
+ library_name = params[:library_name]
9
+
10
+ build_path = params[:build_as] and
11
+ @build_path = "#{build_path}.#{DLEXT}"
12
+ install_path = params[:install_as] and
13
+ @install_path = "#{install_path}.#{DLEXT}"
14
+
15
+ if name
16
+ @task_name = "ext:#{name}"
17
+ @path = params[:path] || "ext/#{name}"
18
+ @build_path ||= "#{path}/#{name}.#{DLEXT}"
19
+ @install_path ||= "lib/#{library_name}/#{name}.#{DLEXT}"
20
+ else
21
+ @task_name = 'ext'
22
+ @path = params[:path] || 'ext'
23
+ @build_path ||= "#{path}/#{library_name}.#{DLEXT}"
24
+ @install_path ||= "lib/#{library_name}/#{library_name}.#{DLEXT}"
25
+ end
26
+
27
+ CLEAN.include(compiled_paths)
28
+ CLOBBER.include(@install_path)
29
+ end
30
+
31
+ attr_reader :name, :task_name, :path, :build_path, :install_path
32
+
33
+ def define_tasks
34
+ raise NotImplementedError, 'abstract'
35
+ end
36
+
37
+ protected
38
+
39
+ def source_paths
40
+ raise NotImplementedError, 'abstract'
41
+ end
42
+
43
+ def compiled_path_for(source_path)
44
+ raise NotImplementedError, 'abstract'
45
+ end
46
+
47
+ def compiled_paths
48
+ @compiled_paths ||= source_paths.map { |s| compiled_path_for(s) }
49
+ end
50
+
51
+ def relative_path(absolute_path)
52
+ Pathname(absolute_path).relative_path_from(Pathname(path))
53
+ end
54
+ end
55
+ end
56
+ end