frame 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +14 -0
- data/Rakefile +19 -0
- data/lib/generators/frame.rb +29 -0
- data/lib/generators/frame/devise/USAGE +11 -0
- data/lib/generators/frame/devise/devise_generator.rb +31 -0
- data/lib/generators/frame/devise/templates/defaults.html.erb +45 -0
- data/lib/generators/frame/gitignore/USAGE +11 -0
- data/lib/generators/frame/gitignore/gitignore_generator.rb +17 -0
- data/lib/generators/frame/layout/USAGE +11 -0
- data/lib/generators/frame/layout/layout_generator.rb +43 -0
- data/lib/generators/frame/layout/templates/application.html.erb +3 -0
- data/lib/generators/frame/layout/templates/application_helper.rb +12 -0
- data/lib/generators/frame/layout/templates/default_layout.html.erb +27 -0
- data/lib/generators/frame/layout/templates/defaults.html.erb +39 -0
- data/lib/generators/frame/mysql/USAGE +11 -0
- data/lib/generators/frame/mysql/mysql_generator.rb +35 -0
- data/lib/generators/frame/pages/USAGE +11 -0
- data/lib/generators/frame/pages/pages_generator.rb +93 -0
- data/lib/generators/frame/pages/templates/_error_messages.html.erb +13 -0
- data/lib/generators/frame/pages/templates/_form.html.erb +36 -0
- data/lib/generators/frame/pages/templates/_links.html.erb +5 -0
- data/lib/generators/frame/pages/templates/_page.html.erb +2 -0
- data/lib/generators/frame/pages/templates/_sidebar.html.erb +9 -0
- data/lib/generators/frame/pages/templates/index.html.erb +31 -0
- data/lib/generators/frame/pages/templates/pages.html.erb +6 -0
- data/lib/generators/frame/pages/templates/show.html.erb +9 -0
- data/lib/generators/frame/secret/USAGE +11 -0
- data/lib/generators/frame/secret/secret_generator.rb +35 -0
- data/lib/generators/frame/secret/templates/database.yml +27 -0
- data/test/test_frame_secret_generator.rb +7 -0
- data/test/test_helper.rb +26 -0
- metadata +35 -6
- data/lib/frame.rb +0 -9
- data/lib/frame/engine.rb +0 -5
- data/lib/generators/frame/frame_generator.rb +0 -30
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#require 'rubygems'
|
2
|
+
#require 'rake'
|
3
|
+
#require 'cucumber'
|
4
|
+
#require 'cucumber/rake/task'
|
5
|
+
#
|
6
|
+
#Cucumber::Rake::Task.new(:features) do |t|
|
7
|
+
# t.cucumber_opts = "features --format progress"
|
8
|
+
#end
|
9
|
+
#
|
10
|
+
#task :default => :features
|
11
|
+
|
12
|
+
require 'rake/testtask'
|
13
|
+
|
14
|
+
Rake::TestTask.new do |t|
|
15
|
+
t.libs << 'test'
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Run tests"
|
19
|
+
task :default => :test
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module Frame
|
4
|
+
module Generators
|
5
|
+
class Base < Rails::Generators::Base #:nodoc:
|
6
|
+
def self.source_root
|
7
|
+
@_frame_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'frame', generator_name, 'templates'))
|
8
|
+
end
|
9
|
+
|
10
|
+
#def self.banner
|
11
|
+
# "rails generate frame:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
|
12
|
+
#end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def add_gem(name, options = {})
|
17
|
+
gemfile_content = File.read(destination_path("Gemfile"))
|
18
|
+
File.open(destination_path("Gemfile"), 'a') { |f| f.write("\n") } unless gemfile_content =~ /\n\Z/
|
19
|
+
gem name, options unless gemfile_content.include? name
|
20
|
+
end
|
21
|
+
|
22
|
+
#def print_usage
|
23
|
+
# self.class.help(Thor::Base.shell.new)
|
24
|
+
# exit
|
25
|
+
#end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'generators/frame'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module Frame
|
5
|
+
module Generators
|
6
|
+
class DeviseGenerator < Base
|
7
|
+
include Rails::Generators::Migration
|
8
|
+
|
9
|
+
desc "Installs Devise."
|
10
|
+
|
11
|
+
def install_devise
|
12
|
+
gem("rspec-rails", :group => "test")
|
13
|
+
gem("cucumber-rails", :group => "test")
|
14
|
+
|
15
|
+
if yes?("Would you like to install Devise?")
|
16
|
+
gem("devise")
|
17
|
+
generate("devise:install")
|
18
|
+
model_name = ask("What would you like the user model to be called? [user]")
|
19
|
+
model_name = "user" if model_name.blank?
|
20
|
+
generate("devise", model_name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#test/development:
|
25
|
+
# config.action_mailer.default_url_options = { :host => 'localhost:3000' }
|
26
|
+
#production:
|
27
|
+
# config.action_mailer.default_url_options = { :host => 'proj_name.com' }
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<%% content_for :head do %>
|
2
|
+
<%%= favicon_link_tag('/assets/favicon.ico') %>
|
3
|
+
<%%= stylesheet_link_tag "application" %>
|
4
|
+
<%%= javascript_include_tag "application" %>
|
5
|
+
<%%= csrf_meta_tag %>
|
6
|
+
<%% end %>
|
7
|
+
|
8
|
+
<%% content_for :header do %>
|
9
|
+
<nav class="span-24 append-bottom">
|
10
|
+
<ul>
|
11
|
+
<%%= render :partial => "pages/links", :collection => @display_pages.topbar, :as => :page, :locals => {:classes => "left hover"} %>
|
12
|
+
<%% if user_signed_in? %>
|
13
|
+
<%%= link_to '<li class="left hover">Account</li>'.html_safe, edit_user_registration_path %>
|
14
|
+
<%%= link_to '<li class="left hover">Sign out</li>'.html_safe, destroy_user_session_path, :method => :delete %>
|
15
|
+
<li class="right last">Signed in as <%%= current_user.email %></li>
|
16
|
+
<%% else %>
|
17
|
+
<%%= link_to '<li class="right hover">Sign in</li>'.html_safe, user_session_path %>
|
18
|
+
<%% end %>
|
19
|
+
</ul>
|
20
|
+
</nav>
|
21
|
+
<banner>
|
22
|
+
<%%= link_to logo, root_path, {:class => "right"} %>
|
23
|
+
<h1 class="left alt prepend-1 append-1"><%%= yield(:title) %></h1>
|
24
|
+
<%% flash.each do |key, value| %>
|
25
|
+
<div id="notice" class="left flash <%%= key %>"><%%= value %></div>
|
26
|
+
<%% end %>
|
27
|
+
</banner>
|
28
|
+
<hr/>
|
29
|
+
<%% end %>
|
30
|
+
|
31
|
+
<%% content_for :sidebar do %>
|
32
|
+
<%%= render 'shared/sidebar', :sidebar => @display_pages.sidebar %>
|
33
|
+
<%% end %>
|
34
|
+
|
35
|
+
<%% content_for :userbar do %>
|
36
|
+
<%%= render 'shared/sidebar', :sidebar => @display_pages.userbar %>
|
37
|
+
<%% end %>
|
38
|
+
|
39
|
+
<%% content_for :footer do %>
|
40
|
+
<nav class="span-24 prepend-top last">
|
41
|
+
<ul>
|
42
|
+
<%%= render :partial => "pages/links", :collection => @display_pages.bottombar, :as => :page, :locals => {:classes => "left hover"} %>
|
43
|
+
</ul>
|
44
|
+
</nav>
|
45
|
+
<%% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'generators/frame'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module Frame
|
5
|
+
module Generators
|
6
|
+
class GitignoreGenerator < Base
|
7
|
+
include Rails::Generators::Migration
|
8
|
+
|
9
|
+
desc "Installs Gitignore if it doesn't already exist."
|
10
|
+
|
11
|
+
def create_gitignore
|
12
|
+
template ".gitignore", ".gitignore"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'generators/frame'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module Frame
|
5
|
+
module Generators
|
6
|
+
class LayoutGenerator < Base
|
7
|
+
include Rails::Generators::Migration
|
8
|
+
|
9
|
+
desc "Setup Pages."
|
10
|
+
|
11
|
+
class_option :force, :type => :boolean, :default => false, :desc => "Force file regeneration"
|
12
|
+
|
13
|
+
def add_gems
|
14
|
+
add_gem "mysql2"
|
15
|
+
end
|
16
|
+
|
17
|
+
def remove_index
|
18
|
+
#remove_file "public/index.html"
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_default_layout
|
22
|
+
template 'defaults.html.erb', 'app/views/layouts/defaults.html.erb'
|
23
|
+
template 'default_layout.html.erb', 'app/views/layouts/default_layout.html.erb'
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_page_helpers
|
27
|
+
template 'application_helper.rb', 'app/helpers/application_helper.rb'
|
28
|
+
end
|
29
|
+
|
30
|
+
def replace_html_app
|
31
|
+
@title = Rails.application.class.parent_name
|
32
|
+
template 'application.html.erb', 'app/views/layouts/application.html.erb'
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def destination_path(path)
|
38
|
+
File.join(destination_root, path)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%%= yield(:title) %></title>
|
5
|
+
<%%= yield :head %>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div class="container">
|
9
|
+
<header>
|
10
|
+
<%%= yield :header %>
|
11
|
+
</header>
|
12
|
+
<content>
|
13
|
+
<div class="span-4 colborder">
|
14
|
+
<%%= yield :sidebar %>
|
15
|
+
<%%= yield :userbar %>
|
16
|
+
</div>
|
17
|
+
<div class="span-18 last">
|
18
|
+
<%%= yield %>
|
19
|
+
</div>
|
20
|
+
</content>
|
21
|
+
<footer>
|
22
|
+
<%%= yield :footer %>
|
23
|
+
</footer>
|
24
|
+
<%%= debug(params) if Rails.env.development? %>
|
25
|
+
</div>
|
26
|
+
</body>
|
27
|
+
</html>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<%% content_for :head do %>
|
2
|
+
<%%= favicon_link_tag('/assets/favicon.ico') %>
|
3
|
+
<%%= stylesheet_link_tag "application" %>
|
4
|
+
<%%= javascript_include_tag "application" %>
|
5
|
+
<%%= csrf_meta_tag %>
|
6
|
+
<%% end %>
|
7
|
+
|
8
|
+
<%% content_for :header do %>
|
9
|
+
<nav class="span-24 append-bottom">
|
10
|
+
<ul>
|
11
|
+
<%%= render :partial => "pages/links", :collection => @display_pages.topbar, :as => :page, :locals => {:classes => "left hover"} %>
|
12
|
+
<%%= link_to '<li class="left hover">Pages</li>'.html_safe, pages_path %>
|
13
|
+
</ul>
|
14
|
+
</nav>
|
15
|
+
<banner>
|
16
|
+
<%%= link_to logo, root_path, {:class => "right"} %>
|
17
|
+
<h1 class="left alt prepend-1 append-1"><%%= yield(:title) %></h1>
|
18
|
+
<%% flash.each do |key, value| %>
|
19
|
+
<div id="notice" class="left flash <%%= key %>"><%%= value %></div>
|
20
|
+
<%% end %>
|
21
|
+
</banner>
|
22
|
+
<hr/>
|
23
|
+
<%% end %>
|
24
|
+
|
25
|
+
<%% content_for :sidebar do %>
|
26
|
+
<%%= render 'shared/sidebar', :sidebar => @display_pages.sidebar %>
|
27
|
+
<%% end %>
|
28
|
+
|
29
|
+
<%% content_for :userbar do %>
|
30
|
+
<%%= render 'shared/sidebar', :sidebar => @display_pages.userbar %>
|
31
|
+
<%% end %>
|
32
|
+
|
33
|
+
<%% content_for :footer do %>
|
34
|
+
<nav class="span-24 prepend-top last">
|
35
|
+
<ul>
|
36
|
+
<%%= render :partial => "pages/links", :collection => @display_pages.bottombar, :as => :page, :locals => {:classes => "left hover"} %>
|
37
|
+
</ul>
|
38
|
+
</nav>
|
39
|
+
<%% end %>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'generators/frame'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module Frame
|
5
|
+
module Generators
|
6
|
+
class MysqlGenerator < Base
|
7
|
+
include Rails::Generators::Migration
|
8
|
+
|
9
|
+
desc "Update MySQL with user priveleges."
|
10
|
+
|
11
|
+
def add_user
|
12
|
+
config = YAML.load_file('config/database.yml')
|
13
|
+
user = config[Rails.env]["username"]
|
14
|
+
pw = config[Rails.env]["password"]
|
15
|
+
puts "creating user: #{user}"
|
16
|
+
puts "using pw: #{pw}"
|
17
|
+
output = create_file 'tmp/create_user.sql', "CREATE USER '#{user}'@localhost IDENTIFIED BY '#{pw}';"
|
18
|
+
puts "output: #{output}"
|
19
|
+
system "mysql -u root -p < #{output}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def grant_user
|
23
|
+
config = YAML.load_file('config/database.yml')
|
24
|
+
user = config[Rails.env]["username"]
|
25
|
+
db = config[Rails.env]["database"]
|
26
|
+
puts "granting user: #{user}"
|
27
|
+
puts "all on db: #{db}"
|
28
|
+
output = create_file 'tmp/grant_user.sql', "GRANT ALL PRIVILEGES ON #{db}.* TO '#{user}'@localhost;"
|
29
|
+
puts "output: #{output}"
|
30
|
+
system "mysql -u root -p < #{output}"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'generators/frame'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module Frame
|
5
|
+
module Generators
|
6
|
+
class PagesGenerator < Base
|
7
|
+
include Rails::Generators::Migration
|
8
|
+
|
9
|
+
desc "Setup Pages."
|
10
|
+
|
11
|
+
class_option :force, :type => :boolean, :default => false, :desc => "Force file regeneration"
|
12
|
+
|
13
|
+
def add_gems
|
14
|
+
add_gem "mysql2"
|
15
|
+
end
|
16
|
+
|
17
|
+
def remove_index
|
18
|
+
#remove_file "public/index.html"
|
19
|
+
end
|
20
|
+
|
21
|
+
def generate_scaffold
|
22
|
+
generate("scaffold", "Page name:string title:string location:string content:text url:string ordinal:integer")
|
23
|
+
append_to_file 'db/seeds.rb' do
|
24
|
+
"\nPage.create(:name => 'Home', :title => 'Welcome to Home!', :content => '<h2>Content</h2>This is the content of the home page...', :location => 'topbar', :url => '', :ordinal => '1')\n"
|
25
|
+
end
|
26
|
+
generate("scaffold_controller", "Page")
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_root_route
|
30
|
+
insert_into_file 'config/routes.rb', "root :to => 'pages#show', :id => 0\n", :after => "#{Rails.application.class.parent_name}::Application.routes.draw do\n"
|
31
|
+
end
|
32
|
+
|
33
|
+
def update_page_controller
|
34
|
+
comment_lines 'app/controllers/pages_controller.rb', /@pages = Page.all/
|
35
|
+
gsub_file 'app/controllers/pages_controller.rb', /def show\n\s+\@page \= Page\.find\(params\[\:id\]\)/ do
|
36
|
+
"def show
|
37
|
+
if params[:id] == 0
|
38
|
+
@page = Page.find_by_name('home') || Page.first
|
39
|
+
else
|
40
|
+
@page = Page.find(params[:id])
|
41
|
+
end"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def create_pages_partials
|
46
|
+
template '_links.html.erb', 'app/views/pages/_links.html.erb'
|
47
|
+
template '_form.html.erb', 'app/views/pages/_form.html.erb'
|
48
|
+
template '_error_messages.html.erb', 'app/views/shared/_error_messages.html.erb'
|
49
|
+
template '_sidebar.html.erb', 'app/views/shared/_sidebar.html.erb'
|
50
|
+
template '_page.html.erb', 'app/views/pages/_page.html.erb'
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_pages_views
|
54
|
+
template 'pages.html.erb', 'app/views/layouts/pages.html.erb'
|
55
|
+
template 'index.html.erb', 'app/views/pages/index.html.erb'
|
56
|
+
template 'show.html.erb', 'app/views/pages/show.html.erb'
|
57
|
+
end
|
58
|
+
|
59
|
+
def add_scopes
|
60
|
+
inject_into_class "app/models/page.rb", Page do
|
61
|
+
'
|
62
|
+
validates_presence_of :name
|
63
|
+
|
64
|
+
scope :topbar, where(:location => "topbar")
|
65
|
+
scope :sidebar, where(:location => "sidebar")
|
66
|
+
scope :userbar, where(:location => "userbar")
|
67
|
+
scope :bottombar, where(:location => "bottombar")
|
68
|
+
|
69
|
+
'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def application_page_loader
|
74
|
+
inject_into_class "app/controllers/application_controller.rb", ApplicationController do '
|
75
|
+
before_filter :get_variables
|
76
|
+
|
77
|
+
def get_variables
|
78
|
+
@display_pages = Page.order("ordinal")
|
79
|
+
end
|
80
|
+
|
81
|
+
'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def destination_path(path)
|
88
|
+
File.join(destination_root, path)
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%% if object.errors.any? %>
|
2
|
+
<div class="error">
|
3
|
+
<h2><%%= pluralize(object.errors.count, "error") %>
|
4
|
+
prohibited this <%%= object.class.to_s.underscore.humanize.downcase %>
|
5
|
+
from being saved:</h2>
|
6
|
+
<p>There were problems with the following fields:</p>
|
7
|
+
<ul>
|
8
|
+
<%% object.errors.full_messages.each do |msg| %>
|
9
|
+
<li><%%= msg %></li>
|
10
|
+
<%% end %>
|
11
|
+
</ul>
|
12
|
+
</div>
|
13
|
+
<%% end %>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<%%= form_for(@page) do |f| %>
|
2
|
+
<%%= render 'shared/error_messages', :object => f.object %>
|
3
|
+
<div class="field">
|
4
|
+
<%%= f.label :name %>
|
5
|
+
<br/>
|
6
|
+
<%%= f.text_field :name %>
|
7
|
+
</div>
|
8
|
+
<div class="field">
|
9
|
+
<%%= f.label :title %>
|
10
|
+
<br/>
|
11
|
+
<%%= f.text_field :title %>
|
12
|
+
</div>
|
13
|
+
<div class="field">
|
14
|
+
<%%= f.label :ordinal %>
|
15
|
+
<br/>
|
16
|
+
<%%= f.text_field :ordinal %>
|
17
|
+
</div>
|
18
|
+
<div class="field">
|
19
|
+
<%%= f.label :location %>
|
20
|
+
<br/>
|
21
|
+
<%%= f.select(:location, [['Top', 'topbar'], ['Userbar', 'userbar'], ['Sidebar', 'sidebar'], ['Bottom', 'bottombar'], ['Disabled', 'off']]) %>
|
22
|
+
</div>
|
23
|
+
<div class="field">
|
24
|
+
<%%= f.label :url %>
|
25
|
+
<br/>
|
26
|
+
<%%= f.url_field :url %>
|
27
|
+
</div>
|
28
|
+
<div class="field">
|
29
|
+
<%%= f.label :content %>
|
30
|
+
<br/>
|
31
|
+
<%%= f.text_area :content %>
|
32
|
+
</div>
|
33
|
+
<div class="actions">
|
34
|
+
<%%= f.submit %>
|
35
|
+
</div>
|
36
|
+
<%% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<%% title 'All pages' %>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<th>Name</th>
|
6
|
+
<th>Title</th>
|
7
|
+
<th>Location</th>
|
8
|
+
<th>URL</th>
|
9
|
+
<th>Content</th>
|
10
|
+
<th></th>
|
11
|
+
<th></th>
|
12
|
+
<th></th>
|
13
|
+
</tr>
|
14
|
+
|
15
|
+
<%% @display_pages.each do |page| %>
|
16
|
+
<tr>
|
17
|
+
<td><%%= page.name %></td>
|
18
|
+
<td><%%= page.title %></td>
|
19
|
+
<td><%%= page.location %></td>
|
20
|
+
<td><%%= page.url %></td>
|
21
|
+
<td><%%= page.content %></td>
|
22
|
+
<td><%%= link_to 'Show', page %></td>
|
23
|
+
<td><%%= link_to 'Edit', edit_page_path(page) %></td>
|
24
|
+
<td><%%= link_to 'Destroy', page, :method => :delete, :data => { :confirm => 'Are you sure?' } %></td>
|
25
|
+
</tr>
|
26
|
+
<%% end %>
|
27
|
+
</table>
|
28
|
+
|
29
|
+
<br />
|
30
|
+
|
31
|
+
<%%= link_to 'New Page', new_page_path %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Description:
|
2
|
+
Generates config files with private information.
|
3
|
+
|
4
|
+
Usage:
|
5
|
+
Use to generate secret files for a project, such as database.yml.
|
6
|
+
|
7
|
+
Examples:
|
8
|
+
rails generate frame:secret
|
9
|
+
|
10
|
+
Methods:
|
11
|
+
There are several methods generated which you can use in your application.
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'generators/frame'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module Frame
|
5
|
+
module Generators
|
6
|
+
class SecretGenerator < Base
|
7
|
+
include Rails::Generators::Migration
|
8
|
+
|
9
|
+
desc "Installs Secret files if they don't already exist."
|
10
|
+
|
11
|
+
class_option :force, :type => :boolean, :default => false, :desc => "Force file regeneration"
|
12
|
+
|
13
|
+
#def opt
|
14
|
+
# puts options.force
|
15
|
+
#end
|
16
|
+
|
17
|
+
def create_database
|
18
|
+
config = YAML.load_file(File.expand_path(File.join(File.dirname(__FILE__), 'templates', 'database.yml')))
|
19
|
+
|
20
|
+
['development','test','production'].each do |i|
|
21
|
+
config["#{i}"]["database"] = Rails.application.class.parent_name.downcase
|
22
|
+
config["#{i}"]["username"] = "#{Rails.application.class.parent_name.downcase}admin"
|
23
|
+
end
|
24
|
+
|
25
|
+
create_file 'config/database.yml', YAML.dump(config)
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_secret_token
|
29
|
+
secret = `rake secret`.rstrip
|
30
|
+
initializer("secret_token.rb", "#{Rails.application.class.parent_name}::Application.config.secret_token = '#{secret}'")
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
development:
|
2
|
+
adapter: mysql2
|
3
|
+
encoding: utf8
|
4
|
+
reconnet: false
|
5
|
+
database: proj
|
6
|
+
pool: 5
|
7
|
+
username: projadmin
|
8
|
+
password: password
|
9
|
+
host: localhost
|
10
|
+
test:
|
11
|
+
adapter: mysql2
|
12
|
+
encoding: utf8
|
13
|
+
reconnet: false
|
14
|
+
database: proj
|
15
|
+
pool: 5
|
16
|
+
username: projadmin
|
17
|
+
password: test
|
18
|
+
host: localhost
|
19
|
+
production:
|
20
|
+
adapter: mysql2
|
21
|
+
encoding: utf8
|
22
|
+
reconnet: false
|
23
|
+
database: proj
|
24
|
+
pool: 5
|
25
|
+
username: projadmin
|
26
|
+
password: supersecret
|
27
|
+
host: localhost
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#require 'test/unit'
|
2
|
+
|
3
|
+
# Must set before requiring generator libs.
|
4
|
+
#TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
|
5
|
+
#PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME)
|
6
|
+
#app_root = File.join(TMP_ROOT, PROJECT_NAME)
|
7
|
+
#if defined?(APP_ROOT)
|
8
|
+
# APP_ROOT.replace(app_root)
|
9
|
+
#else
|
10
|
+
# APP_ROOT = app_root
|
11
|
+
#end
|
12
|
+
#if defined?(RAILS_ROOT)
|
13
|
+
# RAILS_ROOT.replace(app_root)
|
14
|
+
#else
|
15
|
+
# RAILS_ROOT = app_root
|
16
|
+
#end
|
17
|
+
|
18
|
+
#require 'rubygems'
|
19
|
+
#gem 'rails', '2.0.2' # getting a Rails.configuration error with 2.1
|
20
|
+
#gem 'rubigen', '1.4'
|
21
|
+
#gem 'shoulda', '2.0.6'
|
22
|
+
#require 'rubigen' # gem install rubigen --version=1.4
|
23
|
+
#require 'rubigen/helpers/generator_test_helper'
|
24
|
+
#require 'rails_generator'
|
25
|
+
#require 'shoulda' # gem install shoulda --version=2.0.6
|
26
|
+
#require 'mocha'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -20,9 +20,38 @@ executables: []
|
|
20
20
|
extensions: []
|
21
21
|
extra_rdoc_files: []
|
22
22
|
files:
|
23
|
-
- lib/frame.rb
|
24
|
-
- lib/frame/
|
25
|
-
- lib/generators/frame/
|
23
|
+
- lib/generators/frame.rb
|
24
|
+
- lib/generators/frame/layout/templates/defaults.html.erb
|
25
|
+
- lib/generators/frame/layout/templates/application.html.erb
|
26
|
+
- lib/generators/frame/layout/templates/application_helper.rb
|
27
|
+
- lib/generators/frame/layout/templates/default_layout.html.erb
|
28
|
+
- lib/generators/frame/layout/layout_generator.rb
|
29
|
+
- lib/generators/frame/layout/USAGE
|
30
|
+
- lib/generators/frame/mysql/USAGE
|
31
|
+
- lib/generators/frame/mysql/mysql_generator.rb
|
32
|
+
- lib/generators/frame/secret/templates/database.yml
|
33
|
+
- lib/generators/frame/secret/secret_generator.rb
|
34
|
+
- lib/generators/frame/secret/USAGE
|
35
|
+
- lib/generators/frame/pages/templates/pages.html.erb
|
36
|
+
- lib/generators/frame/pages/templates/show.html.erb
|
37
|
+
- lib/generators/frame/pages/templates/index.html.erb
|
38
|
+
- lib/generators/frame/pages/templates/_page.html.erb
|
39
|
+
- lib/generators/frame/pages/templates/_form.html.erb
|
40
|
+
- lib/generators/frame/pages/templates/_sidebar.html.erb
|
41
|
+
- lib/generators/frame/pages/templates/_links.html.erb
|
42
|
+
- lib/generators/frame/pages/templates/_error_messages.html.erb
|
43
|
+
- lib/generators/frame/pages/pages_generator.rb
|
44
|
+
- lib/generators/frame/pages/USAGE
|
45
|
+
- lib/generators/frame/devise/templates/defaults.html.erb
|
46
|
+
- lib/generators/frame/devise/USAGE
|
47
|
+
- lib/generators/frame/devise/devise_generator.rb
|
48
|
+
- lib/generators/frame/gitignore/gitignore_generator.rb
|
49
|
+
- lib/generators/frame/gitignore/USAGE
|
50
|
+
- test/test_frame_secret_generator.rb
|
51
|
+
- test/test_helper.rb
|
52
|
+
- Rakefile
|
53
|
+
- Gemfile.lock
|
54
|
+
- Gemfile
|
26
55
|
homepage: https://github.com/ncimino/frame
|
27
56
|
licenses: []
|
28
57
|
post_install_message:
|
@@ -40,9 +69,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
69
|
requirements:
|
41
70
|
- - ! '>='
|
42
71
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
72
|
+
version: 1.3.4
|
44
73
|
requirements: []
|
45
|
-
rubyforge_project:
|
74
|
+
rubyforge_project: frame
|
46
75
|
rubygems_version: 1.8.24
|
47
76
|
signing_key:
|
48
77
|
specification_version: 3
|
data/lib/frame.rb
DELETED
data/lib/frame/engine.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
require 'rails/generators/named_base'
|
3
|
-
|
4
|
-
module Frame
|
5
|
-
module Generators
|
6
|
-
class FrameGenerator < Rails::Generators::NamedBase
|
7
|
-
|
8
|
-
desc "Installs Secret files if they don't already exist."
|
9
|
-
|
10
|
-
# Commandline options can be defined here using Thor-like options:
|
11
|
-
class_option :my_opt, :type => :boolean, :default => false, :desc => "My Option"
|
12
|
-
|
13
|
-
# I can later access that option using:
|
14
|
-
puts options[:my_opt]
|
15
|
-
|
16
|
-
|
17
|
-
#def self.source_root
|
18
|
-
# @source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
19
|
-
#end
|
20
|
-
|
21
|
-
#include Rails::Generators::Migration
|
22
|
-
|
23
|
-
|
24
|
-
#def create_secret
|
25
|
-
# template 'database.yml', 'config/database.yml'
|
26
|
-
#end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|