sunstone 6.1.0.2 → 6.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/ext/active_record/finder_methods.rb +2 -1
  3. data/lib/active_record/connection_adapters/sunstone/column.rb +1 -1
  4. data/lib/sunstone/version.rb +1 -1
  5. metadata +18 -58
  6. data/.github/workflows/main.yml +0 -141
  7. data/.gitignore +0 -31
  8. data/.tm_properties +0 -1
  9. data/Gemfile +0 -4
  10. data/README.md +0 -46
  11. data/Rakefile +0 -37
  12. data/TODO.md +0 -89
  13. data/sunstone.gemspec +0 -40
  14. data/test/active_record/associations/belongs_to_test.rb +0 -162
  15. data/test/active_record/associations/has_and_belongs_to_many_test.rb +0 -125
  16. data/test/active_record/associations/has_many_test.rb +0 -244
  17. data/test/active_record/eager_loading_test.rb +0 -62
  18. data/test/active_record/persistance_test.rb +0 -184
  19. data/test/active_record/preload_test.rb +0 -51
  20. data/test/active_record/query/all_test.rb +0 -33
  21. data/test/active_record/query/count_test.rb +0 -51
  22. data/test/active_record/query/distinct_test.rb +0 -30
  23. data/test/active_record/query/find_test.rb +0 -37
  24. data/test/active_record/query/limit_test.rb +0 -19
  25. data/test/active_record/query/order_test.rb +0 -27
  26. data/test/active_record/query/where_test.rb +0 -79
  27. data/test/active_record/query_test.rb +0 -131
  28. data/test/active_record/rpc_test.rb +0 -30
  29. data/test/schema_mock.rb +0 -121
  30. data/test/sunstone/connection/column_definition_test.rb +0 -30
  31. data/test/sunstone/connection/configuration_test.rb +0 -44
  32. data/test/sunstone/connection/cookie_store_test.rb +0 -37
  33. data/test/sunstone/connection/request_helper_test.rb +0 -105
  34. data/test/sunstone/connection/send_request_test.rb +0 -164
  35. data/test/sunstone/connection_test.rb +0 -23
  36. data/test/test_helper.rb +0 -153
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52f0e0a557ddc1ec6d7dcc9728d3cfbf602d8c467d1647571cb887b56755e3cc
4
- data.tar.gz: 8db1bd8849700b80328ac2cf1248ff5260659d0afc49648e694fae33790c79cc
3
+ metadata.gz: 67c26e8a4275aa67d9e09b43cfce417732142a043b6ca49d2c1e85bbfb74950d
4
+ data.tar.gz: a46c586fe763e9d90029a007074919fca9e997efa8ddddf57588136d6cb2b883
5
5
  SHA512:
6
- metadata.gz: a656ce5545ac0ad4a3f660f61857e8068a9c1f59060d4e9f9f06b1d80d2f6daca73e3317e02b35669a100ea1f8c578695f8ca0cc3a9eb2f00fc908708c1d18ff
7
- data.tar.gz: 3395da82c6d52adc2029570a459f98cb7311c428a3f92c9f598d61ae8f0b7c5c7a354bb4d88933a6096e2cd5271997f929535f9ad2a35cda2c066d59472dae72
6
+ metadata.gz: 1fd7cb872485fa5507d1bcb21e28e81d92b807279fbdbf12440a74de32cd39c4584c42e6f0ea1fd371261a3c614358967d94c1abc30bb304b2364bb8ae7e9dab
7
+ data.tar.gz: 3d3105125dfaad25f7884648406444ca3a4dab3e2782b482659179ca8a484ce52bded0222af6b48210ad7f0f00c901ca92a3e780380b22d4b62cb3e3c57019f8
@@ -212,7 +212,7 @@ module ActiveRecord
212
212
  ).reflections
213
213
  )
214
214
  )
215
- if has_limit_or_offset?
215
+ if has_limit_or_offset? && !connection.is_a?(ActiveRecord::ConnectionAdapters::SunstoneAPIAdapter)
216
216
  limited_ids = limited_ids_for(relation)
217
217
  limited_ids.empty? ? relation.none! : relation.where!(primary_key => limited_ids)
218
218
  end
@@ -225,6 +225,7 @@ module ActiveRecord
225
225
  relation
226
226
  end
227
227
  end
228
+
228
229
  end
229
230
 
230
231
  end
@@ -8,7 +8,7 @@ module ActiveRecord
8
8
  @name = name.freeze
9
9
  @sql_type_metadata = sql_type_metadata
10
10
  @null = options['null']
11
- @default = options['default']
11
+ @default = (sql_type_metadata.type == :json ? JSON.generate(options['default']) : options['default'])
12
12
  @default_function = nil
13
13
  @collation = nil
14
14
  @table_name = nil
@@ -1,3 +1,3 @@
1
1
  module Sunstone
2
- VERSION = '6.1.0.2'
2
+ VERSION = '6.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunstone
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.0.2
4
+ version: 6.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Bracy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-23 00:00:00.000000000 Z
11
+ date: 2021-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -222,6 +222,20 @@ dependencies:
222
222
  version: '0'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: activerecord
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: 6.1.3
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: 6.1.3
237
+ - !ruby/object:Gem::Dependency
238
+ name: arel-extensions
225
239
  requirement: !ruby/object:Gem::Requirement
226
240
  requirements:
227
241
  - - ">="
@@ -235,7 +249,7 @@ dependencies:
235
249
  - !ruby/object:Gem::Version
236
250
  version: 6.1.0
237
251
  - !ruby/object:Gem::Dependency
238
- name: arel-extensions
252
+ name: activerecord-filter
239
253
  requirement: !ruby/object:Gem::Requirement
240
254
  requirements:
241
255
  - - ">="
@@ -255,14 +269,7 @@ executables: []
255
269
  extensions: []
256
270
  extra_rdoc_files: []
257
271
  files:
258
- - ".github/workflows/main.yml"
259
- - ".gitignore"
260
- - ".tm_properties"
261
- - Gemfile
262
272
  - LICENSE
263
- - README.md
264
- - Rakefile
265
- - TODO.md
266
273
  - ext/active_record/associations.rb
267
274
  - ext/active_record/associations/collection_association.rb
268
275
  - ext/active_record/attribute_methods.rb
@@ -298,30 +305,6 @@ files:
298
305
  - lib/sunstone/exception.rb
299
306
  - lib/sunstone/gis.rb
300
307
  - lib/sunstone/version.rb
301
- - sunstone.gemspec
302
- - test/active_record/associations/belongs_to_test.rb
303
- - test/active_record/associations/has_and_belongs_to_many_test.rb
304
- - test/active_record/associations/has_many_test.rb
305
- - test/active_record/eager_loading_test.rb
306
- - test/active_record/persistance_test.rb
307
- - test/active_record/preload_test.rb
308
- - test/active_record/query/all_test.rb
309
- - test/active_record/query/count_test.rb
310
- - test/active_record/query/distinct_test.rb
311
- - test/active_record/query/find_test.rb
312
- - test/active_record/query/limit_test.rb
313
- - test/active_record/query/order_test.rb
314
- - test/active_record/query/where_test.rb
315
- - test/active_record/query_test.rb
316
- - test/active_record/rpc_test.rb
317
- - test/schema_mock.rb
318
- - test/sunstone/connection/column_definition_test.rb
319
- - test/sunstone/connection/configuration_test.rb
320
- - test/sunstone/connection/cookie_store_test.rb
321
- - test/sunstone/connection/request_helper_test.rb
322
- - test/sunstone/connection/send_request_test.rb
323
- - test/sunstone/connection_test.rb
324
- - test/test_helper.rb
325
308
  homepage: http://sunstonerb.com
326
309
  licenses: []
327
310
  metadata: {}
@@ -344,27 +327,4 @@ rubygems_version: 3.2.3
344
327
  signing_key:
345
328
  specification_version: 4
346
329
  summary: A library for interacting with REST APIs
347
- test_files:
348
- - test/active_record/associations/belongs_to_test.rb
349
- - test/active_record/associations/has_and_belongs_to_many_test.rb
350
- - test/active_record/associations/has_many_test.rb
351
- - test/active_record/eager_loading_test.rb
352
- - test/active_record/persistance_test.rb
353
- - test/active_record/preload_test.rb
354
- - test/active_record/query/all_test.rb
355
- - test/active_record/query/count_test.rb
356
- - test/active_record/query/distinct_test.rb
357
- - test/active_record/query/find_test.rb
358
- - test/active_record/query/limit_test.rb
359
- - test/active_record/query/order_test.rb
360
- - test/active_record/query/where_test.rb
361
- - test/active_record/query_test.rb
362
- - test/active_record/rpc_test.rb
363
- - test/schema_mock.rb
364
- - test/sunstone/connection/column_definition_test.rb
365
- - test/sunstone/connection/configuration_test.rb
366
- - test/sunstone/connection/cookie_store_test.rb
367
- - test/sunstone/connection/request_helper_test.rb
368
- - test/sunstone/connection/send_request_test.rb
369
- - test/sunstone/connection_test.rb
370
- - test/test_helper.rb
330
+ test_files: []
@@ -1,141 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches: [ master ]
6
- pull_request:
7
- branches: [ master ]
8
-
9
- jobs:
10
- sunstone:
11
- name: Sunstone Test
12
- runs-on: ubuntu-20.04
13
-
14
- steps:
15
- - uses: ruby/setup-ruby@v1
16
- with:
17
- ruby-version: 3.0
18
-
19
- - uses: actions/checkout@v2
20
-
21
- - run: bundle
22
-
23
- - run: bundle exec rake test
24
-
25
- ar-postgresql:
26
- name: ActiveRecord PostgresQL Test
27
- strategy:
28
- matrix:
29
- rails: [v6.1.3]
30
-
31
- runs-on: ubuntu-20.04
32
-
33
- steps:
34
- - name: Install Postgresql
35
- run: |
36
- sudo apt-get install curl ca-certificates gnupg
37
- curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
38
- sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
39
- sudo apt-get update
40
- sudo apt-get install postgresql-13
41
- sudo systemctl start postgresql@13-main.service
42
- sudo -u postgres createuser runner --superuser
43
-
44
- - uses: ruby/setup-ruby@v1
45
- with:
46
- ruby-version: 3.0
47
-
48
- - uses: actions/checkout@v2
49
-
50
- - name: Download Rails
51
- run: |
52
- git clone --branch ${{ matrix.rails }} https://github.com/rails/rails.git ~/rails
53
- pushd ~/rails
54
- cat /home/runner/work/_temp/*.sh
55
- sed -i "s/Gem.ruby, '-w'/Gem.ruby, '-w0'/" ~/rails/activerecord/Rakefile
56
- sed -i "s/t.warning = true/t.warning = false/g" ~/rails/activerecord/Rakefile
57
- sed -i "/require 'support\/connection'/a \$LOAD_PATH.unshift\(File.expand_path\(ENV['GITHUB_WORKSPACE']\)\)\nrequire 'sunstone'" ~/rails/activerecord/test/cases/helper.rb
58
- rm ~/rails/Gemfile.lock
59
- sed -i "/# Active Record./a gem 'sunstone', path: File.expand_path\(ENV['GITHUB_WORKSPACE']\)" ~/rails/Gemfile
60
- cat ~/rails/Gemfile
61
- bundle update --jobs=3 --retry=3
62
-
63
- - run: |
64
- pushd ~/rails/activerecord
65
- bundle exec rake db:postgresql:rebuild postgresql:test
66
- bundle exec rake db:postgresql:rebuild postgresql:isolated_test
67
-
68
- ar-sqlite:
69
- name: ActiveRecord SQLite Test
70
- strategy:
71
- matrix:
72
- rails: [v6.1.3]
73
-
74
- runs-on: ubuntu-20.04
75
-
76
- steps:
77
- - uses: ruby/setup-ruby@v1
78
- with:
79
- ruby-version: 3.0
80
-
81
- - uses: actions/checkout@v2
82
-
83
- - name: Download Rails
84
- run: |
85
- git clone --branch ${{ matrix.rails }} https://github.com/rails/rails.git ~/rails
86
- pushd ~/rails
87
- cat /home/runner/work/_temp/*.sh
88
- sed -i "s/Gem.ruby, '-w'/Gem.ruby, '-w0'/" ~/rails/activerecord/Rakefile
89
- sed -i "s/t.warning = true/t.warning = false/g" ~/rails/activerecord/Rakefile
90
- sed -i "/require 'support\/connection'/a \$LOAD_PATH.unshift\(File.expand_path\(ENV['GITHUB_WORKSPACE']\)\)\nrequire 'sunstone'" ~/rails/activerecord/test/cases/helper.rb
91
- rm ~/rails/Gemfile.lock
92
- sed -i "/# Active Record./a gem 'sunstone', path: File.expand_path\(ENV['GITHUB_WORKSPACE']\)" ~/rails/Gemfile
93
- cat ~/rails/Gemfile
94
- bundle update --jobs=3 --retry=3
95
-
96
- - run: |
97
- pushd ~/rails/activerecord
98
- bundle exec rake sqlite3:test
99
- rm test/db/*.sqlite3 test/fixtures/*.sqlite3
100
- bundle exec rake sqlite3:isolated_test
101
- rm test/db/*.sqlite3 test/fixtures/*.sqlite3
102
- bundle exec rake sqlite3_mem:test
103
-
104
- ar-mysql:
105
- name: ActiveRecord MySQL Test
106
- strategy:
107
- matrix:
108
- rails: [v6.1.3]
109
-
110
- runs-on: ubuntu-20.04
111
-
112
- steps:
113
- - name: Install MySQL
114
- run: |
115
- sudo /etc/init.d/mysql start
116
- mysql -uroot -proot -e "CREATE USER 'rails'@'%';"
117
- mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'rails'@'%' WITH GRANT OPTION;"
118
-
119
- - uses: ruby/setup-ruby@v1
120
- with:
121
- ruby-version: 3.0
122
-
123
- - uses: actions/checkout@v2
124
-
125
- - name: Download Rails
126
- run: |
127
- git clone --branch ${{ matrix.rails }} https://github.com/rails/rails.git ~/rails
128
- pushd ~/rails
129
- cat /home/runner/work/_temp/*.sh
130
- sed -i "s/Gem.ruby, '-w'/Gem.ruby, '-w0'/" ~/rails/activerecord/Rakefile
131
- sed -i "s/t.warning = true/t.warning = false/g" ~/rails/activerecord/Rakefile
132
- sed -i "/require 'support\/connection'/a \$LOAD_PATH.unshift\(File.expand_path\(ENV['GITHUB_WORKSPACE']\)\)\nrequire 'sunstone'" ~/rails/activerecord/test/cases/helper.rb
133
- rm ~/rails/Gemfile.lock
134
- sed -i "/# Active Record./a gem 'sunstone', path: File.expand_path\(ENV['GITHUB_WORKSPACE']\)" ~/rails/Gemfile
135
- cat ~/rails/Gemfile
136
- bundle update --jobs=3 --retry=3
137
-
138
- - run: |
139
- pushd ~/rails/activerecord
140
- bundle exec rake db:mysql:rebuild mysql2:test
141
- bundle exec rake db:mysql:rebuild mysql2:isolated_test
data/.gitignore DELETED
@@ -1,31 +0,0 @@
1
- *.gem
2
- *.rbc
3
- /.config
4
- /coverage/
5
- /InstalledFiles
6
- /pkg/
7
- /spec/reports/
8
- /test/tmp/
9
- /test/version_tmp/
10
- /tmp/
11
- .DS_Store
12
-
13
- ## Documentation cache and generated files:
14
- /.yardoc/
15
- /_yardoc/
16
- /doc/
17
- /rdoc/
18
-
19
- ## Environment normalisation:
20
- /.bundle/
21
- /lib/bundler/man/
22
-
23
- # for a library or gem, you might want to ignore these files since the code is
24
- # intended to run in multiple environments; otherwise, check them in:
25
- Gemfile.lock
26
- .ruby-version
27
- .ruby-gemset
28
-
29
- # Text Editor scraps
30
- *~
31
- .byebug_history
data/.tm_properties DELETED
@@ -1 +0,0 @@
1
- exclude = '{$exclude,log,bin,tmp,.tm_properties,coverage}'
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in sunstone.gemspec
4
- gemspec
data/README.md DELETED
@@ -1,46 +0,0 @@
1
- # Sunstone
2
-
3
- Sunstone is an [ActiveRecord](https://rubygems.org/gems/activerecord) adapter for quering
4
- APIs conforming to [Standard API](https://github.com/waratuman/standardapi).
5
-
6
- Configuration
7
- -------------
8
-
9
- ### Rails
10
-
11
- Add `sunstone` to your Gemfile:
12
-
13
- ```ruby
14
- gem 'sunstone'
15
- ```
16
-
17
- Update `config/database.yml`"
18
-
19
- ```yaml
20
- development:
21
- adapter: sunstone
22
- url: https://mystanda.rd/api
23
- api_key: ..optional..
24
- user_agent: ..optional..
25
- ```
26
-
27
- ### Standalone ActiveRecord
28
-
29
- Initialize the connection on `ActiveRecord::Base` or your abstract model (`ApplicationRecord` for example)
30
-
31
- ```ruby
32
- ActiveRecord::Base.establish_connection(
33
- adapter: 'sunstone',
34
- url: 'https://mystanda.rd/api'
35
- )
36
- ```
37
-
38
- Usage
39
- -----
40
-
41
- Mention fitler / etc...
42
-
43
- TODO:
44
- =====
45
- Make `cookie_store` and optional
46
- stream building model instances with wankel
data/Rakefile DELETED
@@ -1,37 +0,0 @@
1
- require 'bundler/setup'
2
- require "bundler/gem_tasks"
3
- Bundler.require(:development)
4
- require 'rake/testtask'
5
- require 'rdoc/task'
6
-
7
- task :console do
8
- exec 'irb -I lib -r sunstone.rb'
9
- end
10
- task :c => :console
11
-
12
- Rake::TestTask.new do |t|
13
- t.libs << 'test'
14
- t.test_files = FileList['test/**/*_test.rb']
15
- t.warning = true
16
- #t.verbose = true
17
- end
18
-
19
- Rake::RDocTask.new do |rd|
20
- rd.main = 'README.md'
21
- rd.title = 'Sunstone Documentation'
22
- rd.rdoc_dir = 'doc'
23
-
24
- rd.options << '-f' << 'sdoc'
25
- rd.options << '-T' << '42floors'
26
- rd.options << '-g' # Generate github links
27
-
28
- rd.rdoc_files.include('README.rdoc')
29
- rd.rdoc_files.include('lib/**/*.rb')
30
- end
31
-
32
- desc "Run tests"
33
- task :default => :test
34
-
35
- namespace :pages do
36
- #TODO: https://github.com/defunkt/sdoc-helpers/blob/master/lib/sdoc_helpers/pages.rb
37
- end
data/TODO.md DELETED
@@ -1,89 +0,0 @@
1
- - Check if `Sunstone#to_key` needs to be added
2
-
3
- - Add `Sunstone::Model::Persistance` with the following methods:
4
-
5
- - `#new_record?`
6
- - `#persisted?`
7
- - `#save`
8
- - `#save!`
9
- - `#update`
10
- - `#update!`
11
- - `#create`
12
- - `#to_param` ?
13
- - `::all`
14
- - `::where` (probably goes in an Arel like engine)
15
- - `::build`
16
- - `::create!`
17
- - `#==`
18
- - `::create`
19
-
20
- ```ruby
21
- # Creates an object and saves it to the MLS. The resulting object is returned
22
- # whether or no the object was saved successfully to the MLS or not.
23
- #
24
- # ==== Examples
25
- # #!ruby
26
- # # Create a single new object
27
- # User.create(:first_name => 'Jamie')
28
- #
29
- # # Create a single object and pass it into a block to set other attributes.
30
- # User.create(:first_name => 'Jamie') do |u|
31
- # u.is_admin = false
32
- # end
33
- def self.create(attributes={}, &block) # TODO: testme
34
- model = self.new(attributes)
35
- yield(model) if block_given?
36
- model.save
37
- model
38
- end
39
-
40
-
41
- - Look at https://gist.github.com/malomalo/91f360fe52db3dbe1c99 files for inspiration, came from
42
- Rails code I think
43
-
44
- - Simplify `Sunstone::Type::Value` to `Sunstone::Type`
45
-
46
- - Add a `find_class(type)` in `Sunstone::Schema`
47
-
48
- - Possibly use Classes to hold information about each attribute in addition to the type
49
-
50
- ```ruby
51
- class MLS::Attribute
52
-
53
- DEFAULT_OPTIONS = { :serialize => true }
54
-
55
- attr_reader :model, :name, :instance_variable_name, :options, :default
56
- attr_reader :reader_visibility, :writer_visibility
57
-
58
- def initialize(name, options={})
59
- @name = name
60
- @instance_variable_name = "@#{@name}".freeze
61
- @options = DEFAULT_OPTIONS.merge(options)
62
-
63
- @default = @options[:default]
64
- @reader_visibility = @options[:reader] || :public
65
- @writer_visibility = @options[:writer] || :public
66
- end
67
- end
68
- ```
69
-
70
- - Use Association classes to model the association:
71
-
72
- ```ruby
73
- class MLS::Association
74
- class BelongsTo
75
- attr_reader :klass, :foreign_key, :foreign_type, :primary_key, :polymorphic
76
-
77
- def initialize(name, options={})
78
- @name = name
79
- @klass = options[:class_name] ? options[:class_name].constantize : name.camelize.constantize
80
-
81
- @polymorphic = options[:polymorphic] || false
82
- @foreign_key = options[:foreign_key] || "#{name}_id".to_sym
83
- @foreign_type = options[:foreign_type] || "#{name}_type".to_sym
84
- @primary_key = options[:primary_key] || :id
85
- end
86
- end
87
-
88
- end
89
- ```