apicasso 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +226 -223
- data/Rakefile +23 -23
- data/app/controllers/apicasso/apidocs_controller.rb +309 -299
- data/app/controllers/apicasso/application_controller.rb +170 -147
- data/app/controllers/apicasso/crud_controller.rb +246 -245
- data/app/controllers/concerns/orderable.rb +45 -45
- data/app/models/apicasso/ability.rb +38 -38
- data/app/models/apicasso/application_record.rb +6 -6
- data/app/models/apicasso/key.rb +25 -25
- data/app/models/apicasso/request.rb +8 -8
- data/config/routes.rb +14 -14
- data/lib/apicasso/active_record_extension.rb +0 -44
- data/lib/apicasso/engine.rb +13 -13
- data/lib/apicasso/version.rb +3 -3
- data/lib/apicasso.rb +15 -13
- data/lib/generators/apicasso/install/install_generator.rb +25 -25
- data/lib/generators/apicasso/install/templates/create_apicasso_tables.rb +20 -20
- data/spec/dummy/Gemfile +56 -0
- data/spec/dummy/Gemfile.lock +237 -0
- data/spec/dummy/app/controllers/application_controller.rb +1 -1
- data/spec/dummy/app/models/used_model.rb +42 -0
- data/spec/dummy/app/serializers/used_model_serializer.rb +3 -0
- data/spec/dummy/bin/rails +5 -0
- data/spec/dummy/bin/rake +5 -0
- data/spec/dummy/bin/setup +0 -3
- data/spec/dummy/bin/spring +17 -0
- data/spec/dummy/bin/update +0 -3
- data/spec/dummy/config/application.rb +14 -10
- data/spec/dummy/config/cable.yml +1 -1
- data/spec/dummy/config/credentials.yml.enc +1 -0
- data/spec/dummy/config/database.yml +5 -14
- data/spec/dummy/config/environments/development.rb +6 -10
- data/spec/dummy/config/environments/production.rb +1 -10
- data/spec/dummy/config/initializers/cors.rb +16 -0
- data/spec/dummy/config/locales/en.yml +7 -32
- data/spec/dummy/config/routes.rb +1 -1
- data/{db/migrate/20180826141433_create_apicasso_tables.rb → spec/dummy/db/migrate/20180918134607_create_apicasso_tables.rb} +1 -0
- data/spec/dummy/db/migrate/20180918141254_create_used_models.rb +44 -0
- data/spec/dummy/db/migrate/20180919130152_create_active_storage_tables.active_storage.rb +26 -0
- data/spec/dummy/db/migrate/20180920133933_change_used_model_to_validates.rb +7 -0
- data/spec/dummy/db/schema.rb +98 -0
- data/spec/dummy/db/seeds.rb +56 -0
- data/spec/factories/used_model.rb +28 -0
- data/spec/models/used_model_spec.rb +35 -0
- data/spec/rails_helper.rb +66 -0
- data/spec/requests/requests_spec.rb +227 -0
- data/spec/spec_helper.rb +7 -9
- data/spec/support/factory_bot.rb +3 -0
- metadata +83 -64
- data/spec/controllers/apicasso/aplication_controller_spec.rb +0 -18
- data/spec/controllers/apicasso/crud_controller_spec.rb +0 -107
- data/spec/dummy/app/assets/config/manifest.js +0 -3
- data/spec/dummy/app/assets/javascripts/application.js +0 -15
- data/spec/dummy/app/assets/javascripts/cable.js +0 -13
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/channels/application_cable/channel.rb +0 -4
- data/spec/dummy/app/channels/application_cable/connection.rb +0 -4
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/jobs/application_job.rb +0 -2
- data/spec/dummy/app/mailers/application_mailer.rb +0 -4
- data/spec/dummy/app/views/layouts/application.html.erb +0 -15
- data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
- data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
- data/spec/dummy/bin/yarn +0 -11
- data/spec/dummy/config/initializers/assets.rb +0 -14
- data/spec/dummy/config/initializers/content_security_policy.rb +0 -25
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/apicasso_key.rb +0 -9
- data/spec/factories/object.rb +0 -5
- data/spec/models/apicasso/key.rb +0 -5
- data/spec/routing/appointments_routing_spec.rb +0 -38
@@ -1,6 +1,6 @@
|
|
1
|
-
module Apicasso
|
2
|
-
class ApplicationRecord < ActiveRecord::Base
|
3
|
-
self.abstract_class = true
|
4
|
-
self.table_name_prefix = 'apicasso_'
|
5
|
-
end
|
6
|
-
end
|
1
|
+
module Apicasso
|
2
|
+
class ApplicationRecord < ActiveRecord::Base
|
3
|
+
self.abstract_class = true
|
4
|
+
self.table_name_prefix = 'apicasso_'
|
5
|
+
end
|
6
|
+
end
|
data/app/models/apicasso/key.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'securerandom'
|
4
|
-
module Apicasso
|
5
|
-
# A model to abstract API access, with scope options, token generation, request limiting
|
6
|
-
class Key < Apicasso::ApplicationRecord
|
7
|
-
before_create :set_auth_token
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
# Method that generates `SecureRandom.uuid` as token until
|
12
|
-
# an unique one has been acquired
|
13
|
-
def set_auth_token
|
14
|
-
loop do
|
15
|
-
self.token = generate_auth_token
|
16
|
-
break unless self.class.exists?(token: token)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# RFC4122 style token
|
21
|
-
def generate_auth_token
|
22
|
-
SecureRandom.uuid.delete('-')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
module Apicasso
|
5
|
+
# A model to abstract API access, with scope options, token generation, request limiting
|
6
|
+
class Key < Apicasso::ApplicationRecord
|
7
|
+
before_create :set_auth_token
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
# Method that generates `SecureRandom.uuid` as token until
|
12
|
+
# an unique one has been acquired
|
13
|
+
def set_auth_token
|
14
|
+
loop do
|
15
|
+
self.token = generate_auth_token
|
16
|
+
break unless self.class.exists?(token: token)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# RFC4122 style token
|
21
|
+
def generate_auth_token
|
22
|
+
SecureRandom.uuid.delete('-')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Apicasso
|
4
|
-
# A model to abstract API access, with scope options, token generation, request limiting
|
5
|
-
class Request < Apicasso::ApplicationRecord
|
6
|
-
belongs_to :api_key, class_name: 'Apicasso::Key'
|
7
|
-
end
|
8
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Apicasso
|
4
|
+
# A model to abstract API access, with scope options, token generation, request limiting
|
5
|
+
class Request < Apicasso::ApplicationRecord
|
6
|
+
belongs_to :api_key, class_name: 'Apicasso::Key'
|
7
|
+
end
|
8
|
+
end
|
data/config/routes.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
Apicasso::Engine.routes.draw do
|
2
|
-
scope module: :apicasso do
|
3
|
-
resources :apidocs, only: [:index]
|
4
|
-
get '/:resource/', to: 'crud#index', via: :get
|
5
|
-
match '/:resource/', to: 'crud#create', via: :post
|
6
|
-
get '/:resource/:id', to: 'crud#show', via: :get
|
7
|
-
match '/:resource/:id', to: 'crud#update', via: :patch
|
8
|
-
match '/:resource/:id', to: 'crud#destroy', via: :delete
|
9
|
-
match '/:resource/:id/:nested/', to: 'crud#nested_index', via: :get
|
10
|
-
match '/:resource/', to: 'crud#schema', via: :options
|
11
|
-
match '/:resource/:id', to: 'crud#schema', via: :options
|
12
|
-
match '/:resource/:id/:nested/', to: 'crud#schema', via: :options
|
13
|
-
end
|
14
|
-
end
|
1
|
+
Apicasso::Engine.routes.draw do
|
2
|
+
scope module: :apicasso do
|
3
|
+
resources :apidocs, only: [:index]
|
4
|
+
get '/:resource/', to: 'crud#index', via: :get
|
5
|
+
match '/:resource/', to: 'crud#create', via: :post
|
6
|
+
get '/:resource/:id', to: 'crud#show', via: :get
|
7
|
+
match '/:resource/:id', to: 'crud#update', via: :patch
|
8
|
+
match '/:resource/:id', to: 'crud#destroy', via: :delete
|
9
|
+
match '/:resource/:id/:nested/', to: 'crud#nested_index', via: :get
|
10
|
+
match '/:resource/', to: 'crud#schema', via: :options
|
11
|
+
match '/:resource/:id', to: 'crud#schema', via: :options
|
12
|
+
match '/:resource/:id/:nested/', to: 'crud#schema', via: :options
|
13
|
+
end
|
14
|
+
end
|
@@ -29,50 +29,6 @@ module Apicasso
|
|
29
29
|
validated_attrs_for(:presence)
|
30
30
|
end
|
31
31
|
end
|
32
|
-
included do
|
33
|
-
include ::Swagger::Blocks
|
34
|
-
@@klass = self
|
35
|
-
swagger_schema @@klass.name.to_sym do
|
36
|
-
key :required, %i[*presence_validators] if @@klass.presence_validators?
|
37
|
-
@@klass.columns_hash.each do |name, type|
|
38
|
-
property name.to_sym do
|
39
|
-
key :type, type.type
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
swagger_schema "#{@@klass.name}Input".to_sym do
|
44
|
-
allOf do
|
45
|
-
schema do
|
46
|
-
key :'$ref', "#{@@klass.name}Input".to_sym
|
47
|
-
end
|
48
|
-
schema do
|
49
|
-
key :required, %i[*presence_validators] if @@klass.presence_validators?
|
50
|
-
@@klass.columns_hash.each do |name, type|
|
51
|
-
property name.to_sym do
|
52
|
-
key :type, type.type
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
swagger_schema "#{@@klass.name}Metadata".to_sym do
|
59
|
-
allOf do
|
60
|
-
schema do
|
61
|
-
key :'$ref', "#{@@klass.name}Metadata".to_sym
|
62
|
-
end
|
63
|
-
schema do
|
64
|
-
@@klass.columns_hash.each do |name, type|
|
65
|
-
property name.to_sym do
|
66
|
-
key :description, type.type
|
67
|
-
key :type, :string
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
rescue ActiveRecord::ConnectionNotEstablished
|
74
|
-
puts "No database connection to setup APIcasso routes in documentation"
|
75
|
-
end
|
76
32
|
end
|
77
33
|
end
|
78
34
|
|
data/lib/apicasso/engine.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Apicasso
|
4
|
-
# Behavior control for the Apicasso::Engine
|
5
|
-
class Engine < ::Rails::Engine
|
6
|
-
config.generators do |g|
|
7
|
-
g.test_framework :rspec, fixture: false
|
8
|
-
g.fixture_replacement :factory_girl, dir: 'spec/factories'
|
9
|
-
g.assets false
|
10
|
-
g.helper false
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Apicasso
|
4
|
+
# Behavior control for the Apicasso::Engine
|
5
|
+
class Engine < ::Rails::Engine
|
6
|
+
config.generators do |g|
|
7
|
+
g.test_framework :rspec, fixture: false
|
8
|
+
g.fixture_replacement :factory_girl, dir: 'spec/factories'
|
9
|
+
g.assets false
|
10
|
+
g.helper false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/apicasso/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Apicasso
|
2
|
-
VERSION = '0.4.
|
3
|
-
end
|
1
|
+
module Apicasso
|
2
|
+
VERSION = '0.4.6'.freeze
|
3
|
+
end
|
data/lib/apicasso.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'cancancan'
|
4
|
-
require 'swagger/blocks'
|
5
|
-
require 'ransack'
|
6
|
-
require 'will_paginate'
|
7
|
-
require '
|
8
|
-
require 'apicasso/
|
9
|
-
require 'apicasso/
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cancancan'
|
4
|
+
require 'swagger/blocks'
|
5
|
+
require 'ransack'
|
6
|
+
require 'will_paginate/array'
|
7
|
+
require 'will_paginate'
|
8
|
+
require 'apicasso/version'
|
9
|
+
require 'apicasso/engine'
|
10
|
+
require 'apicasso/active_record_extension'
|
11
|
+
require 'friendly_id'
|
12
|
+
|
13
|
+
module Apicasso
|
14
|
+
# Your code goes here...
|
15
|
+
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
require 'rails/generators/migration'
|
2
|
-
|
3
|
-
module Apicasso
|
4
|
-
module Generators
|
5
|
-
class InstallGenerator < ::Rails::Generators::Base
|
6
|
-
include Rails::Generators::Migration
|
7
|
-
source_root File.expand_path('../templates', __FILE__)
|
8
|
-
desc 'Add the required migrations to run APIcasso'
|
9
|
-
|
10
|
-
def self.next_migration_number(path)
|
11
|
-
if @prev_migration_nr
|
12
|
-
@prev_migration_nr += 1
|
13
|
-
else
|
14
|
-
@prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
15
|
-
end
|
16
|
-
@prev_migration_nr.to_s
|
17
|
-
end
|
18
|
-
|
19
|
-
def copy_migrations
|
20
|
-
migration_template 'create_apicasso_tables.rb',
|
21
|
-
'db/migrate/create_apicasso_tables.rb'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
module Apicasso
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < ::Rails::Generators::Base
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
desc 'Add the required migrations to run APIcasso'
|
9
|
+
|
10
|
+
def self.next_migration_number(path)
|
11
|
+
if @prev_migration_nr
|
12
|
+
@prev_migration_nr += 1
|
13
|
+
else
|
14
|
+
@prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
15
|
+
end
|
16
|
+
@prev_migration_nr.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def copy_migrations
|
20
|
+
migration_template 'create_apicasso_tables.rb',
|
21
|
+
'db/migrate/create_apicasso_tables.rb'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
|
-
class CreateApicassoTables < ActiveRecord::Migration[5.0]
|
2
|
-
def change
|
3
|
-
execute <<-SQL
|
4
|
-
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
5
|
-
SQL
|
6
|
-
create_table :apicasso_keys, id: :uuid do |t|
|
7
|
-
t.json :scope
|
8
|
-
t.integer :scope_type
|
9
|
-
t.json :request_limiting
|
10
|
-
t.text :token
|
11
|
-
t.datetime :deleted_at
|
12
|
-
t.timestamps null: false
|
13
|
-
end
|
14
|
-
create_table :apicasso_requests, id: :uuid do |t|
|
15
|
-
t.text :api_key_id
|
16
|
-
t.json :object
|
17
|
-
t.timestamps null: false
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
1
|
+
class CreateApicassoTables < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
execute <<-SQL
|
4
|
+
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
5
|
+
SQL
|
6
|
+
create_table :apicasso_keys, id: :uuid do |t|
|
7
|
+
t.json :scope
|
8
|
+
t.integer :scope_type
|
9
|
+
t.json :request_limiting
|
10
|
+
t.text :token
|
11
|
+
t.datetime :deleted_at
|
12
|
+
t.timestamps null: false
|
13
|
+
end
|
14
|
+
create_table :apicasso_requests, id: :uuid do |t|
|
15
|
+
t.text :api_key_id
|
16
|
+
t.json :object
|
17
|
+
t.timestamps null: false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/spec/dummy/Gemfile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
|
+
|
4
|
+
ruby '2.5.1'
|
5
|
+
|
6
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
7
|
+
gem 'rails', '~> 5.2.0'
|
8
|
+
# Use postgresql as the database for Active Record
|
9
|
+
gem 'pg', '>= 0.18', '< 2.0'
|
10
|
+
# Use Puma as the app server
|
11
|
+
gem 'puma', '~> 3.11'
|
12
|
+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
13
|
+
# gem 'jbuilder', '~> 2.5'
|
14
|
+
# Use Redis adapter to run Action Cable in production
|
15
|
+
gem 'redis', '~> 4.0'
|
16
|
+
# Use ActiveModel has_secure_password
|
17
|
+
# gem 'bcrypt', '~> 3.1.7'
|
18
|
+
|
19
|
+
# Use ActiveStorage variant
|
20
|
+
# gem 'mini_magick', '~> 4.8'
|
21
|
+
|
22
|
+
# Use Capistrano for deployment
|
23
|
+
# gem 'capistrano-rails', group: :development
|
24
|
+
|
25
|
+
# Reduces boot times through caching; required in config/boot.rb
|
26
|
+
gem 'bootsnap', '>= 1.1.0', require: false
|
27
|
+
|
28
|
+
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
|
29
|
+
# gem 'rack-cors'
|
30
|
+
|
31
|
+
# gem 'cancancan'
|
32
|
+
# gem 'ransack'
|
33
|
+
# gem 'will_paginate'
|
34
|
+
gem 'apicasso'
|
35
|
+
gem 'redis-rails'
|
36
|
+
gem 'redis-namespace'
|
37
|
+
gem 'active_model_serializers'
|
38
|
+
|
39
|
+
group :development, :test do
|
40
|
+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
41
|
+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
42
|
+
gem 'rspec-rails'
|
43
|
+
gem 'factory_bot_rails'
|
44
|
+
gem 'faker', :git => 'https://github.com/stympy/faker.git', :branch => 'master'
|
45
|
+
end
|
46
|
+
|
47
|
+
group :development do
|
48
|
+
gem 'listen', '>= 3.0.5', '< 3.2'
|
49
|
+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
50
|
+
gem 'spring'
|
51
|
+
gem 'spring-watcher-listen', '~> 2.0.0'
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
56
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
@@ -0,0 +1,237 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/stympy/faker.git
|
3
|
+
revision: 62b5857970218fc7615deb12d844fc4645c4c69f
|
4
|
+
branch: master
|
5
|
+
specs:
|
6
|
+
faker (1.9.1)
|
7
|
+
i18n (>= 0.7)
|
8
|
+
|
9
|
+
PATH
|
10
|
+
remote: ../APIcasso
|
11
|
+
specs:
|
12
|
+
apicasso (0.4.4)
|
13
|
+
cancancan (~> 2.0)
|
14
|
+
friendly_id (~> 5.2.0)
|
15
|
+
rails (> 5)
|
16
|
+
ransack
|
17
|
+
swagger-blocks
|
18
|
+
will_paginate (~> 3.1.0)
|
19
|
+
|
20
|
+
GEM
|
21
|
+
remote: https://rubygems.org/
|
22
|
+
specs:
|
23
|
+
actioncable (5.2.1)
|
24
|
+
actionpack (= 5.2.1)
|
25
|
+
nio4r (~> 2.0)
|
26
|
+
websocket-driver (>= 0.6.1)
|
27
|
+
actionmailer (5.2.1)
|
28
|
+
actionpack (= 5.2.1)
|
29
|
+
actionview (= 5.2.1)
|
30
|
+
activejob (= 5.2.1)
|
31
|
+
mail (~> 2.5, >= 2.5.4)
|
32
|
+
rails-dom-testing (~> 2.0)
|
33
|
+
actionpack (5.2.1)
|
34
|
+
actionview (= 5.2.1)
|
35
|
+
activesupport (= 5.2.1)
|
36
|
+
rack (~> 2.0)
|
37
|
+
rack-test (>= 0.6.3)
|
38
|
+
rails-dom-testing (~> 2.0)
|
39
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
40
|
+
actionview (5.2.1)
|
41
|
+
activesupport (= 5.2.1)
|
42
|
+
builder (~> 3.1)
|
43
|
+
erubi (~> 1.4)
|
44
|
+
rails-dom-testing (~> 2.0)
|
45
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
46
|
+
active_model_serializers (0.10.8)
|
47
|
+
actionpack (>= 4.1, < 6)
|
48
|
+
activemodel (>= 4.1, < 6)
|
49
|
+
case_transform (>= 0.2)
|
50
|
+
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
51
|
+
activejob (5.2.1)
|
52
|
+
activesupport (= 5.2.1)
|
53
|
+
globalid (>= 0.3.6)
|
54
|
+
activemodel (5.2.1)
|
55
|
+
activesupport (= 5.2.1)
|
56
|
+
activerecord (5.2.1)
|
57
|
+
activemodel (= 5.2.1)
|
58
|
+
activesupport (= 5.2.1)
|
59
|
+
arel (>= 9.0)
|
60
|
+
activestorage (5.2.1)
|
61
|
+
actionpack (= 5.2.1)
|
62
|
+
activerecord (= 5.2.1)
|
63
|
+
marcel (~> 0.3.1)
|
64
|
+
activesupport (5.2.1)
|
65
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
66
|
+
i18n (>= 0.7, < 2)
|
67
|
+
minitest (~> 5.1)
|
68
|
+
tzinfo (~> 1.1)
|
69
|
+
arel (9.0.0)
|
70
|
+
bootsnap (1.3.2)
|
71
|
+
msgpack (~> 1.0)
|
72
|
+
builder (3.2.3)
|
73
|
+
byebug (10.0.2)
|
74
|
+
cancancan (2.3.0)
|
75
|
+
case_transform (0.2)
|
76
|
+
activesupport
|
77
|
+
concurrent-ruby (1.1.1)
|
78
|
+
crass (1.0.4)
|
79
|
+
diff-lcs (1.3)
|
80
|
+
erubi (1.7.1)
|
81
|
+
factory_bot (4.11.1)
|
82
|
+
activesupport (>= 3.0.0)
|
83
|
+
factory_bot_rails (4.11.1)
|
84
|
+
factory_bot (~> 4.11.1)
|
85
|
+
railties (>= 3.0.0)
|
86
|
+
ffi (1.9.25)
|
87
|
+
friendly_id (5.2.4)
|
88
|
+
activerecord (>= 4.0.0)
|
89
|
+
globalid (0.4.1)
|
90
|
+
activesupport (>= 4.2.0)
|
91
|
+
i18n (1.1.1)
|
92
|
+
concurrent-ruby (~> 1.0)
|
93
|
+
jsonapi-renderer (0.2.0)
|
94
|
+
listen (3.1.5)
|
95
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
96
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
97
|
+
ruby_dep (~> 1.2)
|
98
|
+
loofah (2.2.3)
|
99
|
+
crass (~> 1.0.2)
|
100
|
+
nokogiri (>= 1.5.9)
|
101
|
+
mail (2.7.1)
|
102
|
+
mini_mime (>= 0.1.1)
|
103
|
+
marcel (0.3.3)
|
104
|
+
mimemagic (~> 0.3.2)
|
105
|
+
method_source (0.9.1)
|
106
|
+
mimemagic (0.3.2)
|
107
|
+
mini_mime (1.0.1)
|
108
|
+
mini_portile2 (2.3.0)
|
109
|
+
minitest (5.11.3)
|
110
|
+
msgpack (1.2.4)
|
111
|
+
nio4r (2.3.1)
|
112
|
+
nokogiri (1.8.5)
|
113
|
+
mini_portile2 (~> 2.3.0)
|
114
|
+
pg (1.1.3)
|
115
|
+
puma (3.12.0)
|
116
|
+
rack (2.0.5)
|
117
|
+
rack-test (1.1.0)
|
118
|
+
rack (>= 1.0, < 3)
|
119
|
+
rails (5.2.1)
|
120
|
+
actioncable (= 5.2.1)
|
121
|
+
actionmailer (= 5.2.1)
|
122
|
+
actionpack (= 5.2.1)
|
123
|
+
actionview (= 5.2.1)
|
124
|
+
activejob (= 5.2.1)
|
125
|
+
activemodel (= 5.2.1)
|
126
|
+
activerecord (= 5.2.1)
|
127
|
+
activestorage (= 5.2.1)
|
128
|
+
activesupport (= 5.2.1)
|
129
|
+
bundler (>= 1.3.0)
|
130
|
+
railties (= 5.2.1)
|
131
|
+
sprockets-rails (>= 2.0.0)
|
132
|
+
rails-dom-testing (2.0.3)
|
133
|
+
activesupport (>= 4.2.0)
|
134
|
+
nokogiri (>= 1.6)
|
135
|
+
rails-html-sanitizer (1.0.4)
|
136
|
+
loofah (~> 2.2, >= 2.2.2)
|
137
|
+
railties (5.2.1)
|
138
|
+
actionpack (= 5.2.1)
|
139
|
+
activesupport (= 5.2.1)
|
140
|
+
method_source
|
141
|
+
rake (>= 0.8.7)
|
142
|
+
thor (>= 0.19.0, < 2.0)
|
143
|
+
rake (12.3.1)
|
144
|
+
ransack (2.1.0)
|
145
|
+
actionpack (>= 5.0)
|
146
|
+
activerecord (>= 5.0)
|
147
|
+
activesupport (>= 5.0)
|
148
|
+
i18n
|
149
|
+
rb-fsevent (0.10.3)
|
150
|
+
rb-inotify (0.9.10)
|
151
|
+
ffi (>= 0.5.0, < 2)
|
152
|
+
redis (4.0.3)
|
153
|
+
redis-actionpack (5.0.2)
|
154
|
+
actionpack (>= 4.0, < 6)
|
155
|
+
redis-rack (>= 1, < 3)
|
156
|
+
redis-store (>= 1.1.0, < 2)
|
157
|
+
redis-activesupport (5.0.7)
|
158
|
+
activesupport (>= 3, < 6)
|
159
|
+
redis-store (>= 1.3, < 2)
|
160
|
+
redis-namespace (1.6.0)
|
161
|
+
redis (>= 3.0.4)
|
162
|
+
redis-rack (2.0.4)
|
163
|
+
rack (>= 1.5, < 3)
|
164
|
+
redis-store (>= 1.2, < 2)
|
165
|
+
redis-rails (5.0.2)
|
166
|
+
redis-actionpack (>= 5.0, < 6)
|
167
|
+
redis-activesupport (>= 5.0, < 6)
|
168
|
+
redis-store (>= 1.2, < 2)
|
169
|
+
redis-store (1.6.0)
|
170
|
+
redis (>= 2.2, < 5)
|
171
|
+
rspec-core (3.8.0)
|
172
|
+
rspec-support (~> 3.8.0)
|
173
|
+
rspec-expectations (3.8.2)
|
174
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
175
|
+
rspec-support (~> 3.8.0)
|
176
|
+
rspec-mocks (3.8.0)
|
177
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
178
|
+
rspec-support (~> 3.8.0)
|
179
|
+
rspec-rails (3.8.1)
|
180
|
+
actionpack (>= 3.0)
|
181
|
+
activesupport (>= 3.0)
|
182
|
+
railties (>= 3.0)
|
183
|
+
rspec-core (~> 3.8.0)
|
184
|
+
rspec-expectations (~> 3.8.0)
|
185
|
+
rspec-mocks (~> 3.8.0)
|
186
|
+
rspec-support (~> 3.8.0)
|
187
|
+
rspec-support (3.8.0)
|
188
|
+
ruby_dep (1.5.0)
|
189
|
+
spring (2.0.2)
|
190
|
+
activesupport (>= 4.2)
|
191
|
+
spring-watcher-listen (2.0.1)
|
192
|
+
listen (>= 2.7, < 4.0)
|
193
|
+
spring (>= 1.2, < 3.0)
|
194
|
+
sprockets (3.7.2)
|
195
|
+
concurrent-ruby (~> 1.0)
|
196
|
+
rack (> 1, < 3)
|
197
|
+
sprockets-rails (3.2.1)
|
198
|
+
actionpack (>= 4.0)
|
199
|
+
activesupport (>= 4.0)
|
200
|
+
sprockets (>= 3.0.0)
|
201
|
+
swagger-blocks (2.0.2)
|
202
|
+
thor (0.20.0)
|
203
|
+
thread_safe (0.3.6)
|
204
|
+
tzinfo (1.2.5)
|
205
|
+
thread_safe (~> 0.1)
|
206
|
+
websocket-driver (0.7.0)
|
207
|
+
websocket-extensions (>= 0.1.0)
|
208
|
+
websocket-extensions (0.1.3)
|
209
|
+
will_paginate (3.1.6)
|
210
|
+
|
211
|
+
PLATFORMS
|
212
|
+
ruby
|
213
|
+
|
214
|
+
DEPENDENCIES
|
215
|
+
active_model_serializers
|
216
|
+
apicasso!
|
217
|
+
bootsnap (>= 1.1.0)
|
218
|
+
byebug
|
219
|
+
factory_bot_rails
|
220
|
+
faker!
|
221
|
+
listen (>= 3.0.5, < 3.2)
|
222
|
+
pg (>= 0.18, < 2.0)
|
223
|
+
puma (~> 3.11)
|
224
|
+
rails (~> 5.2.0)
|
225
|
+
redis (~> 4.0)
|
226
|
+
redis-namespace
|
227
|
+
redis-rails
|
228
|
+
rspec-rails
|
229
|
+
spring
|
230
|
+
spring-watcher-listen (~> 2.0.0)
|
231
|
+
tzinfo-data
|
232
|
+
|
233
|
+
RUBY VERSION
|
234
|
+
ruby 2.5.1p57
|
235
|
+
|
236
|
+
BUNDLED WITH
|
237
|
+
1.16.6
|
@@ -1,2 +1,2 @@
|
|
1
|
-
class ApplicationController < ActionController::
|
1
|
+
class ApplicationController < ActionController::API
|
2
2
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class UsedModel < ApplicationRecord
|
2
|
+
include Rails.application.routes.url_helpers
|
3
|
+
|
4
|
+
validates :account_id, presence: true
|
5
|
+
validates :unit_id, presence: true
|
6
|
+
validates :slug, presence: true, uniqueness: true
|
7
|
+
|
8
|
+
has_one_attached :file_highlighted
|
9
|
+
has_many_attached :files
|
10
|
+
|
11
|
+
extend FriendlyId
|
12
|
+
friendly_id :name, use: :slugged
|
13
|
+
|
14
|
+
def file_highlighted_url
|
15
|
+
rails_blob_path(file_highlighted, only_path: true) if nil? { file_highlighted_url = nil }
|
16
|
+
end
|
17
|
+
|
18
|
+
def files_url
|
19
|
+
used_model_attachments = self.files.attachments
|
20
|
+
urls = []
|
21
|
+
used_model_attachments.each do |attachment|
|
22
|
+
urls << rails_blob_path(attachment, only_path: true)
|
23
|
+
end
|
24
|
+
urls
|
25
|
+
end
|
26
|
+
|
27
|
+
def cache_key(*timestamp_names)
|
28
|
+
case
|
29
|
+
when new_record?
|
30
|
+
"#{model_name.cache_key}/new"
|
31
|
+
when timestamp_names.any?
|
32
|
+
timestamp = max_updated_column_timestamp(timestamp_names = timestamp_attributes_for_update_in_model)
|
33
|
+
timestamp = timestamp.utc.to_s(cache_timestamp_format)
|
34
|
+
"#{model_name.cache_key}/#{id}-#{timestamp}"
|
35
|
+
when timestamp = max_updated_column_timestamp
|
36
|
+
timestamp = timestamp.utc.to_s(cache_timestamp_format)
|
37
|
+
"#{model_name.cache_key}/#{id}-#{timestamp}"
|
38
|
+
else
|
39
|
+
"#{model_name.cache_key}/#{id}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/spec/dummy/bin/rails
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
begin
|
3
|
+
load File.expand_path('../spring', __FILE__)
|
4
|
+
rescue LoadError => e
|
5
|
+
raise unless e.message.include?('spring')
|
6
|
+
end
|
2
7
|
APP_PATH = File.expand_path('../config/application', __dir__)
|
3
8
|
require_relative '../config/boot'
|
4
9
|
require 'rails/commands'
|