rom-fmp 0.0.4

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.
@@ -0,0 +1,48 @@
1
+ module ROM
2
+ module SQL
3
+ class Relation < ROM::Relation
4
+ module ClassMethods
5
+ def inherited(klass)
6
+ klass.class_eval do
7
+ class << self
8
+ attr_reader :model, :associations
9
+ end
10
+ end
11
+ klass.instance_variable_set('@model', Class.new(Sequel::Model))
12
+ klass.instance_variable_set('@associations', [])
13
+ super
14
+ end
15
+
16
+ def one_to_many(name, options)
17
+ associations << [__method__, name, options.merge(relation: name)]
18
+ end
19
+
20
+ def many_to_many(name, options = {})
21
+ associations << [__method__, name, options.merge(relation: name)]
22
+ end
23
+
24
+ def many_to_one(name, options = {})
25
+ relation_name = Inflector.pluralize(name).to_sym
26
+ new_options = options.merge(relation: relation_name)
27
+ associations << [__method__, name, new_options]
28
+ end
29
+
30
+ def finalize(relations, relation)
31
+ model.set_dataset(relation.dataset)
32
+ model.dataset.naked!
33
+
34
+ associations.each do |*args, options|
35
+ model = relation.model
36
+ other = relations[options.fetch(:relation)].model
37
+
38
+ model.public_send(*args, options.merge(class: other))
39
+ end
40
+
41
+ model.freeze
42
+
43
+ super
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,16 @@
1
+ module ROM
2
+ module SQL
3
+ class Relation < ROM::Relation
4
+ module Inspection
5
+ def model
6
+ self.class.model
7
+ end
8
+
9
+ # @api private
10
+ def primary_key
11
+ model.primary_key
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env ruby
2
+ # YAML structure defining a SAX parsing scheme for fmresultset xml.
3
+ # The initial object of this parse should be a new instance of Rfm::Resultset.
4
+ # This template is intended for use with dm-filemaker-adapter, and not as
5
+ # a general Rfm::Resultset template.
6
+ ---
7
+ # I don't know how this would affect output.
8
+ #attach: [private, 'ROM::FMP::Dataset', ':new', self]
9
+
10
+ attach_elements: _meta
11
+ attach_attributes: _meta
12
+ create_accessors: all
13
+ elements:
14
+ - name: doctype
15
+ attach: none
16
+ attributes:
17
+ - name: value
18
+ as_name: doctype
19
+ - name: fmresultset
20
+ attach: none
21
+ - name: product
22
+ - name: error
23
+ attach: none
24
+ before_close: :check_for_errors
25
+ attributes:
26
+ - name: code
27
+ as_name: error
28
+ - name: datasource
29
+ attach: none
30
+ before_close: [object, end_datasource_element_callback, self]
31
+ attributes:
32
+ - name: total_count
33
+ accessor: none
34
+ - name: metadata
35
+ attach: none
36
+ - name: field_definition
37
+ attach: [cursor, 'Rfm::Metadata::Field', ':allocate']
38
+ delimiter: name
39
+ attach_attributes: private
40
+ before_close: [object, field_definition_element_close_callback, self]
41
+ - name: relatedset_definition
42
+ delimiter: table
43
+ as_name: portal_meta
44
+ attach_attributes: private
45
+ elements:
46
+ - name: field_definition
47
+ attach: [cursor, 'Rfm::Metadata::Field', ':allocate']
48
+ delimiter: name
49
+ as_name: field_meta
50
+ attach_attributes: private
51
+ before_close: [object, relatedset_field_definition_element_close_callback, self]
52
+ - name: resultset
53
+ attach: none
54
+ attributes:
55
+ - name: count
56
+ accessor: none
57
+ - name: fetch_size
58
+ accessor: none
59
+ - name: record
60
+ #attach: [array, 'Rfm::Record', new, object]
61
+ attach: [array, 'Hash', new]
62
+ attach_attributes: private
63
+ compact: true
64
+ #before_close: '@loaded=true'
65
+ elements:
66
+ - name: field
67
+ attach: [cursor, 'Rfm::Metadata::Datum', ':allocate']
68
+ compact: false
69
+ before_close: [object, field_element_close_callback, self]
70
+ - name: relatedset
71
+ attach: [private, 'Rfm::Resultset', ':allocate']
72
+ as_name: portals
73
+ attach_attributes: private
74
+ create_accessors: all
75
+ delimiter: table
76
+ elements:
77
+ - name: record
78
+ attach: [default, 'Hash', ':allocate']
79
+ attach_attributes: private
80
+ #before_close: '@loaded=true'
81
+ elements:
82
+ - name: field
83
+ compact: true
84
+ attach: [cursor, 'Rfm::Metadata::Datum', ':allocate']
85
+ before_close: [object, portal_field_element_close_callback, self]
86
+
@@ -0,0 +1,8 @@
1
+ require 'rfm'
2
+
3
+ class Rfm::Layout
4
+ # Strip out unnecessary output in Rfm::Layout#inspect
5
+ def inspect
6
+ "#<#{self.class.name}:#{self.object_id} @name=#{self.name} @database=#{database.name} @server=#{server.host_name} @loaded=#{@loaded}>"
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module ROM
2
+ module FMP
3
+ VERSION = "0.0.4"
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rom/fmp/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rom-fmp"
8
+ spec.version = ROM::FMP::VERSION
9
+ spec.authors = ["wbr"]
10
+ spec.email = ["wbr@mac.com"]
11
+ spec.summary = %q{Filemaker adapter for rom-rb}
12
+ spec.description = %q{Allows ROM to use Filemaker Server as a datastore}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "rom", "~> 0.9"
22
+ spec.add_runtime_dependency "ginjo-rfm", "~> 3.0.11"
23
+ spec.add_runtime_dependency "charlatan", "~> 0.1"
24
+
25
+ spec.add_development_dependency "bundler"#, "~> 1.7"
26
+ spec.add_development_dependency "rake"#, "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.2"
28
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe ROM::FMP do
4
+ it 'has a version number' do
5
+ expect(ROM::FMP::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'loads ginjo-rfm gem ~> 3.0' do
9
+ expect(Rfm::VERSION.major).to eq('3')
10
+ expect(Rfm::VERSION.minor).to eq('0')
11
+ end
12
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ require 'rom/lint/spec'
4
+
5
+ # These pass!
6
+ describe ROM::FMP::Gateway do
7
+ let(:result){[Rfm::Layout.new('layout_one', DB_CONFIG), Rfm::Layout.new('layout_two', DB_CONFIG)]}
8
+ before do
9
+ allow(result).to receive(:all).and_return(result)
10
+ allow(result).to receive(:names).and_return(result)
11
+ allow_any_instance_of(Rfm::Database).to receive(:layouts).and_return(result)
12
+ end
13
+
14
+ it_behaves_like 'a rom gateway' do
15
+ let(:identifier) { :fmp }
16
+ let(:gateway) { ROM::FMP::Gateway }
17
+ let(:uri) { DB_CONFIG }
18
+ end
19
+ end
20
+
21
+ # This is really for Dataset, which doesn't exist for rom-fmp as a distinct class yet.
22
+ # Taken from https://github.com/rom-rb/rom/blob/master/spec/unit/rom/memory/dataset_spec.rb
23
+ # These don't pass (yet).
24
+ describe 'ROM::FMP::Gateway#dataset' do
25
+ let(:layouts){[Rfm::Layout.new('layout_one', DB_CONFIG), Rfm::Layout.new('layout_two', DB_CONFIG)]}
26
+ before do
27
+ allow(layouts).to receive(:all).and_return(layouts)
28
+ allow(layouts).to receive(:names).and_return(layouts.map {|r| r.name})
29
+ allow(layouts[0]).to receive(:find).and_return(data)
30
+ allow_any_instance_of(Rfm::Database).to receive(:layouts).and_return(layouts)
31
+ end
32
+
33
+ # Use this when a ROM::FMP::Dataset class doesn't exist yet.
34
+ #subject(:dataset) { Rfm::Layout.new('layout_one', DB_CONFIG) } #{ described_class.new(data) }
35
+
36
+ # Use this after you develop a ROM::FMP::Dataset class
37
+ subject(:dataset) { ROM::FMP::Dataset.new(layouts[0]) } #{ described_class.new(data) }
38
+
39
+ before do
40
+ allow_any_instance_of(Rfm::Layout).to receive(:get_records).and_return(data)
41
+ end
42
+
43
+ let(:data) do
44
+ [
45
+ { name: 'Jane', email: 'jane@doe.org', age: 10 },
46
+ { name: 'Jade', email: 'jade@doe.org', age: 11 },
47
+ { name: 'Joe', email: 'joe@doe.org', age: 12 }
48
+ ]
49
+ end
50
+
51
+ it_behaves_like "a rom enumerable dataset"
52
+
53
+ end
@@ -0,0 +1,17 @@
1
+ # require 'spec_helper'
2
+ #
3
+ # require 'rom/lint/spec'
4
+ #
5
+ # # These pass!
6
+ # describe ROM::FMP::Relation do
7
+ #
8
+ # # This doesn't exist.
9
+ # it_behaves_like 'a rom relation' do
10
+ # let(:identifier) { :fmp }
11
+ # let(:gateway) { ROM::FMP::Gateway }
12
+ # let(:uri) { DB_CONFIG }
13
+ # end
14
+ #
15
+ # end
16
+
17
+
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'rom/fmp'
3
+
4
+ DB_CONFIG = {
5
+ adapter: 'fmp',
6
+ host: 'cerne03.cernesystems.com',
7
+ account_name: 'test',
8
+ password: 'test',
9
+ database: 'PUBLIC',
10
+ ssl: 'true',
11
+ port: 443,
12
+ root_cert: false,
13
+ log_actions: true,
14
+ log_responses: false
15
+ }
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rom-fmp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - wbr
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rom
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ginjo-rfm
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.0.11
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.0.11
41
+ - !ruby/object:Gem::Dependency
42
+ name: charlatan
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.2'
97
+ description: Allows ROM to use Filemaker Server as a datastore
98
+ email:
99
+ - wbr@mac.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - CHANGELOG.md
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - lib/rom-fmp.rb
113
+ - lib/rom/fmp.rb
114
+ - lib/rom/fmp/commands.rb
115
+ - lib/rom/fmp/commands/create.rb
116
+ - lib/rom/fmp/commands/delete.rb
117
+ - lib/rom/fmp/commands/update.rb
118
+ - lib/rom/fmp/dataset.rb
119
+ - lib/rom/fmp/gateway.rb
120
+ - lib/rom/fmp/header.rb
121
+ - lib/rom/fmp/micro01.rb
122
+ - lib/rom/fmp/micro02.rb
123
+ - lib/rom/fmp/mini.rb
124
+ - lib/rom/fmp/relation.rb
125
+ - lib/rom/fmp/relation/associations.rb
126
+ - lib/rom/fmp/relation/class_methods.rb
127
+ - lib/rom/fmp/relation/inspection.rb
128
+ - lib/rom/fmp/rfm/fmresultset.yml
129
+ - lib/rom/fmp/rfm/layout.rb
130
+ - lib/rom/fmp/version.rb
131
+ - rom-fmp.gemspec
132
+ - spec/rom/fmp_spec.rb
133
+ - spec/rom/gateway_spec.rb
134
+ - spec/rom/relation_spec.rb
135
+ - spec/spec_helper.rb
136
+ homepage: ''
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.4.5
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: Filemaker adapter for rom-rb
160
+ test_files:
161
+ - spec/rom/fmp_spec.rb
162
+ - spec/rom/gateway_spec.rb
163
+ - spec/rom/relation_spec.rb
164
+ - spec/spec_helper.rb