mega_bar 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +31 -0
- data/Rakefile +23 -0
- data/app/assets/javascripts/mega_bar/application.js +13 -0
- data/app/assets/stylesheets/mega_bar/application.css +15 -0
- data/app/controllers/mega_bar/application_controller.rb +28 -0
- data/app/controllers/mega_bar/checkboxes_controller.rb +19 -0
- data/app/controllers/mega_bar/field_displays_controller.rb +11 -0
- data/app/controllers/mega_bar/fields_controller.rb +11 -0
- data/app/controllers/mega_bar/grid_html.rb +27 -0
- data/app/controllers/mega_bar/mega_bar_concern.rb +169 -0
- data/app/controllers/mega_bar/model_displays_controller.rb +11 -0
- data/app/controllers/mega_bar/models_controller.rb +14 -0
- data/app/controllers/mega_bar/profile_table.rb +27 -0
- data/app/controllers/mega_bar/radio_buttons_controller.rb +18 -0
- data/app/controllers/mega_bar/records_formats_controller.rb +10 -0
- data/app/controllers/mega_bar/selects_controller.rb +12 -0
- data/app/controllers/mega_bar/testers_controller.rb +11 -0
- data/app/controllers/mega_bar/tests_controller.rb +5 -0
- data/app/controllers/mega_bar/textboxes_controller.rb +11 -0
- data/app/controllers/mega_bar/textreads_controller.rb +10 -0
- data/app/controllers/mega_bar/tmp_field_displays_controller.rb +18 -0
- data/app/controllers/mega_bar/tmp_fields_controller.rb +18 -0
- data/app/controllers/mega_bar/tmp_model_displays_controller.rb +18 -0
- data/app/controllers/mega_bar/tmp_models_controller.rb +16 -0
- data/app/controllers/mega_bar/tmp_records_formats_controller.rb +18 -0
- data/app/controllers/mega_bar/tmp_selects_controller.rb +18 -0
- data/app/controllers/mega_bar/tmp_textboxes_controller.rb +18 -0
- data/app/controllers/mega_bar/tmp_textreads_controller.rb +18 -0
- data/app/helpers/mega_bar/application_helper.rb +41 -0
- data/app/helpers/mega_bar/fields_helper.rb +13 -0
- data/app/helpers/mega_bar/models_helper.rb +13 -0
- data/app/models/mega_bar/checkbox.rb +8 -0
- data/app/models/mega_bar/field.rb +31 -0
- data/app/models/mega_bar/field_display.rb +25 -0
- data/app/models/mega_bar/mega_bar_model_concern.rb +20 -0
- data/app/models/mega_bar/model.rb +35 -0
- data/app/models/mega_bar/model_display.rb +10 -0
- data/app/models/mega_bar/radio_button.rb +6 -0
- data/app/models/mega_bar/records_format.rb +5 -0
- data/app/models/mega_bar/select.rb +9 -0
- data/app/models/mega_bar/test.rb +2 -0
- data/app/models/mega_bar/tester.rb +5 -0
- data/app/models/mega_bar/textarea.rb +9 -0
- data/app/models/mega_bar/textbox.rb +8 -0
- data/app/models/mega_bar/textread.rb +9 -0
- data/app/models/mega_bar/tmp_field.rb +6 -0
- data/app/models/mega_bar/tmp_field_display.rb +6 -0
- data/app/models/mega_bar/tmp_model.rb +6 -0
- data/app/models/mega_bar/tmp_model_display.rb +6 -0
- data/app/models/mega_bar/tmp_records_format.rb +6 -0
- data/app/models/mega_bar/tmp_select.rb +6 -0
- data/app/models/mega_bar/tmp_textbox.rb +6 -0
- data/app/models/mega_bar/tmp_textread.rb +6 -0
- data/app/views/mega_bar/application/_hello.html.erb +1 -0
- data/app/views/mega_bar/application/_mega_bar_read.html.erb +38 -0
- data/app/views/mega_bar/application/_mega_bar_write.html.erb +27 -0
- data/app/views/mega_bar/application/mega_bar.html.erb +62 -0
- data/app/views/textboxes/_form.html.erb +0 -0
- data/app/views/textboxes/edit.html.erb +0 -0
- data/app/views/textboxes/index.html.erb +0 -0
- data/app/views/textboxes/index.json.jbuilder +4 -0
- data/app/views/textboxes/new.html.erb +0 -0
- data/app/views/textboxes/show.html.erb +5 -0
- data/app/views/textboxes/show.json.jbuilder +1 -0
- data/app/views/textreads/_form.html.erb +0 -0
- data/app/views/textreads/edit.html.erb +0 -0
- data/app/views/textreads/index.html.erb +0 -0
- data/app/views/textreads/index.json.jbuilder +4 -0
- data/app/views/textreads/new.html.erb +0 -0
- data/app/views/textreads/show.html.erb +1 -0
- data/app/views/textreads/show.html.erb.orig.rhtml +0 -0
- data/app/views/textreads/show.json.jbuilder +1 -0
- data/config/routes.rb +30 -0
- data/db/mega_bar.seeds.rb +814 -0
- data/db/migrate/20140505150251_create_models.rb +12 -0
- data/db/migrate/20140505174947_create_model_displays.rb +11 -0
- data/db/migrate/20140505195607_create_records_formats.rb +11 -0
- data/db/migrate/20140505211530_create_textreads.rb +12 -0
- data/db/migrate/20140505214403_create_textboxes.rb +10 -0
- data/db/migrate/20140521220256_create_fields.rb +12 -0
- data/db/migrate/20140521222528_create_field_displays.rb +12 -0
- data/db/migrate/20140523160810_create_selects.rb +16 -0
- data/db/migrate/20140523200921_create_testers.rb +11 -0
- data/db/migrate/20140618170624_create_tests.rb +9 -0
- data/db/migrate/20141227235653_create_tmp_models.rb +11 -0
- data/db/migrate/20141228061208_create_mega_bar_tmp_fields.rb +12 -0
- data/db/migrate/20141228163900_create_mega_bar_tmp_model_displays.rb +11 -0
- data/db/migrate/20141228163956_create_mega_bar_tmp_field_displays.rb +11 -0
- data/db/migrate/20141228164052_create_mega_bar_tmp_records_formats.rb +10 -0
- data/db/migrate/20141228164245_create_mega_bar_tmp_textboxes.rb +10 -0
- data/db/migrate/20141228164314_create_mega_bar_tmp_textreads.rb +12 -0
- data/db/migrate/20141228164350_create_mega_bar_tmp_selects.rb +16 -0
- data/db/migrate/20141229173832_create_mega_bar_checkboxes.mega_bar.rb +8 -0
- data/db/migrate/20141229180849_create_mega_bar_radio_buttons.mega_bar.rb +8 -0
- data/db/migrate/20141230171751_create_mega_bar_textareas.mega_bar.rb +8 -0
- data/db/migrate/20141230173142_create_mega_bar_checkboxes.mega_bar.rb +9 -0
- data/lib/generators/mega_bar/mega_bar/USAGE +8 -0
- data/lib/generators/mega_bar/mega_bar/mega_bar_generator.rb +91 -0
- data/lib/generators/mega_bar/mega_bar/templates/generic_controller.rb +18 -0
- data/lib/generators/mega_bar/mega_bar/templates/generic_model.rb +6 -0
- data/lib/generators/mega_bar/mega_bar_fields/USAGE +8 -0
- data/lib/generators/mega_bar/mega_bar_fields/mega_bar_fields_generator.rb +13 -0
- data/lib/generators/mega_bar/mega_bar_fields/templates/generic_controller.rb +15 -0
- data/lib/generators/mega_bar/mega_bar_fields/templates/generic_model.rb +6 -0
- data/lib/mega_bar/engine.rb +15 -0
- data/lib/mega_bar/generators/mega_bar_generator.rb +6 -0
- data/lib/mega_bar/version.rb +3 -0
- data/lib/mega_bar.rb +4 -0
- data/lib/tasks/mega_bar_tasks.rake +270 -0
- metadata +393 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateSelects < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :mega_bar_selects do |t|
|
4
|
+
t.integer :field_display_id
|
5
|
+
t.integer :model_id
|
6
|
+
t.integer :field_id
|
7
|
+
t.string :collection
|
8
|
+
t.string :value_method
|
9
|
+
t.string :text_method
|
10
|
+
t.integer :data_size
|
11
|
+
t.string :include_blank
|
12
|
+
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateMegaBarTmpTextreads < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :mega_bar_tmp_textreads do |t|
|
4
|
+
t.integer :field_display_id
|
5
|
+
t.integer :truncation
|
6
|
+
t.text :truncation_format
|
7
|
+
t.text :transformation
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateMegaBarTmpSelects < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :mega_bar_tmp_selects do |t|
|
4
|
+
t.integer :field_display_id
|
5
|
+
t.integer :model_id
|
6
|
+
t.integer :field_id
|
7
|
+
t.string :collection
|
8
|
+
t.string :value_method
|
9
|
+
t.string :text_method
|
10
|
+
t.integer :data_size
|
11
|
+
t.string :include_blank
|
12
|
+
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module MegaBar
|
2
|
+
class MegaBarGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
argument :filename, type: :string
|
5
|
+
argument :model_id, type: :string
|
6
|
+
|
7
|
+
# in generators, all public methods are run. Weird, huh?
|
8
|
+
|
9
|
+
def create_controller_file
|
10
|
+
template "generic_controller.rb", "#{the_controller_file_name}.rb"
|
11
|
+
if the_module_name
|
12
|
+
# template "generic_controller.rb", "tmp_#{the_controller_file_name}.rb"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
def create_model_file
|
17
|
+
template "generic_model.rb", "#{the_model_file_name}"
|
18
|
+
if the_module_name
|
19
|
+
# template "generic_model.rb", "Tmp#{the_model_file_name}.rb"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def generate_migration
|
23
|
+
if the_module_name
|
24
|
+
generate 'migration create_' + the_module_name + '_' + the_table_name + ' created_at:datetime updated_at:datetime'
|
25
|
+
# generate 'migration create_tmp_' + the_module_name + '_' + the_table_name + ' created_at:datetime updated_at:datetime'
|
26
|
+
else
|
27
|
+
generate 'migration create_' + the_table_name + ' created_at:datetime updated_at:datetime'
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
def route
|
32
|
+
|
33
|
+
line = ' ##### MEGABAR END'
|
34
|
+
text = File.read('config/routes.rb')
|
35
|
+
new_contents = text.gsub( /(#{Regexp.escape(line)})/mi, 'resource :' + the_route_name + "\n #{line}\n")
|
36
|
+
# To write changes to the file, use:
|
37
|
+
File.open('config/routes.rb', "w") {|file| file.puts new_contents }
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def the_file_name
|
43
|
+
if filename.include? '::'
|
44
|
+
return filename[filename.index('::')+2..-1]
|
45
|
+
else
|
46
|
+
return filename
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def the_model_file_name
|
51
|
+
if the_module_name
|
52
|
+
'app/models/' + the_module_name.underscore + '/' + the_file_name.to_s.singularize.underscore + '.rb'
|
53
|
+
else
|
54
|
+
'app/models/' + the_file_name.to_s.singularize.underscore + '.rb'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def the_model_name
|
59
|
+
the_file_name.classify
|
60
|
+
end
|
61
|
+
|
62
|
+
def the_controller_file_name
|
63
|
+
if the_module_name
|
64
|
+
'app/controllers/' + the_module_name.underscore + '/' + the_file_name.pluralize.underscore + "_controller"
|
65
|
+
else
|
66
|
+
'app/controllers/' + the_file_name.pluralize.underscore + "_controller"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def the_controller_name
|
71
|
+
the_file_name.classify.pluralize + 'Controller'
|
72
|
+
end
|
73
|
+
|
74
|
+
def the_table_name
|
75
|
+
the_file_name.pluralize
|
76
|
+
end
|
77
|
+
|
78
|
+
def the_module_name
|
79
|
+
if filename.include? '::'
|
80
|
+
return filename[0..filename.index('::')-1]
|
81
|
+
else
|
82
|
+
return nil
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def the_route_name
|
87
|
+
the_file_name.pluralize.underscore
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<% if the_module_name %>
|
2
|
+
module <%=the_module_name%>
|
3
|
+
<% end %>class <%= the_controller_name %> < ApplicationController
|
4
|
+
include MegaBarConcern
|
5
|
+
before_action ->{ myinit <%= model_id %> }, only: [:index, :show, :edit, :new]
|
6
|
+
|
7
|
+
|
8
|
+
private
|
9
|
+
def _params
|
10
|
+
permits = []
|
11
|
+
controller_name.classify.constantize.attribute_names.each do |att|
|
12
|
+
permits << att unless ['id', 'created_at', 'updated_at'].include?(att)
|
13
|
+
end
|
14
|
+
params.require(controller_name.singularize).permit(permits)
|
15
|
+
end
|
16
|
+
|
17
|
+
<% if the_module_name %> end<% end %>
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module MegaBar
|
2
|
+
class MegaBarFieldsGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
argument :tablename, type: :string
|
5
|
+
argument :fieldname, type: :string
|
6
|
+
argument :fieldtype, type: :string
|
7
|
+
|
8
|
+
def generate_migration
|
9
|
+
generate 'migration add_' + fieldname + '_to_' + tablename + ' ' + fieldname + ':' + fieldtype
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% if the_module_name %>
|
2
|
+
module <%=the_module_name%>
|
3
|
+
<% end %>class <%= the_controller_name %> < ApplicationController
|
4
|
+
include MegaBarConcern
|
5
|
+
before_action ->{ myinit <%= model_id %> }, only: [:index, :show, :edit, :new]
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
private
|
10
|
+
# Never trust parameters from the scary internet, only allow the white list through.
|
11
|
+
def _params
|
12
|
+
params.require(:textbox).permit()
|
13
|
+
end
|
14
|
+
<% if the_module_name %> end<% end %>
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module MegaBar
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace MegaBar
|
4
|
+
|
5
|
+
|
6
|
+
config.generators do |g|
|
7
|
+
g.test_framework :rspec
|
8
|
+
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
9
|
+
end
|
10
|
+
### taskrabbit: http://tech.taskrabbit.com/blog/2014/02/11/rails-4-engines/
|
11
|
+
### http://pivotallabs.com/leave-your-migrations-in-your-rails-engines/
|
12
|
+
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
data/lib/mega_bar.rb
ADDED