Class: Jquery::Generators::UiGenerator
- Defined in:
- lib/generators/jquery/ui/ui_generator.rb
Instance Method Summary collapse
- #copy_javascript_files ⇒ Object
- #copy_stylesheet_files ⇒ Object
- #create_application_layout_file ⇒ Object
- #create_initializer_file ⇒ Object
- #delete_tmp_files ⇒ Object
- #fetch_jquery_ui_files ⇒ Object
- #fetch_rails_jquery_ujs_file ⇒ Object
- #show_readme ⇒ Object
Methods inherited from Base
Instance Method Details
#copy_javascript_files ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/generators/jquery/ui/ui_generator.rb', line 23 def copy_javascript_files Dir.glob("#{unzip_path}/js/jquery-*.min.js").each do |js_file| source_file = (js_file) if js_file =~ /-ui-.+\.custom/ # jquery-ui-VERSION.custom.js copy_file source_file, 'public/javascripts/jquery-ui.js' else # jquery-VERSION.js copy_file source_file, 'public/javascripts/jquery.js' end end end |
#copy_stylesheet_files ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/generators/jquery/ui/ui_generator.rb', line 34 def copy_stylesheet_files Dir.glob("#{unzip_path}/css/**/*").each do |css_file| source_file = (css_file) target_file = css_file.sub("#{unzip_path}/css", 'public/stylesheets') if File.directory? source_file empty_directory target_file elsif source_file =~ /\.png$/ # images/*.png copy_file source_file, target_file elsif source_file =~ /\.css$/ # jquery-ui-VERSION.custom.css copy_file source_file, target_file.sub(/-ui-.+\.css$/, '-ui.css') end end end |
#create_application_layout_file ⇒ Object
52 53 54 |
# File 'lib/generators/jquery/ui/ui_generator.rb', line 52 def create_application_layout_file copy_file 'application.html.erb', 'app/views/layouts/application.html.erb' end |
#create_initializer_file ⇒ Object
48 49 50 |
# File 'lib/generators/jquery/ui/ui_generator.rb', line 48 def create_initializer_file copy_file 'jquery.rb', 'config/initializers/jquery.rb' end |
#delete_tmp_files ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/generators/jquery/ui/ui_generator.rb', line 56 def delete_tmp_files in_root do if [:clean] run "rm -rf #{app_tmp_path}", :verbose => false else run "rm -rf #{unzip_path}", :verbose => false end end end |
#fetch_jquery_ui_files ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/generators/jquery/ui/ui_generator.rb', line 10 def fetch_jquery_ui_files empty_directory app_tmp_path inside(app_tmp_path) do get "#{download_path}/#{zip_file}", zip_file unless File.exists? zip_file run "unzip #{zip_file} -d #{unzip_folder}", :verbose => false end end |
#fetch_rails_jquery_ujs_file ⇒ Object
18 19 20 |
# File 'lib/generators/jquery/ui/ui_generator.rb', line 18 def fetch_rails_jquery_ujs_file get 'http://github.com/rails/jquery-ujs/raw/master/src/rails.js', 'public/javascripts/rails.js' end |
#show_readme ⇒ Object
66 67 68 |
# File 'lib/generators/jquery/ui/ui_generator.rb', line 66 def show_readme readme 'README' end |