Class: Mockup::Project
Class Attribute Summary collapse
-
.full_name ⇒ Object
readonly
Returns the value of attribute full_name.
-
.location ⇒ Object
readonly
Returns the value of attribute location.
-
.name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
- .compass_config ⇒ Object
- .config_ru ⇒ Object
- .convert(options) ⇒ Object
- .create(options) ⇒ Object
- .create_javascript_dir ⇒ Object
- .get_javascript_file(name, path) ⇒ Object
- .gitignore ⇒ Object
- .install_javascript(options) ⇒ Object
- .install_jquery ⇒ Object
- .install_mootools ⇒ Object
- .install_prototype ⇒ Object
- .license ⇒ Object
- .setup_base_project ⇒ Object
Class Attribute Details
.full_name ⇒ Object (readonly)
Returns the value of attribute full_name.
5 6 7 |
# File 'lib/mockup/project.rb', line 5 def full_name @full_name end |
.location ⇒ Object (readonly)
Returns the value of attribute location.
5 6 7 |
# File 'lib/mockup/project.rb', line 5 def location @location end |
.name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/mockup/project.rb', line 5 def name @name end |
Class Method Details
.compass_config ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/mockup/project.rb', line 92 def compass_config <<-COMPASS_CONFIG http_path = '/' http_stylesheets_path = '/stylesheets' http_images_path = '/images' http_javascripts_path = '/javascripts' sass_dir = 'sass' css_dir = 'public/stylesheets' images_dir = 'public/images' javascripts_dir = 'public/javascripts' relative_assets = true COMPASS_CONFIG end |
.config_ru ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/mockup/project.rb', line 110 def config_ru <<-CONFIG_RU gem 'activesupport' gem 'serve', '~> 0.11.7' require 'serve' require 'serve/rack' require 'sass/plugin/rack' require 'compass' # The project root directory root = ::File.dirname(__FILE__) # Compass Compass.add_project_configuration(root + '/compass.config') Compass.configure_sass_plugin! # Rack Middleware use Rack::ShowStatus # Nice looking 404s and other messages use Rack::ShowExceptions # Nice looking errors use Sass::Plugin::Rack # Compile Sass on the fly # Rack Application if ENV['SERVER_SOFTWARE'] =~ /passenger/i # Passendger only needs the adapter run Serve::RackAdapter.new(root + '/views') else # We use Rack::Cascade and Rack::Directory on other platforms to handle static # assets run Rack::Cascade.new([ Serve::RackAdapter.new(root + '/views'), Rack::Directory.new(root + '/public') ]) end CONFIG_RU end |
.convert(options) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mockup/project.rb', line 42 def convert() @location = .location ? File.join(File.(.location)) : Dir.pwd @full_name = git_config('user.name') || 'Your Full Name' setup_base_project # Move Compass files that were created. FileUtils.mv(File.join(@location, 'images'), File.join(@location, 'public/')) if File.exists?(File.join(@location, 'images')) FileUtils.mv(File.join(@location, 'stylesheets'), File.join(@location, 'public/')) if File.exists?(File.join(@location, 'stylesheets')) FileUtils.mv(File.join(@location, 'javascripts'), File.join(@location, 'public/')) if File.exists?(File.join(@location, 'javascripts')) # Move default src (from compass create) to sass FileUtils.mv(File.join(@location, 'src'), File.join(@location, 'sass')) # FileUtils.cp(File.join(@location, 'config.rb'), File.join(@location, 'compass.config')) File.open(File.join(@location, "compass.config"), 'w+') { |f| f.puts compass_config } install_javascript() end |
.create(options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mockup/project.rb', line 7 def create() @name = .name || 'mockup' @location = .location ? File.join(File.(.location), @name.underscore) : File.join(Dir.pwd, @name.underscore) @full_name = git_config('user.name') || 'Your Full Name' setup_base_project FileUtils.mkdir_p(File.join(@location, 'sass')) FileUtils.mkdir_p(File.join(@location, 'public/images')) FileUtils.mkdir_p(File.join(@location, 'public/stylesheets')) File.open(File.join(@location, "compass.config"), 'w+') { |f| f.puts compass_config } install_javascript() end |
.create_javascript_dir ⇒ Object
208 209 210 211 |
# File 'lib/mockup/project.rb', line 208 def create_javascript_dir FileUtils.mkdir_p(File.join(@location, 'public/javascripts')) unless File.exists?(File.join(@location, 'javascripts')) FileUtils.touch(File.join(@location, 'public/javascripts/application.js')) end |
.get_javascript_file(name, path) ⇒ Object
201 202 203 204 205 |
# File 'lib/mockup/project.rb', line 201 def get_javascript_file(name, path) create_javascript_dir filename = File.join(@location, "public/javascripts/#{name}.js") `curl -o #{filename} #{path}` end |
.gitignore ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/mockup/project.rb', line 149 def gitignore <<-IGNORE ## MAC OS .DS_Store ## TEXTMATE *.tmproj tmtags ## EMACS *~ \#* .\#* ## VIM *.swp ## PROJECT::GENERAL coverage rdoc pkg ## PROJECT::SPECIFIC *.gem IGNORE end |
.install_javascript(options) ⇒ Object
176 177 178 179 180 |
# File 'lib/mockup/project.rb', line 176 def install_javascript() install_jquery if .jquery install_mootools if .mootools install_prototype if .prototype end |
.install_jquery ⇒ Object
183 184 185 186 |
# File 'lib/mockup/project.rb', line 183 def install_jquery get_javascript_file('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js') get_javascript_file('jquery_ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js') end |
.install_mootools ⇒ Object
189 190 191 |
# File 'lib/mockup/project.rb', line 189 def install_mootools get_javascript_file('mootools', 'http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js') end |
.install_prototype ⇒ Object
194 195 196 197 |
# File 'lib/mockup/project.rb', line 194 def install_prototype get_javascript_file('prototype', 'http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js') get_javascript_file('scriptaculous', 'http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.3/scriptaculous.js') end |
.license ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/mockup/project.rb', line 66 def license <<-LICENSE Copyright (c) #{Time.now.year} #{@full_name} Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. LICENSE end |
.setup_base_project ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mockup/project.rb', line 24 def setup_base_project FileUtils.mkdir_p(File.join(@location, 'public')) FileUtils.mkdir_p(File.join(@location, 'tmp')) FileUtils.mkdir_p(File.join(@location, 'views/layouts')) FileUtils.touch(File.join(@location, 'README.mk')) FileUtils.touch(File.join(@location, 'tmp/restart.txt')) File.open(File.join(@location, "config.ru"), 'w+') { |f| f.puts config_ru } File.open(File.join(@location, "LICENSE"), 'w+') { |f| f.puts license } File.open(File.join(@location, ".gitignore"), 'w+') { |f| f.puts gitignore } end |