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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2f887112bdf790a1bf2e5d6d6feceee1b7bd290893b6f27db7373748f429737
4
- data.tar.gz: f1160be60fa4eadaed4d7e4cd369515b17a86a429184334c6039c3e1f80dbded
3
+ metadata.gz: 3d52f9f6537c4fa827f6bffc6fa4d128493ab1b8ad2021b124c05b83f28a5172
4
+ data.tar.gz: 0523d9e15436ee8b132ad71cf2b5dc08c85291d82dfcadcb71976b55c2216eaf
5
5
  SHA512:
6
- metadata.gz: 8e71dbf26436a94f95ba7011c30019d319645529f6b0ece18b0b204b390692f549c9db98bedb9f8ea1e13087288cc3db6ce91b6fa130a60007bb3480b6e1e80b
7
- data.tar.gz: 173fd2b57931811fd60b1da1105567cf0a24ddfac3f46e4e05eab158952b3c77366d34aee094d94f0ea8b86859df2b47ae3fe67ca3a59a8ef770b36eb28142ac
6
+ metadata.gz: f73481e36d991371b123cf24584c2c59d34eb960394f61d87a8789244f6ef138d12eb59f474392ff68244256b1f379d0643bcdf8cd7dfacf73605fcc57eb3870
7
+ data.tar.gz: c4a82e46dba7122d8ce0803111f08c62b5e4ec7b5591f8a9a7d97b7a105c7ae71651bb48b50e0e8699a5a6a046e76d873572a0e3e5fd70bac1c3a86833a177cb
data/.gitignore CHANGED
@@ -1 +1,7 @@
1
1
  *.gem
2
+
3
+ # Ignore all logfiles and tempfiles.
4
+ /log/*
5
+ /spec/example_app/log/*
6
+ /tmp/*
7
+ /spec/example_app/tmp/*
@@ -0,0 +1,96 @@
1
+ #############################
2
+ #
3
+ # Metrics
4
+ #
5
+ #############################
6
+
7
+ Metrics/BlockLength:
8
+ Exclude:
9
+ - 'spec/lib/administrate/field/*.rb'
10
+
11
+ #############################
12
+ #
13
+ # Layout
14
+ #
15
+ #############################
16
+
17
+ Layout/EmptyLinesAroundAttributeAccessor:
18
+ Enabled: true
19
+
20
+ Layout/SpaceAroundMethodCallOperator:
21
+ Enabled: true
22
+
23
+ #############################
24
+ #
25
+ # Lint
26
+ #
27
+ #############################
28
+
29
+ Lint/DeprecatedOpenSSLConstant:
30
+ Enabled: true
31
+
32
+ Lint/DuplicateElsifCondition:
33
+ Enabled: true
34
+
35
+ Lint/MixedRegexpCaptureTypes:
36
+ Enabled: true
37
+
38
+ Lint/RaiseException:
39
+ Enabled: true
40
+
41
+ Lint/StructNewOverride:
42
+ Enabled: true
43
+
44
+ #############################
45
+ #
46
+ # Style
47
+ #
48
+ #############################
49
+
50
+ Style/AccessorGrouping:
51
+ Enabled: true
52
+
53
+ Style/ArrayCoercion:
54
+ Enabled: true
55
+
56
+ Style/BisectedAttrAccessor:
57
+ Enabled: true
58
+
59
+ Style/CaseLikeIf:
60
+ Enabled: true
61
+
62
+ Style/ExponentialNotation:
63
+ Enabled: true
64
+
65
+ Style/HashAsLastArrayItem:
66
+ Enabled: true
67
+
68
+ Style/HashEachMethods:
69
+ Enabled: true
70
+
71
+ Style/HashLikeCase:
72
+ Enabled: true
73
+
74
+ Style/HashTransformKeys:
75
+ Enabled: true
76
+
77
+ Style/HashTransformValues:
78
+ Enabled: true
79
+
80
+ Style/RedundantAssignment:
81
+ Enabled: true
82
+
83
+ Style/RedundantFetchBlock:
84
+ Enabled: true
85
+
86
+ Style/RedundantFileExtensionInRequire:
87
+ Enabled: true
88
+
89
+ Style/RedundantRegexpCharacterClass:
90
+ Enabled: true
91
+
92
+ Style/RedundantRegexpEscape:
93
+ Enabled: true
94
+
95
+ Style/SlicingWithRange:
96
+ Enabled: true
data/Gemfile CHANGED
@@ -1,7 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'http://rubygems.org'
2
4
 
3
5
  gemspec
4
6
 
5
7
  group :development, :test do
6
- gem 'rspec-rails', '~> 3.5.0'
8
+ gem 'actionpack', '~> 5.2.0'
9
+ gem 'actionview', '~> 5.2.0'
10
+ gem 'activerecord', '~> 5.2.0'
11
+ gem 'pg', '0.21.0'
12
+
13
+ gem 'rspec-rails', '~> 4.0.0'
14
+ gem 'rubocop', require: false
7
15
  end
@@ -61,6 +61,7 @@ GEM
61
61
  sassc-rails (~> 2.1)
62
62
  selectize-rails (~> 0.6)
63
63
  arel (9.0.0)
64
+ ast (2.4.1)
64
65
  autoprefixer-rails (9.8.5)
65
66
  execjs
66
67
  builder (3.2.3)
@@ -68,7 +69,7 @@ GEM
68
69
  crass (1.0.4)
69
70
  datetime_picker_rails (0.0.7)
70
71
  momentjs-rails (>= 2.8.1)
71
- diff-lcs (1.3)
72
+ diff-lcs (1.4.4)
72
73
  erubi (1.8.0)
73
74
  execjs (2.7.0)
74
75
  ffi (1.13.1)
@@ -109,6 +110,10 @@ GEM
109
110
  nio4r (2.5.2)
110
111
  nokogiri (1.10.3)
111
112
  mini_portile2 (~> 2.4.0)
113
+ parallel (1.19.2)
114
+ parser (2.7.1.4)
115
+ ast (~> 2.4.1)
116
+ pg (0.21.0)
112
117
  rack (2.0.7)
113
118
  rack-test (1.1.0)
114
119
  rack (>= 1.0, < 3)
@@ -136,24 +141,39 @@ GEM
136
141
  method_source
137
142
  rake (>= 0.8.7)
138
143
  thor (>= 0.19.0, < 2.0)
144
+ rainbow (3.0.0)
139
145
  rake (12.3.2)
140
- rspec-core (3.5.4)
141
- rspec-support (~> 3.5.0)
142
- rspec-expectations (3.5.0)
146
+ regexp_parser (1.7.1)
147
+ rexml (3.2.4)
148
+ rspec-core (3.9.2)
149
+ rspec-support (~> 3.9.3)
150
+ rspec-expectations (3.9.2)
143
151
  diff-lcs (>= 1.2.0, < 2.0)
144
- rspec-support (~> 3.5.0)
145
- rspec-mocks (3.5.0)
152
+ rspec-support (~> 3.9.0)
153
+ rspec-mocks (3.9.1)
146
154
  diff-lcs (>= 1.2.0, < 2.0)
147
- rspec-support (~> 3.5.0)
148
- rspec-rails (3.5.2)
149
- actionpack (>= 3.0)
150
- activesupport (>= 3.0)
151
- railties (>= 3.0)
152
- rspec-core (~> 3.5.0)
153
- rspec-expectations (~> 3.5.0)
154
- rspec-mocks (~> 3.5.0)
155
- rspec-support (~> 3.5.0)
156
- rspec-support (3.5.0)
155
+ rspec-support (~> 3.9.0)
156
+ rspec-rails (4.0.1)
157
+ actionpack (>= 4.2)
158
+ activesupport (>= 4.2)
159
+ railties (>= 4.2)
160
+ rspec-core (~> 3.9)
161
+ rspec-expectations (~> 3.9)
162
+ rspec-mocks (~> 3.9)
163
+ rspec-support (~> 3.9)
164
+ rspec-support (3.9.3)
165
+ rubocop (0.88.0)
166
+ parallel (~> 1.10)
167
+ parser (>= 2.7.1.1)
168
+ rainbow (>= 2.2.2, < 4.0)
169
+ regexp_parser (>= 1.7)
170
+ rexml
171
+ rubocop-ast (>= 0.1.0, < 1.0)
172
+ ruby-progressbar (~> 1.7)
173
+ unicode-display_width (>= 1.4.0, < 2.0)
174
+ rubocop-ast (0.2.0)
175
+ parser (>= 2.7.0.1)
176
+ ruby-progressbar (1.10.1)
157
177
  sassc (2.4.0)
158
178
  ffi (~> 1.9)
159
179
  sassc-rails (2.1.2)
@@ -175,6 +195,7 @@ GEM
175
195
  tilt (2.0.10)
176
196
  tzinfo (1.2.5)
177
197
  thread_safe (~> 0.1)
198
+ unicode-display_width (1.7.0)
178
199
  websocket-driver (0.7.3)
179
200
  websocket-extensions (>= 0.1.0)
180
201
  websocket-extensions (0.1.5)
@@ -183,8 +204,13 @@ PLATFORMS
183
204
  ruby
184
205
 
185
206
  DEPENDENCIES
207
+ actionpack (~> 5.2.0)
208
+ actionview (~> 5.2.0)
209
+ activerecord (~> 5.2.0)
186
210
  administrate-field-jsontable!
187
- rspec-rails (~> 3.5.0)
211
+ pg (= 0.21.0)
212
+ rspec-rails (~> 4.0.0)
213
+ rubocop
188
214
 
189
215
  BUNDLED WITH
190
216
  1.17.3
data/README.md CHANGED
@@ -12,3 +12,10 @@ This repository is a field plugin for Administrate.
12
12
  Add to your gemfile `gem 'administrate-field-jsontable'`
13
13
 
14
14
  [Administrate]: https://github.com/thoughtbot/administrate
15
+
16
+ ## Contributing
17
+
18
+ Run `bundle exec rake db:setup` to set up example rails app on development environment
19
+ Run `bundle exec rspec` to run tests
20
+ Run `bundle exec rubocop` to linting tests
21
+
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ require File.expand_path('spec/example_app/config/application', __dir__)
10
+
11
+ Rails.application.load_tasks
@@ -4,7 +4,7 @@ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'administrate-field-jsontable'
7
- s.version = '0.0.5'
7
+ s.version = '0.1.0'
8
8
  s.authors = ['Adrian Rangel', 'Enrique Barragan']
9
9
  s.email = ['adrian@valiot.io', 'enrique@valiot.io']
10
10
  s.homepage = 'https://github.com/Valiot/administrate-field-jsontable'
@@ -0,0 +1,18 @@
1
+ <%#
2
+ # Enum Show Partial
3
+
4
+ This partial renders an enum attribute,
5
+ to be displayed on a resource's show page.
6
+
7
+ By default, the attribute is rendered as a text tag.
8
+
9
+ ## Local variables:
10
+
11
+ - `field`:
12
+ An instance of [Administrate::Field::Enum][1].
13
+ A wrapper around the enum attributes pulled from the model.
14
+
15
+ %>
16
+
17
+
18
+ <%= render partial: '/fields/jsontable/json_table_field', locals: { data: field.data } %>
@@ -0,0 +1,30 @@
1
+ <%#
2
+ # Enum Show Partial
3
+
4
+ This partial renders an enum attribute,
5
+ to be displayed on a resource's show page.
6
+
7
+ By default, the attribute is rendered as a text tag.
8
+
9
+ ## Local variables:
10
+
11
+ - `field`:
12
+ An instance of [Administrate::Field::Enum][1].
13
+ A wrapper around the enum attributes pulled from the model.
14
+
15
+ %>
16
+
17
+ <% if data.kind_of?(Hash) %>
18
+ <table>
19
+ <tbody>
20
+ <% data.each do |key, value| %>
21
+ <tr>
22
+ <td><%= key %></td>
23
+ <td><%= if value.blank? then "-" else render partial: '/fields/jsontable/json_table_field', locals: { data: value } end %></td>
24
+ </tr>
25
+ <% end %>
26
+ <tbody>
27
+ </table>
28
+ <% else %>
29
+ <%= if data.blank? then "-" else data end %>
30
+ <% end %>
@@ -14,32 +14,5 @@ By default, the attribute is rendered as a text tag.
14
14
 
15
15
  %>
16
16
 
17
- <table>
18
- <thead>
19
- <tr>
20
- <% field.data.each do |k,v| %>
21
- <th><%= t(k) %></th>
22
- <% end %>
23
- </tr>
24
- </thead>
25
- <tbody>
26
- <% if field.data.first[1].kind_of?(Array) %>
27
- <tr>
28
- <% field.data.each do |k,v| %>
29
- <td><%= if v[0].blank? then "-" else v[0] end %></td>
30
- <% end %>
31
- </tr>
32
- <tr>
33
- <% field.data.each do |k,v| %>
34
- <td><%= if v[1].blank? then "-" else v[1] end %></td>
35
- <% end %>
36
- </tr>
37
- <% else %>
38
- <tr>
39
- <% field.data.each do |k,v| %>
40
- <td><%= if v.blank? then "-" else v end %></td>
41
- <% end %>
42
- </tr>
43
- <% end %>
44
- </tbody>
45
- </table>
17
+
18
+ <%= render partial: '/fields/jsontable/json_table_field', locals: { data: field.data } %>
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'administrate/field/base'
2
4
  require 'rails'
3
5
 
@@ -0,0 +1,2 @@
1
+ //= link administrate/application.css
2
+ //= link administrate/application.js
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationController < ActionController::Base
4
+ # Prevent CSRF attacks by raising an exception.
5
+ # For APIs, you may want to use :null_session instead.
6
+ protect_from_forgery with: :exception
7
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ end
@@ -0,0 +1,31 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="ROBOTS" content="NOODP" />
6
+ <meta name="viewport" content="initial-scale=1" />
7
+ <%#
8
+ Configure default and controller-, and view-specific titles in
9
+ config/locales/en.yml. For more see:
10
+ https://github.com/calebthompson/title#usage
11
+ %>
12
+ <title><%= title %></title>
13
+ <%= stylesheet_link_tag "//fonts.googleapis.com/css?family=Lato:300,400,900", media: "all" %>
14
+ <%= stylesheet_link_tag :application, media: "all" %>
15
+ <%= csrf_meta_tags %>
16
+ </head>
17
+
18
+ <body class="<%= body_class %>">
19
+ <main class="main">
20
+ <%= render "navigation" -%>
21
+
22
+ <div class="content">
23
+ <%= render "flashes" -%>
24
+
25
+ <%= yield %>
26
+
27
+ <%= render "javascript" %>
28
+ </div>
29
+ </main>
30
+ </body>
31
+ </html>