friendly 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -15,9 +15,9 @@ begin
15
15
  gem.add_development_dependency "jferris-mocha"
16
16
  gem.add_development_dependency "memcached"
17
17
  gem.add_dependency "sequel", ">= 3.7.0"
18
- gem.add_dependency "json_pure"
19
- gem.add_dependency "activesupport"
18
+ gem.add_dependency "activesupport", "=2.3.5"
20
19
  gem.add_dependency "will_paginate"
20
+ gem.add_dependency "rufus-json", "=0.2.3"
21
21
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
22
22
  end
23
23
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.6.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{friendly}
8
- s.version = "0.5.1"
8
+ s.version = "0.6.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["James Golick"]
12
- s.date = %q{2010-01-25}
12
+ s.date = %q{2010-07-02}
13
13
  s.description = %q{}
14
14
  s.email = %q{jamesgolick@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -156,7 +156,7 @@ Gem::Specification.new do |s|
156
156
  s.homepage = %q{http://friendlyorm.com}
157
157
  s.rdoc_options = ["--charset=UTF-8"]
158
158
  s.require_paths = ["lib"]
159
- s.rubygems_version = %q{1.3.5}
159
+ s.rubygems_version = %q{1.3.7}
160
160
  s.summary = %q{NoSQL with MySQL in Ruby}
161
161
  s.test_files = [
162
162
  "spec/fakes/data_store_fake.rb",
@@ -207,24 +207,24 @@ Gem::Specification.new do |s|
207
207
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
208
208
  s.specification_version = 3
209
209
 
210
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
210
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
211
211
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
212
212
  s.add_development_dependency(%q<cucumber>, [">= 0"])
213
213
  s.add_development_dependency(%q<jferris-mocha>, [">= 0"])
214
214
  s.add_development_dependency(%q<memcached>, [">= 0"])
215
215
  s.add_runtime_dependency(%q<sequel>, [">= 3.7.0"])
216
- s.add_runtime_dependency(%q<json_pure>, [">= 0"])
217
- s.add_runtime_dependency(%q<activesupport>, [">= 0"])
216
+ s.add_runtime_dependency(%q<activesupport>, ["= 2.3.5"])
218
217
  s.add_runtime_dependency(%q<will_paginate>, [">= 0"])
218
+ s.add_runtime_dependency(%q<rufus-json>, ["= 0.2.3"])
219
219
  else
220
220
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
221
221
  s.add_dependency(%q<cucumber>, [">= 0"])
222
222
  s.add_dependency(%q<jferris-mocha>, [">= 0"])
223
223
  s.add_dependency(%q<memcached>, [">= 0"])
224
224
  s.add_dependency(%q<sequel>, [">= 3.7.0"])
225
- s.add_dependency(%q<json_pure>, [">= 0"])
226
- s.add_dependency(%q<activesupport>, [">= 0"])
225
+ s.add_dependency(%q<activesupport>, ["= 2.3.5"])
227
226
  s.add_dependency(%q<will_paginate>, [">= 0"])
227
+ s.add_dependency(%q<rufus-json>, ["= 0.2.3"])
228
228
  end
229
229
  else
230
230
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
@@ -232,9 +232,9 @@ Gem::Specification.new do |s|
232
232
  s.add_dependency(%q<jferris-mocha>, [">= 0"])
233
233
  s.add_dependency(%q<memcached>, [">= 0"])
234
234
  s.add_dependency(%q<sequel>, [">= 3.7.0"])
235
- s.add_dependency(%q<json_pure>, [">= 0"])
236
- s.add_dependency(%q<activesupport>, [">= 0"])
235
+ s.add_dependency(%q<activesupport>, ["= 2.3.5"])
237
236
  s.add_dependency(%q<will_paginate>, [">= 0"])
237
+ s.add_dependency(%q<rufus-json>, ["= 0.2.3"])
238
238
  end
239
239
  end
240
240
 
@@ -18,7 +18,6 @@ require 'friendly/storage_proxy'
18
18
  require 'friendly/translator'
19
19
  require 'friendly/uuid'
20
20
 
21
- require 'json/pure'
22
21
  require 'will_paginate/collection'
23
22
 
24
23
  module Friendly
@@ -1,17 +1,19 @@
1
+ require "rufus-json"
2
+
1
3
  module Friendly
2
4
  class Translator
3
5
  RESERVED_ATTRS = [:id, :created_at, :updated_at].freeze
4
6
 
5
7
  attr_reader :serializer, :time
6
8
 
7
- def initialize(serializer = JSON, time = Time)
9
+ def initialize(serializer = Rufus::Json, time = Time)
8
10
  @serializer = serializer
9
11
  @time = time
10
12
  end
11
13
 
12
14
  def to_object(klass, record)
13
15
  record.delete(:added_id)
14
- attributes = serializer.parse(record.delete(:attributes))
16
+ attributes = serializer.decode(record.delete(:attributes))
15
17
  attributes.merge!(record).merge!(:new_record => false)
16
18
  klass.new_without_change_tracking attributes
17
19
  end
@@ -26,7 +28,7 @@ module Friendly
26
28
  protected
27
29
  def serialize(document)
28
30
  attrs = document.to_hash.reject { |k,v| RESERVED_ATTRS.include?(k) }
29
- serializer.generate(attrs)
31
+ serializer.encode(attrs)
30
32
  end
31
33
  end
32
34
  end
@@ -1,5 +1,6 @@
1
1
  require 'friendly/time'
2
2
  require 'friendly/attribute'
3
+ require 'rufus-json'
3
4
 
4
5
  # This class was extracted from the cassandra gem by Evan Weaver
5
6
  # As such, it is distributed under the terms of the apache license.
@@ -85,7 +86,7 @@ module Friendly
85
86
  end
86
87
 
87
88
  def to_json(*args)
88
- to_guid.to_json(*args)
89
+ Rufus::Json.encode(to_guid)
89
90
  end
90
91
 
91
92
  def seconds
@@ -1,4 +1,5 @@
1
1
  require File.expand_path("../../spec_helper", __FILE__)
2
+ require 'rufus-json'
2
3
 
3
4
  describe "Creating and retrieving an object" do
4
5
  before do
@@ -39,7 +40,7 @@ describe "Creating and retrieving an object" do
39
40
 
40
41
  it "doesn't serialize id, created_at, or updated_at in the attributes column" do
41
42
  result = $db.from("users").first(:id => @user.id)
42
- attrs = JSON.parse(result[:attributes])
43
+ attrs = Rufus::Json.decode(result[:attributes])
43
44
  attrs.keys.should_not include("id")
44
45
  attrs.keys.should_not include("created_at")
45
46
  attrs.keys.should_not include("updated_at")
@@ -7,7 +7,7 @@ require 'rubygems'
7
7
  require 'spec'
8
8
  require 'spec/autorun'
9
9
  require 'sequel'
10
- require 'json/pure'
10
+ require 'yajl'
11
11
  gem 'jferris-mocha'
12
12
  require 'mocha'
13
13
  require 'memcached'
@@ -10,7 +10,7 @@ describe "Friendly::Translator" do
10
10
 
11
11
  describe "translating a row to an object" do
12
12
  before do
13
- @serializer.stubs(:parse).with("THE JSON").returns(:name => "Stewie")
13
+ @serializer.stubs(:decode).with("THE JSON").returns(:name => "Stewie")
14
14
  @time = Time.new
15
15
  @row = {:added_id => 12345,
16
16
  :created_at => @time,
@@ -33,7 +33,7 @@ describe "Friendly::Translator" do
33
33
  before do
34
34
  @hash = {:name => "Stewie"}
35
35
  @time.stubs(:new).returns(Time.new)
36
- @serializer.stubs(:generate).with(@hash).returns("SOME JSON")
36
+ @serializer.stubs(:encode).with(@hash).returns("SOME JSON")
37
37
  @document = stub(:to_hash => @hash,
38
38
  :new_record? => true,
39
39
  :created_at => nil,
@@ -62,7 +62,7 @@ describe "Friendly::Translator" do
62
62
  :created_at => @created_at,
63
63
  :updated_at => Time.new}
64
64
  @time.stubs(:new).returns(Time.new + 5000)
65
- @serializer.stubs(:generate).returns("SOME JSON")
65
+ @serializer.stubs(:encode).returns("SOME JSON")
66
66
  @document = stub(:to_hash => @hash,
67
67
  :created_at => @created_at,
68
68
  :new_record? => false,
@@ -71,7 +71,7 @@ describe "Friendly::Translator" do
71
71
  end
72
72
 
73
73
  it "serializes the attributes" do
74
- @serializer.should have_received(:generate).with(:name => "Stewie")
74
+ @serializer.should have_received(:encode).with(:name => "Stewie")
75
75
  @record[:attributes].should == "SOME JSON"
76
76
  end
77
77
 
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: friendly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ hash: 7
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 6
9
+ - 0
10
+ version: 0.6.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - James Golick
@@ -9,89 +15,129 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-01-25 00:00:00 -08:00
18
+ date: 2010-07-02 00:00:00 -04:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: rspec
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 1
32
+ - 2
33
+ - 9
23
34
  version: 1.2.9
24
- version:
35
+ type: :development
36
+ version_requirements: *id001
25
37
  - !ruby/object:Gem::Dependency
26
38
  name: cucumber
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
30
42
  requirements:
31
43
  - - ">="
32
44
  - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
33
48
  version: "0"
34
- version:
49
+ type: :development
50
+ version_requirements: *id002
35
51
  - !ruby/object:Gem::Dependency
36
52
  name: jferris-mocha
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
40
56
  requirements:
41
57
  - - ">="
42
58
  - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
43
62
  version: "0"
44
- version:
63
+ type: :development
64
+ version_requirements: *id003
45
65
  - !ruby/object:Gem::Dependency
46
66
  name: memcached
47
- type: :development
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
50
70
  requirements:
51
71
  - - ">="
52
72
  - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
53
76
  version: "0"
54
- version:
77
+ type: :development
78
+ version_requirements: *id004
55
79
  - !ruby/object:Gem::Dependency
56
80
  name: sequel
57
- type: :runtime
58
- version_requirement:
59
- version_requirements: !ruby/object:Gem::Requirement
81
+ prerelease: false
82
+ requirement: &id005 !ruby/object:Gem::Requirement
83
+ none: false
60
84
  requirements:
61
85
  - - ">="
62
86
  - !ruby/object:Gem::Version
87
+ hash: 27
88
+ segments:
89
+ - 3
90
+ - 7
91
+ - 0
63
92
  version: 3.7.0
64
- version:
65
- - !ruby/object:Gem::Dependency
66
- name: json_pure
67
93
  type: :runtime
68
- version_requirement:
69
- version_requirements: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: "0"
74
- version:
94
+ version_requirements: *id005
75
95
  - !ruby/object:Gem::Dependency
76
96
  name: activesupport
77
- type: :runtime
78
- version_requirement:
79
- version_requirements: !ruby/object:Gem::Requirement
97
+ prerelease: false
98
+ requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
80
100
  requirements:
81
- - - ">="
101
+ - - "="
82
102
  - !ruby/object:Gem::Version
83
- version: "0"
84
- version:
103
+ hash: 9
104
+ segments:
105
+ - 2
106
+ - 3
107
+ - 5
108
+ version: 2.3.5
109
+ type: :runtime
110
+ version_requirements: *id006
85
111
  - !ruby/object:Gem::Dependency
86
112
  name: will_paginate
87
- type: :runtime
88
- version_requirement:
89
- version_requirements: !ruby/object:Gem::Requirement
113
+ prerelease: false
114
+ requirement: &id007 !ruby/object:Gem::Requirement
115
+ none: false
90
116
  requirements:
91
117
  - - ">="
92
118
  - !ruby/object:Gem::Version
119
+ hash: 3
120
+ segments:
121
+ - 0
93
122
  version: "0"
94
- version:
123
+ type: :runtime
124
+ version_requirements: *id007
125
+ - !ruby/object:Gem::Dependency
126
+ name: rufus-json
127
+ prerelease: false
128
+ requirement: &id008 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - "="
132
+ - !ruby/object:Gem::Version
133
+ hash: 17
134
+ segments:
135
+ - 0
136
+ - 2
137
+ - 3
138
+ version: 0.2.3
139
+ type: :runtime
140
+ version_requirements: *id008
95
141
  description: ""
96
142
  email: jamesgolick@gmail.com
97
143
  executables: []
@@ -247,21 +293,27 @@ rdoc_options:
247
293
  require_paths:
248
294
  - lib
249
295
  required_ruby_version: !ruby/object:Gem::Requirement
296
+ none: false
250
297
  requirements:
251
298
  - - ">="
252
299
  - !ruby/object:Gem::Version
300
+ hash: 3
301
+ segments:
302
+ - 0
253
303
  version: "0"
254
- version:
255
304
  required_rubygems_version: !ruby/object:Gem::Requirement
305
+ none: false
256
306
  requirements:
257
307
  - - ">="
258
308
  - !ruby/object:Gem::Version
309
+ hash: 3
310
+ segments:
311
+ - 0
259
312
  version: "0"
260
- version:
261
313
  requirements: []
262
314
 
263
315
  rubyforge_project:
264
- rubygems_version: 1.3.5
316
+ rubygems_version: 1.3.7
265
317
  signing_key:
266
318
  specification_version: 3
267
319
  summary: NoSQL with MySQL in Ruby