introspective_admin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/Gemfile +5 -0
  4. data/Gemfile.lock +279 -0
  5. data/LICENSE +22 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.md +52 -0
  8. data/Rakefile +26 -0
  9. data/bin/rails +12 -0
  10. data/introspective_admin.gemspec +38 -0
  11. data/lib/introspective_admin/base.rb +170 -0
  12. data/lib/introspective_admin/version.rb +3 -0
  13. data/lib/introspective_admin.rb +4 -0
  14. data/lib/tasks/introspective_admin_tasks.rake +4 -0
  15. data/spec/admin/company_admin_spec.rb +72 -0
  16. data/spec/admin/job_admin_spec.rb +61 -0
  17. data/spec/admin/location_admin_spec.rb +65 -0
  18. data/spec/admin/project__admin_spec.rb +71 -0
  19. data/spec/dummy/README.rdoc +28 -0
  20. data/spec/dummy/Rakefile +6 -0
  21. data/spec/dummy/app/admin/company_admin.rb +4 -0
  22. data/spec/dummy/app/admin/job_admin.rb +4 -0
  23. data/spec/dummy/app/admin/location_admin.rb +4 -0
  24. data/spec/dummy/app/admin/project_admin.rb +6 -0
  25. data/spec/dummy/app/admin/role_admin.rb +5 -0
  26. data/spec/dummy/app/admin/user_admin.rb +9 -0
  27. data/spec/dummy/app/assets/images/.keep +0 -0
  28. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  29. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  30. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  31. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  32. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  33. data/spec/dummy/app/mailers/.keep +0 -0
  34. data/spec/dummy/app/models/.keep +0 -0
  35. data/spec/dummy/app/models/abstract_adapter.rb +13 -0
  36. data/spec/dummy/app/models/admin_user.rb +6 -0
  37. data/spec/dummy/app/models/chat.rb +18 -0
  38. data/spec/dummy/app/models/chat_message.rb +34 -0
  39. data/spec/dummy/app/models/chat_message_user.rb +17 -0
  40. data/spec/dummy/app/models/chat_user.rb +16 -0
  41. data/spec/dummy/app/models/company.rb +12 -0
  42. data/spec/dummy/app/models/concerns/.keep +0 -0
  43. data/spec/dummy/app/models/job.rb +10 -0
  44. data/spec/dummy/app/models/locatable.rb +6 -0
  45. data/spec/dummy/app/models/location.rb +26 -0
  46. data/spec/dummy/app/models/location_beacon.rb +16 -0
  47. data/spec/dummy/app/models/location_gps.rb +64 -0
  48. data/spec/dummy/app/models/project.rb +20 -0
  49. data/spec/dummy/app/models/project_job.rb +7 -0
  50. data/spec/dummy/app/models/role.rb +25 -0
  51. data/spec/dummy/app/models/team.rb +9 -0
  52. data/spec/dummy/app/models/team_user.rb +13 -0
  53. data/spec/dummy/app/models/user/chatter.rb +79 -0
  54. data/spec/dummy/app/models/user.rb +75 -0
  55. data/spec/dummy/app/models/user_location.rb +28 -0
  56. data/spec/dummy/app/models/user_project_job.rb +16 -0
  57. data/spec/dummy/app/views/layouts/application.html.erb +13 -0
  58. data/spec/dummy/bin/bundle +3 -0
  59. data/spec/dummy/bin/rails +4 -0
  60. data/spec/dummy/bin/rake +4 -0
  61. data/spec/dummy/bin/setup +29 -0
  62. data/spec/dummy/config/application.rb +32 -0
  63. data/spec/dummy/config/boot.rb +5 -0
  64. data/spec/dummy/config/database.yml +18 -0
  65. data/spec/dummy/config/environment.rb +11 -0
  66. data/spec/dummy/config/environments/development.rb +41 -0
  67. data/spec/dummy/config/environments/production.rb +79 -0
  68. data/spec/dummy/config/environments/test.rb +43 -0
  69. data/spec/dummy/config/initializers/active_admin.rb +7 -0
  70. data/spec/dummy/config/initializers/assets.rb +11 -0
  71. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  72. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  73. data/spec/dummy/config/initializers/devise.rb +260 -0
  74. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  75. data/spec/dummy/config/initializers/inflections.rb +16 -0
  76. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  77. data/spec/dummy/config/initializers/session_store.rb +3 -0
  78. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  79. data/spec/dummy/config/locales/en.yml +23 -0
  80. data/spec/dummy/config/routes.rb +9 -0
  81. data/spec/dummy/config/secrets.yml +22 -0
  82. data/spec/dummy/config.ru +4 -0
  83. data/spec/dummy/db/development.sqlite3 +0 -0
  84. data/spec/dummy/db/migrate/20141002205024_devise_create_users.rb +42 -0
  85. data/spec/dummy/db/migrate/20141002211055_devise_create_admin_users.rb +48 -0
  86. data/spec/dummy/db/migrate/20141002211057_create_active_admin_comments.rb +19 -0
  87. data/spec/dummy/db/migrate/20141002220722_add_lockable_to_users.rb +8 -0
  88. data/spec/dummy/db/migrate/20150406213646_create_companies.rb +11 -0
  89. data/spec/dummy/db/migrate/20150414213154_add_user_authentication_token.rb +11 -0
  90. data/spec/dummy/db/migrate/20150415222005_create_roles.rb +12 -0
  91. data/spec/dummy/db/migrate/20150505181635_create_chats.rb +9 -0
  92. data/spec/dummy/db/migrate/20150505181636_create_chat_users.rb +11 -0
  93. data/spec/dummy/db/migrate/20150505181640_create_chat_messages.rb +11 -0
  94. data/spec/dummy/db/migrate/20150507191529_create_chat_message_users.rb +11 -0
  95. data/spec/dummy/db/migrate/20150601200526_create_locations.rb +12 -0
  96. data/spec/dummy/db/migrate/20150601200533_create_locatables.rb +10 -0
  97. data/spec/dummy/db/migrate/20150601212924_create_location_beacons.rb +15 -0
  98. data/spec/dummy/db/migrate/20150601213542_create_location_gps.rb +12 -0
  99. data/spec/dummy/db/migrate/20150609201823_create_user_locations.rb +14 -0
  100. data/spec/dummy/db/migrate/20150617232519_create_projects.rb +10 -0
  101. data/spec/dummy/db/migrate/20150617232521_create_jobs.rb +9 -0
  102. data/spec/dummy/db/migrate/20150617232522_create_project_jobs.rb +11 -0
  103. data/spec/dummy/db/migrate/20150623170133_create_user_project_jobs.rb +12 -0
  104. data/spec/dummy/db/migrate/20150701234929_create_teams.rb +11 -0
  105. data/spec/dummy/db/migrate/20150701234930_create_team_users.rb +11 -0
  106. data/spec/dummy/db/migrate/20150727214950_add_confirmable_to_devise.rb +11 -0
  107. data/spec/dummy/db/migrate/20150820190524_add_user_names.rb +6 -0
  108. data/spec/dummy/db/migrate/20150909225019_add_password_to_project.rb +5 -0
  109. data/spec/dummy/db/schema.rb +261 -0
  110. data/spec/dummy/lib/assets/.keep +0 -0
  111. data/spec/dummy/log/.keep +0 -0
  112. data/spec/dummy/public/404.html +67 -0
  113. data/spec/dummy/public/422.html +67 -0
  114. data/spec/dummy/public/500.html +66 -0
  115. data/spec/dummy/public/favicon.ico +0 -0
  116. data/spec/rails_helper.rb +13 -0
  117. data/spec/support/blueprints.rb +119 -0
  118. data/spec/support/location_helper.rb +56 -0
  119. metadata +420 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 34a8d5c710a6b80906412e0fe2cb801d6b52fd4e
4
+ data.tar.gz: e2fca9348cc6a20528ef56d6e4888232e4902b22
5
+ SHA512:
6
+ metadata.gz: d71883839c6bb9c36da4d1410859600227c1e2fd270c1ec405057c1d2abdbb32fbe3ba2f0b4b8bf2fa393385d75a1c39ced44c0d9429fa35fc8b77da6e9494b3
7
+ data.tar.gz: 3b15037166cfae55f8333a2d79b5b55004d855c79e4e0c16a47b0df20d53df23bb68ed6cdb18aa6ed063a8618c36d1a3d445f7bd716f4694ecaae31ad8fb5f27
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ .bundle/
2
+ log/*.log
3
+ Gemfile.lock
4
+ pkg/
5
+ spec/dummy/db/*.sqlite3
6
+ spec/dummy/db/*.sqlite3-journal
7
+ spec/dummy/log/*.log
8
+ spec/dummy/tmp/
9
+ spec/dummy/.sass-cache
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # A sample Gemfile
2
+ source "https://rubygems.org"
3
+
4
+ gemspec
5
+ gem 'activeadmin', github: 'activeadmin'
data/Gemfile.lock ADDED
@@ -0,0 +1,279 @@
1
+ GIT
2
+ remote: git://github.com/activeadmin/activeadmin.git
3
+ revision: 9021962577c144b34aa74cb70676d04948d0722f
4
+ specs:
5
+ activeadmin (1.0.0.pre2)
6
+ arbre (~> 1.0, >= 1.0.2)
7
+ bourbon
8
+ coffee-rails
9
+ formtastic (~> 3.1)
10
+ formtastic_i18n
11
+ inherited_resources (~> 1.6)
12
+ jquery-rails
13
+ jquery-ui-rails
14
+ kaminari (~> 0.15)
15
+ rails (>= 3.2, < 5.0)
16
+ ransack (~> 1.3)
17
+ sass-rails
18
+
19
+ PATH
20
+ remote: .
21
+ specs:
22
+ introspective_admin (0.0.1)
23
+ sass-rails
24
+
25
+ GEM
26
+ remote: https://rubygems.org/
27
+ specs:
28
+ actionmailer (4.2.4)
29
+ actionpack (= 4.2.4)
30
+ actionview (= 4.2.4)
31
+ activejob (= 4.2.4)
32
+ mail (~> 2.5, >= 2.5.4)
33
+ rails-dom-testing (~> 1.0, >= 1.0.5)
34
+ actionpack (4.2.4)
35
+ actionview (= 4.2.4)
36
+ activesupport (= 4.2.4)
37
+ rack (~> 1.6)
38
+ rack-test (~> 0.6.2)
39
+ rails-dom-testing (~> 1.0, >= 1.0.5)
40
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
41
+ actionview (4.2.4)
42
+ activesupport (= 4.2.4)
43
+ builder (~> 3.1)
44
+ erubis (~> 2.7.0)
45
+ rails-dom-testing (~> 1.0, >= 1.0.5)
46
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
47
+ activejob (4.2.4)
48
+ activesupport (= 4.2.4)
49
+ globalid (>= 0.3.0)
50
+ activemodel (4.2.4)
51
+ activesupport (= 4.2.4)
52
+ builder (~> 3.1)
53
+ activerecord (4.2.4)
54
+ activemodel (= 4.2.4)
55
+ activesupport (= 4.2.4)
56
+ arel (~> 6.0)
57
+ activesupport (4.2.4)
58
+ i18n (~> 0.7)
59
+ json (~> 1.7, >= 1.7.7)
60
+ minitest (~> 5.1)
61
+ thread_safe (~> 0.3, >= 0.3.4)
62
+ tzinfo (~> 1.1)
63
+ arbre (1.0.3)
64
+ activesupport (>= 3.0.0)
65
+ arel (6.0.3)
66
+ bcrypt (3.1.10)
67
+ bourbon (4.2.6)
68
+ sass (~> 3.4)
69
+ thor (~> 0.19)
70
+ builder (3.2.2)
71
+ byebug (6.0.2)
72
+ coffee-rails (4.1.0)
73
+ coffee-script (>= 2.2.0)
74
+ railties (>= 4.0.0, < 5.0)
75
+ coffee-script (2.4.1)
76
+ coffee-script-source
77
+ execjs
78
+ coffee-script-source (1.9.1.1)
79
+ devise (3.5.2)
80
+ bcrypt (~> 3.0)
81
+ orm_adapter (~> 0.1)
82
+ railties (>= 3.2.6, < 5)
83
+ responders
84
+ thread_safe (~> 0.1)
85
+ warden (~> 1.2.3)
86
+ devise-async (0.10.1)
87
+ devise (~> 3.2)
88
+ diff-lcs (1.2.5)
89
+ docile (1.1.5)
90
+ erubis (2.7.0)
91
+ execjs (2.6.0)
92
+ formtastic (3.1.3)
93
+ actionpack (>= 3.2.13)
94
+ formtastic_i18n (0.4.1)
95
+ globalid (0.3.6)
96
+ activesupport (>= 4.1.0)
97
+ has_scope (0.6.0)
98
+ actionpack (>= 3.2, < 5)
99
+ activesupport (>= 3.2, < 5)
100
+ i18n (0.7.0)
101
+ inherited_resources (1.6.0)
102
+ actionpack (>= 3.2, < 5)
103
+ has_scope (~> 0.6.0.rc)
104
+ railties (>= 3.2, < 5)
105
+ responders
106
+ its-it (1.1.1)
107
+ jquery-rails (4.0.5)
108
+ rails-dom-testing (~> 1.0)
109
+ railties (>= 4.2.0)
110
+ thor (>= 0.14, < 2.0)
111
+ jquery-ui-rails (5.0.5)
112
+ railties (>= 3.2.16)
113
+ json (1.8.3)
114
+ kaminari (0.16.3)
115
+ actionpack (>= 3.0.0)
116
+ activesupport (>= 3.0.0)
117
+ key_struct (0.4.2)
118
+ loofah (2.0.3)
119
+ nokogiri (>= 1.5.9)
120
+ machinist (2.0)
121
+ mail (2.6.3)
122
+ mime-types (>= 1.16, < 3)
123
+ mime-types (2.6.2)
124
+ mini_portile (0.6.2)
125
+ minitest (5.8.2)
126
+ modware (0.1.2)
127
+ its-it
128
+ key_struct (~> 0.4)
129
+ nokogiri (1.6.6.2)
130
+ mini_portile (~> 0.6.0)
131
+ orm_adapter (0.5.0)
132
+ polyamorous (1.2.0)
133
+ activerecord (>= 3.0)
134
+ rack (1.6.4)
135
+ rack-test (0.6.3)
136
+ rack (>= 1.0)
137
+ rails (4.2.4)
138
+ actionmailer (= 4.2.4)
139
+ actionpack (= 4.2.4)
140
+ actionview (= 4.2.4)
141
+ activejob (= 4.2.4)
142
+ activemodel (= 4.2.4)
143
+ activerecord (= 4.2.4)
144
+ activesupport (= 4.2.4)
145
+ bundler (>= 1.3.0, < 2.0)
146
+ railties (= 4.2.4)
147
+ sprockets-rails
148
+ rails-deprecated_sanitizer (1.0.3)
149
+ activesupport (>= 4.2.0.alpha)
150
+ rails-dom-testing (1.0.7)
151
+ activesupport (>= 4.2.0.beta, < 5.0)
152
+ nokogiri (~> 1.6.0)
153
+ rails-deprecated_sanitizer (>= 1.0.1)
154
+ rails-html-sanitizer (1.0.2)
155
+ loofah (~> 2.0)
156
+ railties (4.2.4)
157
+ actionpack (= 4.2.4)
158
+ activesupport (= 4.2.4)
159
+ rake (>= 0.8.7)
160
+ thor (>= 0.18.1, < 2.0)
161
+ rake (10.4.2)
162
+ ransack (1.7.0)
163
+ actionpack (>= 3.0)
164
+ activerecord (>= 3.0)
165
+ activesupport (>= 3.0)
166
+ i18n
167
+ polyamorous (~> 1.2)
168
+ responders (2.1.0)
169
+ railties (>= 4.2.0, < 5)
170
+ rspec-core (3.3.2)
171
+ rspec-support (~> 3.3.0)
172
+ rspec-expectations (3.3.1)
173
+ diff-lcs (>= 1.2.0, < 2.0)
174
+ rspec-support (~> 3.3.0)
175
+ rspec-mocks (3.3.2)
176
+ diff-lcs (>= 1.2.0, < 2.0)
177
+ rspec-support (~> 3.3.0)
178
+ rspec-rails (3.3.3)
179
+ actionpack (>= 3.0, < 4.3)
180
+ activesupport (>= 3.0, < 4.3)
181
+ railties (>= 3.0, < 4.3)
182
+ rspec-core (~> 3.3.0)
183
+ rspec-expectations (~> 3.3.0)
184
+ rspec-mocks (~> 3.3.0)
185
+ rspec-support (~> 3.3.0)
186
+ rspec-support (3.3.0)
187
+ rufus-mnemo (1.2.3)
188
+ sass (3.4.19)
189
+ sass-rails (5.0.4)
190
+ railties (>= 4.0.0, < 5.0)
191
+ sass (~> 3.1)
192
+ sprockets (>= 2.8, < 4.0)
193
+ sprockets-rails (>= 2.0, < 4.0)
194
+ tilt (>= 1.1, < 3)
195
+ schema_monkey (2.1.3)
196
+ activerecord (~> 4.2)
197
+ its-it
198
+ modware (~> 0.1)
199
+ schema_plus (2.0.0.pre12)
200
+ activerecord (~> 4.2)
201
+ schema_monkey (~> 2.1)
202
+ schema_plus_columns (~> 0.1)
203
+ schema_plus_core (~> 0.2)
204
+ schema_plus_db_default (~> 0.1)
205
+ schema_plus_default_expr (~> 0.1)
206
+ schema_plus_enums (~> 0.1)
207
+ schema_plus_indexes (~> 0.1, >= 0.1.3)
208
+ schema_plus_pg_indexes (~> 0.1, >= 0.1.3)
209
+ schema_plus_tables (~> 0.1)
210
+ schema_plus_views (~> 0.1)
211
+ valuable
212
+ schema_plus_columns (0.1.0)
213
+ activerecord (~> 4.2)
214
+ schema_plus_indexes (~> 0.1)
215
+ schema_plus_core (0.6.0)
216
+ activerecord (~> 4.2)
217
+ schema_monkey (~> 2.1)
218
+ schema_plus_db_default (0.1.0)
219
+ activerecord (~> 4.2)
220
+ schema_plus_core (~> 0.2, >= 0.2.1)
221
+ schema_plus_default_expr (0.1.0)
222
+ activerecord (~> 4.2)
223
+ schema_plus_core (~> 0.2, >= 0.2.1)
224
+ schema_plus_enums (0.1.0)
225
+ activerecord (~> 4.2)
226
+ schema_plus_core (~> 0.2, >= 0.2.1)
227
+ schema_plus_indexes (0.2.0)
228
+ activerecord (~> 4.2)
229
+ schema_plus_core (~> 0.1)
230
+ schema_plus_pg_indexes (0.1.8)
231
+ activerecord (~> 4.2)
232
+ schema_plus_indexes (~> 0.1, >= 0.1.3)
233
+ schema_plus_tables (0.1.0)
234
+ activerecord (~> 4.2)
235
+ schema_plus_core (~> 0.2)
236
+ schema_plus_views (0.3.0)
237
+ activerecord (~> 4.2)
238
+ schema_plus_core (~> 0.1)
239
+ schema_validations (1.3.1)
240
+ activerecord (~> 4.2, >= 4.2.1)
241
+ schema_plus_columns
242
+ valuable
243
+ simplecov (0.10.0)
244
+ docile (~> 1.1.0)
245
+ json (~> 1.8)
246
+ simplecov-html (~> 0.10.0)
247
+ simplecov-html (0.10.0)
248
+ sprockets (3.4.0)
249
+ rack (> 1, < 3)
250
+ sprockets-rails (2.3.3)
251
+ actionpack (>= 3.0)
252
+ activesupport (>= 3.0)
253
+ sprockets (>= 2.8, < 4.0)
254
+ sqlite3 (1.3.11)
255
+ thor (0.19.1)
256
+ thread_safe (0.3.5)
257
+ tilt (2.0.1)
258
+ tzinfo (1.2.2)
259
+ thread_safe (~> 0.1)
260
+ valuable (0.9.9)
261
+ warden (1.2.3)
262
+ rack (>= 1.0)
263
+
264
+ PLATFORMS
265
+ ruby
266
+
267
+ DEPENDENCIES
268
+ activeadmin!
269
+ byebug
270
+ devise
271
+ devise-async
272
+ introspective_admin!
273
+ machinist
274
+ rspec-rails (>= 3.0)
275
+ rufus-mnemo
276
+ schema_plus (= 2.0.0.pre12)
277
+ schema_validations
278
+ simplecov
279
+ sqlite3
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # IntrospectiveAdmin
2
+
3
+ IntrospectiveAdmin is a Rails Plugin for DRYing up ActiveAdmin configurations by
4
+ laying out simple defaults and including nested relations according to the models'
5
+ accepts_nested_attributes_for :relation declarations.
6
+
7
+ ## Documentation
8
+
9
+ In your Gemfile:
10
+
11
+ ```
12
+ gem 'introspective_admin', git: 'https://github.com/buermann/introspective_admin.git'
13
+ ```
14
+
15
+ And bundle install.
16
+
17
+ ```
18
+ class MyAdmin < IntrospectiveAdmin::Base
19
+ def self.exclude_params
20
+ %w(fields to exclude from the admin screen)
21
+ end
22
+
23
+ register MyModel do
24
+ # Add additional ActiveAdmin configuration options under the Admin::MyModelController namespace.
25
+ end
26
+ end
27
+ ```
28
+
29
+ Customizing select box options for associations is done by adding an
30
+ "options_for_X" class method on the administrated model:
31
+
32
+ ```
33
+ class MyModel < ActiveRecord::Base
34
+ belongs_to :parent
35
+ has_many :other_models
36
+ accepts_nested_attributes_for :other_models, :allow_destroy => true
37
+
38
+ def self.options_for_parent(instance_of_my_model)
39
+ Parent.order(:appelation).map.{|p| ["#{p.appelation}", p.id] }
40
+ end
41
+ end
42
+ ```
43
+
44
+ ## Dependencies
45
+
46
+ Tool | Description
47
+ --------------------- | -----------
48
+ [ActiveAdmin] | The current master branch or, when it's released, version >1.0
49
+
50
+ [ActiveAdmin]: https://github.com/activeadmin
51
+
52
+
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'IntrospectiveAdmin'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
data/bin/rails ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/introspective_admin/engine', __FILE__)
6
+
7
+ # Set up gems listed in the Gemfile.
8
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
9
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
10
+
11
+ require 'rails/all'
12
+ require 'rails/engine/commands'
@@ -0,0 +1,38 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "introspective_admin/version"
5
+ require "introspective_admin/base"
6
+
7
+ # Describe your gem and declare its dependencies:
8
+ Gem::Specification.new do |s|
9
+ s.name = "introspective_admin"
10
+ s.version = IntrospectiveAdmin::VERSION
11
+ s.authors = ["Josh Buermann"]
12
+ s.email = ["buermann@gmail.com"]
13
+ s.homepage = "https://github.com/buermann/introspective_admin"
14
+ s.summary = "Set up basic ActiveAdmin screens for an ActiveRecord model."
15
+ s.description = "Set up basic ActiveAdmin screens for an ActiveRecord model."
16
+ s.license = "MIT"
17
+
18
+ s.files = `git ls-files`.split("\n").sort
19
+ s.test_files = `git ls-files -- spec/*`.split("\n")
20
+
21
+ s.required_ruby_version = '>= 1.9.3'
22
+
23
+ s.add_dependency 'sass-rails'
24
+
25
+ s.add_development_dependency "sqlite3"
26
+ s.add_development_dependency "rspec-rails", '>= 3.0'
27
+ s.add_development_dependency 'devise'
28
+ s.add_development_dependency 'devise-async'
29
+ s.add_development_dependency 'machinist'
30
+ s.add_development_dependency 'simplecov'
31
+ s.add_development_dependency 'rufus-mnemo'
32
+ # For compatibility of schema_validations with AR 4.2.1+
33
+ s.add_development_dependency "schema_plus", "2.0.0.pre12"
34
+ s.add_development_dependency "schema_validations"
35
+ s.add_development_dependency 'byebug'
36
+
37
+ end
38
+
@@ -0,0 +1,170 @@
1
+ module IntrospectiveAdmin
2
+ class Base
3
+ # Generate an active admin interface by introspecting on the models.
4
+
5
+ # For polymorphic associations set up virtual 'assign' attributes on the model like so:
6
+ #
7
+ # def <polymorphism>_assign
8
+ # "#{<polymorphism>_type}-#{<polymorphism>_id}"
9
+ # end
10
+ # def <polymorphism>_assign=(value)
11
+ # self.<polymorphism>_type,self.<polymorphism>_id = value.split('-')
12
+ # end
13
+ #
14
+ # And designate the selection options in a class method, you can pass the
15
+ # target model to modify the options list accordingly
16
+ #
17
+ # def self.<polymorphism>_options(model=nil)
18
+ # (Model.all + SecondModel.all).map { |i| [ i.name, "#{i.class}-#{i.id}"] }
19
+ # end
20
+
21
+ class << self
22
+
23
+ def exclude_params
24
+ [] # do not display the field in the index page and forms.
25
+ end
26
+
27
+ def polymorphic?(model,column)
28
+ (model.reflections[column.sub(/_id$/,'')].try(:options)||{})[:polymorphic]
29
+ end
30
+
31
+ def column_list(model)
32
+ model.columns.map {|c|
33
+ c.name.sub(/(_type|_id)$/,'')
34
+ }.uniq-['created_at','updated_at']-exclude_params
35
+ end
36
+
37
+ def params_list(model)
38
+ model.columns.map {|c|
39
+ polymorphic?(model,c.name) ? c.name.sub(/_id$/,'')+"_assign" : c.name
40
+ }
41
+ end
42
+
43
+ def link_record(record)
44
+ link_text = record.try(:name) || record.try(:title) || record.class.to_s
45
+ link_href = begin eval("admin_#{record.class.name.underscore}_path(#{record.id})") rescue false end
46
+ if link_href
47
+ link_to link_text, link_href
48
+ elsif link_text
49
+ link_text
50
+ else
51
+ record
52
+ end
53
+ end
54
+
55
+ def register(model)
56
+ # Defining activeadmin pages will break pending migrations:
57
+ begin ActiveRecord::Migration.check_pending! rescue return end
58
+
59
+ klass = self
60
+ model_name = model.to_s.underscore
61
+ nested_config = Hash[model.nested_attributes_options.map {|assoc,options|
62
+ reflection = model.reflections[assoc.to_s]
63
+ reflection_class = reflection.class_name.constantize
64
+ # merge the options of the nested attribute and relationship declarations
65
+ options = options.merge(reflection_class.reflections[assoc.to_s].try(:options) || {})
66
+ options[:class] = reflection_class
67
+ options[:columns] = klass.column_list(reflection_class)
68
+ options[:params] = klass.params_list(reflection_class)
69
+ options[:reflection] = reflection
70
+ options[:polymorphic_reference] = reflection.options[:as].to_s
71
+ [assoc, options]
72
+ }]
73
+
74
+ ActiveAdmin.register model do
75
+ index do
76
+ cols = model.columns.map(&:name)-klass.exclude_params
77
+ cols.each_with_index do |c,i|
78
+ column c
79
+ end
80
+ actions
81
+ end
82
+
83
+ show do
84
+ instance = self.send(model_name)
85
+
86
+ attributes_table do
87
+ model.columns.each do |c|
88
+ next if (c.name =~ /password/)
89
+ row c.name
90
+ end
91
+
92
+ nested_config.each do |assoc,options|
93
+ panel assoc.capitalize do
94
+ table_for instance.send(assoc) do
95
+ options[:columns].each do |c|
96
+ if options[:class].reflections[c]
97
+ column( c ) do |r|
98
+ klass.link_record(r.send(c)) if r
99
+ end
100
+ else
101
+ column c
102
+ end
103
+ end
104
+
105
+ admin_route = begin url_for(['admin', options[:class].name.underscore]) rescue false end
106
+ if admin_route
107
+ column 'actions' do |child|
108
+ span link_to "View", url_for(['admin', child])
109
+ span link_to "Edit", url_for(['edit','admin',child])
110
+ span link_to "Delete", url_for(['admin',child]), method: :delete, confirm: "Are you sure you want to delete this?"
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
118
+
119
+ permit_params klass.params_list(model) + [Hash[nested_config.map{|assoc,o|
120
+ ["#{assoc}_attributes", o[:params]+[(o[:allow_destroy] ? :_destroy : '')] ]
121
+ }]]
122
+
123
+ form do |f|
124
+ f.actions
125
+
126
+ klass.column_list(model).each do |column|
127
+ if column == model.primary_key
128
+ elsif klass.polymorphic?(model,column)
129
+ f.input column+"_assign", collection: model.send("#{column}_assign_options")
130
+ elsif model.respond_to?("options_for_#{column}")
131
+ f.input column, collection: model.send("options_for_#{column}", f.object)
132
+ else
133
+ f.input column
134
+ end
135
+ end
136
+
137
+ div { '&nbsp'.html_safe }
138
+
139
+ nested_config.each do |assoc,options|
140
+ aclass = options[:class]
141
+ columns = options[:columns]-[aclass.primary_key]
142
+ f.inputs do
143
+ f.has_many assoc, allow_destroy: options[:allow_destroy] do |r|
144
+ columns.each do |c|
145
+ if c == model_name || c == options[:polymorphic_reference]
146
+ # the join to the parent is implicit
147
+ elsif klass.polymorphic?(aclass,c)
148
+ r.input c, collection: aclass.send("#{c}_assign_options")
149
+ elsif aclass.reflections[c] && aclass.respond_to?("options_for_#{c}")
150
+ # If the class has an options_for_<column> method defined use that
151
+ # rather than the default behavior, pass the instance for scoping,
152
+ # e.g. UserProjectJob.options_for_job is scoped by the Project's
153
+ # jobs:
154
+ r.input c, collection: aclass.send("options_for_#{c}",f.object)
155
+ else
156
+ r.input c
157
+ end
158
+ end
159
+ end
160
+ end
161
+ end
162
+ end
163
+
164
+ yield # Yield the DSL to the child class for further customization
165
+
166
+ end
167
+ end
168
+ end
169
+ end
170
+ end
@@ -0,0 +1,3 @@
1
+ module IntrospectiveAdmin
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ require 'activeadmin'
2
+ module IntrospectiveAdmin
3
+ autoload :Base, 'introspective_admin/base'
4
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :introspective_admin do
3
+ # # Task goes here
4
+ # end