administrate-field-jsontable 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -0
  3. data/.rubocop.yml +96 -0
  4. data/Gemfile +9 -1
  5. data/Gemfile.lock +43 -17
  6. data/README.md +7 -0
  7. data/Rakefile +11 -0
  8. data/administrate-field-jsontable.gemspec +1 -1
  9. data/app/views/fields/jsontable/_index.html.erb +18 -0
  10. data/app/views/fields/jsontable/_json_table_field.html.erb +30 -0
  11. data/app/views/fields/jsontable/_show.html.erb +2 -29
  12. data/lib/administrate/field/jsontable.rb +2 -0
  13. data/spec/example_app/app/assets/config/manifest.js +2 -0
  14. data/spec/example_app/app/assets/javascripts/application.js +15 -0
  15. data/spec/example_app/app/assets/stylesheets/application.css +15 -0
  16. data/spec/example_app/app/controllers/application_controller.rb +7 -0
  17. data/spec/example_app/app/models/application_record.rb +5 -0
  18. data/spec/example_app/app/views/layouts/application.html.erb +31 -0
  19. data/spec/example_app/app/views/pages/.keep +0 -0
  20. data/spec/example_app/config.ru +6 -0
  21. data/spec/example_app/config/application.rb +39 -0
  22. data/spec/example_app/config/boot.rb +4 -0
  23. data/spec/example_app/config/database.yml +11 -0
  24. data/spec/example_app/config/environment.rb +7 -0
  25. data/spec/example_app/config/environments/development.rb +39 -0
  26. data/spec/example_app/config/environments/production.rb +78 -0
  27. data/spec/example_app/config/environments/staging.rb +3 -0
  28. data/spec/example_app/config/environments/test.rb +43 -0
  29. data/spec/example_app/config/initializers/assets.rb +13 -0
  30. data/spec/example_app/config/initializers/backtrace_silencers.rb +8 -0
  31. data/spec/example_app/config/initializers/cookies_serializer.rb +5 -0
  32. data/spec/example_app/config/initializers/disable_xml_params.rb +5 -0
  33. data/spec/example_app/config/initializers/errors.rb +20 -0
  34. data/spec/example_app/config/initializers/filter_parameter_logging.rb +6 -0
  35. data/spec/example_app/config/initializers/inflections.rb +18 -0
  36. data/spec/example_app/config/initializers/json_encoding.rb +3 -0
  37. data/spec/example_app/config/initializers/mime_types.rb +5 -0
  38. data/spec/example_app/config/initializers/session_store.rb +5 -0
  39. data/spec/example_app/config/initializers/wrap_parameters.rb +16 -0
  40. data/spec/example_app/config/routes.rb +4 -0
  41. data/spec/example_app/config/secrets.yml +15 -0
  42. data/spec/example_app/db/schema.rb +18 -0
  43. data/spec/example_app/db/seeds.rb +8 -0
  44. data/spec/example_app/public/robots.txt +5 -0
  45. data/spec/fixtures/jsontable/array_contains_hash.html +1 -0
  46. data/spec/fixtures/jsontable/hash_contains_array.html +31 -0
  47. data/spec/fixtures/jsontable/pure_hash.html +58 -0
  48. data/spec/lib/administrate/field/jsontable_index_spec.rb +95 -0
  49. data/spec/lib/administrate/field/jsontable_show_spec.rb +95 -0
  50. data/spec/lib/administrate/field/jsontable_spec.rb +16 -5
  51. data/spec/rails_helper.rb +6 -0
  52. data/spec/support/read_fixture.rb +7 -0
  53. metadata +84 -2
File without changes
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is used by Rack-based servers to start the application.
4
+
5
+ require ::File.expand_path('config/environment', __dir__)
6
+ run Rails.application
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('boot', __dir__)
4
+
5
+ require 'active_model/railtie'
6
+ require 'active_record/railtie'
7
+ require 'active_job/railtie'
8
+ require 'action_controller/railtie'
9
+ require 'action_view/railtie'
10
+ require 'sprockets/railtie'
11
+
12
+ # Require the gems listed in Gemfile, including any gems
13
+ # you've limited to :test, :development, or :production.
14
+ Bundler.require(*Rails.groups)
15
+
16
+ module AdministrateJsontablePrototype
17
+ class Application < Rails::Application
18
+ config.i18n.enforce_available_locales = true
19
+
20
+ config.generators do |generate|
21
+ generate.helper false
22
+ generate.javascript_engine false
23
+ generate.request_specs false
24
+ generate.routing_specs false
25
+ generate.stylesheets false
26
+ generate.test_framework :rspec
27
+ generate.view_specs false
28
+ end
29
+
30
+ config.action_controller.action_on_unpermitted_parameters = :raise
31
+
32
+ if Rails::VERSION::MAJOR < 5
33
+ # Do not swallow errors in after_commit/after_rollback callbacks.
34
+ config.active_record.raise_in_transactional_callbacks = true
35
+ end
36
+
37
+ config.active_record.time_zone_aware_types = %i[datetime time] if Rails::VERSION::MAJOR >= 5
38
+ end
39
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
4
+ require 'bundler/setup'
@@ -0,0 +1,11 @@
1
+ development: &default
2
+ adapter: postgresql
3
+ database: administrate-jsontable_prototype_development
4
+ encoding: utf8
5
+ min_messages: warning
6
+ pool: 2
7
+ timeout: 5000
8
+
9
+ test:
10
+ <<: *default
11
+ database: administrate-jsontable_prototype_test
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Load the Rails application.
4
+ require_relative 'application'
5
+
6
+ # Initialize the Rails application.
7
+ Rails.application.initialize!
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # In the development environment your application's code is reloaded on
7
+ # every request. This slows down response time but is perfect for development
8
+ # since you don't have to restart the web server when you make code changes.
9
+ config.cache_classes = false
10
+
11
+ # Do not eager load code on boot.
12
+ config.eager_load = false
13
+
14
+ # Show full error reports and disable caching.
15
+ config.consider_all_requests_local = true
16
+ config.action_controller.perform_caching = false
17
+ config.cache_store = :null_store
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Raise an error on page load if there are pending migrations.
23
+ config.active_record.migration_error = :page_load
24
+
25
+ # Highlight code that triggered database queries in logs.
26
+ config.active_record.verbose_query_logs = true
27
+
28
+ # Debug mode disables concatenation and preprocessing of assets.
29
+ # This option may cause significant delays in view rendering with a large
30
+ # number of complex assets.
31
+ config.assets.debug = true
32
+ config.i18n.default_locale = :tr
33
+
34
+ # Suppress logger output for asset requests.
35
+ config.assets.quiet = true
36
+
37
+ # Raises error for missing translations.
38
+ config.action_view.raise_on_missing_translations = true
39
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # Code is not reloaded between requests.
7
+ config.cache_classes = true
8
+
9
+ # Eager load code on boot. This eager loads most of Rails and
10
+ # your application in memory, allowing both threaded web servers
11
+ # and those relying on copy on write to perform better.
12
+ # Rake tasks automatically ignore this option for performance.
13
+ config.eager_load = true
14
+
15
+ # Full error reports are disabled and caching is turned on.
16
+ config.consider_all_requests_local = false
17
+ config.action_controller.perform_caching = true
18
+
19
+ # Ensures that a master key has been made available in either
20
+ # ENV["RAILS_MASTER_KEY"] or in config/master.key. This key is used to
21
+ # decrypt credentials (and other encrypted files).
22
+ # config.require_master_key = true
23
+
24
+ # Disable serving static files from the `/public` folder by default since
25
+ # Apache or NGINX already handles this.
26
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
27
+
28
+ # Compress CSS using a preprocessor.
29
+ # config.assets.css_compressor = :sass
30
+
31
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
32
+ config.assets.compile = false
33
+
34
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
35
+ # config.action_controller.asset_host = 'http://assets.example.com'
36
+
37
+ # Specifies the header that your server uses for sending files.
38
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
39
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
40
+
41
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
42
+ # config.force_ssl = true
43
+
44
+ # Use the lowest log level to ensure availability of diagnostic information
45
+ # when problems arise.
46
+ config.log_level = :debug
47
+
48
+ # Prepend all log lines with the following tags.
49
+ config.log_tags = [:request_id]
50
+
51
+ # Use a different cache store in production.
52
+ # config.cache_store = :mem_cache_store
53
+
54
+ # Use a real queuing backend for Active Job (and separate queues per
55
+ # environment).
56
+ # config.active_job.queue_adapter = :resque
57
+ # config.active_job.queue_name_prefix = "administrate_prototype_production"
58
+
59
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
60
+ # the I18n.default_locale when a translation cannot be found).
61
+ config.i18n.fallbacks = true
62
+ config.i18n.default_locale = :tr
63
+
64
+ # Send deprecation notices to registered listeners.
65
+ config.active_support.deprecation = :notify
66
+
67
+ # Use default logging formatter so that PID and timestamp are not suppressed.
68
+ config.log_formatter = ::Logger::Formatter.new
69
+
70
+ if ENV['RAILS_LOG_TO_STDOUT'].present?
71
+ logger = ActiveSupport::Logger.new(STDOUT)
72
+ logger.formatter = config.log_formatter
73
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
74
+ end
75
+
76
+ # Do not dump schema after migrations.
77
+ config.active_record.dump_schema_after_migration = false
78
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'production'
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+
8
+ Rails.application.configure do
9
+ config.cache_classes = true
10
+
11
+ # Do not eager load code on boot. This avoids loading your whole application
12
+ # just for the purpose of running a single test. If you are using a tool that
13
+ # preloads Rails for running tests, you may have to set it to true.
14
+ config.eager_load = false
15
+
16
+ # Configure public file server for tests with Cache-Control for performance.
17
+ if config.respond_to?(:public_file_server)
18
+ config.public_file_server.enabled = true
19
+ config.public_file_server.headers = {
20
+ 'Cache-Control' => 'public, max-age=3600'
21
+ }
22
+ else
23
+ config.serve_static_files = true
24
+ config.static_cache_control = 'public, max-age=3600'
25
+ end
26
+
27
+ # Show full error reports and disable caching.
28
+ config.consider_all_requests_local = true
29
+ config.action_controller.perform_caching = false
30
+ config.cache_store = :null_store
31
+
32
+ # Raise exceptions instead of rendering exception templates.
33
+ config.action_dispatch.show_exceptions = false
34
+
35
+ # Disable request forgery protection in test environment.
36
+ config.action_controller.allow_forgery_protection = false
37
+
38
+ # Print deprecation notices to the stderr.
39
+ config.active_support.deprecation = :stderr
40
+
41
+ # Raises error for missing translations.
42
+ config.action_view.raise_on_missing_translations = true
43
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # Version of your assets, change this if you want to expire all your assets.
6
+ Rails.application.config.assets.version = (ENV['ASSETS_VERSION'] || '1.0')
7
+
8
+ # Add additional assets to the asset load path
9
+ # Rails.application.config.assets.paths << Emoji.images_path
10
+
11
+ # Precompile additional assets.
12
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
13
+ Rails.application.config.assets.precompile += %w[docs.css]
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
5
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
6
+
7
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
8
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ Rails.application.config.action_dispatch.cookies_serializer = :marshal
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Protect against injection attacks
4
+ # http://www.kb.cert.org/vuls/id/380039
5
+ ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML) if Rails::VERSION::MAJOR < 5
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'net/http'
4
+
5
+ # Example:
6
+ # begin
7
+ # some http call
8
+ # rescue *HTTP_ERRORS => error
9
+ # notify_hoptoad error
10
+ # end
11
+
12
+ HTTP_ERRORS = [
13
+ EOFError,
14
+ Errno::ECONNRESET,
15
+ Errno::EINVAL,
16
+ Net::HTTPBadResponse,
17
+ Net::HTTPHeaderSyntaxError,
18
+ Net::ProtocolError,
19
+ Timeout::Error
20
+ ].freeze
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # Configure sensitive parameters which will be filtered from the log file.
6
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # Add new inflection rules using the following format. Inflections
6
+ # are locale specific, and you may define rules for as many different
7
+ # locales as you wish. All of these examples are active by default:
8
+ ActiveSupport::Inflector.inflections(:en) do |inflect|
9
+ # inflect.plural /^(ox)$/i, '\1en'
10
+ # inflect.singular /^(ox)en/i, '\1'
11
+ # inflect.irregular 'person', 'people'
12
+ inflect.uncountable %w[series]
13
+ end
14
+
15
+ # These inflection rules are supported but not enabled by default:
16
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
17
+ # inflect.acronym 'RESTful'
18
+ # end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ ActiveSupport::JSON::Encoding.time_precision = 0
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # Add new mime types for use in respond_to blocks:
5
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ Rails.application.config.session_store :cookie_store, key: '_administrate-field-json-to-table'
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # This file contains settings for ActionController::ParamsWrapper which
6
+ # is enabled by default.
7
+
8
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
9
+ ActiveSupport.on_load(:action_controller) do
10
+ wrap_parameters format: [:json]
11
+ end
12
+
13
+ # To enable root element in JSON for ActiveRecord objects.
14
+ # ActiveSupport.on_load(:active_record) do
15
+ # self.include_root_in_json = true
16
+ # end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ end
@@ -0,0 +1,15 @@
1
+ default: &default
2
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
3
+
4
+ development:
5
+ <<: *default
6
+ secret_key_base: 1a022e4f335d24af3d6bd622b9daef5a44808afbe16d4f1c8bed03675ab91ecd9c76ddc1a30f3fbb668b02c00abcba2ecc3714c95943b8f4af86289a2a46d5e1
7
+
8
+ test:
9
+ secret_key_base: test_secret
10
+
11
+ staging:
12
+ <<: *default
13
+
14
+ production:
15
+ <<: *default
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated from the current state of the database. Instead
4
+ # of editing this file, please use the migrations feature of Active Record to
5
+ # incrementally modify your database, and then regenerate this schema definition.
6
+ #
7
+ # This file is the source Rails uses to define your schema when running `rails
8
+ # db:schema:load`. When creating a new database, `rails db:schema:load` tends to
9
+ # be faster and is potentially less error prone than running all of your
10
+ # migrations from scratch. Old migrations may fail to apply correctly if those
11
+ # migrations use external dependencies or application code.
12
+ #
13
+ # It's strongly recommended that you check this file into your version control system.
14
+
15
+ ActiveRecord::Schema.define(version: 20_200_326_202_615) do
16
+ # These are extensions that must be enabled in order to support this database
17
+ enable_extension 'plpgsql'
18
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ # This file should contain all the record creation needed to seed the database with its default values.
3
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
4
+ #
5
+ # Examples:
6
+ #
7
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
8
+ # Mayor.create(name: 'Emanuel', city: cities.first)
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
@@ -0,0 +1 @@
1
+ [1, 2, 3, {:&quot;2019&quot;=&gt;{:start_date=&gt;&quot;2019-01-01&quot;, :end_date=&gt;&quot;2019-12-31&quot;, :id=&gt;&quot;123456_2019&quot;}}]
@@ -0,0 +1,31 @@
1
+ <table>
2
+ <tbody>
3
+ <tr>
4
+ <td>2019</td>
5
+ <td>
6
+ <table>
7
+ <tbody>
8
+ <tr>
9
+ <td>ids</td>
10
+ <td>
11
+ [1, 2, 3, 4]
12
+ </td>
13
+ </tr>
14
+ <tr>
15
+ <td>end_date</td>
16
+ <td>
17
+ 2019-12-31
18
+ </td>
19
+ </tr>
20
+ <tr>
21
+ <td>id</td>
22
+ <td>
23
+ 123456_2019
24
+ </td>
25
+ </tr>
26
+ <tbody>
27
+ </table>
28
+ </td>
29
+ </tr>
30
+ <tbody>
31
+ </table>