prepend 0.1.0-i386-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ 10/10/210 version 0.1.0
2
+ * release!
@@ -0,0 +1,31 @@
1
+ Prepend
2
+ --------------
3
+
4
+ (c) John Mair (banisterfiend), Asher (Asher)
5
+ MIT license
6
+
7
+ Enables modules to be prepended to classes (or other modules).
8
+
9
+ ** This is BETA software and has not yet been thoroughly tested, use
10
+ at own risk **
11
+
12
+ install the gem: **for testing purposes only**
13
+ `gem install prepend`
14
+
15
+ example:
16
+
17
+ module M
18
+ def hello
19
+ puts "hello!"
20
+ end
21
+ end
22
+
23
+ class A
24
+ def hello
25
+ puts "I feel only hate and loathing"
26
+ end
27
+ prepend M
28
+ end
29
+
30
+ # invoke class method
31
+ A.new.hello #=> hello!
@@ -0,0 +1,39 @@
1
+
2
+ $LOAD_PATH.unshift File.join(File.expand_path(__FILE__), '..')
3
+
4
+ require 'rake/clean'
5
+ require 'rake/gempackagetask'
6
+
7
+ # get the texplay version
8
+ require 'lib/prepend/version'
9
+
10
+ $dlext = Config::CONFIG['DLEXT']
11
+
12
+ CLEAN.include("ext/**/*.#{$dlext}", "ext/**/*.log", "ext/**/*.o", "ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "ext/**/*.def", "ext/**/*.pdb")
13
+ CLOBBER.include("**/*.#{$dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
14
+
15
+ specification = Gem::Specification.new do |s|
16
+ s.name = "prepend"
17
+ s.summary = "Prepend modules in front of a class"
18
+ s.version = Prepend::VERSION
19
+ s.date = Time.now.strftime '%Y-%m-%d'
20
+ s.author = "John Mair (banisterfiend)"
21
+ s.email = 'jrmair@gmail.com'
22
+ s.description = s.summary
23
+ s.require_path = 'lib'
24
+ s.platform = Gem::Platform::RUBY
25
+ s.platform = 'i386-mingw32'
26
+ s.homepage = "http://banisterfiend.wordpress.com"
27
+ s.has_rdoc = false
28
+
29
+ #s.extensions = ["ext/prepend/extconf.rb"]
30
+ s.files = ["Rakefile", "README.markdown", "CHANGELOG",
31
+ "lib/prepend.rb", "lib/prepend/version.rb"] +
32
+ ["lib/1.9/prepend.so", "lib/1.8/prepend.so"] +
33
+ FileList["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c"].to_a
34
+ end
35
+
36
+ Rake::GemPackageTask.new(specification) do |package|
37
+ package.need_zip = false
38
+ package.need_tar = false
39
+ end
@@ -0,0 +1,23 @@
1
+ /* contains basic macros to facilitate ruby 1.8 and ruby 1.9 compatibility */
2
+
3
+ #ifndef GUARD_COMPAT_H
4
+ #define GUARD_COMPAT_H
5
+
6
+ #include <ruby.h>
7
+
8
+ /* macros for backwards compatibility with 1.8 */
9
+ #ifndef RUBY_19
10
+ # define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
11
+ # define RCLASS_SUPER(c) (RCLASS(c)->super)
12
+ # define RCLASS_IV_TBL(c) (RCLASS(c)->iv_tbl)
13
+ # define OBJ_UNTRUSTED OBJ_TAINTED
14
+ # include "st.h"
15
+ #endif
16
+
17
+ # define FALSE 0
18
+ # define TRUE 1
19
+
20
+ /* a useful macro. cannot use ordinary CLASS_OF as it does not return an lvalue */
21
+ #define KLASS_OF(c) (RBASIC(c)->klass)
22
+
23
+ #endif
@@ -0,0 +1,9 @@
1
+ require 'mkmf'
2
+
3
+ # 1.9 compatibility
4
+ $CFLAGS += " -DRUBY_19" if RUBY_VERSION =~ /1.9/
5
+
6
+ # let's use c99
7
+ $CFLAGS += " -std=c99"
8
+
9
+ create_makefile('prepend')
@@ -0,0 +1,57 @@
1
+ /* (c) 2010 John Mair (banisterfiend), MIT license */
2
+
3
+ #include "compat.h"
4
+ #include "ruby.h"
5
+
6
+ static VALUE
7
+ class_mod_wrapper_to_s(VALUE self)
8
+ {
9
+ return rb_iv_get(self, "__class_name__");
10
+ }
11
+
12
+ static VALUE
13
+ klass_to_s(VALUE self)
14
+ {
15
+ return rb_str_concat(rb_mod_name(self), rb_str_new2("*"));
16
+ }
17
+
18
+ static VALUE
19
+ rb_prepend_module(VALUE klass, VALUE module)
20
+ {
21
+ /* create wrapper module to hold current class's M_TBL */
22
+ VALUE class_mod_wrapper = rb_module_new();
23
+
24
+ /* clear the default M_TBL already allocated for the new wrapper module */
25
+ st_free_table(RCLASS_M_TBL(class_mod_wrapper));
26
+
27
+ /* set the wrapper module's M_TBL to the current class's */
28
+ RCLASS_M_TBL(class_mod_wrapper) = RCLASS_M_TBL(klass);
29
+
30
+ /* store name of current class in wrapper module for use by #to_s and #inspect */
31
+ rb_iv_set(class_mod_wrapper, "__class_name__", rb_mod_name(klass));
32
+
33
+ /* set current class's #to_s to return ClassName* */
34
+ rb_define_singleton_method(klass, "to_s", klass_to_s, 0);
35
+
36
+ /* set wrapper module's #to_s to name of current class */
37
+ rb_define_singleton_method(class_mod_wrapper, "to_s", class_mod_wrapper_to_s, 0);
38
+
39
+ /* erase the current class's M_TBL as we're now storing it in the wrapper module */
40
+ RCLASS_M_TBL(klass) = st_init_numtable();
41
+
42
+ /* include the wrapper module first */
43
+ rb_funcall(klass, rb_intern("include"), 1, class_mod_wrapper);
44
+
45
+ /* include the module we want to 'prepend' second, so that its M_TBL gets precedence over M_TBL of original class
46
+ (NB: original class's M_TBL is now stored in wrapper module) */
47
+ rb_funcall(klass, rb_intern("include"), 1, module);
48
+
49
+ rb_clear_cache();
50
+
51
+ return klass;
52
+ }
53
+
54
+ void
55
+ Init_prepend() {
56
+ rb_define_method(rb_cModule, "prepend", rb_prepend_module, 1);
57
+ }
Binary file
Binary file
@@ -0,0 +1,15 @@
1
+ direc = File.dirname(__FILE__)
2
+
3
+ begin
4
+ if RUBY_VERSION && RUBY_VERSION =~ /1.9/
5
+ require "#{direc}/1.9/prepend"
6
+ else
7
+ require "#{direc}/1.8/prepend"
8
+ end
9
+ rescue LoadError => e
10
+ require 'rbconfig'
11
+ dlext = Config::CONFIG['DLEXT']
12
+ require "#{direc}/prepend.#{dlext}"
13
+ end
14
+
15
+ require "#{direc}/prepend/version"
@@ -0,0 +1,3 @@
1
+ module Prepend
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prepend
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: i386-mingw32
12
+ authors:
13
+ - John Mair (banisterfiend)
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-10 00:00:00 +13:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Prepend modules in front of a class
23
+ email: jrmair@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - Rakefile
32
+ - README.markdown
33
+ - CHANGELOG
34
+ - lib/prepend.rb
35
+ - lib/prepend/version.rb
36
+ - lib/1.9/prepend.so
37
+ - lib/1.8/prepend.so
38
+ - ext/prepend/extconf.rb
39
+ - ext/prepend/compat.h
40
+ - ext/prepend/prepend.c
41
+ has_rdoc: false
42
+ homepage: http://banisterfiend.wordpress.com
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.3.7
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Prepend modules in front of a class
75
+ test_files: []
76
+