aspector 0.12.0 → 0.12.1

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.12.0
1
+ 0.12.1
data/aspector.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "aspector"
8
- s.version = "0.12.0"
8
+ s.version = "0.12.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Guoliang Cao"]
@@ -73,7 +73,8 @@ Gem::Specification.new do |s|
73
73
  "spec/unit/before_spec.rb",
74
74
  "spec/unit/deferred_logic_spec.rb",
75
75
  "spec/unit/method_matcher_spec.rb",
76
- "spec/unit/raw_spec.rb"
76
+ "spec/unit/raw_spec.rb",
77
+ "spec/unit/special_chars_spec.rb"
77
78
  ]
78
79
  s.homepage = "http://github.com/gcao/aspector"
79
80
  s.licenses = ["MIT"]
@@ -9,7 +9,8 @@ module Aspector
9
9
  @aop_creating_method or
10
10
  @aop_instances.nil? or @aop_instances.empty?
11
11
 
12
- aop_applied_flag = :"@aop_applied_#{method}"
12
+ aop_applied_flag = "@aop_applied_#{method}"
13
+ aop_applied_flag.gsub! %r([?!=+\-\*/\^\|&\[\]<>%~]), "_"
13
14
  return (block_given? and yield) if instance_variable_get(aop_applied_flag)
14
15
 
15
16
  begin
@@ -32,7 +33,8 @@ module Aspector
32
33
  aop_instances = eigen_class.instance_variable_get(:@aop_instances)
33
34
  return (block_given? and yield) if aop_instances.nil? or aop_instances.empty?
34
35
 
35
- aop_applied_flag = :"@aop_applied_#{method}"
36
+ aop_applied_flag = "@aop_applied_#{method}"
37
+ aop_applied_flag.gsub! %r([?!=+\-\*/\^\|&\[\]<>%~]), "_"
36
38
  return (block_given? and yield) if eigen_class.instance_variable_get(aop_applied_flag)
37
39
 
38
40
  begin
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,7 @@ ENV["ASPECTOR_LOG_LEVEL"] ||= "warn"
3
3
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
5
5
  require 'rspec'
6
+ require 'rspec/autorun'
6
7
  require 'aspector'
7
8
 
8
9
  # Requires supporting files with custom matchers and macros, etc,
@@ -0,0 +1,83 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe "Special chars in method names" do
4
+ ['?', '!', '='].each do |char|
5
+ it "should work with methods whose name contains #{char}" do
6
+ klass = Class.new do
7
+ aspector do
8
+ before "test#{char}", :do_this
9
+ end
10
+
11
+ def value
12
+ @value ||= []
13
+ end
14
+
15
+ def do_this *args
16
+ value << "do_this"
17
+ end
18
+
19
+ class_eval <<-CODE
20
+ def test#{char} *args
21
+ value << "test"
22
+ end
23
+ CODE
24
+ end
25
+
26
+ obj = klass.new
27
+ obj.send "test#{char}", 1
28
+ obj.value.should == %w"do_this test"
29
+ end
30
+ end
31
+
32
+ it "should work with []" do
33
+ klass = Class.new do
34
+ aspector do
35
+ before "[]", :do_this
36
+ end
37
+
38
+ def value
39
+ @value ||= []
40
+ end
41
+
42
+ def do_this *args
43
+ value << "do_this"
44
+ end
45
+
46
+ def [] *args
47
+ value << "test"
48
+ end
49
+ end
50
+
51
+ obj = klass.new
52
+ obj[1]
53
+ obj.value.should == %w"do_this test"
54
+ end
55
+
56
+ ['+', '-', '*', '/', '~', '|', '%', '&', '^', '<', '>', '[]', '[]='].each do |meth|
57
+ it "should work with #{meth}" do
58
+ klass = Class.new do
59
+ aspector do
60
+ before meth, :do_this
61
+ end
62
+
63
+ def value
64
+ @value ||= []
65
+ end
66
+
67
+ def do_this *args
68
+ value << "do_this"
69
+ end
70
+
71
+ define_method meth do |*args|
72
+ value << "test"
73
+ end
74
+ end
75
+
76
+ obj = klass.new
77
+ obj.send meth, 1, 2
78
+ obj.value.should == %w"do_this test"
79
+ end
80
+ end
81
+
82
+ end
83
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aspector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -252,6 +252,7 @@ files:
252
252
  - spec/unit/deferred_logic_spec.rb
253
253
  - spec/unit/method_matcher_spec.rb
254
254
  - spec/unit/raw_spec.rb
255
+ - spec/unit/special_chars_spec.rb
255
256
  homepage: http://github.com/gcao/aspector
256
257
  licenses:
257
258
  - MIT
@@ -267,7 +268,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
267
268
  version: '0'
268
269
  segments:
269
270
  - 0
270
- hash: -1253931844087075152
271
+ hash: -1261563091961094828
271
272
  required_rubygems_version: !ruby/object:Gem::Requirement
272
273
  none: false
273
274
  requirements: