dm-persevere-adapter 0.23.0 → 0.25.0

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.23.0
1
+ 0.25.0
@@ -94,7 +94,6 @@ class Persevere
94
94
 
95
95
  def update(path, resource, headers = {})
96
96
  json_blob = resource.to_json
97
- # puts "JSON to PERSEVERE: #{json_blob}"
98
97
  response = nil
99
98
  while response.nil?
100
99
  begin
@@ -109,7 +108,6 @@ class Persevere
109
108
 
110
109
  def delete(path, headers = {})
111
110
  response = nil
112
- # puts "DELETING #{path}"
113
111
  while response.nil?
114
112
  begin
115
113
  response = @persevere.send_request('DELETE', path, nil, HEADERS.merge(headers))
@@ -174,6 +174,8 @@ module DataMapper
174
174
  class PersevereAdapter < AbstractAdapter
175
175
  extend Chainable
176
176
  extend Deprecate
177
+
178
+ RESERVED_CLASSNAMES = ['User','Transaction','Capability','File','Class']
177
179
 
178
180
  include Migrations::PersevereAdapter
179
181
 
@@ -188,7 +190,7 @@ module DataMapper
188
190
  scale = Property::DEFAULT_SCALE_BIGDECIMAL
189
191
 
190
192
  @type_map ||= {
191
- Types::Serial => { :primitive => 'string' },
193
+ Types::Serial => { :primitive => 'integer' },
192
194
  Types::Boolean => { :primitive => 'boolean' },
193
195
  Integer => { :primitive => 'integer'},
194
196
  String => { :primitive => 'string'},
@@ -426,11 +428,13 @@ module DataMapper
426
428
  else
427
429
  path = "/Class/#{project}/#{name}"
428
430
  end
429
-
430
431
  result = @persevere.retrieve(path)
431
-
432
432
  if result.code == "200"
433
- return result.body
433
+ schemas = [JSON.parse(result.body)].flatten.select{ |schema| not RESERVED_CLASSNAMES.include?(schema['id']) }
434
+ schemas.each do |schema|
435
+ schema['properties']['id'] = { 'type' => Types::Serial}
436
+ end
437
+ return schemas.length > 1 ? schemas : schemas[0]
434
438
  else
435
439
  return false
436
440
  end
@@ -438,7 +442,6 @@ module DataMapper
438
442
 
439
443
  def put_schema(schema_hash, project = nil)
440
444
  path = "/Class/"
441
-
442
445
  if ! project.nil?
443
446
  if schema_hash.has_key?("id")
444
447
  if ! schema_hash['id'].index(project)
@@ -448,6 +451,7 @@ module DataMapper
448
451
  puts "You need an id key/value in the hash"
449
452
  end
450
453
  end
454
+ schema_hash['properties'].delete('id') if schema_hash['properties'].has_key?('id')
451
455
  result = @persevere.create(path, schema_hash)
452
456
  if result.code == '201'
453
457
  return JSON.parse(result.body)
@@ -457,7 +461,6 @@ module DataMapper
457
461
  end
458
462
 
459
463
  def update_schema(schema_hash, project = nil)
460
-
461
464
  id = schema_hash['id']
462
465
  payload = schema_hash.reject{|key,value| key.to_sym.eql?(:id) }
463
466
 
@@ -8,6 +8,8 @@ require agg_dir / 'spec' / 'public' / 'shared' / 'aggregate_shared_spec'
8
8
 
9
9
  require Pathname(__FILE__).dirname.expand_path.parent + 'lib/persevere_adapter'
10
10
 
11
+ require 'ruby-debug'
12
+
11
13
  describe DataMapper::Adapters::PersevereAdapter do
12
14
  before :all do
13
15
  # This needs to point to a valid persevere server
@@ -65,7 +67,7 @@ describe DataMapper::Adapters::PersevereAdapter do
65
67
  Bozon.auto_migrate!
66
68
  Bozon.auto_migrate_down!
67
69
  end
68
-
70
+
69
71
  it "should destroy Create then Remove the Bozon Storage" do
70
72
  @adapter.get_schema(Bozon.storage_name).should == false
71
73
  Bozon.auto_migrate_up!
@@ -90,27 +92,17 @@ describe DataMapper::Adapters::PersevereAdapter do
90
92
 
91
93
  describe '#get_schema' do
92
94
  it 'should return all of the schemas (in json) if no name is provided' do
95
+ # debugger
93
96
  result = @adapter.get_schema()
94
97
  result.should_not == false
95
- JSON.parse(result).class.should == Array
98
+ result.class.should == Array
96
99
  end
97
100
 
98
101
  it 'should return the json schema of the class specified' do
99
102
  result = @adapter.get_schema("Object")
100
103
  result.should_not == false
101
- JSON.parse(result)["id"].should == "Object"
104
+ result["id"].should == "Object"
102
105
  end
103
-
104
- # I don't think we need these tests.
105
- # it 'should return all of the schemas (in json) for a project if no name is provided' do
106
- # result = @adapter.get_schema(nil, "Class")
107
- # debugger
108
- # result
109
- # end
110
- #
111
- # it 'should return all of the schemas (in json) if no name is provided' do
112
- # @adapter.get_schema("Object", "Class")
113
- # end
114
106
  end
115
107
 
116
108
  describe '#update_schema' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-persevere-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan R. Judson
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-01-21 00:00:00 -07:00
13
+ date: 2010-01-25 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency