super 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +165 -0
  3. data/README.md +102 -8
  4. data/app/assets/config/super_manifest.js +1 -0
  5. data/app/assets/javascripts/super/application.js +3483 -0
  6. data/app/assets/stylesheets/super/application.css +35265 -0
  7. data/app/controllers/super/application_controller.rb +84 -0
  8. data/app/views/layouts/super/application.html.erb +39 -0
  9. data/app/views/super/application/_form.html.erb +13 -0
  10. data/app/views/super/application/_form_field.html.erb +7 -0
  11. data/app/views/super/application/_form_generic_select.html.erb +19 -0
  12. data/app/views/super/application/_form_generic_text.html.erb +7 -0
  13. data/app/views/super/application/_index.html.erb +58 -0
  14. data/app/views/super/application/edit.html.erb +7 -0
  15. data/app/views/super/application/index.html.erb +1 -0
  16. data/app/views/super/application/new.html.erb +7 -0
  17. data/app/views/super/application/show.html.erb +10 -0
  18. data/app/views/super/feather/README.md +32 -0
  19. data/app/views/super/feather/_chevron_down.svg +1 -0
  20. data/frontend/super-frontend/build.js +34 -0
  21. data/frontend/super-frontend/dist/application.css +35265 -0
  22. data/frontend/super-frontend/dist/application.js +3483 -0
  23. data/frontend/super-frontend/package.json +14 -0
  24. data/frontend/super-frontend/postcss.config.js +6 -0
  25. data/frontend/super-frontend/src/javascripts/super/application.js +11 -0
  26. data/frontend/super-frontend/src/stylesheets/super/application.css +14 -0
  27. data/frontend/super-frontend/tailwind.config.js +7 -0
  28. data/frontend/super-frontend/yarn.lock +5355 -0
  29. data/lib/generators/super/install/USAGE +32 -0
  30. data/lib/generators/super/install/install_generator.rb +47 -0
  31. data/lib/generators/super/install/templates/base_controller.rb.tt +2 -0
  32. data/lib/generators/super/install/templates/initializer.rb.tt +5 -0
  33. data/lib/generators/super/resource/USAGE +9 -0
  34. data/lib/generators/super/resource/resource_generator.rb +54 -0
  35. data/lib/generators/super/resource/templates/resource_dashboard.rb.tt +65 -0
  36. data/lib/generators/super/resource/templates/resources_controller.rb.tt +9 -0
  37. data/lib/generators/super/webpacker/USAGE +14 -0
  38. data/lib/generators/super/webpacker/templates/pack_super_application.js.erb.tt +2 -0
  39. data/lib/generators/super/webpacker/webpacker_generator.rb +17 -0
  40. data/lib/super.rb +17 -4
  41. data/lib/super/assets.rb +62 -0
  42. data/lib/super/configuration.rb +88 -0
  43. data/lib/super/controls.rb +25 -0
  44. data/lib/super/display.rb +9 -0
  45. data/lib/super/display/schema_types.rb +41 -0
  46. data/lib/super/engine.rb +5 -0
  47. data/lib/super/error.rb +8 -0
  48. data/lib/super/form/schema_types.rb +47 -0
  49. data/lib/super/inline_callback.rb +82 -0
  50. data/lib/super/navigation/automatic.rb +69 -0
  51. data/lib/super/pagination.rb +59 -0
  52. data/lib/super/plugin.rb +89 -0
  53. data/lib/super/schema.rb +24 -0
  54. data/lib/super/test_support/fixtures/members.yml +336 -0
  55. data/lib/super/test_support/fixtures/ships.yml +10 -0
  56. data/lib/super/test_support/setup.rb +79 -0
  57. data/lib/super/test_support/starfleet_seeder.rb +49 -0
  58. data/lib/super/test_support/templates/20190216224956_create_members.rb +11 -0
  59. data/lib/super/test_support/templates/20190803143320_create_ships.rb +11 -0
  60. data/lib/super/test_support/templates/20190806014121_add_ship_to_members.rb +5 -0
  61. data/lib/super/test_support/templates/admin/members_controller.rb +9 -0
  62. data/lib/super/test_support/templates/admin/ships_controller.rb +9 -0
  63. data/lib/super/test_support/templates/admin_controller.rb +2 -0
  64. data/lib/super/test_support/templates/member.rb +16 -0
  65. data/lib/super/test_support/templates/member_dashboard.rb +90 -0
  66. data/lib/super/test_support/templates/routes.rb +10 -0
  67. data/lib/super/test_support/templates/seeds.rb +2 -0
  68. data/lib/super/test_support/templates/ship.rb +3 -0
  69. data/lib/super/test_support/templates/ship_dashboard.rb +79 -0
  70. data/lib/super/version.rb +1 -1
  71. data/lib/super/view.rb +25 -0
  72. metadata +131 -12
  73. data/LICENSE.txt +0 -40
@@ -0,0 +1,49 @@
1
+ class StarfleetSeeder
2
+ def self.seed
3
+ seeder = StarfleetSeeder.new
4
+ seeder.seed_from_fixture("ships", Ship)
5
+ seeder.seed_from_fixture("members", Member)
6
+ end
7
+
8
+ def initialize
9
+ @seeded = {}
10
+ @association_reflections = {}
11
+ end
12
+
13
+ def seed(basename, key, klass, value)
14
+ @seeded[basename] ||= {}
15
+ puts "--> #{key} (#{value})"
16
+ @association_reflections[klass] ||= klass.reflect_on_all_associations
17
+
18
+ @association_reflections[klass].each do |ar|
19
+ ar_name = ar.name.to_s
20
+ ar_plural_name = ar.plural_name.to_s
21
+
22
+ if value.key?(ar_name)
23
+ value[ar_name] = @seeded.fetch(ar_plural_name).fetch(value[ar_name])
24
+ end
25
+ end
26
+
27
+ @seeded[basename][key] = klass.find_or_create_by(value)
28
+ puts " success!"
29
+ rescue => e
30
+ puts " failure (#{e.message})"
31
+ end
32
+
33
+ def seed_from_fixture(basename, klass)
34
+ puts "==> #{basename}"
35
+ fixtures(basename).each do |key, value|
36
+ seed(basename, key, klass, value)
37
+ end
38
+
39
+ nil
40
+ end
41
+
42
+ private
43
+
44
+ def fixtures(basename)
45
+ @fixtures_dir ||= Pathname.new("./fixtures").expand_path(__dir__)
46
+
47
+ YAML.load_file(@fixtures_dir.join("#{basename}.yml"))
48
+ end
49
+ end
@@ -0,0 +1,11 @@
1
+ class CreateMembers < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :members do |t|
4
+ t.string :name, null: false
5
+ t.string :rank, null: false
6
+ t.string :position
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateShips < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :ships do |t|
4
+ t.string :name
5
+ t.string :registry
6
+ t.string :class_name
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ class AddShipToMembers < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_reference :members, :ship, foreign_key: true
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ module Admin
2
+ class MembersController < AdminController
3
+ private
4
+
5
+ def dashboard
6
+ MemberDashboard.new
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Admin
2
+ class ShipsController < AdminController
3
+ private
4
+
5
+ def dashboard
6
+ ShipDashboard.new
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ class AdminController < Super::ApplicationController
2
+ end
@@ -0,0 +1,16 @@
1
+ class Member < ApplicationRecord
2
+ enum rank: {
3
+ captain: "Captain",
4
+ commander: "Commander",
5
+ lieutenant_commander: "Lieutenant Commander",
6
+ lieutenant: "Lieutenant",
7
+ lieutenant_junior_grade: "Lieutenant Junior Grade",
8
+ ensign: "Ensign",
9
+ nco: "NCO",
10
+ }
11
+
12
+ belongs_to :ship
13
+
14
+ validates :name, presence: true
15
+ validates :rank, presence: true
16
+ end
@@ -0,0 +1,90 @@
1
+ class MemberDashboard
2
+ def title
3
+ Member.name.pluralize
4
+ end
5
+
6
+ def model
7
+ Member
8
+ end
9
+
10
+ def index_scope
11
+ Member.all
12
+ end
13
+
14
+ def index_schema
15
+ Super::Schema.new(Super::Display::SchemaTypes.new) do |fields, type|
16
+ fields[:name] = type.dynamic { |name| name }
17
+ fields[:rank] = type.dynamic { |rank| rank }
18
+ fields[:position] = type.dynamic { |position| position }
19
+ fields[:ship] = type.dynamic { |ship| "#{ship.name} (Ship ##{ship.id})" }
20
+ fields[:created_at] = type.dynamic(&:iso8601)
21
+ end
22
+ end
23
+
24
+ def create_scope
25
+ Member.all
26
+ end
27
+
28
+ def create_permitted_params(params)
29
+ params.require(:member).permit(:name, :rank, :position, :ship_id)
30
+ end
31
+
32
+ def new_scope
33
+ Member.all
34
+ end
35
+
36
+ def new_schema
37
+ Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type|
38
+ fields[:name] = type.generic("form_generic_text")
39
+ fields[:rank] = type.generic("form_generic_select", collection: Member.ranks.keys)
40
+ fields[:position] = type.generic("form_generic_text")
41
+ fields[:ship_id] = type.generic(
42
+ "form_generic_select",
43
+ collection: Ship.all.map { |s| ["#{s.name} (Ship ##{s.id})", s.id] },
44
+ )
45
+ end
46
+ end
47
+
48
+ def edit_scope
49
+ Member.all
50
+ end
51
+
52
+ def edit_schema
53
+ Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type|
54
+ fields[:name] = type.generic("form_generic_text")
55
+ fields[:rank] = type.generic("form_generic_select", collection: Member.ranks.keys)
56
+ fields[:position] = type.generic("form_generic_text")
57
+ fields[:ship_id] = type.generic(
58
+ "form_generic_select",
59
+ collection: Ship.all.map { |s| ["#{s.name} (Ship ##{s.id})", s.id] },
60
+ )
61
+ end
62
+ end
63
+
64
+ def show_scope
65
+ Member.all
66
+ end
67
+
68
+ def show_schema
69
+ Super::Schema.new(Super::Display::SchemaTypes.new) do |fields, type|
70
+ fields[:name] = type.dynamic { |name| name }
71
+ fields[:rank] = type.dynamic { |rank| rank }
72
+ fields[:position] = type.dynamic { |position| position }
73
+ fields[:ship] = type.dynamic { |ship| "#{ship.name} (Ship ##{ship.id})" }
74
+ fields[:created_at] = type.dynamic(&:iso8601)
75
+ fields[:updated_at] = type.dynamic(&:iso8601)
76
+ end
77
+ end
78
+
79
+ def update_scope
80
+ Member.all
81
+ end
82
+
83
+ def update_permitted_params(params)
84
+ params.require(:member).permit(:name, :rank, :position, :ship_id)
85
+ end
86
+
87
+ def destroy_scope
88
+ Member.all
89
+ end
90
+ end
@@ -0,0 +1,10 @@
1
+ Rails.application.routes.draw do
2
+ namespace :admin do
3
+ resources :members
4
+ resources :ships
5
+
6
+ root to: redirect("admin/members", status: 302)
7
+ end
8
+
9
+ root to: redirect("admin/members", status: 302)
10
+ end
@@ -0,0 +1,2 @@
1
+ require "super/test_support/starfleet_seeder"
2
+ StarfleetSeeder.seed
@@ -0,0 +1,3 @@
1
+ class Ship < ApplicationRecord
2
+ has_many :members
3
+ end
@@ -0,0 +1,79 @@
1
+ class ShipDashboard
2
+ def title
3
+ Ship.name.pluralize
4
+ end
5
+
6
+ def model
7
+ Ship
8
+ end
9
+
10
+ def index_scope
11
+ Ship.all
12
+ end
13
+
14
+ def index_schema
15
+ Super::Schema.new(Super::Display::SchemaTypes.new) do |fields, type|
16
+ fields[:name] = type.dynamic { |name| name }
17
+ fields[:registry] = type.dynamic { |registry| registry }
18
+ fields[:class_name] = type.dynamic { |class_name| class_name }
19
+ end
20
+ end
21
+
22
+ def create_scope
23
+ Ship.all
24
+ end
25
+
26
+ def create_permitted_params(params)
27
+ params.require(:ship).permit(:name, :registry, :class_name)
28
+ end
29
+
30
+ def new_scope
31
+ Ship.all
32
+ end
33
+
34
+ def new_schema
35
+ Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type|
36
+ fields[:name] = type.generic("form_generic_text")
37
+ fields[:registry] = type.generic("form_generic_text")
38
+ fields[:class_name] = type.generic("form_generic_text")
39
+ end
40
+ end
41
+
42
+ def edit_scope
43
+ Ship.all
44
+ end
45
+
46
+ def edit_schema
47
+ Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type|
48
+ fields[:name] = type.generic("form_generic_text")
49
+ fields[:registry] = type.generic("form_generic_text")
50
+ fields[:class_name] = type.generic("form_generic_text")
51
+ end
52
+ end
53
+
54
+ def show_scope
55
+ Ship.all
56
+ end
57
+
58
+ def show_schema
59
+ Super::Schema.new(Super::Display::SchemaTypes.new) do |fields, type|
60
+ fields[:name] = type.dynamic { |name| name }
61
+ fields[:registry] = type.dynamic { |registry| registry }
62
+ fields[:class_name] = type.dynamic { |class_name| class_name }
63
+ fields[:created_at] = type.dynamic(&:iso8601)
64
+ fields[:updated_at] = type.dynamic(&:iso8601)
65
+ end
66
+ end
67
+
68
+ def update_scope
69
+ Ship.all
70
+ end
71
+
72
+ def update_permitted_params(params)
73
+ params.require(:ship).permit(:name, :registry, :class_name)
74
+ end
75
+
76
+ def destroy_scope
77
+ Ship.all
78
+ end
79
+ end
data/lib/super/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Super
2
- VERSION = '0.0.0'
2
+ VERSION = "0.0.1"
3
3
  end
data/lib/super/view.rb ADDED
@@ -0,0 +1,25 @@
1
+ module Super
2
+ module View
3
+ module_function
4
+
5
+ def gutter_h(pm, positive = true)
6
+ if pm == :p
7
+ if positive
8
+ "px-2"
9
+ else
10
+ raise Error::InvalidStyle, "invalid style: -px-2"
11
+ end
12
+ else
13
+ if positive
14
+ "mx-2"
15
+ else
16
+ "-mx-2"
17
+ end
18
+ end
19
+ end
20
+
21
+ def classes(*list)
22
+ list.flatten.select(&:present?).join(" ")
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Ahn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-12 00:00:00.000000000 Z
11
+ date: 2019-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.2
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: capybara
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
25
39
  - !ruby/object:Gem::Version
26
- version: 5.2.2
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: sqlite3
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +52,48 @@ dependencies:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: 1.3.6
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest-ci
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: appraisal
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
41
97
  description:
42
98
  email:
43
99
  - engineering@zachahn.com
@@ -45,18 +101,82 @@ executables: []
45
101
  extensions: []
46
102
  extra_rdoc_files: []
47
103
  files:
48
- - LICENSE.txt
104
+ - LICENSE
49
105
  - README.md
50
106
  - Rakefile
51
107
  - app/assets/config/super_manifest.js
108
+ - app/assets/javascripts/super/application.js
109
+ - app/assets/stylesheets/super/application.css
110
+ - app/controllers/super/application_controller.rb
111
+ - app/views/layouts/super/application.html.erb
112
+ - app/views/super/application/_form.html.erb
113
+ - app/views/super/application/_form_field.html.erb
114
+ - app/views/super/application/_form_generic_select.html.erb
115
+ - app/views/super/application/_form_generic_text.html.erb
116
+ - app/views/super/application/_index.html.erb
117
+ - app/views/super/application/edit.html.erb
118
+ - app/views/super/application/index.html.erb
119
+ - app/views/super/application/new.html.erb
120
+ - app/views/super/application/show.html.erb
121
+ - app/views/super/feather/README.md
122
+ - app/views/super/feather/_chevron_down.svg
52
123
  - config/routes.rb
124
+ - frontend/super-frontend/build.js
125
+ - frontend/super-frontend/dist/application.css
126
+ - frontend/super-frontend/dist/application.js
127
+ - frontend/super-frontend/package.json
128
+ - frontend/super-frontend/postcss.config.js
129
+ - frontend/super-frontend/src/javascripts/super/application.js
130
+ - frontend/super-frontend/src/stylesheets/super/application.css
131
+ - frontend/super-frontend/tailwind.config.js
132
+ - frontend/super-frontend/yarn.lock
133
+ - lib/generators/super/install/USAGE
134
+ - lib/generators/super/install/install_generator.rb
135
+ - lib/generators/super/install/templates/base_controller.rb.tt
136
+ - lib/generators/super/install/templates/initializer.rb.tt
137
+ - lib/generators/super/resource/USAGE
138
+ - lib/generators/super/resource/resource_generator.rb
139
+ - lib/generators/super/resource/templates/resource_dashboard.rb.tt
140
+ - lib/generators/super/resource/templates/resources_controller.rb.tt
141
+ - lib/generators/super/webpacker/USAGE
142
+ - lib/generators/super/webpacker/templates/pack_super_application.js.erb.tt
143
+ - lib/generators/super/webpacker/webpacker_generator.rb
53
144
  - lib/super.rb
145
+ - lib/super/assets.rb
146
+ - lib/super/configuration.rb
147
+ - lib/super/controls.rb
148
+ - lib/super/display.rb
149
+ - lib/super/display/schema_types.rb
54
150
  - lib/super/engine.rb
151
+ - lib/super/error.rb
152
+ - lib/super/form/schema_types.rb
153
+ - lib/super/inline_callback.rb
154
+ - lib/super/navigation/automatic.rb
155
+ - lib/super/pagination.rb
156
+ - lib/super/plugin.rb
157
+ - lib/super/schema.rb
158
+ - lib/super/test_support/fixtures/members.yml
159
+ - lib/super/test_support/fixtures/ships.yml
160
+ - lib/super/test_support/setup.rb
161
+ - lib/super/test_support/starfleet_seeder.rb
162
+ - lib/super/test_support/templates/20190216224956_create_members.rb
163
+ - lib/super/test_support/templates/20190803143320_create_ships.rb
164
+ - lib/super/test_support/templates/20190806014121_add_ship_to_members.rb
165
+ - lib/super/test_support/templates/admin/members_controller.rb
166
+ - lib/super/test_support/templates/admin/ships_controller.rb
167
+ - lib/super/test_support/templates/admin_controller.rb
168
+ - lib/super/test_support/templates/member.rb
169
+ - lib/super/test_support/templates/member_dashboard.rb
170
+ - lib/super/test_support/templates/routes.rb
171
+ - lib/super/test_support/templates/seeds.rb
172
+ - lib/super/test_support/templates/ship.rb
173
+ - lib/super/test_support/templates/ship_dashboard.rb
55
174
  - lib/super/version.rb
175
+ - lib/super/view.rb
56
176
  - lib/tasks/super_tasks.rake
57
177
  homepage:
58
178
  licenses:
59
- - Fair Source 5
179
+ - LGPL-3.0-only
60
180
  metadata: {}
61
181
  post_install_message:
62
182
  rdoc_options: []
@@ -66,16 +186,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
186
  requirements:
67
187
  - - ">="
68
188
  - !ruby/object:Gem::Version
69
- version: '0'
189
+ version: 2.3.0
70
190
  required_rubygems_version: !ruby/object:Gem::Requirement
71
191
  requirements:
72
192
  - - ">="
73
193
  - !ruby/object:Gem::Version
74
194
  version: '0'
75
195
  requirements: []
76
- rubyforge_project:
77
- rubygems_version: 2.7.6
196
+ rubygems_version: 3.0.3
78
197
  signing_key:
79
198
  specification_version: 4
80
- summary: A simple, powerful, zero* dependency Rails admin framework
199
+ summary: A simple, powerful, single dependency Rails admin framework
81
200
  test_files: []