cambium 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 (111) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -1
  3. data/Rakefile +0 -1
  4. data/bin/cambium +20 -0
  5. data/cambium.gemspec +24 -1
  6. data/lib/cambium/engine.rb +6 -0
  7. data/lib/cambium/version.rb +1 -1
  8. data/lib/cambium.rb +1 -1
  9. data/lib/docs/notes.md +4 -0
  10. data/lib/generators/cambium/setup/config_generator.rb +185 -0
  11. data/lib/generators/cambium/setup/controllers_generator.rb +95 -0
  12. data/lib/generators/cambium/setup/devise_generator.rb +78 -0
  13. data/lib/generators/cambium/setup/helpers_generator.rb +71 -0
  14. data/lib/generators/cambium/setup/javascripts_generator.rb +111 -0
  15. data/lib/generators/cambium/setup/models_generator.rb +116 -0
  16. data/lib/generators/cambium/setup/stylesheets_generator.rb +86 -0
  17. data/lib/generators/cambium/setup/utilities_generator.rb +87 -0
  18. data/lib/generators/cambium/setup/views_generator.rb +86 -0
  19. data/lib/generators/cambium/templates/Gemfile.erb +41 -0
  20. data/lib/generators/cambium/templates/app/assets/javascripts/.DS_Store +0 -0
  21. data/lib/generators/cambium/templates/app/assets/javascripts/admin/admin.js +12 -0
  22. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/admin.js.coffee +22 -0
  23. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/models/.gitkeep +0 -0
  24. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/routers/router.js.coffee +12 -0
  25. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/templates/paginator_controls.jst.ejs +8 -0
  26. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/templates/paginator_nav.jst.ejs +11 -0
  27. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/accordion.js.coffee +33 -0
  28. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/counter.js.coffee +25 -0
  29. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/dropdown_toggle.js.coffee +16 -0
  30. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/init_counter.js.coffee +13 -0
  31. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/paginator.js.coffee +86 -0
  32. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/publishable.js.coffee +12 -0
  33. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/wysiwyg.js.coffee +10 -0
  34. data/lib/generators/cambium/templates/app/assets/javascripts/admin/wysihtml5.js +9521 -0
  35. data/lib/generators/cambium/templates/app/assets/javascripts/application.js +7 -0
  36. data/lib/generators/cambium/templates/app/assets/javascripts/backbone/app.js.coffee +22 -0
  37. data/lib/generators/cambium/templates/app/assets/javascripts/backbone/routers/router.js.coffee +23 -0
  38. data/lib/generators/cambium/templates/app/assets/javascripts/backbone/views/default_helpers.js.coffee +16 -0
  39. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/admin.scss +14 -0
  40. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/__default.scss +14 -0
  41. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_buttons.scss +21 -0
  42. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_colors.scss +93 -0
  43. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_components.scss +4 -0
  44. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_forms.scss +28 -0
  45. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_helpers.scss +31 -0
  46. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_images.scss +23 -0
  47. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_nav.scss +117 -0
  48. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_tables.scss +12 -0
  49. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_typography.scss +83 -0
  50. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_wireframe.scss +18 -0
  51. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones.scss +68 -0
  52. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_content.scss +88 -0
  53. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_form.scss +470 -0
  54. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_globals.scss +39 -0
  55. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_header.scss +121 -0
  56. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_icons.scss +5194 -0
  57. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_nav.scss +45 -0
  58. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_wireframe.scss +24 -0
  59. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/wysihtml5.css +7 -0
  60. data/lib/generators/cambium/templates/app/assets/stylesheets/application.scss +9 -0
  61. data/lib/generators/cambium/templates/app/controllers/admin/users_controller.rb +13 -0
  62. data/lib/generators/cambium/templates/app/controllers/admin_controller.rb +88 -0
  63. data/lib/generators/cambium/templates/app/controllers/application_controller.rb +15 -0
  64. data/lib/generators/cambium/templates/app/helpers/admin_helper.rb +120 -0
  65. data/lib/generators/cambium/templates/app/models/concerns/idx.rb +28 -0
  66. data/lib/generators/cambium/templates/app/models/concerns/name.rb +7 -0
  67. data/lib/generators/cambium/templates/app/models/concerns/publishable.rb +50 -0
  68. data/lib/generators/cambium/templates/app/models/concerns/slug.rb +52 -0
  69. data/lib/generators/cambium/templates/app/models/concerns/tags.rb +28 -0
  70. data/lib/generators/cambium/templates/app/models/concerns/title.rb +7 -0
  71. data/lib/generators/cambium/templates/app/models/user.rb +14 -0
  72. data/lib/generators/cambium/templates/app/views/admin/_buttons.html.erb +5 -0
  73. data/lib/generators/cambium/templates/app/views/admin/_form.html.erb +11 -0
  74. data/lib/generators/cambium/templates/app/views/admin/_title.html.erb +1 -0
  75. data/lib/generators/cambium/templates/app/views/admin/edit.html.erb +2 -0
  76. data/lib/generators/cambium/templates/app/views/admin/index.html.erb +50 -0
  77. data/lib/generators/cambium/templates/app/views/admin/new.html.erb +2 -0
  78. data/lib/generators/cambium/templates/app/views/admin/shared/_footer.html.erb +2 -0
  79. data/lib/generators/cambium/templates/app/views/admin/shared/_header.html.erb +2 -0
  80. data/lib/generators/cambium/templates/app/views/admin/shared/_nav.html.erb +12 -0
  81. data/lib/generators/cambium/templates/app/views/admin/shared/_status.html.erb +3 -0
  82. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_editor.html.erb +54 -0
  83. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_form_column_left.html.erb +9 -0
  84. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_form_column_right.html.erb +9 -0
  85. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_form_page.html.erb +18 -0
  86. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_form_section.html.erb +8 -0
  87. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_publishable.html.erb +33 -0
  88. data/lib/generators/cambium/templates/app/views/admin/users/_form.html.erb +11 -0
  89. data/lib/generators/cambium/templates/app/views/application/_status.html.erb +3 -0
  90. data/lib/generators/cambium/templates/app/views/layouts/.DS_Store +0 -0
  91. data/lib/generators/cambium/templates/app/views/layouts/admin.html.erb +44 -0
  92. data/lib/generators/cambium/templates/app/views/layouts/application.html.erb +24 -0
  93. data/lib/generators/cambium/templates/config/application.rb +15 -0
  94. data/lib/generators/cambium/templates/config/database.mysql2.yml.erb +15 -0
  95. data/lib/generators/cambium/templates/config/database.pg.yml.erb +14 -0
  96. data/lib/generators/cambium/templates/config/database.sqlite3.yml.erb +18 -0
  97. data/lib/generators/cambium/templates/config/initializers/_settings.rb +11 -0
  98. data/lib/generators/cambium/templates/config/initializers/assets.rb +1 -0
  99. data/lib/generators/cambium/templates/config/routes.rb.erb +33 -0
  100. data/lib/generators/cambium/templates/config/settings.yml +15 -0
  101. data/lib/generators/cambium/templates/config/settings_private.sample.yml +15 -0
  102. data/lib/generators/cambium/templates/config/settings_private.yml +13 -0
  103. data/lib/generators/cambium/templates/db/seeds.rb +25 -0
  104. data/lib/generators/cambium/templates/gitignore +29 -0
  105. data/lib/generators/cambium/templates/lib/.DS_Store +0 -0
  106. data/lib/generators/cambium/templates/lib/tasks/db.rake +22 -0
  107. data/lib/generators/cambium/templates/lib/tasks/rename.rake +28 -0
  108. data/lib/generators/cambium/templates/vendor/assets/javascripts/modernizr.js +4 -0
  109. data/lib/generators/cambium/templates/vendor/assets/stylesheets/normalize.scss +406 -0
  110. data/lib/help/cambium +7 -0
  111. metadata +375 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da2eae2ca37c095440cc118137adb352d076d204
4
- data.tar.gz: 65fb19d688fa4d30c15abfdb32096a9dc5da97ea
3
+ metadata.gz: 0e28aa619df1b233dfde079815b4311a97b6baf8
4
+ data.tar.gz: cee209b988492319a11bedbe913848868b2e2d1e
5
5
  SHA512:
6
- metadata.gz: fbb8322b212204e0533547c5c4befc32173409c9a6f552a22658ffb388061636d5b5a3a8e0274e39f3945d85b1b96ad92047eb6c9a3f92c47e87f15b2d627955
7
- data.tar.gz: c70688fc73069329a825ce55dc0e67f4e856cbe6dc0df4907f25176322b305435857aa827335f0383255d3b20cd5e8643389eb1ea1dfdb9e69ec30422b8ea6a6
6
+ metadata.gz: b628402023f64e5f40ec18988e60175c66e7bf480c891f669f5de58372efb058d64bc7846c969f0755665401f6f407b6e9d280fb320efaa1a7e67f6fb2e38620
7
+ data.tar.gz: 0ade2250383704544931a67ca71464d88d471a94c0269d12a7a6f25db7c82f42851c793776c3d5b49d1c1a50a37aac2415996da18b4bacaea73eaf8a23f05916
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Cambium
2
2
 
3
- TODO: Write a gem description
3
+ Cambium speeds up app development to keep you focusing on business logic and not
4
+ worrying about repetitive tasks.
5
+
6
+ **Initial sprint in progress. Documentation will be provided when the gem is
7
+ ready for distribution.**
4
8
 
5
9
  ## Installation
6
10
 
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
1
  require "bundler/gem_tasks"
2
-
data/bin/cambium ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ @be = "bundle exec"
4
+ @g = "#{@be} rails g"
5
+
6
+ case ARGV.first
7
+ when "setup"
8
+ system "#{@g} cambium:setup:config"
9
+ system "#{@g} cambium:setup:devise"
10
+ system "#{@g} cambium:setup:models"
11
+ system "#{@g} cambium:setup:controllers"
12
+ system "#{@g} cambium:setup:views"
13
+ system "#{@g} cambium:setup:helpers"
14
+ system "#{@g} cambium:setup:javascripts"
15
+ system "#{@g} cambium:setup:stylesheets"
16
+ system "#{@g} cambium:setup:utilities"
17
+ else
18
+ gem_root = Gem::Specification.find_by_name("cambium").gem_dir
19
+ puts File.read("#{gem_root}/lib/help/cambium")
20
+ end
data/cambium.gemspec CHANGED
@@ -19,5 +19,28 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
- spec.add_development_dependency "rake"
22
+ spec.add_dependency "rake"
23
+ spec.add_dependency "rails"
24
+
25
+ [
26
+ 'annotate',
27
+ 'bones-rails',
28
+ 'bourbon',
29
+ 'carrierwave',
30
+ 'coffee-rails',
31
+ 'devise',
32
+ 'factory_girl_rails',
33
+ 'faker',
34
+ 'hirb',
35
+ 'jbuilder',
36
+ 'jquery-rails',
37
+ 'pickadate-rails',
38
+ 'rails-backbone',
39
+ 'sass-rails',
40
+ 'simple_form',
41
+ 'uglifier',
42
+ 'unicorn-rails',
43
+ 'wysihtml5-rails',
44
+ ].each { |g| spec.add_dependency g }
45
+
23
46
  end
@@ -0,0 +1,6 @@
1
+ require 'rails'
2
+
3
+ module Cambium
4
+ class Engine < Rails::Engine
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module Cambium
2
- VERSION = "0.0.0"
2
+ VERSION = "0.0.1"
3
3
  end
data/lib/cambium.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "cambium/version"
2
2
 
3
3
  module Cambium
4
- # Your code goes here...
4
+ require 'cambium/engine' if defined?(Rails)
5
5
  end
data/lib/docs/notes.md ADDED
@@ -0,0 +1,4 @@
1
+ Doc Notes
2
+
3
+ * add `gem 'cambium'` to `Gemfile`
4
+ *
@@ -0,0 +1,185 @@
1
+ require 'rake'
2
+ require 'rails/generators'
3
+
4
+ module Cambium
5
+ module Setup
6
+ class ConfigGenerator < Rails::Generators::Base
7
+ desc "Setup config files for new rails project"
8
+
9
+ # ------------------------------------------ Class Methods
10
+
11
+ source_root File.expand_path('../../templates', __FILE__)
12
+
13
+ # ------------------------------------------ Config
14
+
15
+ def cambium_setup
16
+ @config = {
17
+ :db => {},
18
+ :app => {}
19
+ }
20
+ end
21
+
22
+ def auto_config
23
+ # Read Gemfile
24
+ File.open("#{Rails.root}/Gemfile") do |f|
25
+ f.each_line do |line|
26
+ # Database
27
+ if line.include?("'mysql2'")
28
+ @config[:db][:adapter] = "mysql2"
29
+ elsif line.include?("'pg'")
30
+ @config[:db][:adapter] = "sqlite3"
31
+ elsif line.include?("'sqlite3'")
32
+ @config[:db][:adapter] = "pg"
33
+ end
34
+ # Rails Version
35
+ if line.match(/gem\ \'rails\'/)
36
+ @config[:app][:version] = line.gsub(/gem\ \'rails\'\,/, '').gsub(/\'/, '').strip
37
+ end
38
+ end
39
+ end
40
+ # Application Class Name
41
+ @config[:app][:name] = Rails.application.class.parent_name
42
+ # Database Name
43
+ @config[:db][:name] = @config[:app][:name].underscore.downcase
44
+ end
45
+
46
+ def user_config
47
+ # Database
48
+ if @config[:db][:adapter].present? && yes?("\nCambium, in all its wisdom, thinks your database adapter as #{set_color(@config[:db][:adapter], :green, :bold)}. Is this correct? [yes, no]")
49
+ say("Oh, goodie! Moving on...")
50
+ else
51
+ new_adapter = ask("What would you prefer?", :limited_to => ['mysql2','pg','sqlite3'])
52
+ unless new_adapter == @config[:db][:adapter]
53
+ say set_color("\nPlease add:", :red, :bold)
54
+ say "\n gem '#{new_adapter}'"
55
+ say set_color("\nto your Gemfile. Then run `bundle install` and `bundle exec cambium setup`.", :red, :bold)
56
+ exit
57
+ end
58
+ end
59
+
60
+ # Root URL (for mailers)
61
+ @config[:app][:dev_url] = ask("\n#{set_color('Development URL', :green, :bold)}: [leave blank for localhost:3000]")
62
+ @config[:app][:dev_url] = 'localhost:3000' if @config[:app][:dev_url].blank?
63
+ @config[:app][:prod_url] = ask("#{set_color('Production URL', :green, :bold)}: [leave blank for localhost:3000]")
64
+ @config[:app][:prod_url] = 'localhost:3000' if @config[:app][:prod_url].blank?
65
+
66
+ # Database Credentials
67
+ @config[:db][:user] = confirm_ask("#{set_color('Database User', :green, :bold)}: [leave blank for no user]")
68
+ if @config[:db][:user].present?
69
+ @config[:db][:password] = confirm_ask("#{set_color('Database Password', :green, :bold)}: [leave blank for no password]")
70
+ else
71
+ @config[:db][:password] = ''
72
+ end
73
+ end
74
+
75
+ # ------------------------------------------ Gems & Gemfile
76
+
77
+ def install_gemfile
78
+ remove_file "Gemfile"
79
+ template "Gemfile.erb", "Gemfile"
80
+ run_cmd "bundle clean"
81
+ end
82
+
83
+ # ------------------------------------------ Application Settings & Config
84
+
85
+ def add_application_config
86
+ insert_into_file(
87
+ "config/application.rb",
88
+ file_contents("config/application.rb"),
89
+ :after => "class Application < Rails::Application"
90
+ )
91
+ end
92
+
93
+ # ------------------------------------------ Environment Settings
94
+
95
+ def add_env_settings
96
+ insert_into_file "config/environments/development.rb",
97
+ :after => "Rails.application.configure do" do
98
+ "\n\n config.action_mailer.default_url_options = { :host => '#{@config[:app][:dev_url]}' }\n"
99
+ end
100
+ insert_into_file "config/environments/production.rb",
101
+ :after => "Rails.application.configure do" do
102
+ output = ''
103
+ output += "\n\n config.action_mailer.default_url_options = { :host => '#{@config[:app][:prod_url]}' }"
104
+ output += "\n\n config.assets.precompile += %w( admin/admin.css admin/admin.js admin/wysihtml5.css modernizr.js )\n"
105
+ output
106
+ end
107
+ end
108
+
109
+ # ------------------------------------------ Assets Initializer
110
+
111
+ def add_assets_initializer
112
+ template "config/initializers/assets.rb",
113
+ "config/initializers/assets.rb"
114
+ end
115
+
116
+ # ------------------------------------------ Database Setup
117
+
118
+ def setup_database
119
+ copy_file "#{Rails.root}/config/database.yml", "config/database.sample.yml"
120
+ remove_file "config/database.yml"
121
+ template "config/database.#{@config[:db][:adapter]}.yml.erb", "config/database.yml"
122
+ run_cmd "#{rake} db:drop", :quiet => true
123
+ run_cmd "#{rake} db:create"
124
+ run_cmd "#{rake} db:migrate"
125
+ end
126
+
127
+ # ------------------------------------------ .gitignore
128
+
129
+ def add_gitignore
130
+ remove_file ".gitignore"
131
+ template "gitignore", ".gitignore"
132
+ end
133
+
134
+ # ------------------------------------------ Private Methods
135
+
136
+ private
137
+
138
+ def run_cmd(cmd, options = {})
139
+ print_table(
140
+ [
141
+ [set_color("run", :green, :bold), cmd]
142
+ ],
143
+ :indent => 9
144
+ )
145
+ if options[:quiet] == true
146
+ `#{cmd}`
147
+ else
148
+ system(cmd)
149
+ end
150
+ end
151
+
152
+ def template_file(name)
153
+ File.expand_path("../../templates/#{name}", __FILE__)
154
+ end
155
+
156
+ def file_contents(template)
157
+ File.read(template_file(template))
158
+ end
159
+
160
+ def be
161
+ "bundle exec"
162
+ end
163
+
164
+ def g
165
+ "#{be} rails g"
166
+ end
167
+
168
+ def rake
169
+ "#{be} rake"
170
+ end
171
+
172
+ def confirm_ask(question)
173
+ answer = ask("\n#{question}")
174
+ match = ask("CONFIRM #{question}")
175
+ if answer == match
176
+ answer
177
+ else
178
+ say set_color("Did not match.", :red)
179
+ confirm_ask(question)
180
+ end
181
+ end
182
+
183
+ end
184
+ end
185
+ end
@@ -0,0 +1,95 @@
1
+ require 'rake'
2
+ require 'rails/generators'
3
+
4
+ module Cambium
5
+ module Setup
6
+ class ControllersGenerator < Rails::Generators::Base
7
+ desc "Setup controllers for new rails project"
8
+
9
+ # ------------------------------------------ Class Methods
10
+
11
+ source_root File.expand_path('../../templates', __FILE__)
12
+
13
+ # ------------------------------------------ Admin Controller
14
+
15
+ def add_admin_controller
16
+ template "app/controllers/admin_controller.rb",
17
+ "app/controllers/admin_controller.rb"
18
+ end
19
+
20
+ # ------------------------------------------ Admin Users Controller
21
+
22
+ def add_admin_users_controller
23
+ template "app/controllers/admin/users_controller.rb",
24
+ "app/controllers/admin/users_controller.rb"
25
+ end
26
+
27
+ # ------------------------------------------ Routes
28
+
29
+ def add_default_routes
30
+ remove_file "config/routes.rb"
31
+ template "config/routes.rb.erb", "config/routes.rb"
32
+ end
33
+
34
+ # ------------------------------------------ Log In/Out Redirects
35
+
36
+ def add_application_controller_redirects
37
+ insert_into_file(
38
+ "app/controllers/application_controller.rb",
39
+ file_contents("app/controllers/application_controller.rb"),
40
+ :after => ":exception"
41
+ )
42
+ end
43
+
44
+ # ------------------------------------------ Private Methods
45
+
46
+ private
47
+
48
+ def run_cmd(cmd, options = {})
49
+ print_table(
50
+ [
51
+ [set_color("run", :green, :bold), cmd]
52
+ ],
53
+ :indent => 9
54
+ )
55
+ if options[:quiet] == true
56
+ `#{cmd}`
57
+ else
58
+ system(cmd)
59
+ end
60
+ end
61
+
62
+ def template_file(name)
63
+ File.expand_path("../../templates/#{name}", __FILE__)
64
+ end
65
+
66
+ def file_contents(template)
67
+ File.read(template_file(template))
68
+ end
69
+
70
+ def be
71
+ "bundle exec"
72
+ end
73
+
74
+ def g
75
+ "#{be} rails g"
76
+ end
77
+
78
+ def rake
79
+ "#{be} rake"
80
+ end
81
+
82
+ def confirm_ask(question)
83
+ answer = ask("\n#{question}")
84
+ match = ask("Confirm: #{question}")
85
+ if answer == match
86
+ answer
87
+ else
88
+ say set_color("Did not match.", :red)
89
+ confirm_ask(question)
90
+ end
91
+ end
92
+
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,78 @@
1
+ require 'rake'
2
+ require 'rails/generators'
3
+
4
+ module Cambium
5
+ module Setup
6
+ class DeviseGenerator < Rails::Generators::Base
7
+ desc "Setup Devise for new rails project"
8
+
9
+ # ------------------------------------------ Class Methods
10
+
11
+ source_root File.expand_path('../../templates', __FILE__)
12
+
13
+ # ------------------------------------------ Devise
14
+
15
+ def install_devise
16
+ unless File.exist?("#{Rails.root}/config/initializers/devise.rb")
17
+ run_cmd "#{g} devise:install"
18
+ end
19
+ unless File.exist?("#{Rails.root}/app/models/user.rb")
20
+ run_cmd "#{g} devise User"
21
+ run_cmd "#{rake} db:migrate"
22
+ end
23
+ end
24
+
25
+ # ------------------------------------------ Private Methods
26
+
27
+ private
28
+
29
+ def run_cmd(cmd, options = {})
30
+ print_table(
31
+ [
32
+ [set_color("run", :green, :bold), cmd]
33
+ ],
34
+ :indent => 9
35
+ )
36
+ if options[:quiet] == true
37
+ `#{cmd}`
38
+ else
39
+ system(cmd)
40
+ end
41
+ end
42
+
43
+ def template_file(name)
44
+ File.expand_path("../../templates/#{name}", __FILE__)
45
+ end
46
+
47
+ def file_contents(template)
48
+ File.read(template_file(template))
49
+ end
50
+
51
+ def be
52
+ "bundle exec"
53
+ end
54
+
55
+ def g
56
+ "#{be} rails g"
57
+ end
58
+
59
+ def rake
60
+ "#{be} rake"
61
+ end
62
+
63
+ def confirm_ask(question)
64
+ answer = ask("\n#{question}")
65
+ match = ask("Confirm: #{question}")
66
+ if answer == match
67
+ answer
68
+ else
69
+ say set_color("Did not match.", :red)
70
+ confirm_ask(question)
71
+ end
72
+ end
73
+
74
+ # ------------------------------------------
75
+
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,71 @@
1
+ require 'rake'
2
+ require 'rails/generators'
3
+
4
+ module Cambium
5
+ module Setup
6
+ class HelpersGenerator < Rails::Generators::Base
7
+ desc "Setup helpers for new rails project"
8
+
9
+ # ------------------------------------------ Class Methods
10
+
11
+ source_root File.expand_path('../../templates', __FILE__)
12
+
13
+ # ------------------------------------------ Admin Helper
14
+
15
+ def add_admin_helper
16
+ template "app/helpers/admin_helper.rb",
17
+ "app/helpers/admin_helper.rb"
18
+ end
19
+
20
+ # ------------------------------------------ Private Methods
21
+
22
+ private
23
+
24
+ def run_cmd(cmd, options = {})
25
+ print_table(
26
+ [
27
+ [set_color("run", :green, :bold), cmd]
28
+ ],
29
+ :indent => 9
30
+ )
31
+ if options[:quiet] == true
32
+ `#{cmd}`
33
+ else
34
+ system(cmd)
35
+ end
36
+ end
37
+
38
+ def template_file(name)
39
+ File.expand_path("../../templates/#{name}", __FILE__)
40
+ end
41
+
42
+ def file_contents(template)
43
+ File.read(template_file(template))
44
+ end
45
+
46
+ def be
47
+ "bundle exec"
48
+ end
49
+
50
+ def g
51
+ "#{be} rails g"
52
+ end
53
+
54
+ def rake
55
+ "#{be} rake"
56
+ end
57
+
58
+ def confirm_ask(question)
59
+ answer = ask("\n#{question}")
60
+ match = ask("Confirm: #{question}")
61
+ if answer == match
62
+ answer
63
+ else
64
+ say set_color("Did not match.", :red)
65
+ confirm_ask(question)
66
+ end
67
+ end
68
+
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,111 @@
1
+ require 'rake'
2
+ require 'rails/generators'
3
+
4
+ module Cambium
5
+ module Setup
6
+ class JavascriptsGenerator < Rails::Generators::Base
7
+ desc "Setup javascripts for new rails project"
8
+
9
+ # ------------------------------------------ Class Methods
10
+
11
+ source_root File.expand_path('../../templates', __FILE__)
12
+
13
+ # ------------------------------------------ Public Setup
14
+
15
+ def install_backbone
16
+ run_cmd "#{g} backbone:install"
17
+ end
18
+
19
+ def default_application_js
20
+ app_js = "app/assets/javascripts/application.js"
21
+ remove_file app_js
22
+ template app_js, app_js
23
+ end
24
+
25
+ def rename_backbone_root
26
+ app_name = Rails.application.class.parent_name.underscore.downcase
27
+ remove_file "app/assets/javascripts/backbone/#{app_name}.js.coffee"
28
+ template "app/assets/javascripts/backbone/app.js.coffee",
29
+ "app/assets/javascripts/backbone/app.js.coffee"
30
+ end
31
+
32
+ # ------------------------------------------ Public Files
33
+
34
+ def add_public_router
35
+ remove_file "app/assets/javascripts/backbone/routers/.gitkeep"
36
+ template "app/assets/javascripts/backbone/routers/router.js.coffee",
37
+ "app/assets/javascripts/backbone/routers/router.js.coffee"
38
+ end
39
+
40
+ def add_default_view
41
+ remove_file "app/assets/javascripts/backbone/views/.gitkeep"
42
+ template "app/assets/javascripts/backbone/views/default_helpers.js.coffee",
43
+ "app/assets/javascripts/backbone/views/default_helpers.js.coffee"
44
+ end
45
+
46
+ # ------------------------------------------ Admin Setup
47
+
48
+ def add_admin_files
49
+ directory "app/assets/javascripts/admin",
50
+ "app/assets/javascripts/admin"
51
+ end
52
+
53
+ # ------------------------------------------ Add Modernizr
54
+
55
+ def add_modernizr
56
+ modernizr = "vendor/assets/javascripts/modernizr.js"
57
+ copy_file modernizr, modernizr
58
+ end
59
+
60
+ # ------------------------------------------ Private Methods
61
+
62
+ private
63
+
64
+ def run_cmd(cmd, options = {})
65
+ print_table(
66
+ [
67
+ [set_color("run", :green, :bold), cmd]
68
+ ],
69
+ :indent => 9
70
+ )
71
+ if options[:quiet] == true
72
+ `#{cmd}`
73
+ else
74
+ system(cmd)
75
+ end
76
+ end
77
+
78
+ def template_file(name)
79
+ File.expand_path("../../templates/#{name}", __FILE__)
80
+ end
81
+
82
+ def file_contents(template)
83
+ File.read(template_file(template))
84
+ end
85
+
86
+ def be
87
+ "bundle exec"
88
+ end
89
+
90
+ def g
91
+ "#{be} rails g"
92
+ end
93
+
94
+ def rake
95
+ "#{be} rake"
96
+ end
97
+
98
+ def confirm_ask(question)
99
+ answer = ask("\n#{question}")
100
+ match = ask("Confirm: #{question}")
101
+ if answer == match
102
+ answer
103
+ else
104
+ say set_color("Did not match.", :red)
105
+ confirm_ask(question)
106
+ end
107
+ end
108
+
109
+ end
110
+ end
111
+ end