ampex 1.1.2 → 1.2.0

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.
Files changed (2) hide show
  1. data/lib/ampex.rb +23 -5
  2. metadata +6 -6
@@ -1,10 +1,22 @@
1
- require 'blankslate'
2
-
3
1
  # Copyright 2010 Conrad Irwin <conrad.irwin@gmail.com> MIT License
4
2
  #
5
3
  # For detailed usage notes, please see README.markdown
6
- #
7
- class Metavariable < BlankSlate
4
+
5
+ # NOTE: Ruby 1.9 seems to provide a default blank slate that isn't
6
+ # very blank, luckily it also provides a BasicObject which is pretty
7
+ # basic.
8
+ if defined? BasicObject
9
+ superclass = BasicObject
10
+ else
11
+ require 'rubygems'
12
+ require 'blankslate'
13
+ superclass = BlankSlate
14
+ end
15
+
16
+ class Metavariable < superclass
17
+ # Take a local copy of these as constant lookup is destroyed by BasicObject.
18
+ Metavariable = self
19
+ Thread = ::Thread
8
20
 
9
21
  # When you pass an argument with & in ruby, you're actually calling #to_proc
10
22
  # on the object. So it's Symbol#to_proc that makes the &:to_s trick work,
@@ -12,7 +24,7 @@ class Metavariable < BlankSlate
12
24
  attr_reader :to_proc
13
25
 
14
26
  def initialize(&block)
15
- @to_proc = block || lambda{|x| x}
27
+ @to_proc = block || ::Proc.new{|x| x}
16
28
  end
17
29
 
18
30
  # Each time a method is called on a Metavariable, we want to create a new
@@ -32,6 +44,12 @@ class Metavariable < BlankSlate
32
44
  mv
33
45
  end
34
46
 
47
+ # BlankSlate and BasicObject have different sets of methods that you don't want.
48
+ # let's remove them all.
49
+ instance_methods.each do |method|
50
+ undef_method method unless %w(method_missing to_proc __send__ __id__).include? method.to_s
51
+ end
52
+
35
53
  private
36
54
 
37
55
  # In order to support assignment via &X (expressions of the form &X['one'] = 2),
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ampex
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
4
+ hash: 31
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
9
8
  - 2
10
- version: 1.1.2
9
+ - 0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Conrad Irwin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-04 00:00:00 -08:00
18
+ date: 2011-06-26 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  requirements: []
75
75
 
76
76
  rubyforge_project:
77
- rubygems_version: 1.3.7
77
+ rubygems_version: 1.5.2
78
78
  signing_key:
79
79
  specification_version: 3
80
80
  summary: Provides a meta-variable X which can be used to create procs more prettily