simple-json 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -57,10 +57,10 @@ class SimpleJSON
57
57
  elsif r_data.is_a?(Hash)
58
58
  mem[obj[0]] = r_data
59
59
  else
60
- mem[obj[0]] = [false, "SDB Error. Unable to 'put attributes'"]
60
+ mem[obj[0]] = {'error', "SDB ERROR! Transaction returned: #{r_data.inspect}"}
61
61
  end
62
62
  rescue => ex
63
- mem[obj[0]] = [false, "#{ex.class}: #{ex.message}"]
63
+ mem[obj[0]] = {"error", "#{ex.class}: #{ex.message}"}
64
64
  end
65
65
  mem
66
66
  end
@@ -74,7 +74,7 @@ class SimpleJSON
74
74
  if ids.is_a?(Array)
75
75
  ids.inject(Hash.new) { |mem,id| mem[id] = query_get(id,v); mem }
76
76
  else
77
- return [false,"Query Failed: v:#{v.inspect} | r:#{r_ids.inspect}"]
77
+ return "Query Failed: v:#{v.inspect} | r:#{r_ids.inspect}"
78
78
  end
79
79
  end
80
80
  end
@@ -4,7 +4,7 @@ require 'json'
4
4
 
5
5
  # require File.join( File.dirname( File.expand_path(__FILE__)), '..','aws-sdb','lib','aws_sdb')
6
6
  require 'aws_sdb'
7
- require File.join( File.dirname( File.expand_path(__FILE__)), '..','simple_json')
7
+ require File.join( File.dirname( File.expand_path(__FILE__)), '..', 'lib', 'simple_json')
8
8
 
9
9
  class TestSimpleJSONDB < Test::Unit::TestCase
10
10
  BEGIN {
@@ -16,7 +16,7 @@ class TestSimpleJSONDB < Test::Unit::TestCase
16
16
  end
17
17
 
18
18
  def test_01_bootload
19
- @@sdb = AwsSdb::Service.new
19
+ @@sdb = AwsSdb::Service.new(:logger=>SimpleJSON::DB::LogDuck.new)
20
20
  config = eval(File.open(File.join( File.dirname( File.expand_path(__FILE__)), '..','simple_json_config.rb'), 'r').read)
21
21
  assert(@@sdb.list_domains[0].include?(config['AMAZON_DOMAIN']), 'boot?')
22
22
  end
@@ -79,7 +79,7 @@ class TestSimpleJSONDB < Test::Unit::TestCase
79
79
  assert(o_data[@@id]['more'].size == 2, 'append data?')
80
80
  end
81
81
 
82
- def test_08_query_all
82
+ def test_08_query_id_only
83
83
  o_data = JSON.parse( SimpleJSON.rack_mock(:query, JSON.generate({'' => nil}))[2])
84
84
  assert(o_data.is_a?(Hash),'query all is not a Hash?')
85
85
  assert(o_data.size == 1,'query all Hash contains more than one key value pair')
@@ -87,7 +87,16 @@ class TestSimpleJSONDB < Test::Unit::TestCase
87
87
  assert(o_data[''].to_a.map { |obj| obj[1] }.uniq.size == 1,'query all Hash does not bring id => nil? ')
88
88
  end
89
89
 
90
- def test_09_query_specific_all
90
+ def test_09_query_all
91
+ o_data = JSON.parse( SimpleJSON.rack_mock(:query, JSON.generate({'' => true}))[2])
92
+ assert(o_data.is_a?(Hash),'query all is not a Hash?')
93
+ assert(o_data.size == 1,'query all Hash contains more than one key value pair')
94
+ assert(o_data.has_key?(''),'query all Hash does not contain the query string as key')
95
+ assert(o_data[''].has_key?(@@id))
96
+ assert(o_data[''][@@id].size > 1)
97
+ end
98
+
99
+ def test_10_query_specific_all
91
100
  query = "['name' = '#{@@id}']"
92
101
  t_data = {query => true}
93
102
  o_data = JSON.parse( SimpleJSON.rack_mock(:query, JSON.generate(t_data))[2])
@@ -98,7 +107,7 @@ class TestSimpleJSONDB < Test::Unit::TestCase
98
107
  assert(o_data[query][@@id].size == @@i_data[@@id].size)
99
108
  end
100
109
 
101
- def test_10_query_specific_none
110
+ def test_11_query_specific_none
102
111
  query = "['name' = '#{@@id}']"
103
112
  t_data = {query => nil}
104
113
  o_data = JSON.parse( SimpleJSON.rack_mock(:query, JSON.generate(t_data))[2])
@@ -109,7 +118,7 @@ class TestSimpleJSONDB < Test::Unit::TestCase
109
118
  assert(o_data[query][@@id].nil?)
110
119
  end
111
120
 
112
- def test_11_query_specific_some
121
+ def test_12_query_specific_some
113
122
  query = "['name' = '#{@@id}']"
114
123
  t_data = {query => {'name' => nil, 'more' => nil}}
115
124
  o_data = JSON.parse( SimpleJSON.rack_mock(:query, JSON.generate(t_data))[2])
@@ -120,7 +129,7 @@ class TestSimpleJSONDB < Test::Unit::TestCase
120
129
  assert(o_data[query][@@id].size == 2)
121
130
  end
122
131
 
123
- def test_12_delete
132
+ def test_13_delete
124
133
  o_data = JSON.parse( SimpleJSON.rack_mock(:delete, JSON.generate({@@id => nil}))[2])
125
134
  assert(o_data.is_a?(Hash))
126
135
  assert(o_data.size == 1)
@@ -135,7 +144,7 @@ class TestSimpleJSONDB < Test::Unit::TestCase
135
144
  assert(o_data[@@id].empty?)
136
145
  end
137
146
 
138
- def test_13_other_config
147
+ def test_14_other_config
139
148
  domain = 'other_test_domain'
140
149
  o_data = JSON.parse( SimpleJSON.rack_mock(:delete, JSON.generate({@@id => nil}), {'AMAZON_DOMAIN' => domain})[2])
141
150
  assert(@@sdb.list_domains[0].include?(domain), 'other domain')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-json
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis-Philippe Perron
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-01 00:00:00 -04:00
12
+ date: 2009-10-05 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  version: "0"
79
79
  version:
80
80
  requirements:
81
- - an Amazon Web Service account to access SimpleDB
81
+ - an Amazon Web Service Secret Key to access SimpleDB
82
82
  rubyforge_project: SimpleJSON
83
83
  rubygems_version: 1.3.5
84
84
  signing_key: