RubyInline 3.3.2 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/History.txt +10 -0
  2. data/Makefile +1 -1
  3. data/example.rb +2 -6
  4. data/inline.rb +31 -12
  5. metadata +3 -3
data/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ *** 3.4.0 / 2005-07-13
2
+
3
+ + 2 minor enhancement
4
+ + Changed inline to take the language and a hash of options.
5
+ + Still backwards compatible, for now, and emits a warning.
6
+ + Options are available via the builder passed to your block.
7
+ + 2 bug fixes
8
+ + Modified caller discovery, yet again, due to changes in ruby 1.8.3.
9
+ + More compatible and clean with non-gems systems.
10
+
1
11
  *** 3.3.2 / 2005-05-19
2
12
 
3
13
  + 4 bug fixes
data/Makefile CHANGED
@@ -1,5 +1,5 @@
1
1
  RUBY?=/usr/local/bin/ruby
2
- RDOC?=rdoc18
2
+ RDOC?=rdoc
3
3
  RUBYLIB=$(shell $(RUBY) -rrbconfig -e 'include Config; print CONFIG["sitelibdir"]')
4
4
  PREFIX?=/usr/local
5
5
 
data/example.rb CHANGED
@@ -1,11 +1,7 @@
1
1
  #!/usr/local/bin/ruby -w
2
2
 
3
- begin
4
- require 'rubygems'
5
- require_gem "RubyInline"
6
- rescue LoadError
7
- require 'inline'
8
- end
3
+ begin require 'rubygems' rescue LoadError end
4
+ require 'inline'
9
5
 
10
6
  class MyTest
11
7
 
data/inline.rb CHANGED
@@ -51,7 +51,7 @@ class CompilationError < RuntimeError; end
51
51
  # the current namespace.
52
52
 
53
53
  module Inline
54
- VERSION = '3.3.2'
54
+ VERSION = '3.4.0'
55
55
 
56
56
  $stderr.puts "RubyInline v #{VERSION}" if $DEBUG
57
57
 
@@ -262,9 +262,12 @@ module Inline
262
262
 
263
263
  def initialize(mod)
264
264
  raise ArgumentError, "Class/Module arg is required" unless Module === mod
265
-
266
- real_caller = caller[2] # new -> inline -> real_caller|eval
267
- real_caller = caller[5] if real_caller =~ /\(eval\)/
265
+ # new (but not on some 1.8s) -> inline -> real_caller|eval
266
+ stack = caller
267
+ meth = stack.shift until meth =~ /in .(inline|test_)/ or stack.empty?
268
+ raise "Couldn't discover caller" if stack.empty?
269
+ real_caller = stack.first
270
+ real_caller = stack[3] if real_caller =~ /\(eval\)/
268
271
  @real_caller = real_caller.split(/:/).first
269
272
  @rb_file = File.expand_path(@real_caller)
270
273
 
@@ -549,25 +552,41 @@ end # module Inline
549
552
 
550
553
  class Module
551
554
 
555
+ ##
556
+ # options is a hash that allows you to pass extra data to your
557
+ # builder. The only key that is guaranteed to exist is :testing.
558
+
559
+ attr_reader :options
560
+
552
561
  ##
553
562
  # Extends the Module class to have an inline method. The default
554
563
  # language/builder used is C, but can be specified with the +lang+
555
564
  # parameter.
556
565
 
557
- def inline(lang = :C, testing=false)
558
-
559
- begin
560
- builder_class = Inline.const_get(lang)
561
- rescue NameError
562
- require "inline/#{lang}"
563
- builder_class = Inline.const_get(lang)
566
+ def inline(lang = :C, options={})
567
+ case options
568
+ when TrueClass, FalseClass then
569
+ warn "WARNING: 2nd argument to inline is now a hash, changing to {:testing=>#{options}}" unless options
570
+ options = { :testing => options }
571
+ when Hash
572
+ options[:testing] ||= false
573
+ else
574
+ raise ArgumentError, "BLAH"
564
575
  end
565
576
 
577
+ builder_class = begin
578
+ Inline.const_get(lang)
579
+ rescue NameError
580
+ require "inline/#{lang}"
581
+ Inline.const_get(lang)
582
+ end
583
+
584
+ @options = options
566
585
  builder = builder_class.new self
567
586
 
568
587
  yield builder
569
588
 
570
- unless testing then
589
+ unless options[:testing] then
571
590
  unless builder.load_cache then
572
591
  builder.build
573
592
  builder.load
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.10
2
+ rubygems_version: 0.8.10.1
3
3
  specification_version: 1
4
4
  name: RubyInline
5
5
  version: !ruby/object:Gem::Version
6
- version: 3.3.2
7
- date: 2005-05-19
6
+ version: 3.4.0
7
+ date: 2005-07-13
8
8
  summary: Multi-language extension coding within ruby.
9
9
  require_paths:
10
10
  - "."