memoit 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8ece57c9bea6440805f8ccd28b6bae60c977d40
4
- data.tar.gz: cd5fd4c30fd3c6a9fa040c6a85510a88b8fbd00d
3
+ metadata.gz: 441068286347f797f32789bc41d38aa58f7f28f9
4
+ data.tar.gz: 97f957be3579a93f742469e13f1059d52c5fd19e
5
5
  SHA512:
6
- metadata.gz: 4091ce16342522f9321735939e83d78f17f401c77480fb572c2d5b20de87f94ee58db4f6b0d1ca87a9c207b0df4a1eed1f32a738596a9e43c895dada06b05b99
7
- data.tar.gz: cbe78faf3d28a6d100f14df8c90994170ded87f95991e7c8a607f4593d36ff13cd9ac8e5ce9063589d8d654847e015be3540bc5a20dad0d7caac996351517b77
6
+ metadata.gz: bec090942ddc7b26f8312bacde3c84a1859e174fc4fa3cad6427fc8ecfc1d6b1a39fc3046977d2ff76c45bba3c10c6b8749d4cd6d569a4bae05effdb4dce219e
7
+ data.tar.gz: c60894c04f3f29a528730be230693c5610510d34b58656be597dd888cc4b6527976a0009e680ffc6c0ede10ee7d71a0659212474d1162fa726f8c0f2cd6a0f59
data/README.md CHANGED
@@ -30,4 +30,4 @@ end
30
30
 
31
31
  ## License
32
32
 
33
- [MIT](License.txt)
33
+ [MIT](LICENSE.txt)
data/Rakefile CHANGED
@@ -1,2 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
2
3
 
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -11,7 +11,8 @@ module Memoit
11
11
  # end
12
12
  # end
13
13
  def memoize(name)
14
- ivar_name = "@_memo_#{name}".to_sym
14
+ ivar_method_name = name.to_s.sub("?", "__questionmark").sub("!", "__bang")
15
+ ivar_name = "@_memo_#{ivar_method_name}".to_sym
15
16
  mod = Module.new do
16
17
  define_method(name) do |*args, &block|
17
18
  return super(*args, &block) if block
@@ -1,3 +1,3 @@
1
1
  module Memoit
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -19,6 +19,18 @@ describe Memoit do
19
19
  foo
20
20
  false
21
21
  end
22
+
23
+ memoize def query?
24
+ rand
25
+ end
26
+
27
+ memoize def bang!
28
+ rand
29
+ end
30
+
31
+ memoize def ☃
32
+ rand
33
+ end
22
34
  end
23
35
  end
24
36
  let(:instance) { klass.new }
@@ -46,6 +58,18 @@ describe Memoit do
46
58
  expect(instance.falsy).to eq(instance.falsy)
47
59
  end
48
60
 
61
+ it "handles question-mark methods" do
62
+ expect(instance.query?).to eq(instance.query?)
63
+ end
64
+
65
+ it "handles bang methods" do
66
+ expect(instance.bang!).to eq(instance.bang!)
67
+ end
68
+
69
+ it "handles non-ASCII-name methods" do
70
+ expect(instance.☃).to eq(instance.☃)
71
+ end
72
+
49
73
  it "returns the name of the method" do
50
74
  name = nil
51
75
  Class.new do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memoit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Nicklas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-09 00:00:00.000000000 Z
11
+ date: 2015-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,4 +94,3 @@ specification_version: 4
94
94
  summary: Memoize is back!
95
95
  test_files:
96
96
  - spec/memoit_spec.rb
97
- has_rdoc: