gateway-memcache 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -6,9 +6,9 @@ gem "memcache-client", ">= 1.8.5"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
- gem "rspec", "~> 2.8.0"
10
- gem "yard", "~> 0.7"
11
- gem "rdoc", "~> 3.12"
12
- gem "bundler", "~> 1.0.0"
13
- gem "jeweler", "~> 1.8.3"
9
+ gem "bundler"
10
+ gem "rspec"
11
+ gem "yard"
12
+ gem "rdoc"
13
+ gem "jeweler"
14
14
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gateway-memcache"
8
- s.version = "0.1.1"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Qian"]
12
- s.date = "2012-05-15"
12
+ s.date = "2013-01-23"
13
13
  s.description = " Gateway wrapper for memcache-client "
14
14
  s.email = "aq1018@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -28,12 +28,13 @@ Gem::Specification.new do |s|
28
28
  "lib/gateway-memcache.rb",
29
29
  "lib/gateway/memcache.rb",
30
30
  "spec/gateway-memcache_spec.rb",
31
- "spec/spec_helper.rb"
31
+ "spec/spec_helper.rb",
32
+ "spec/support/gateway_test.rb"
32
33
  ]
33
34
  s.homepage = "http://github.com/aq1018/gateway-memcache"
34
35
  s.licenses = ["MIT"]
35
36
  s.require_paths = ["lib"]
36
- s.rubygems_version = "1.8.19"
37
+ s.rubygems_version = "1.8.24"
37
38
  s.summary = "Gateway wrapper for memcache-client"
38
39
 
39
40
  if s.respond_to? :specification_version then
@@ -42,28 +43,28 @@ Gem::Specification.new do |s|
42
43
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
44
  s.add_runtime_dependency(%q<gateway>, [">= 0.1.0"])
44
45
  s.add_runtime_dependency(%q<memcache-client>, [">= 1.8.5"])
45
- s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
46
- s.add_development_dependency(%q<yard>, ["~> 0.7"])
47
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
48
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
49
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
46
+ s.add_development_dependency(%q<bundler>, [">= 0"])
47
+ s.add_development_dependency(%q<rspec>, [">= 0"])
48
+ s.add_development_dependency(%q<yard>, [">= 0"])
49
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
50
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
50
51
  else
51
52
  s.add_dependency(%q<gateway>, [">= 0.1.0"])
52
53
  s.add_dependency(%q<memcache-client>, [">= 1.8.5"])
53
- s.add_dependency(%q<rspec>, ["~> 2.8.0"])
54
- s.add_dependency(%q<yard>, ["~> 0.7"])
55
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
56
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
57
- s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
54
+ s.add_dependency(%q<bundler>, [">= 0"])
55
+ s.add_dependency(%q<rspec>, [">= 0"])
56
+ s.add_dependency(%q<yard>, [">= 0"])
57
+ s.add_dependency(%q<rdoc>, [">= 0"])
58
+ s.add_dependency(%q<jeweler>, [">= 0"])
58
59
  end
59
60
  else
60
61
  s.add_dependency(%q<gateway>, [">= 0.1.0"])
61
62
  s.add_dependency(%q<memcache-client>, [">= 1.8.5"])
62
- s.add_dependency(%q<rspec>, ["~> 2.8.0"])
63
- s.add_dependency(%q<yard>, ["~> 0.7"])
64
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
65
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
- s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
63
+ s.add_dependency(%q<bundler>, [">= 0"])
64
+ s.add_dependency(%q<rspec>, [">= 0"])
65
+ s.add_dependency(%q<yard>, [">= 0"])
66
+ s.add_dependency(%q<rdoc>, [">= 0"])
67
+ s.add_dependency(%q<jeweler>, [">= 0"])
67
68
  end
68
69
  end
69
70
 
@@ -48,5 +48,13 @@ module Gateway
48
48
  # external control only making things worse
49
49
  #conn.reset
50
50
  end
51
+
52
+ def success_status(resp)
53
+ resp ? 200 : 404
54
+ end
55
+
56
+ def success_message(resp)
57
+ resp ? 'HIT' : 'MISS'
58
+ end
51
59
  end
52
60
  end
@@ -1,5 +1,44 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe Gateway::Memcache do
4
- it "should be worked on"
4
+ before do
5
+ described_class.mock_connection = double 'connection'
6
+ end
7
+
8
+ it "should profile a get request" do
9
+ conn.stub('get') { true }
10
+
11
+ subject.get 'foo'
12
+ profiler.first.should be_a_profile_req_like name: 'tester',
13
+ status: 200,
14
+ desc: 'HIT',
15
+ req: 'GET foo'
16
+ end
17
+
18
+ it 'should profile a bad get request' do
19
+ conn.stub('get') { false }
20
+
21
+ subject.get 'foo'
22
+ profiler.first.should be_a_profile_req_like status: 404,
23
+ desc: 'MISS',
24
+ req: 'GET foo'
25
+ end
26
+
27
+ it "should profile a set request" do
28
+ conn.stub('set') { true }
29
+
30
+ subject.set 'foo', 1
31
+ profiler.first.should be_a_profile_req_like status: 200,
32
+ desc: 'HIT',
33
+ req: 'SET foo'
34
+ end
35
+
36
+ it 'should profile a bad set request' do
37
+ conn.stub('set') { false }
38
+
39
+ subject.set 'foo', 1
40
+ profiler.first.should be_a_profile_req_like status: 404,
41
+ desc: 'MISS',
42
+ req: 'SET foo'
43
+ end
5
44
  end
data/spec/spec_helper.rb CHANGED
@@ -10,3 +10,7 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
10
10
  RSpec.configure do |config|
11
11
 
12
12
  end
13
+
14
+ class Gateway::Memcache
15
+ include Gateway::Test
16
+ end
@@ -0,0 +1,44 @@
1
+ module Gateway::Test
2
+ class Profiler < Array
3
+ def performance(*args)
4
+ self << args
5
+ end
6
+ end
7
+ def self.included(klass)
8
+ klass.class_eval do
9
+ class_attribute :mock_connection
10
+ end
11
+ end
12
+ def initialize name = 'tester', opts = {}
13
+ super
14
+ end
15
+ def connection_type() :test end
16
+ def with_test() yield self.class.mock_connection end
17
+ def profiler()
18
+ @profiler ||= Profiler.new
19
+ end
20
+ end
21
+
22
+ module Gateway::SpecHelper
23
+ def profiler
24
+ subject.profiler
25
+ end
26
+
27
+ def conn
28
+ described_class.mock_connection
29
+ end
30
+ end
31
+
32
+ RSpec::Matchers.define :be_a_profile_req_like do |expected|
33
+ match do |name, duration, status, desc, req|
34
+ name.should == expected[:name] if expected.key? :name
35
+ duration.should == expected[:duration] if expected.key? :duration
36
+ status.should == expected[:status] if expected.key? :status
37
+ desc.should == expected[:desc] if expected.key? :desc
38
+ req.should == expected[:req] if expected.key? :req
39
+ end
40
+ end
41
+
42
+ RSpec.configure do |c|
43
+ c.include Gateway::SpecHelper
44
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gateway-memcache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-15 00:00:00.000000000 Z
12
+ date: 2013-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gateway
@@ -44,85 +44,85 @@ dependencies:
44
44
  - !ruby/object:Gem::Version
45
45
  version: 1.8.5
46
46
  - !ruby/object:Gem::Dependency
47
- name: rspec
47
+ name: bundler
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ~>
51
+ - - ! '>='
52
52
  - !ruby/object:Gem::Version
53
- version: 2.8.0
53
+ version: '0'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ~>
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
- version: 2.8.0
61
+ version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
- name: yard
63
+ name: rspec
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
- - - ~>
67
+ - - ! '>='
68
68
  - !ruby/object:Gem::Version
69
- version: '0.7'
69
+ version: '0'
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
- - - ~>
75
+ - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
- version: '0.7'
77
+ version: '0'
78
78
  - !ruby/object:Gem::Dependency
79
- name: rdoc
79
+ name: yard
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
- - - ~>
83
+ - - ! '>='
84
84
  - !ruby/object:Gem::Version
85
- version: '3.12'
85
+ version: '0'
86
86
  type: :development
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
- - - ~>
91
+ - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
- version: '3.12'
93
+ version: '0'
94
94
  - !ruby/object:Gem::Dependency
95
- name: bundler
95
+ name: rdoc
96
96
  requirement: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
- - - ~>
99
+ - - ! '>='
100
100
  - !ruby/object:Gem::Version
101
- version: 1.0.0
101
+ version: '0'
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
- - - ~>
107
+ - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
- version: 1.0.0
109
+ version: '0'
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: jeweler
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements:
115
- - - ~>
115
+ - - ! '>='
116
116
  - !ruby/object:Gem::Version
117
- version: 1.8.3
117
+ version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  none: false
122
122
  requirements:
123
- - - ~>
123
+ - - ! '>='
124
124
  - !ruby/object:Gem::Version
125
- version: 1.8.3
125
+ version: '0'
126
126
  description: ! ' Gateway wrapper for memcache-client '
127
127
  email: aq1018@gmail.com
128
128
  executables: []
@@ -143,6 +143,7 @@ files:
143
143
  - lib/gateway/memcache.rb
144
144
  - spec/gateway-memcache_spec.rb
145
145
  - spec/spec_helper.rb
146
+ - spec/support/gateway_test.rb
146
147
  homepage: http://github.com/aq1018/gateway-memcache
147
148
  licenses:
148
149
  - MIT
@@ -158,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
159
  version: '0'
159
160
  segments:
160
161
  - 0
161
- hash: 2196172132403878567
162
+ hash: -2358803944027340374
162
163
  required_rubygems_version: !ruby/object:Gem::Requirement
163
164
  none: false
164
165
  requirements:
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
168
  version: '0'
168
169
  requirements: []
169
170
  rubyforge_project:
170
- rubygems_version: 1.8.19
171
+ rubygems_version: 1.8.24
171
172
  signing_key:
172
173
  specification_version: 3
173
174
  summary: Gateway wrapper for memcache-client