ipage 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/Gemfile +8 -0
  2. data/Gemfile.lock +123 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.rdoc +22 -0
  5. data/Rakefile +42 -0
  6. data/bin/ipage +9 -0
  7. data/ipage.gemspec +75 -0
  8. data/lib/ipage.rb +177 -0
  9. data/lib/templates/Gemfile +4 -0
  10. data/lib/templates/app/helpers/application_helper.rb +11 -0
  11. data/lib/templates/app/views/layouts/application.html.erb +20 -0
  12. data/lib/templates/config/initializers/js_css.rb +30 -0
  13. data/lib/templates/gitignore +6 -0
  14. data/lib/templates/hgignore +4 -0
  15. data/lib/templates/javascripts/design/main.js +3 -0
  16. data/lib/templates/javascripts/framework/jquery-1.5.1.min.js +16 -0
  17. data/lib/templates/javascripts/test/tdd/qunit.js +1412 -0
  18. data/lib/templates/javascripts/test/tdd/window.js +17 -0
  19. data/lib/templates/javascripts/test/x_test.js +11 -0
  20. data/lib/templates/stylesheets/content/base.css +263 -0
  21. data/lib/templates/stylesheets/content/tables.css +0 -0
  22. data/lib/templates/stylesheets/design/controls/buttons.css +0 -0
  23. data/lib/templates/stylesheets/design/controls/forms.css +0 -0
  24. data/lib/templates/stylesheets/design/controls/notifications.css +0 -0
  25. data/lib/templates/stylesheets/design/controls/tabs.css +142 -0
  26. data/lib/templates/stylesheets/design/footer.css +0 -0
  27. data/lib/templates/stylesheets/design/header.css +0 -0
  28. data/lib/templates/stylesheets/design/menu.css +0 -0
  29. data/lib/templates/stylesheets/design/panels.css +0 -0
  30. data/lib/templates/stylesheets/design/popup-windows.css +0 -0
  31. data/lib/templates/stylesheets/global/global.css +32 -0
  32. metadata +112 -0
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+
3
+ #gemspec
4
+
5
+ #gem "sqlite3"
6
+ #gem "rspec", "~> 2.0"
7
+ #gem "rspec-rails", "~> 2.0"
8
+ #gem "capybara", "~> 0.4"
data/Gemfile.lock ADDED
@@ -0,0 +1,123 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ enginex (0.8.0)
5
+ rails (~> 3.0.3)
6
+ rake (~> 0.8)
7
+ thor (~> 0.14)
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ abstract (1.0.0)
13
+ actionmailer (3.0.4)
14
+ actionpack (= 3.0.4)
15
+ mail (~> 2.2.15)
16
+ actionpack (3.0.4)
17
+ activemodel (= 3.0.4)
18
+ activesupport (= 3.0.4)
19
+ builder (~> 2.1.2)
20
+ erubis (~> 2.6.6)
21
+ i18n (~> 0.4)
22
+ rack (~> 1.2.1)
23
+ rack-mount (~> 0.6.13)
24
+ rack-test (~> 0.5.7)
25
+ tzinfo (~> 0.3.23)
26
+ activemodel (3.0.4)
27
+ activesupport (= 3.0.4)
28
+ builder (~> 2.1.2)
29
+ i18n (~> 0.4)
30
+ activerecord (3.0.4)
31
+ activemodel (= 3.0.4)
32
+ activesupport (= 3.0.4)
33
+ arel (~> 2.0.2)
34
+ tzinfo (~> 0.3.23)
35
+ activeresource (3.0.4)
36
+ activemodel (= 3.0.4)
37
+ activesupport (= 3.0.4)
38
+ activesupport (3.0.4)
39
+ arel (2.0.8)
40
+ builder (2.1.2)
41
+ capybara (0.4.1.2)
42
+ celerity (>= 0.7.9)
43
+ culerity (>= 0.2.4)
44
+ mime-types (>= 1.16)
45
+ nokogiri (>= 1.3.3)
46
+ rack (>= 1.0.0)
47
+ rack-test (>= 0.5.4)
48
+ selenium-webdriver (>= 0.0.27)
49
+ xpath (~> 0.1.3)
50
+ celerity (0.8.8)
51
+ childprocess (0.1.7)
52
+ ffi (~> 0.6.3)
53
+ culerity (0.2.15)
54
+ diff-lcs (1.1.2)
55
+ erubis (2.6.6)
56
+ abstract (>= 1.0.0)
57
+ ffi (0.6.3)
58
+ rake (>= 0.8.7)
59
+ i18n (0.5.0)
60
+ json_pure (1.5.1)
61
+ mail (2.2.15)
62
+ activesupport (>= 2.3.6)
63
+ i18n (>= 0.4.0)
64
+ mime-types (~> 1.16)
65
+ treetop (~> 1.4.8)
66
+ mime-types (1.16)
67
+ nokogiri (1.4.4)
68
+ polyglot (0.3.1)
69
+ rack (1.2.1)
70
+ rack-mount (0.6.13)
71
+ rack (>= 1.0.0)
72
+ rack-test (0.5.7)
73
+ rack (>= 1.0)
74
+ rails (3.0.4)
75
+ actionmailer (= 3.0.4)
76
+ actionpack (= 3.0.4)
77
+ activerecord (= 3.0.4)
78
+ activeresource (= 3.0.4)
79
+ activesupport (= 3.0.4)
80
+ bundler (~> 1.0)
81
+ railties (= 3.0.4)
82
+ railties (3.0.4)
83
+ actionpack (= 3.0.4)
84
+ activesupport (= 3.0.4)
85
+ rake (>= 0.8.7)
86
+ thor (~> 0.14.4)
87
+ rake (0.8.7)
88
+ rspec (2.5.0)
89
+ rspec-core (~> 2.5.0)
90
+ rspec-expectations (~> 2.5.0)
91
+ rspec-mocks (~> 2.5.0)
92
+ rspec-core (2.5.1)
93
+ rspec-expectations (2.5.0)
94
+ diff-lcs (~> 1.1.2)
95
+ rspec-mocks (2.5.0)
96
+ rspec-rails (2.5.0)
97
+ actionpack (~> 3.0)
98
+ activesupport (~> 3.0)
99
+ railties (~> 3.0)
100
+ rspec (~> 2.5.0)
101
+ rubyzip (0.9.4)
102
+ selenium-webdriver (0.1.3)
103
+ childprocess (~> 0.1.5)
104
+ ffi (~> 0.6.3)
105
+ json_pure
106
+ rubyzip
107
+ sqlite3 (1.3.3)
108
+ thor (0.14.6)
109
+ treetop (1.4.9)
110
+ polyglot (>= 0.3.1)
111
+ tzinfo (0.3.24)
112
+ xpath (0.1.3)
113
+ nokogiri (~> 1.3)
114
+
115
+ PLATFORMS
116
+ ruby
117
+
118
+ DEPENDENCIES
119
+ capybara (~> 0.4)
120
+ enginex!
121
+ rspec (~> 2.0)
122
+ rspec-rails (~> 2.0)
123
+ sqlite3
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2010 José Valim http://blog.plataformatec.com.br
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,22 @@
1
+ == Enginex
2
+
3
+ Enginex is a command line tool which creates a Rails 3 Engine with Rakefile, Gemfile and a ready to run test suite on top of a vendored Rails application.
4
+
5
+ Enginex was created for the purpose of and used in José Valim's book: Crafting Rails Applications available at http://plataformatec.com.br/crafting-rails-applications .
6
+
7
+ Engines will be available on Rails 3.1 as the new plugin generator and invoked as: "rails plugin new". The port to Rails was made by Piotr Sarnacki.
8
+
9
+ == Usage
10
+
11
+ $ enginex ENGINE_NAME
12
+
13
+ Give --help to see supported options.
14
+
15
+ == Bugs and Feedback
16
+
17
+ If you discover any bugs, feel free to send me a message or create an issue on GitHub tracker:
18
+
19
+ http://github.com/josevalim
20
+ http://github.com/josevalim/enginex/issues
21
+
22
+ MIT License. Copyright 2010 José Valim. http://blog.plataformatec.com.br
data/Rakefile ADDED
@@ -0,0 +1,42 @@
1
+ # encoding: UTF-8
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'lib'
8
+ t.libs << 'test'
9
+ t.pattern = 'test/*_test.rb'
10
+ t.verbose = true
11
+ end
12
+
13
+ Rake::RDocTask.new(:rdoc) do |rdoc|
14
+ rdoc.rdoc_dir = 'rdoc'
15
+ rdoc.title = 'Ipage'
16
+ rdoc.options << '--line-numbers' << '--inline-source'
17
+ rdoc.rdoc_files.include('README.rdoc')
18
+ rdoc.rdoc_files.include('lib/**/*.rb')
19
+ end
20
+
21
+ begin
22
+ require 'jeweler'
23
+ Jeweler::Tasks.new do |s|
24
+ s.name = "ipage"
25
+ s.version = "1.0.1"
26
+ s.summary = "Creates a Rails 3 app"
27
+ s.email = ""
28
+ s.homepage = ""
29
+ s.description = "Creates a Rails 3 engine with Rakefile, Gemfile and running tests"
30
+ s.authors = ['dvil']
31
+ s.files = FileList["[A-Z]*", "lib/**/*"]
32
+ s.bindir = "bin"
33
+ s.executables = %w(ipage)
34
+ s.add_dependency("thor", "~> 0.14")
35
+ s.add_dependency("rails", "~> 3.0.3")
36
+ s.add_dependency("rake", "~> 0.8")
37
+ end
38
+
39
+ Jeweler::GemcutterTasks.new
40
+ rescue LoadError
41
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
42
+ end
data/bin/ipage ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby -*-
3
+
4
+ require 'ipage'
5
+
6
+ ARGV << "--help" if ARGV.empty?
7
+
8
+ Ipage.start
9
+ #New.start
data/ipage.gemspec ADDED
@@ -0,0 +1,75 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{ipage}
8
+ s.version = "1.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["dvil"]
12
+ s.date = %q{2011-03-26}
13
+ s.default_executable = %q{ipage}
14
+ s.description = %q{Creates a Rails 3 engine with Rakefile, Gemfile and running tests}
15
+ s.email = %q{}
16
+ s.executables = ["ipage"]
17
+ s.extra_rdoc_files = [
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "MIT-LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "ipage.gemspec",
27
+ "lib/ipage.rb",
28
+ "lib/templates/Gemfile",
29
+ "lib/templates/app/helpers/application_helper.rb",
30
+ "lib/templates/app/views/layouts/application.html.erb",
31
+ "lib/templates/config/initializers/js_css.rb",
32
+ "lib/templates/gitignore",
33
+ "lib/templates/hgignore",
34
+ "lib/templates/javascripts/design/main.js",
35
+ "lib/templates/javascripts/framework/jquery-1.5.1.min.js",
36
+ "lib/templates/javascripts/test/tdd/qunit.js",
37
+ "lib/templates/javascripts/test/tdd/window.js",
38
+ "lib/templates/javascripts/test/x_test.js",
39
+ "lib/templates/stylesheets/content/base.css",
40
+ "lib/templates/stylesheets/content/tables.css",
41
+ "lib/templates/stylesheets/design/controls/buttons.css",
42
+ "lib/templates/stylesheets/design/controls/forms.css",
43
+ "lib/templates/stylesheets/design/controls/notifications.css",
44
+ "lib/templates/stylesheets/design/controls/tabs.css",
45
+ "lib/templates/stylesheets/design/footer.css",
46
+ "lib/templates/stylesheets/design/header.css",
47
+ "lib/templates/stylesheets/design/menu.css",
48
+ "lib/templates/stylesheets/design/panels.css",
49
+ "lib/templates/stylesheets/design/popup-windows.css",
50
+ "lib/templates/stylesheets/global/global.css"
51
+ ]
52
+ s.homepage = %q{}
53
+ s.require_paths = ["lib"]
54
+ s.rubygems_version = %q{1.5.0}
55
+ s.summary = %q{Creates a Rails 3 app}
56
+
57
+ if s.respond_to? :specification_version then
58
+ s.specification_version = 3
59
+
60
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
61
+ s.add_runtime_dependency(%q<thor>, ["~> 0.14"])
62
+ s.add_runtime_dependency(%q<rails>, ["~> 3.0.3"])
63
+ s.add_runtime_dependency(%q<rake>, ["~> 0.8"])
64
+ else
65
+ s.add_dependency(%q<thor>, ["~> 0.14"])
66
+ s.add_dependency(%q<rails>, ["~> 3.0.3"])
67
+ s.add_dependency(%q<rake>, ["~> 0.8"])
68
+ end
69
+ else
70
+ s.add_dependency(%q<thor>, ["~> 0.14"])
71
+ s.add_dependency(%q<rails>, ["~> 3.0.3"])
72
+ s.add_dependency(%q<rake>, ["~> 0.8"])
73
+ end
74
+ end
75
+
data/lib/ipage.rb ADDED
@@ -0,0 +1,177 @@
1
+ require "thor/group"
2
+ require "active_support"
3
+ require "active_support/version"
4
+ require "active_support/core_ext/string"
5
+
6
+ require "rails/generators"
7
+ require "rails/generators/rails/app/app_generator"
8
+
9
+
10
+ class Ipage < Thor::Group
11
+ include Thor::Actions
12
+ check_unknown_options!
13
+
14
+ def self.source_root
15
+ @_source_root ||= File.expand_path('../templates', __FILE__)
16
+ end
17
+
18
+ def self.say_step(message)
19
+ @step = (@step || 0) + 1
20
+ class_eval <<-METHOD, __FILE__, __LINE__ + 1
21
+ def step_#{@step}
22
+ #{"puts" if @step > 1}
23
+ say_status "STEP #{@step}", #{message.inspect}
24
+ end
25
+ METHOD
26
+ end
27
+
28
+ #argument :command, :type => :string,
29
+ # :desc => "command", :default => "new"
30
+ argument :path, :type => :string, :default => "newapp"
31
+
32
+ #class_option :test_framework, :default => "test_unit", :aliases => "-t",
33
+ # :desc => "Test framework to use. test_unit or rspec."
34
+
35
+ desc "Creates a Ipage application."
36
+
37
+ say_step "Creating rails 3 application"
38
+ #system "rails new kkkk"
39
+ #set_accessors!
40
+
41
+ def before_creating
42
+ set_accessors!
43
+ end
44
+
45
+ #if comman
46
+ def create_root
47
+
48
+ #set_accessors!
49
+
50
+ #directory "root", "."
51
+ #system "rails new "+name
52
+ invoke Rails::Generators::AppGenerator,
53
+ [ path ]
54
+ self.destination_root = File.expand_path(path, destination_root)
55
+ FileUtils.cd(destination_root)
56
+
57
+ end
58
+
59
+ say_step "Configuring Rails application"
60
+
61
+ def change_config_files
62
+ #store_application_definition!
63
+ template "Gemfile", "Gemfile", :force => true
64
+ template "hgignore", ".hgignore", :force => true
65
+ directory "stylesheets", "public/stylesheets"
66
+ directory "javascripts", "public/javascripts"
67
+ directory "app", "app", :force => true
68
+ directory "config", "config", :force => true
69
+ #directory "layouts", "app/views/layouts", :force => true
70
+ #template "application.html.erb", "app/views/layouts/application.html.erb", :force => true
71
+
72
+ #template "rails/application.rb", "#{dummy_path}/config/application.rb", :force => true
73
+ remove_file ".gitignore"
74
+ remove_file "public/stylesheets/.gitkeep"
75
+ remove_file "public/images/rails.png"
76
+ remove_file "public/index.html"
77
+ remove_file "README"
78
+ remove_file "public/javascripts/application.js"
79
+ remove_file "public/javascripts/controls.js"
80
+ remove_file "public/javascripts/dragdrop.js"
81
+ remove_file "public/javascripts/effects.js"
82
+ remove_file "public/javascripts/prototype.js"
83
+ remove_file "public/javascripts/rails.js"
84
+ end
85
+
86
+ =begin
87
+ def create_tests_or_specs
88
+ directory test_path
89
+ end
90
+
91
+ def change_gitignore
92
+ template "gitignore", ".gitignore"
93
+ end
94
+
95
+ say_step "Vendoring Rails application at test/dummy"
96
+
97
+ def invoke_rails_app_generator
98
+ invoke Rails::Generators::AppGenerator,
99
+ [ File.expand_path(dummy_path, destination_root) ]
100
+ end
101
+
102
+ say_step "Configuring Rails application"
103
+
104
+ def change_config_files
105
+ store_application_definition!
106
+ template "rails/boot.rb", "#{dummy_path}/config/boot.rb", :force => true
107
+ template "rails/application.rb", "#{dummy_path}/config/application.rb", :force => true
108
+ end
109
+
110
+ say_step "Removing unneeded files"
111
+
112
+ def remove_uneeded_rails_files
113
+ inside dummy_path do
114
+ remove_file ".gitignore"
115
+ remove_file "db/seeds.rb"
116
+ remove_file "doc"
117
+ remove_file "Gemfile"
118
+ remove_file "lib/tasks"
119
+ remove_file "public/images/rails.png"
120
+ remove_file "public/index.html"
121
+ remove_file "public/robots.txt"
122
+ remove_file "README"
123
+ remove_file "test"
124
+ remove_file "vendor"
125
+ end
126
+ end
127
+
128
+ system "echo adsf"+name
129
+ =end
130
+ protected
131
+
132
+ def rspec?
133
+ options[:test_framework] == "rspec"
134
+ end
135
+
136
+ def test_unit?
137
+ options[:test_framework] == "test_unit"
138
+ end
139
+
140
+ def test_path
141
+ rspec? ? "spec" : "test"
142
+ end
143
+
144
+ def dummy_path
145
+ "#{test_path}/dummy"
146
+ end
147
+
148
+ def self.banner
149
+ self_task.formatted_usage(self, false)
150
+ end
151
+
152
+ def application_definition
153
+ @application_definition ||= begin
154
+ contents = File.read(File.expand_path("#{dummy_path}/config/application.rb", destination_root))
155
+ contents[(contents.index("module Dummy"))..-1]
156
+ end
157
+ end
158
+ alias :store_application_definition! :application_definition
159
+
160
+ # Cache accessors since we are changing the directory
161
+ def set_accessors!
162
+ self.name
163
+ self.class.source_root
164
+ end
165
+
166
+ def name
167
+ @name ||= File.basename(destination_root)
168
+ end
169
+
170
+ def camelized
171
+ @camelized ||= name.camelize
172
+ end
173
+
174
+ def underscored
175
+ @underscored ||= name.underscore
176
+ end
177
+ end
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '~>3.0'
4
+ gem 'sqlite3'
@@ -0,0 +1,11 @@
1
+ module ApplicationHelper
2
+ def collect_js(*patterns)
3
+ options = patterns.extract_options!.stringify_keys
4
+ recursion = !options["without_recursion"] # with recursion by default
5
+ patterns.collect do |pattern|
6
+ scripts = collect_asset_files(File.join(RAILS_ROOT, 'public', 'javascripts'), pattern + '.js')
7
+ scripts = scripts + collect_asset_files(File.join(RAILS_ROOT, 'public', 'javascripts'), pattern, '**', '*.js') if recursion
8
+ scripts
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title></title>
5
+ <%= stylesheet_link_tag :all, :recursive=>true, :cache=>"all"%>
6
+
7
+ <%= javascript_include_tag collect_js('framework/*'), :cache=>'base' %>
8
+ <%= javascript_include_tag collect_js('design/*'), :cache=>'design' %>
9
+
10
+ <% if Rails.env.development? %>
11
+ <%=javascript_include_tag collect_js('test/*')%>
12
+ <%end%>
13
+ <%= csrf_meta_tag %>
14
+ </head>
15
+ <body>
16
+
17
+ <%= yield %>
18
+
19
+ </body>
20
+ </html>
@@ -0,0 +1,30 @@
1
+ if File.exists?("#{Rails.root}/public/javascripts/all.js")
2
+ File.delete("#{Rails.root}/public/javascripts/all.js")
3
+ end
4
+ if !$app_js
5
+ $app_js = Array.new
6
+ end
7
+ if !$app_js_dev
8
+ $app_js_dev = Array.new
9
+ end
10
+
11
+ if File.exists?("#{Rails.root}/public/stylesheets/all.js")
12
+ File.delete("#{Rails.root}/public/stylesheets/all.js")
13
+ end
14
+ if !$app_css
15
+ $app_css = Array.new
16
+ end
17
+ if !$app_css_dev
18
+ $app_css_dev = Array.new
19
+ end
20
+
21
+
22
+ $app_js.push("#{Rails.root}/public/javascripts/func")
23
+ $app_js.push("#{Rails.root}/public/javascripts/design")
24
+
25
+ $app_js_dev.push("#{Rails.root}/public/javascripts/test")
26
+
27
+
28
+ $app_css.push("#{Rails.root}/public/stylesheets")
29
+
30
+ #$app_css_dev.push("#{Rails.root}/public/javascripts/test")
@@ -0,0 +1,6 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ <%= test_path %>/dummy/db/*.sqlite3
5
+ <%= test_path %>/dummy/log/*.log
6
+ <%= test_path %>/dummy/tmp/
@@ -0,0 +1,4 @@
1
+ syntax: glob
2
+ db/*.sqlite3
3
+ log/*.log
4
+ tmp/
@@ -0,0 +1,3 @@
1
+ $(function(){
2
+
3
+ });