thesilverspoon 0.0.28 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/doc/README.rdoc~ DELETED
@@ -1,12 +0,0 @@
1
- * this is a list with three paragraphs in
2
- the first item. This is the first paragraph.
3
-
4
- And this is the second paragraph.
5
-
6
- 1. This is an indented, numbered list.
7
- 2. This is the second item in that list
8
-
9
- This is the third conventional paragraph in the
10
- first list item.
11
-
12
- * This is the second item in the original list
@@ -1,299 +0,0 @@
1
- # Require the RAILS generators to be able to extend Rails:Generators::NamedBase
2
- require 'rails/generators'
3
-
4
- module Everything
5
- # If you use the NamedBase inheritance, a 'name' parameter has to follow the 'rails g integratedscaffold'. Won't work otherwise. If you don't want this, use ::Base
6
- class Scaffold < Rails::Generators::NamedBase
7
-
8
- # Method in the 'thor' library which gives you access to the accessor methods
9
- no_tasks { attr_accessor :model_attributes, :controller_actions }
10
-
11
- # This captures the arguments that the generator can take after "rails g integratedscaffold name"
12
- argument :g_parameters, :type => :array, :default => [], :banner => "field:type field:type"
13
-
14
- # this sets the path where the code looks for templates within the gem
15
- def self.source_root
16
- File.expand_path("../templates", __FILE__)
17
- end
18
-
19
- def initialize(*args, &block)
20
-
21
- # This is a standard initializer
22
-
23
- super # Call parent class
24
- @model_attributes = [] # Initialize empty array for 'thor' attributes
25
-
26
- # This method splits the name:type arguments in the parameters list
27
- g_parameters.each do |arg|
28
- @model_attributes << Rails::Generators::GeneratedAttribute.new(*arg.split(':'))
29
- end
30
-
31
- # Creates a list of all the standard actions in the controller
32
- @controller_actions=all_actions
33
-
34
- end
35
-
36
-
37
- def create_model
38
-
39
- # creates the model using the 'model.rb' template and puts it into the rails app
40
- template 'model.rb', "app/models/#{model_path}.rb"
41
-
42
- end
43
-
44
- def create_controller
45
-
46
- # creates the controller using the 'controller.rb' template and puts it into the rails app
47
- template 'controller.rb', "app/controllers/#{plural_name}_controller.rb"
48
- end
49
-
50
- def create_migration
51
-
52
- # creates the migration file using the 'migration.rb' template and puts it into the rails app with a time stamp
53
- template 'migration.rb', "db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_#{model_path.pluralize.gsub('/', '_')}.rb"
54
-
55
- end
56
-
57
- def create_helper
58
-
59
- # creates the helper using the 'helper.rb' template and puts it into the rails app
60
- template 'helper.rb', "app/helpers/#{plural_name}_helper.rb"
61
- end
62
-
63
- def create_routes
64
-
65
- # adds the routes for the gem into the routes file
66
- namespaces = plural_name.split('/')
67
- resource = namespaces.pop
68
- route namespaces.reverse.inject("resources :#{resource}") { |acc, namespace|
69
- "namespace(:#{namespace}){ #{acc} }"
70
- }
71
- end
72
-
73
-
74
- def create_views
75
-
76
- # creates the standard views using the '[action].html.erb' templates and puts it into the rails app
77
- controller_actions.each do |action|
78
- if action!="create" and action!="update" and action!="destroy" and action!="parse_save_from_excel"
79
- template "views/erb/#{action}.html.erb", "app/views/#{plural_name}/#{action}.html.erb"
80
- end
81
- end
82
- if form_partial?
83
- template "views/erb/_form.html.erb", "app/views/#{plural_name}/_form.html.erb"
84
- end
85
- end
86
-
87
- private
88
-
89
- def class_name
90
- name.camelize
91
- end
92
-
93
-
94
- def model_path
95
- name.underscore
96
- end
97
-
98
- def controller_methods(dir_name)
99
- controller_actions.map do |action|
100
- read_template("#{dir_name}/#{action}.rb")
101
- end.join("\n").strip
102
- end
103
-
104
- def read_template(relative_path)
105
- ERB.new(File.read(find_in_source_paths(relative_path)), nil, '-').result(binding)
106
- end
107
-
108
- def instance_name
109
- if @namespace_model
110
- singular_name.gsub('/', '_')
111
- else
112
- singular_name.split('/').last
113
- end
114
- end
115
-
116
- def instances_name
117
- instance_name.pluralize
118
- end
119
-
120
- def all_actions
121
- %w[index show new create edit update destroy]
122
- end
123
-
124
- def item_resource
125
- name.underscore.gsub('/', '_')
126
- end
127
-
128
- def items_path
129
- if action? :index
130
- "#{item_resource.pluralize}_path"
131
- else
132
- "root_path"
133
- end
134
- end
135
-
136
- def item_path(options = {})
137
- name = options[:instance_variable] ? "@#{instance_name}" : instance_name
138
- suffix = options[:full_url] ? "url" : "path"
139
- if options[:action].to_s == "new"
140
- "new_#{item_resource}_#{suffix}"
141
- elsif options[:action].to_s == "edit"
142
- "edit_#{item_resource}_#{suffix}(#{name})"
143
- else
144
- if name.include?('::') && !@namespace_model
145
- namespace = singular_name.split('/')[0..-2]
146
- "[:#{namespace.join(', :')}, #{name}]"
147
- else
148
- name
149
- end
150
- end
151
- end
152
-
153
- def item_url
154
- if action? :show
155
- item_path(:full_url => true, :instance_variable => true)
156
- else
157
- items_url
158
- end
159
- end
160
-
161
- def items_url
162
- if action? :index
163
- item_resource.pluralize + '_url'
164
- else
165
- "root_url"
166
- end
167
- end
168
-
169
-
170
- def plural_name
171
- name.underscore.pluralize
172
- end
173
-
174
- def form_partial?
175
- actions? :new, :edit
176
- end
177
-
178
- def all_actions
179
- %w[index show new create edit update destroy parse_save_from_excel integrated_view]
180
- end
181
-
182
- def action?(name)
183
- controller_actions.include? name.to_s
184
- end
185
-
186
- def actions?(*names)
187
- names.all? { |name| action? name }
188
- end
189
-
190
- def add_gem(name, options = {})
191
- gemfile_content = File.read(destination_path("Gemfile"))
192
- File.open(destination_path("Gemfile"), 'a') { |f| f.write("\n") } unless gemfile_content =~ /\n\Z/
193
- gem name, options unless gemfile_content.include? name
194
- end
195
-
196
- def destination_path(path)
197
- File.join(destination_root, path)
198
- end
199
-
200
-
201
- # If you use the NamedBase inheritance, a 'name' parameter has to follow the 'rails g integratedscaffold'. Won't work otherwise. If you don't want this, use ::Base
202
-
203
-
204
- end
205
- #endd of class
206
-
207
- end
208
- module The_silver_spoon
209
- class Install < Rails::Generators::Base
210
-
211
- def self.source_root
212
- File.expand_path("../templates", __FILE__)
213
- end
214
-
215
-
216
- def initialize(*args, &block)
217
- super
218
- #now we invokde generators off twitter boootstrap and gritter
219
- Rails::Generators.invoke('bootstrap:install')
220
- Rails::Generators.invoke('gritter:locale')
221
- Rails::Generators.invoke('devise:install')
222
- Rails::Generators.invoke('devise', ["user"])
223
- Rails::Generators.invoke('devise:views')
224
- Rails::Generators.invoke('cancan:ability')
225
-
226
-
227
-
228
-
229
-
230
-
231
-
232
-
233
- end
234
-
235
- def create_uploader
236
- #creates the uploader ruby file using carrierwave
237
- template 'file_uploader.rb', "app/uploaders/file_uploader.rb"
238
- end
239
-
240
- def create_images
241
-
242
- # copies the standard images into the assets/images folder
243
- @images=Array.new
244
- @images= Dir.entries("#{Install.source_root}/assets/images")
245
- @images.each do |image|
246
-
247
- if image!=".." and image !="."
248
- copy_file "assets/images/#{image.to_s}", "app/assets/images/#{image}"
249
- end
250
- end
251
-
252
-
253
- end
254
-
255
- def create_javascripts
256
-
257
- # copies the standard javascripts into the assets/javascripts folder - Currently hard-coded
258
- # Remove the hardcoding for the javascripts inclusion
259
-
260
- copy_file "#{Install.source_root}/assets/javascripts/jquery.dataTables.min.js", "app/assets/javascripts/jquery.dataTables.min.js"
261
-
262
- end
263
-
264
- def create_stylesheets_exclusions
265
-
266
- # copies the sequenced css into the assets/stylesheets/exclusions folder
267
- directory "#{Install.source_root}/assets/stylesheets/exclusions", "app/assets/stylesheets/exclusions"
268
- end
269
-
270
- def create_javascript_exclusions
271
-
272
- # copies the sequenced javascript into the assets/javascripts/exclusions folder
273
- directory "#{Install.source_root}/assets/javascripts/exclusions", "app/assets/javascripts/exclusions"
274
- end
275
-
276
- def create_stylesheet_images
277
-
278
- # copies the dependent css images into the assets/stylesheets/images folder
279
- directory "#{Install.source_root}/assets/stylesheets/images", "app/assets/stylesheets/images"
280
-
281
- end
282
-
283
-
284
- def create_layouts
285
- #remove hardcoding and make a loop for including all files in this folder
286
- remove_file "app/views/layouts/application.html.erb"
287
- template "#{Install.source_root}/layouts/application.html.erb", "app/views/layouts/application.html.erb"
288
- template "#{Install.source_root}/layouts//dummy_data.html.erb", "app/views/layouts/scaffold.html.erb"
289
- template "#{Install.source_root}/layouts/information_page.html.erb", "app/views/layouts/information_page.html.erb"
290
- template "#{Install.source_root}/layouts/pageslide_form_at.html.erb", "app/views/layouts/pageslide_form_at.html.erb"
291
- template "#{Install.source_root}/layouts/welcome.html.erb", "app/views/layouts/welcome.html.erb"
292
-
293
- end
294
-
295
-
296
- end
297
-
298
-
299
- end
@@ -1,12 +0,0 @@
1
- def create
2
- @<%= instance_name %> = <%= class_name %>.new(params[:<%= instance_name %>])
3
- if @<%= instance_name %>.save
4
- if !params[:integrated_view].nil?
5
- redirect_to <%= item_resource.pluralize %>_integrated_view_path, :notice => "Successfully created <%= class_name.underscore.humanize.downcase %>."
6
- else
7
- redirect_to <%= items_url %>, :notice => "Successfully created <%= class_name.underscore.humanize.downcase %>."
8
- end
9
- else
10
- render :new
11
- end
12
- end
@@ -1,10 +0,0 @@
1
- def destroy
2
- @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
- @<%= instance_name %>.destroy
4
- if !params[:integrated_view].nil?
5
-
6
- redirect_to <%= item_resource.pluralize %>_integrated_view_path, :notice => "Successfully destroyed <%= class_name.underscore.humanize.downcase %>."
7
- else
8
- redirect_to <%= items_url %>, :notice => "Successfully destroyed <%= class_name.underscore.humanize.downcase %>."
9
- end
10
- end
@@ -1,6 +0,0 @@
1
- def edit
2
- @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
- if !params[:get].nil?
4
- render :layout=>false
5
- end
6
- end
@@ -1,4 +0,0 @@
1
- def new
2
- @<%= instance_name %> = <%= class_name %>.new
3
-
4
- end
@@ -1,14 +0,0 @@
1
- def update
2
- @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
- if @<%= instance_name %>.update_attributes(params[:<%= instance_name %>])
4
- if !params[:integrated_view].nil?
5
- redirect_to <%= item_resource.pluralize %>_integrated_view_path, :notice => "Successfully created <%= class_name.underscore.humanize.downcase %>."
6
- else
7
- redirect_to <%= items_url %>, :notice => "Successfully created <%= class_name.underscore.humanize.downcase %>."
8
- end
9
-
10
-
11
- else
12
- render :edit
13
- end
14
- end
@@ -1,29 +0,0 @@
1
- @import "bootstrap";
2
-
3
-
4
- tr.odd {
5
- background-color: #e3f5ac;
6
- }
7
-
8
- tr.odd td.sorting_1 {
9
- background-color: #d7e99f;
10
- }
11
-
12
- tr.even {
13
- background-color: #ffffff;
14
- }
15
-
16
- tr.even td.sorting_1 {
17
- background-color: #f2f2f2;
18
- }
19
-
20
- td.options {
21
- width: 100px;
22
- background: olive;
23
- }
24
-
25
- td.options a {
26
- color: white;
27
- }
28
-
29
-
@@ -1,4 +0,0 @@
1
- class <%= plural_name.camelize %>Controller < ApplicationController
2
- layout 'scaffold'
3
- <%= controller_methods :actions %>
4
- end
@@ -1,80 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>BrandName</title>
5
- <%%= stylesheet_link_tag "application" %>
6
- <%%= javascript_include_tag "application" %>
7
- <%%= csrf_meta_tags %>
8
- <script type="text/javascript">
9
- $(function() {
10
- $(".edit_link").click(function() {
11
- $.get("<%%=params[:controller]%>" + "/" + $(this).attr("id") + "/edit", function(data) {
12
-
13
- $("#edit_form .modal-body").html(data);
14
- $("#edit_form").modal('toggle');
15
- });
16
- });
17
- });
18
- </script>
19
- <%%= yield(:head) %>
20
- </head>
21
- <body>
22
- <div id="wrapper">
23
- <div class="navbar navbar-fixed-top" style="z-index: 999999999">
24
- <div class="navbar-inner" style="z-index: 999999999">
25
- <div class="container">
26
- <a class="brand" href="/">BrandName</a>
27
- <ul class="nav">
28
- <li><a href="#about" style="color:white;">About</a></li>
29
- <!--<li><a href="#contact" style="color:white;">Contact</a></li>-->
30
- </ul>
31
-
32
- <%% if !user_signed_in? %>
33
- <%%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:class =>"pull-right navbar-form"}) do |f| %>
34
- <%%= f.email_field :email, :class=>"input-small", :placeholder=>"Email" %>
35
- <%%= f.password_field :password, :class=>"input-small", :placeholder=>"Password" %>
36
- <%%= f.submit "Sign In", :class=>"primary btn" %>
37
- <%% end %>
38
- <%% else %>
39
- <div class="pull-right" style="margin-top: 10px;color:white;">
40
- <%%= current_user.email %>
41
- <span class="nav_link">
42
- | <%%= link_to "Sign out", destroy_user_session_path, :method => :delete, :style=>"color:white;" %>
43
- </span>
44
- </div>
45
- <%% end %>
46
- </div>
47
- </div>
48
- </div>
49
- <div class="container">
50
-
51
- <div class="page-header" style="height:100px"></div>
52
- <div style="position:absolute;margin-top: -60px;" class="span12">
53
- <h2> <%%= yield(:page_header) %></h2>
54
- </div>
55
- </div>
56
- <div class="container">
57
-
58
- <div class="content">
59
- <%%= js extend_gritter :position => :bottom_right %>
60
- <%%= js add_gritter(flash[:notice], :image => :success, :title => "Notice", :sticky => false, :time => 2000) %>
61
- <%%= js add_gritter(flash[:alert], :image => :warning, :title => "Alert!", :sticky => false, :time => 2000) %>
62
- <%%= yield %>
63
- </div>
64
-
65
- <%% if request.fullpath=="/" %>
66
-
67
-
68
-
69
- <%% end %>
70
- </div>
71
- </div>
72
-
73
- <%%= javascript_include_tag "/assets/exclusions/jquery.pageslide" %>
74
-
75
-
76
- </body>
77
- </html>
78
-
79
-
80
-