jumpstart 0.1.0
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/.bundle/config +2 -0
- data/.document +5 -0
- data/.gitignore +28 -0
- data/Gemfile +8 -0
- data/LICENSE +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/bin/jumpstart +5 -0
- data/config/jumpstart_setup.yml +2 -0
- data/jumpstart.gemspec +222 -0
- data/jumpstart_templates/i0n_rails_3/.gitignore +11 -0
- data/jumpstart_templates/i0n_rails_3/_._Gemfile +5 -0
- data/jumpstart_templates/i0n_rails_3/app/views/home/index.haml +4 -0
- data/jumpstart_templates/i0n_rails_3/app/views/layouts/application.haml +32 -0
- data/jumpstart_templates/i0n_rails_3/config/_2._routes.rb +1 -0
- data/jumpstart_templates/i0n_rails_3/config/_L._database.yml +1 -0
- data/jumpstart_templates/i0n_rails_3/config/deploy.rb +62 -0
- data/jumpstart_templates/i0n_rails_3/config/environments/_18._development.rb +5 -0
- data/jumpstart_templates/i0n_rails_3/config/environments/_27._test.rb +1 -0
- data/jumpstart_templates/i0n_rails_3/config/environments/_41._production.rb +3 -0
- data/jumpstart_templates/i0n_rails_3/config/initializers/setup_mail.rb +14 -0
- data/jumpstart_templates/i0n_rails_3/jumpstart_config/i0n_rails_3.yml +40 -0
- data/jumpstart_templates/i0n_rails_3/jumpstart_config/nginx.local.conf +11 -0
- data/jumpstart_templates/i0n_rails_3/jumpstart_config/nginx.remote.conf +37 -0
- data/jumpstart_templates/i0n_rails_3/lib/development_mail_interceptor.rb +8 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic.rb +11 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic/session/session_generator.rb +18 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic/session/templates/session.rb +2 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper.rb +80 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/migration/migration_generator.rb +26 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/migration/templates/migration.rb +21 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/model_generator.rb +29 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/templates/migration.rb +17 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/templates/model.rb +10 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/observer/observer_generator.rb +15 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/observer/templates/observer.rb +5 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl.rb +11 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl/model/model_generator.rb +14 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl/model/templates/fixtures.rb +7 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb.rb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/USAGE +8 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/controller/controller_generator.rb +24 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/controller/templates/view.html.erb +0 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/scaffold_generator.rb +27 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/_form.html.erb +12 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/edit.html.erb +6 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/index.html.erb +27 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/layout.html.erb +16 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/new.html.erb +5 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/show.html.erb +10 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml.rb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/USAGE +8 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/controller/controller_generator.rb +24 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/controller/templates/view.html.haml +0 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/scaffold_generator.rb +23 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/_form.haml.erb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/edit.haml.erb +7 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/index.haml.erb +23 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/layout.haml.erb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/new.haml.erb +5 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/show.haml.erb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml.rb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/controller/controller_generator.rb +24 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/controller/templates/view.html.haml +0 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/scaffold_generator.rb +26 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/_form.haml.erb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/edit.haml.erb +7 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/index.haml.erb +23 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/layout.haml.erb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/new.haml.erb +5 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/show.haml.erb +9 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/machinist.rb +11 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/model_generator.rb +19 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/templates/blueprint.rb +5 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/templates/machinist_initializer.rb +19 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper.rb +80 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/model/model_generator.rb +29 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/model/templates/model.rb +24 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/observer/observer_generator.rb +15 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda.rb +11 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/controller_generator.rb +16 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/templates/controller.rb +84 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/model/model_generator.rb +16 -0
- data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/model/templates/model.rb +7 -0
- data/jumpstart_templates/i0n_rails_3/lib/tasks/populate.rake +91 -0
- data/jumpstart_templates/i0n_rails_3/public/javascripts/init.js +6 -0
- data/jumpstart_templates/i0n_rails_3/public/javascripts/jquery-1.4.2.min.js +154 -0
- data/jumpstart_templates/i0n_rails_3/public/javascripts/jquery-ui-1.8.custom.min.js +404 -0
- data/jumpstart_templates/i0n_rails_3/public/javascripts/rails.js +126 -0
- data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/_setup.sass +86 -0
- data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/global.sass +58 -0
- data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/handheld.sass +7 -0
- data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/ie.sass +40 -0
- data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/print.sass +57 -0
- data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/screen.sass +170 -0
- data/lib/jumpstart.rb +71 -0
- data/lib/jumpstart/base.rb +547 -0
- data/lib/jumpstart/doc/JumpStart.html +139 -0
- data/lib/jumpstart/doc/JumpStart/Base.html +1566 -0
- data/lib/jumpstart/doc/base_rb.html +52 -0
- data/lib/jumpstart/doc/created.rid +2 -0
- data/lib/jumpstart/doc/index.html +101 -0
- data/lib/jumpstart/doc/rdoc.css +706 -0
- data/lib/jumpstart/filetools.rb +270 -0
- data/source_templates/template_config.yml +77 -0
- data/test/fake_nginx_path/local_nginx_1.conf +81 -0
- data/test/fake_nginx_path/remote_nginx_1.conf +54 -0
- data/test/helper.rb +31 -0
- data/test/jumpstart/test_base.rb +422 -0
- data/test/jumpstart/test_filetools.rb +350 -0
- data/test/test_jumpstart.rb +9 -0
- data/test/test_jumpstart_templates/test_base/_._test_file.txt +0 -0
- data/test/test_jumpstart_templates/test_base/_._test_file_.txt +0 -0
- data/test/test_jumpstart_templates/test_base/_1._test_file1.txt +0 -0
- data/test/test_jumpstart_templates/test_base/_1._test_file1_.txt +0 -0
- data/test/test_jumpstart_templates/test_base/_10._test_file2.txt +0 -0
- data/test/test_jumpstart_templates/test_base/_99999._test_file3.txt +0 -0
- data/test/test_jumpstart_templates/test_base/_a._test_file4.txt +0 -0
- data/test/test_jumpstart_templates/test_base/test_file +0 -0
- data/test/test_jumpstart_templates/test_base/test_file5.txt +0 -0
- data/test/test_jumpstart_templates/test_base/test_file_.6txt +0 -0
- data/test/test_jumpstart_templates/test_fileutils/append_after_line_test.txt +6 -0
- data/test/test_jumpstart_templates/test_fileutils/append_to_end_of_file_source.txt +1 -0
- data/test/test_jumpstart_templates/test_fileutils/append_to_end_of_file_test.txt +5 -0
- data/test/test_jumpstart_templates/test_fileutils/check_source_type +5 -0
- data/test/test_jumpstart_templates/test_fileutils/check_source_type.txt +10 -0
- data/test/test_jumpstart_templates/test_fileutils/config_capistrano_source.rb +62 -0
- data/test/test_jumpstart_templates/test_fileutils/config_capistrano_test.rb +62 -0
- data/test/test_jumpstart_templates/test_fileutils/config_nginx_source.txt +1 -0
- data/test/test_jumpstart_templates/test_fileutils/config_nginx_test.txt +82 -0
- data/test/test_jumpstart_templates/test_fileutils/hosts_test +11 -0
- data/test/test_jumpstart_templates/test_fileutils/insert_text_at_line_number_source.txt +1 -0
- data/test/test_jumpstart_templates/test_fileutils/insert_text_at_line_number_test.txt +4 -0
- data/test/test_jumpstart_templates/test_fileutils/remove_files_test_2.txt +0 -0
- data/test/test_jumpstart_templates/test_fileutils/remove_files_test_3.txt +0 -0
- data/test/test_jumpstart_templates/test_fileutils/remove_lines_test.txt +10 -0
- data/test/test_jumpstart_templates/test_fileutils/replace_strings_test.rb +62 -0
- data/test/test_jumpstart_templates/test_template_1/_._test_append_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/_._test_append_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/_20._test_line_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/_5._test_line_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/_L._test_append_to_end_of_file_remove_last_line_1.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/_l._test_append_to_end_of_file_remove_last_line_2.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/folder with spaces/_._test_append_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/folder with spaces/_._test_append_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/folder with spaces/_5._test_line_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/folder with spaces/_50._test_line_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/folder with spaces/test_whole_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/folder with spaces/test_whole_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/jumpstart_config/test_template_1.yml +31 -0
- data/test/test_jumpstart_templates/test_template_1/normal_folder_name/_._test_append_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/normal_folder_name/_._test_append_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/normal_folder_name/_5._test_line_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/normal_folder_name/_50._test_line_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/normal_folder_name/test_whole_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/normal_folder_name/test_whole_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/test_append_to_end_of_file_remove_last_line_1.txt +10 -0
- data/test/test_jumpstart_templates/test_template_1/test_append_to_end_of_file_remove_last_line_2.txt +10 -0
- data/test/test_jumpstart_templates/test_template_1/test_remove_files/file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/test_remove_files/file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_1/test_replace_strings/replace_strings_1.rb +62 -0
- data/test/test_jumpstart_templates/test_template_1/test_replace_strings/replace_strings_2.txt +23 -0
- data/test/test_jumpstart_templates/test_template_1/test_whole_file_with_extension.txt +1 -0
- data/test/test_jumpstart_templates/test_template_1/test_whole_file_without_extension +1 -0
- data/test/test_jumpstart_templates/test_template_2/jumpstart_config/test_template_2.yml +8 -0
- data/test/test_jumpstart_templates/test_template_3/jumpstart_config/test_template_3.yml +22 -0
- metadata +254 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
%h1 Listing <%= plural_name %>
|
|
2
|
+
|
|
3
|
+
%table
|
|
4
|
+
%tr
|
|
5
|
+
<% for attribute in attributes -%>
|
|
6
|
+
%th <%= attribute.human_name %>
|
|
7
|
+
<% end -%>
|
|
8
|
+
%th
|
|
9
|
+
%th
|
|
10
|
+
%th
|
|
11
|
+
|
|
12
|
+
- @<%= plural_name %>.each do |<%= singular_name %>|
|
|
13
|
+
%tr
|
|
14
|
+
<% for attribute in attributes -%>
|
|
15
|
+
%td= <%= singular_name %>.<%= attribute.name %>
|
|
16
|
+
<% end -%>
|
|
17
|
+
%td= link_to 'Show', <%= singular_name %>
|
|
18
|
+
%td= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>)
|
|
19
|
+
%td= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete
|
|
20
|
+
|
|
21
|
+
%br
|
|
22
|
+
|
|
23
|
+
= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'rails/generators/named_base'
|
|
2
|
+
|
|
3
|
+
module Machinist
|
|
4
|
+
module Generators
|
|
5
|
+
class Base < Rails::Generators::NamedBase #:nodoc:
|
|
6
|
+
def self.source_root
|
|
7
|
+
@_machinist_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'machinist', generator_name, 'templates'))
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'generators/machinist'
|
|
2
|
+
|
|
3
|
+
module Machinist
|
|
4
|
+
module Generators
|
|
5
|
+
class ModelGenerator < Base
|
|
6
|
+
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
|
7
|
+
class_option :dir, :type => :string, :default => "test/blueprints", :desc => "The directory where the blueprints should go"
|
|
8
|
+
|
|
9
|
+
def create_machinist_initializer
|
|
10
|
+
return if File.exists?(File.expand_path("config/initializers/machinist.rb", self.destination_root))
|
|
11
|
+
template "machinist_initializer.rb", "config/initializers/machinist.rb"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def create_blueprint_file
|
|
15
|
+
template 'blueprint.rb', File.join(options[:dir], "#{table_name}.rb")
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Add other envs here e.g. cucumber
|
|
2
|
+
if Rails.env.test?
|
|
3
|
+
require 'machinist'
|
|
4
|
+
# require 'machinist/active_record'
|
|
5
|
+
|
|
6
|
+
def Machinist.clear!
|
|
7
|
+
Sham.clear
|
|
8
|
+
# ActiveRecord::Base.clear_blueprints!
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def Machinist.load_blueprints
|
|
12
|
+
Dir[Rails.root.join(<%= options[:dir].inspect %>, "**", "*.rb")].each do |file|
|
|
13
|
+
load file
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Put Machinist.load_blueprints in the test_helper.rb
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require 'rails/generators/named_base'
|
|
2
|
+
# require 'rails/generators/migration'
|
|
3
|
+
require 'rails/generators/active_model'
|
|
4
|
+
|
|
5
|
+
module Mongomapper
|
|
6
|
+
module Generators
|
|
7
|
+
class Base < Rails::Generators::NamedBase #:nodoc:
|
|
8
|
+
# include Rails::Generators::Migration
|
|
9
|
+
|
|
10
|
+
def self.source_root
|
|
11
|
+
@_mongomapper_source_root ||= File.expand_path(File.join(File.dirname(__FILE__),
|
|
12
|
+
'mongomapper', generator_name, 'templates'))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
protected
|
|
16
|
+
|
|
17
|
+
# # mongomapper does not care if migrations have the same name as long as
|
|
18
|
+
# # they have different ids.
|
|
19
|
+
# #
|
|
20
|
+
# def migration_exists?(dirname, file_name) #:nodoc:
|
|
21
|
+
# false
|
|
22
|
+
# end
|
|
23
|
+
#
|
|
24
|
+
# # Implement the required interface for Rails::Generators::Migration.
|
|
25
|
+
# #
|
|
26
|
+
# def next_migration_number(dirname) #:nodoc:
|
|
27
|
+
# if options[:id]
|
|
28
|
+
# "%.3d" % options[:id]
|
|
29
|
+
# else
|
|
30
|
+
# "%.3d" % (current_migration_number(dirname) + 1)
|
|
31
|
+
# end
|
|
32
|
+
# end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
class ActiveModel < Rails::Generators::ActiveModel #:nodoc:
|
|
36
|
+
def self.all(klass)
|
|
37
|
+
"#{klass}.all"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.find(klass, params=nil)
|
|
41
|
+
"#{klass}.first(#{params})"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def self.build(klass, params=nil)
|
|
45
|
+
if params
|
|
46
|
+
"#{klass}.new(#{params})"
|
|
47
|
+
else
|
|
48
|
+
"#{klass}.new"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def save
|
|
53
|
+
"#{name}.save"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def update_attributes(params=nil)
|
|
57
|
+
"#{name}.update(#{params})"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def errors
|
|
61
|
+
"#{name}.errors"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def destroy
|
|
65
|
+
"#{name}.destroy"
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
module Rails
|
|
72
|
+
module Generators
|
|
73
|
+
class GeneratedAttribute #:nodoc:
|
|
74
|
+
def type_class
|
|
75
|
+
return 'DateTime' if type.to_s == 'datetime'
|
|
76
|
+
return type.to_s.camelcase
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'generators/mongomapper'
|
|
2
|
+
|
|
3
|
+
module Mongomapper
|
|
4
|
+
module Generators
|
|
5
|
+
class ModelGenerator < Base
|
|
6
|
+
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
|
7
|
+
# class_option :_id, :type => :numeric, :desc => "The id to used in the migration"
|
|
8
|
+
|
|
9
|
+
check_class_collision
|
|
10
|
+
|
|
11
|
+
# class_option :migration, :type => :boolean
|
|
12
|
+
class_option :timestamps, :type => :boolean
|
|
13
|
+
class_option :parent, :type => :string, :desc => "The parent class for the generated model"
|
|
14
|
+
|
|
15
|
+
# def create_migration_file
|
|
16
|
+
# if options[:migration] && options[:parent].nil?
|
|
17
|
+
# file_name = "create_#{file_path.gsub(/\//, '_').pluralize}"
|
|
18
|
+
# migration_template "migration.rb", "db/migrate/#{file_name}.rb"
|
|
19
|
+
# end
|
|
20
|
+
# end
|
|
21
|
+
|
|
22
|
+
def create_model_file
|
|
23
|
+
template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
hook_for :test_framework
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class <%= class_name %><%= "< #{options[:parent].classify}" if options[:parent] %>
|
|
2
|
+
<% unless options[:parent] -%>
|
|
3
|
+
include MongoMapper::Document
|
|
4
|
+
|
|
5
|
+
timestamps!
|
|
6
|
+
|
|
7
|
+
# Validations :::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
8
|
+
# validates_presence_of :attribute
|
|
9
|
+
|
|
10
|
+
# Assocations :::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
11
|
+
# belongs_to :model
|
|
12
|
+
# many :model
|
|
13
|
+
# one :model
|
|
14
|
+
|
|
15
|
+
# Callbacks :::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
16
|
+
# before_create :your_model_method
|
|
17
|
+
# after_create :your_model_method
|
|
18
|
+
# before_update :your_model_method
|
|
19
|
+
|
|
20
|
+
<% end -%>
|
|
21
|
+
<% attributes.each do |attribute| -%>
|
|
22
|
+
key :<%= attribute.name %>, <%= attribute.type_class %>
|
|
23
|
+
<% end -%>
|
|
24
|
+
end
|
data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/observer/observer_generator.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'generators/mongomapper'
|
|
2
|
+
|
|
3
|
+
module Mongomapper
|
|
4
|
+
module Generators
|
|
5
|
+
class ObserverGenerator < Base
|
|
6
|
+
check_class_collision :suffix => "Observer"
|
|
7
|
+
|
|
8
|
+
def create_observer_file
|
|
9
|
+
template 'observer.rb', File.join('app/models', class_path, "#{file_name}_observer.rb")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
hook_for :test_framework
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'rails/generators/named_base'
|
|
2
|
+
|
|
3
|
+
module Shoulda
|
|
4
|
+
module Generators
|
|
5
|
+
class Base < Rails::Generators::NamedBase #:nodoc:
|
|
6
|
+
def self.source_root
|
|
7
|
+
@_shoulda_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'shoulda', generator_name, 'templates'))
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/controller_generator.rb
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'generators/shoulda'
|
|
2
|
+
|
|
3
|
+
module Shoulda
|
|
4
|
+
module Generators
|
|
5
|
+
class ControllerGenerator < Base
|
|
6
|
+
argument :actions, :type => :array, :default => [], :banner => "action action"
|
|
7
|
+
class_option :dir, :type => :string, :default => "test/functional", :desc => "The directory where the controller tests should go"
|
|
8
|
+
|
|
9
|
+
check_class_collision :suffix => 'ControllerTest'
|
|
10
|
+
|
|
11
|
+
def create_controller_file
|
|
12
|
+
template 'controller.rb', File.join(options[:dir], "#{file_name}_controller_test.rb")
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/templates/controller.rb
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class <%= plural_name %>ControllerTest < ActionController::TestCase
|
|
4
|
+
<% if actions.include?('index') %>
|
|
5
|
+
|
|
6
|
+
context "index action" do
|
|
7
|
+
should "render index template" do
|
|
8
|
+
get :index
|
|
9
|
+
assert_template 'index'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
<% end %>
|
|
13
|
+
<% if actions.include?('show') %>
|
|
14
|
+
|
|
15
|
+
context "show action" do
|
|
16
|
+
should "render show template" do
|
|
17
|
+
get :show, :id => <%= class_name %>.first
|
|
18
|
+
assert_template 'show'
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
<% end %>
|
|
22
|
+
<% if actions.include?('new') %>
|
|
23
|
+
|
|
24
|
+
context "new action" do
|
|
25
|
+
should "render new template" do
|
|
26
|
+
get :new
|
|
27
|
+
assert_template 'new'
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
<% end %>
|
|
31
|
+
<% if actions.include?('create') %>
|
|
32
|
+
|
|
33
|
+
context "create action" do
|
|
34
|
+
should "render new template when model is invalid" do
|
|
35
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
|
|
36
|
+
post :create
|
|
37
|
+
assert_template 'new'
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
should "redirect when model is valid" do
|
|
41
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
|
|
42
|
+
post :create
|
|
43
|
+
assert_redirected_to
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
<% end %>
|
|
47
|
+
<% if actions.include?('edit') %>
|
|
48
|
+
|
|
49
|
+
context "edit action" do
|
|
50
|
+
should "render edit template" do
|
|
51
|
+
get :edit, :id => <%= class_name %>.first
|
|
52
|
+
assert_template 'edit'
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
<% end %>
|
|
56
|
+
<% if actions.include?('update') %>
|
|
57
|
+
|
|
58
|
+
context "update action" do
|
|
59
|
+
should "render edit template when model is invalid" do
|
|
60
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
|
|
61
|
+
put :update, :id => <%= class_name %>.first
|
|
62
|
+
assert_template 'edit'
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
should "redirect when model is valid" do
|
|
66
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
|
|
67
|
+
put :update, :id => <%= class_name %>.first
|
|
68
|
+
assert_redirected_to
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
<% end %>
|
|
72
|
+
<% if actions.include?('destroy') %>
|
|
73
|
+
|
|
74
|
+
context "destroy action" do
|
|
75
|
+
should "destroy model and redirect to index action" do
|
|
76
|
+
<%= singular_name %> = <%= class_name %>.first
|
|
77
|
+
delete :destroy, :id => <%= singular_name %>
|
|
78
|
+
assert_redirected_to
|
|
79
|
+
assert !<%= class_name %>.exists?(<%= singular_name %>.id)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
<% end %>
|
|
83
|
+
|
|
84
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'generators/shoulda'
|
|
2
|
+
|
|
3
|
+
module Shoulda
|
|
4
|
+
module Generators
|
|
5
|
+
class ModelGenerator < Base
|
|
6
|
+
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
|
7
|
+
class_option :dir, :type => :string, :default => "test/unit", :desc => "The directory where the model tests should go"
|
|
8
|
+
|
|
9
|
+
def create_model_test_file
|
|
10
|
+
template 'model.rb', File.join(options[:dir], "#{singular_name}_test.rb")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
hook_for :fixture_replacement
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
namespace :db do
|
|
2
|
+
|
|
3
|
+
desc "Erase and fill database"
|
|
4
|
+
task :populate => :environment do
|
|
5
|
+
require 'populator'
|
|
6
|
+
require 'faker'
|
|
7
|
+
require 'action_controller/test_process'
|
|
8
|
+
|
|
9
|
+
# [User, Subscription, Valuation].each(&:delete_all)
|
|
10
|
+
|
|
11
|
+
##################### CREATE USERS #####################
|
|
12
|
+
|
|
13
|
+
# User.populate 1 do |admin|
|
|
14
|
+
# admin.login = "ian"
|
|
15
|
+
# admin.name = "Ian Alexander Wood"
|
|
16
|
+
# admin.email = "ianalexanderwood@gmail.com"
|
|
17
|
+
# admin.role = "admin"
|
|
18
|
+
# admin.crypted_password = "8010530181ee423288e72b2a45d9bf045ed97be6"
|
|
19
|
+
# admin.salt = "7823cecd5bcd10b8d86df120d11240e4c35a630b"
|
|
20
|
+
# admin.activation_code = nil
|
|
21
|
+
# admin.activated_at = Time.now
|
|
22
|
+
# end
|
|
23
|
+
|
|
24
|
+
# @new_users = []
|
|
25
|
+
#
|
|
26
|
+
# 200.times do
|
|
27
|
+
# user = User.new( :login => (Faker::Internet.user_name + rand(10000).to_s),
|
|
28
|
+
# :name => Faker::Name.name,
|
|
29
|
+
# :email => (rand(10000).to_s + Faker::Internet.email)
|
|
30
|
+
# )
|
|
31
|
+
# @new_users.map{|x| x.login}.each do |login|
|
|
32
|
+
# if login == user.login
|
|
33
|
+
# user.delete
|
|
34
|
+
# end
|
|
35
|
+
# end
|
|
36
|
+
# @new_users.map{|x| x.email}.each do |email|
|
|
37
|
+
# if email == user.email
|
|
38
|
+
# user.delete
|
|
39
|
+
# end
|
|
40
|
+
# end
|
|
41
|
+
# @new_users << user
|
|
42
|
+
# end
|
|
43
|
+
#
|
|
44
|
+
# @new_users.each do |new_user|
|
|
45
|
+
# User.populate 1 do |user|
|
|
46
|
+
# user.login = new_user.login
|
|
47
|
+
# user.name = new_user.name
|
|
48
|
+
# user.email = new_user.email
|
|
49
|
+
# user.role = ["analyst","investor"]
|
|
50
|
+
# user.crypted_password = "8010530181ee423288e72b2a45d9bf045ed97be6"
|
|
51
|
+
# user.salt = "7823cecd5bcd10b8d86df120d11240e4c35a630b"
|
|
52
|
+
# user.activation_code = nil
|
|
53
|
+
# user.activated_at = Time.now
|
|
54
|
+
# end
|
|
55
|
+
# end
|
|
56
|
+
|
|
57
|
+
##################### CREATE VALUATIONS #####################
|
|
58
|
+
|
|
59
|
+
# @analysts = User.all(:conditions => "role = 'analyst'")
|
|
60
|
+
# @investors = User.all(:conditions => "role = 'investor'")
|
|
61
|
+
# @admins = User.all(:conditions => "role = 'admin'")
|
|
62
|
+
# @users = @analysts + @investors + @admins
|
|
63
|
+
# @random_users = (@users.sample((@users.length / 2)) + @admins).uniq
|
|
64
|
+
#
|
|
65
|
+
# @prices = Price.all
|
|
66
|
+
#
|
|
67
|
+
# @companies = Company.all
|
|
68
|
+
#
|
|
69
|
+
# 100.times do
|
|
70
|
+
# Valuation.create_valuation( @analysts.map {|user| user.id}.shuffle.last, {:company_id => @companies.map {|company| company.id}.shuffle.last, :file => ActionController::TestUploadedFile.new("#{Rails.root}/test/files/test#{rand(10)}.xls","application/vnd.ms-excel") })
|
|
71
|
+
# end
|
|
72
|
+
#
|
|
73
|
+
# @companies.each do |company|
|
|
74
|
+
# @admins.each do |user|
|
|
75
|
+
# Valuation.create_valuation( user.id, {:company_id => company.id, :file => ActionController::TestUploadedFile.new("#{Rails.root}/test/files/test#{rand(10)}.xls","application/vnd.ms-excel") })
|
|
76
|
+
# end
|
|
77
|
+
# end
|
|
78
|
+
|
|
79
|
+
##################### CREATE SUBSCRIPTIONS #####################
|
|
80
|
+
|
|
81
|
+
# @valuations = Valuation.all(:conditions => "active=1")
|
|
82
|
+
#
|
|
83
|
+
# @valuations.each do |valuation|
|
|
84
|
+
# @random_users.each do |user|
|
|
85
|
+
# Subscription.create(:user_id => user.id, :valuation_id => valuation.id)
|
|
86
|
+
# end
|
|
87
|
+
# end
|
|
88
|
+
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
end
|