capucine 0.0.1
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/bin/capucine +21 -0
- data/content/shared/coffeescript/app.js.coffee +9 -0
- data/content/shared/css/import/YOUR_OLD_CSS +0 -0
- data/content/shared/images/favicon/apple-touch-icon-114x114-precomposed.png +0 -0
- data/content/shared/images/favicon/apple-touch-icon-57x57-precomposed.png +0 -0
- data/content/shared/images/favicon/apple-touch-icon-72x72-precomposed.png +0 -0
- data/content/shared/images/favicon/apple-touch-icon-precomposed.png +0 -0
- data/content/shared/images/favicon/favicon.png +0 -0
- data/content/shared/js/app.js +11 -0
- data/content/shared/js/libs/jquery.min.js +4 -0
- data/content/shared/sass/_home.sass +9 -0
- data/content/shared/sass/_ie.sass +4 -0
- data/content/shared/sass/_print.sass +46 -0
- data/content/shared/sass/_responsive.sass +41 -0
- data/content/shared/sass/_shared.sass +32 -0
- data/content/shared/sass/all.scss +12 -0
- data/content/shared/templates/_footer.html +10 -0
- data/content/shared/templates/_header.html +31 -0
- data/content/shared/templates/index.html.erb +7 -0
- data/content/templates/capucine.yaml +35 -0
- data/content/templates/cmd_help.txt +28 -0
- data/content/templates/compass_config.erb +15 -0
- data/lib/capucine.rb +22 -0
- data/lib/coffeescript.rb +104 -0
- data/lib/commands.rb +38 -0
- data/lib/compass-sass.rb +93 -0
- data/lib/incloudr.rb +71 -0
- data/lib/settings.rb +51 -0
- data/lib/templates.rb +55 -0
- data/lib/tools.rb +101 -0
- data/lib/watch.rb +36 -0
- metadata +153 -0
    
        data/lib/coffeescript.rb
    ADDED
    
    | @@ -0,0 +1,104 @@ | |
| 1 | 
            +
            module Capucine
         | 
| 2 | 
            +
              class Coffee
         | 
| 3 | 
            +
                require 'packr'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                def self.run_once file = nil
         | 
| 6 | 
            +
                  require 'coffee-script'
         | 
| 7 | 
            +
                  
         | 
| 8 | 
            +
                  settings = Capucine.settings
         | 
| 9 | 
            +
                  
         | 
| 10 | 
            +
                  coffee_files = file
         | 
| 11 | 
            +
                  coffee_files = "#{settings.working_dir}/#{settings.config['coffeescript_coffee_files_dir']}/**/**.coffee" if not file
         | 
| 12 | 
            +
                  
         | 
| 13 | 
            +
                  Dir.glob(coffee_files).each do |file_coffee_o|
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                    file_coffee = File.expand_path file_coffee_o
         | 
| 16 | 
            +
                    base_in_dir = File.join settings.working_dir, settings.config['coffeescript_coffee_files_dir']
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                    relative_path = File.basename(file_coffee)
         | 
| 19 | 
            +
                    relative_path = relative_path.gsub(/\.coffee$/, '.js')
         | 
| 20 | 
            +
                    relative_path_min = relative_path.gsub(/\.js$/, '.min.js')
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                    file_out = File.join settings.working_dir, settings.config['coffeescript_js_generated_dir'], relative_path
         | 
| 23 | 
            +
                    file_out_min = File.join settings.working_dir, settings.config['coffeescript_js_generated_dir'], relative_path_min
         | 
| 24 | 
            +
             | 
| 25 | 
            +
             | 
| 26 | 
            +
                    relative_coffee_file = file_coffee.gsub(base_in_dir, '')
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                    bare_opt = false
         | 
| 29 | 
            +
                    bare_opt = true if settings.config['coffeescript_coffee_bare']
         | 
| 30 | 
            +
                    
         | 
| 31 | 
            +
                    coffee_output_min = ""
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                    begin
         | 
| 34 | 
            +
                      coffee_output = CoffeeScript.compile(File.read(file_coffee), :bare => bare_opt)
         | 
| 35 | 
            +
                      coffee_output_min << Packr.pack(coffee_output)
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                    rescue Exception => e
         | 
| 38 | 
            +
                      coffee_output = "var message = \"CoffeeScript Error (#{relative_coffee_file.gsub(/^\//, '')}) => \";"
         | 
| 39 | 
            +
                      coffee_output += "message += \"#{e.message}'\";"
         | 
| 40 | 
            +
                      coffee_output += "throw message;"
         | 
| 41 | 
            +
                      message = "#{e.message}"
         | 
| 42 | 
            +
                    end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                    puts "[coffee] - #{message}" if message
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                    FileUtils.mkdir_p File.dirname(file_out)
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                    f1 = File.open(file_out, 'w+')
         | 
| 49 | 
            +
                    f1.write(coffee_output)
         | 
| 50 | 
            +
                    f1.close
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                    f2 = File.open(file_out_min, 'w+')
         | 
| 53 | 
            +
                    f2.write(coffee_output_min)
         | 
| 54 | 
            +
                    f2.close
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                  end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                  puts "[coffee] - Compiled"
         | 
| 59 | 
            +
                  Capucine::Incloudr.run_once if settings.config['incloudr_enable']
         | 
| 60 | 
            +
                end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                def self.proc_watch
         | 
| 63 | 
            +
                  require 'fssm'
         | 
| 64 | 
            +
                  settings = Capucine.settings
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                  coffee_thread = Thread.new {
         | 
| 67 | 
            +
                    files_to_lookat = File.join settings.working_dir, settings.config['coffeescript_coffee_files_dir']
         | 
| 68 | 
            +
                    
         | 
| 69 | 
            +
                    FSSM.monitor(files_to_lookat, :directories => true) do
         | 
| 70 | 
            +
                      update do |b, r|
         | 
| 71 | 
            +
                        Capucine::Coffee.run_once File.join b, r if File.extname(r) == '.coffee'
         | 
| 72 | 
            +
                      end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                      create do |b, r|
         | 
| 75 | 
            +
                        Capucine::Coffee.run_once File.join b, r if File.extname(r) == '.coffee'
         | 
| 76 | 
            +
                      end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                      delete do |b, r|
         | 
| 79 | 
            +
                        js_generated_dir = File.expand_path settings.config['coffeescript_js_generated_dir']
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                        file_name = File.expand_path File.join(b, r)
         | 
| 82 | 
            +
                        folder_name = File.dirname file_name
         | 
| 83 | 
            +
                        js_file = File.join js_generated_dir, r.gsub('.coffee', '.js')
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                        if Dir["#{folder_name}/*"].empty? and folder_name != js_generated_dir
         | 
| 86 | 
            +
                          to_delete = File.expand_path(File.dirname(js_file))
         | 
| 87 | 
            +
                          FileUtils.rm_r to_delete
         | 
| 88 | 
            +
                        else
         | 
| 89 | 
            +
                          File.delete(js_file) if File.exist?(js_file)
         | 
| 90 | 
            +
                        end
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                      end
         | 
| 93 | 
            +
                    end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                  }
         | 
| 96 | 
            +
                  
         | 
| 97 | 
            +
                  return coffee_thread
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                end
         | 
| 100 | 
            +
             | 
| 101 | 
            +
              end
         | 
| 102 | 
            +
              
         | 
| 103 | 
            +
            end
         | 
| 104 | 
            +
             | 
    
        data/lib/commands.rb
    ADDED
    
    | @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            module Capucine
         | 
| 2 | 
            +
              class Commands
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                require 'watch'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                def initialize args
         | 
| 7 | 
            +
                  first_arg = args[0]
         | 
| 8 | 
            +
                  second_arg = args[1]
         | 
| 9 | 
            +
                  cap = Capucine.new
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  if first_arg == 'help'
         | 
| 12 | 
            +
                    self.help
         | 
| 13 | 
            +
                  
         | 
| 14 | 
            +
                  elsif first_arg == 'new' or first_arg == 'n'
         | 
| 15 | 
            +
                    Capucine::Tools.new_project second_arg
         | 
| 16 | 
            +
                  
         | 
| 17 | 
            +
                  elsif first_arg == 'init' or first_arg == 'i'
         | 
| 18 | 
            +
                    Capucine::Tools.init second_arg
         | 
| 19 | 
            +
                  
         | 
| 20 | 
            +
                  elsif first_arg == 'compile' or first_arg == 'c'
         | 
| 21 | 
            +
                    Capucine::Tools.compile
         | 
| 22 | 
            +
                  
         | 
| 23 | 
            +
                  elsif first_arg == 'watch' or first_arg == 'w'
         | 
| 24 | 
            +
                    Capucine::Watchr.new second_arg
         | 
| 25 | 
            +
                    
         | 
| 26 | 
            +
                  else
         | 
| 27 | 
            +
                    self.help
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                def help
         | 
| 32 | 
            +
                  puts "help"
         | 
| 33 | 
            +
                  exit
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
| 38 | 
            +
             | 
    
        data/lib/compass-sass.rb
    ADDED
    
    | @@ -0,0 +1,93 @@ | |
| 1 | 
            +
            module Capucine
         | 
| 2 | 
            +
              class CompassSass
         | 
| 3 | 
            +
                def self.update_plugins force = false
         | 
| 4 | 
            +
                  plugins = Capucine.settings.config['compass_plugins']
         | 
| 5 | 
            +
                  return if not plugins
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  plugins.each do |plugin|
         | 
| 8 | 
            +
                    require 'rubygems'
         | 
| 9 | 
            +
                    require 'sass'
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                    begin 
         | 
| 12 | 
            +
                      require "#{plugin}"
         | 
| 13 | 
            +
                    rescue LoadError
         | 
| 14 | 
            +
                      system("gem install #{plugin} --no-ri --no-rdoc") if force
         | 
| 15 | 
            +
                    end
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def self.update_config
         | 
| 20 | 
            +
                  settings = Capucine.settings
         | 
| 21 | 
            +
                  template_file = File.join settings.gem_content_dir, 'templates', 'compass_config.erb'
         | 
| 22 | 
            +
                  output_file = File.join settings.working_dir, '.compass.rb'
         | 
| 23 | 
            +
                  
         | 
| 24 | 
            +
                  config_ = settings.config
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  result = Capucine::Tools.render_template template_file, config_
         | 
| 27 | 
            +
                  
         | 
| 28 | 
            +
                  f = File.open(output_file, 'w')
         | 
| 29 | 
            +
                  f.write(result)
         | 
| 30 | 
            +
                  f.close
         | 
| 31 | 
            +
                  
         | 
| 32 | 
            +
                  # DEBUG HERE :
         | 
| 33 | 
            +
                  # self.update_plugins force = true
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
                
         | 
| 36 | 
            +
                # def self.load_my_functions
         | 
| 37 | 
            +
                #   rb_files = Dir.glob "#{Capucine.settings.working_dir}/#{Capucine.settings.config['compass_compass_files_dir']}/**/**.rb"
         | 
| 38 | 
            +
                #   
         | 
| 39 | 
            +
                #   rb_files.each do |file|
         | 
| 40 | 
            +
                #     require "#{file}"
         | 
| 41 | 
            +
                #   end
         | 
| 42 | 
            +
                #   
         | 
| 43 | 
            +
                # end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                def self.import_css
         | 
| 46 | 
            +
                  s = Capucine.settings
         | 
| 47 | 
            +
                  import_dir = File.join s.working_dir, s.config['compass_import_css_dir']
         | 
| 48 | 
            +
                  output_dir= File.join s.working_dir, s.config['compass_import_output_dir']
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                  Dir.mkdir(import_dir) if not File.directory?(import_dir)
         | 
| 51 | 
            +
                  Dir.mkdir(output_dir) if not File.directory?(output_dir)
         | 
| 52 | 
            +
                  
         | 
| 53 | 
            +
                  formats = s.config['compass_import_formats'].split
         | 
| 54 | 
            +
                  from_format = formats[0]
         | 
| 55 | 
            +
                  to_format = formats[2]
         | 
| 56 | 
            +
                  
         | 
| 57 | 
            +
                  command = "sass-convert -R --from #{from_format} --to #{to_format} #{import_dir} #{output_dir}"
         | 
| 58 | 
            +
                  system(command)
         | 
| 59 | 
            +
                  Capucine::Tools.archive_file import_dir
         | 
| 60 | 
            +
                  
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                def self.run_once
         | 
| 64 | 
            +
                  self.update_config
         | 
| 65 | 
            +
                  # self.load_my_functions
         | 
| 66 | 
            +
                  self.import_css if Capucine.settings.config['compass_import_css']
         | 
| 67 | 
            +
                  
         | 
| 68 | 
            +
                  config = File.join Capucine.settings.working_dir, '.compass.rb'
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                  command = "compass compile --quiet --config #{config} #{Capucine.settings.working_dir}"
         | 
| 71 | 
            +
                  system(command)
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                  puts "[compass] - Compiled"
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                def self.proc_watch
         | 
| 77 | 
            +
                  self.update_config
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                  config_file = File.join Capucine.settings.working_dir, '.compass.rb'
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                  command = "compass watch --config #{config_file} #{Capucine.settings.working_dir}"
         | 
| 82 | 
            +
                  
         | 
| 83 | 
            +
                  compass_proc = Thread.new {
         | 
| 84 | 
            +
                    system(command)
         | 
| 85 | 
            +
                  }
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                  return compass_proc
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
              end
         | 
| 92 | 
            +
              
         | 
| 93 | 
            +
            end
         | 
    
        data/lib/incloudr.rb
    ADDED
    
    | @@ -0,0 +1,71 @@ | |
| 1 | 
            +
            module Capucine
         | 
| 2 | 
            +
              class Incloudr
         | 
| 3 | 
            +
                require 'open-uri'
         | 
| 4 | 
            +
                require 'fileutils'
         | 
| 5 | 
            +
                require 'uglifier'
         | 
| 6 | 
            +
                require 'packr'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                def self.run_once
         | 
| 9 | 
            +
                  files = Capucine.settings.config['incloudr_files']
         | 
| 10 | 
            +
                  return if files.length == 0
         | 
| 11 | 
            +
                  
         | 
| 12 | 
            +
                  files.each do |base, files|
         | 
| 13 | 
            +
                    self.pack base, files
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
                  puts "[js pack] - Packaged"
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                def self.pack base = nil, files = []
         | 
| 19 | 
            +
                  s = Capucine.settings
         | 
| 20 | 
            +
                  out = File.join s.working_dir, s.config['incloudr_output_dir']
         | 
| 21 | 
            +
                  
         | 
| 22 | 
            +
                  output_file = File.join out, base
         | 
| 23 | 
            +
                  output_file_min = File.join out, base.gsub('.js', '.min.js')
         | 
| 24 | 
            +
                  
         | 
| 25 | 
            +
                  FileUtils.mkdir_p out if not File.exist?(out)
         | 
| 26 | 
            +
                  
         | 
| 27 | 
            +
                  content = ""
         | 
| 28 | 
            +
                  # content_min = ""
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  files.each do |js_file|
         | 
| 31 | 
            +
                    extended = File.join s.working_dir, js_file
         | 
| 32 | 
            +
                    content << File.read(extended) if File.exist?(extended)
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
                  
         | 
| 35 | 
            +
                  f = File.open(output_file, 'w')
         | 
| 36 | 
            +
                  f.write('')
         | 
| 37 | 
            +
                  f.write(content)
         | 
| 38 | 
            +
                  f.close
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  # f2 = File.open(output_file_min, 'w')
         | 
| 41 | 
            +
                  # f2.write('')
         | 
| 42 | 
            +
                  # f2.write(content_min)
         | 
| 43 | 
            +
                  # f2.close
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                # def self.lib_root
         | 
| 48 | 
            +
                #   return "http://dln.name/"
         | 
| 49 | 
            +
                # end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                # def self.compress file
         | 
| 52 | 
            +
                #   return if not File.exist?(file)
         | 
| 53 | 
            +
                #   file_name = file.gsub '.js', ''
         | 
| 54 | 
            +
                #   output_file = "#{file_name}.js"
         | 
| 55 | 
            +
                #   output_file_min = "#{file_name}.min.js"
         | 
| 56 | 
            +
                # end
         | 
| 57 | 
            +
                
         | 
| 58 | 
            +
                # def self.get_lib lib
         | 
| 59 | 
            +
                #   lib_name = lib[0]
         | 
| 60 | 
            +
                #   lib_version = lib[1]
         | 
| 61 | 
            +
                #   lib_url = "#{self.lib_root}#{lib_name}/#{lib_version}"
         | 
| 62 | 
            +
                #   lib_url_min = "#{lib_url}/min"
         | 
| 63 | 
            +
                #   lib_url_cdn = open(lib_url).read
         | 
| 64 | 
            +
                #   lib_url_cdn_min = open(lib_url_min).read
         | 
| 65 | 
            +
                #   lib_content = open(lib_url_cdn).read
         | 
| 66 | 
            +
                #   lib_content_min = open(lib_url_cdn_min).read
         | 
| 67 | 
            +
                #   total = [lib_content, lib_content_min]
         | 
| 68 | 
            +
                # end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              end
         | 
| 71 | 
            +
            end
         | 
    
        data/lib/settings.rb
    ADDED
    
    | @@ -0,0 +1,51 @@ | |
| 1 | 
            +
            module Capucine
         | 
| 2 | 
            +
              
         | 
| 3 | 
            +
              class NoUserConfigFile < RuntimeError
         | 
| 4 | 
            +
              end
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              class Settings
         | 
| 7 | 
            +
                require 'rubygems'
         | 
| 8 | 
            +
                require 'yaml'
         | 
| 9 | 
            +
                
         | 
| 10 | 
            +
                attr_accessor :current_dir, :project_name, :is_usable, :config, :gem_dir, :gem_content_dir, :working_dir
         | 
| 11 | 
            +
                
         | 
| 12 | 
            +
                def initialize
         | 
| 13 | 
            +
                  @current_dir = File.expand_path Dir.pwd
         | 
| 14 | 
            +
                  @project_name = Capucine.get_name
         | 
| 15 | 
            +
                  @is_usable = false
         | 
| 16 | 
            +
                  @config = nil
         | 
| 17 | 
            +
                  @gem_dir = Gem.loaded_specs[Capucine.get_name].full_gem_path
         | 
| 18 | 
            +
                  @gem_content_dir = File.join @gem_dir, 'content'
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  self.reset_working_dir
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                def get_config user_config_file = nil
         | 
| 24 | 
            +
                  default = File.join @gem_content_dir, "templates", "#{Capucine.get_name}.yaml"
         | 
| 25 | 
            +
                  @config = YAML::load(File.open(default)) 
         | 
| 26 | 
            +
                  # Load user config :
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  from_user = File.join @working_dir, "#{Capucine.get_name}.yaml"
         | 
| 29 | 
            +
                  from_user = File.expand_path user_config_file if user_config_file
         | 
| 30 | 
            +
                  
         | 
| 31 | 
            +
                  raise NoUserConfigFile, caller if not File.exist? from_user
         | 
| 32 | 
            +
                  
         | 
| 33 | 
            +
                  @is_usable = true
         | 
| 34 | 
            +
                  additional = YAML::load(File.open(from_user))
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  if additional
         | 
| 37 | 
            +
                    # Overload default.yaml :
         | 
| 38 | 
            +
                    additional.each do |k, v|
         | 
| 39 | 
            +
                      @config[k] = nil
         | 
| 40 | 
            +
                      @config[k] = v
         | 
| 41 | 
            +
                    end
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                end    
         | 
| 44 | 
            +
               
         | 
| 45 | 
            +
                def reset_working_dir
         | 
| 46 | 
            +
                  @working_dir = File.expand_path Dir.pwd
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
            end
         | 
| 51 | 
            +
             | 
    
        data/lib/templates.rb
    ADDED
    
    | @@ -0,0 +1,55 @@ | |
| 1 | 
            +
            module Capucine
         | 
| 2 | 
            +
              class Templates
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                def self.run_once
         | 
| 5 | 
            +
                  settings = Capucine.settings
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  files_to_watch = "#{settings.working_dir}/#{settings.config['templates_erb_files_dir']}/*.erb"
         | 
| 8 | 
            +
                  templates = Dir.glob(files_to_watch)
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  templates.each do |template|
         | 
| 11 | 
            +
                    return if not File.exist? template
         | 
| 12 | 
            +
                    html_name = File.basename(template).gsub('.erb', '')
         | 
| 13 | 
            +
                    new_file = File.join settings.working_dir, html_name
         | 
| 14 | 
            +
                    template_root = File.join settings.working_dir, settings.config['templates_erb_files_dir'] #for ERB binding
         | 
| 15 | 
            +
                    
         | 
| 16 | 
            +
                    result = Capucine::Tools.render_template template, template_root
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                    f = File.open(new_file, 'w+')
         | 
| 19 | 
            +
                    f.write(result)
         | 
| 20 | 
            +
                    f.close
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                  
         | 
| 24 | 
            +
                  puts "[template] - Rendered"
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
                
         | 
| 28 | 
            +
                def self.proc_watch
         | 
| 29 | 
            +
                  require 'fssm'
         | 
| 30 | 
            +
                  
         | 
| 31 | 
            +
                  watchr_thread = Thread.new {
         | 
| 32 | 
            +
                    files_to_lookat = File.join Capucine.settings.working_dir, Capucine.settings.config['templates_erb_files_dir']
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                    FSSM.monitor(files_to_lookat, :directories => true) do
         | 
| 35 | 
            +
                      update do |b, r|
         | 
| 36 | 
            +
                        Capucine::Templates.run_once
         | 
| 37 | 
            +
                      end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                      create do |b, r|
         | 
| 40 | 
            +
                        Capucine::Templates.run_once
         | 
| 41 | 
            +
                      end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                      delete do |b, r|
         | 
| 44 | 
            +
                        Capucine::Templates.run_once
         | 
| 45 | 
            +
                      end
         | 
| 46 | 
            +
                    end
         | 
| 47 | 
            +
                  }
         | 
| 48 | 
            +
                  return watchr_thread
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
             | 
| 53 | 
            +
             | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
            end
         | 
    
        data/lib/tools.rb
    ADDED
    
    | @@ -0,0 +1,101 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Capucine
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              class Tools
         | 
| 6 | 
            +
                require 'fileutils'
         | 
| 7 | 
            +
                require 'erb'   
         | 
| 8 | 
            +
                require "compass-sass.rb"
         | 
| 9 | 
            +
                require "coffeescript.rb"
         | 
| 10 | 
            +
                require "incloudr.rb"
         | 
| 11 | 
            +
                require "templates.rb"
         | 
| 12 | 
            +
                
         | 
| 13 | 
            +
                def self.new_project name = nil
         | 
| 14 | 
            +
                  
         | 
| 15 | 
            +
                  new_project_name = Capucine.settings.project_name
         | 
| 16 | 
            +
                  new_project_name = name if name
         | 
| 17 | 
            +
                  Capucine.settings.working_dir = File.join Capucine.settings.current_dir, new_project_name
         | 
| 18 | 
            +
                  
         | 
| 19 | 
            +
                  self.archive_file Capucine.settings.working_dir
         | 
| 20 | 
            +
                  FileUtils.mkdir Capucine.settings.working_dir if not File.directory? Capucine.settings.working_dir
         | 
| 21 | 
            +
                  
         | 
| 22 | 
            +
                  self.init files = true
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
                
         | 
| 25 | 
            +
                def self.init all = nil
         | 
| 26 | 
            +
                  files = []
         | 
| 27 | 
            +
                  content_files = []
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  self.archive_file File.join Capucine.settings.working_dir, 'capucine.yaml'
         | 
| 30 | 
            +
                  if all
         | 
| 31 | 
            +
                    content_files = Dir.glob("#{Capucine.settings.gem_content_dir}/shared/**")
         | 
| 32 | 
            +
                    content_files.each do |file|
         | 
| 33 | 
            +
                      relative_path = file.gsub(File.join(Capucine.settings.gem_content_dir, 'shared', '/'),'')
         | 
| 34 | 
            +
                      destination = File.join Capucine.settings.working_dir, relative_path
         | 
| 35 | 
            +
                      self.archive_file destination
         | 
| 36 | 
            +
                    end
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  files << File.join(Capucine.settings.gem_content_dir, 'templates', 'capucine.yaml')
         | 
| 40 | 
            +
                  content_files.each {|file| files << file}
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  FileUtils.cp_r files, Capucine.settings.working_dir
         | 
| 43 | 
            +
                  self.compile if all
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  Capucine.settings.reset_working_dir
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                def self.compile
         | 
| 49 | 
            +
                  Capucine.settings.get_config
         | 
| 50 | 
            +
                  @config = Capucine.settings.config
         | 
| 51 | 
            +
                  
         | 
| 52 | 
            +
                  Capucine::CompassSass.run_once if @config['compass_enable']
         | 
| 53 | 
            +
                  Capucine::Coffee.run_once if @config['coffeescript_enable']
         | 
| 54 | 
            +
                  Capucine::Templates.run_once if @config['templates_enable']
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                def self.render_template template_file, content = nil
         | 
| 59 | 
            +
                  config = content
         | 
| 60 | 
            +
                  template = ERB.new File.new(template_file).read
         | 
| 61 | 
            +
                  output = template.result(binding)
         | 
| 62 | 
            +
                end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                def self.archive_file path, force = true
         | 
| 65 | 
            +
                  return if not File.exist? path
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  is_empty = false
         | 
| 68 | 
            +
                  is_dir = File.directory? path
         | 
| 69 | 
            +
                  dir_length = Dir.glob("#{path}/**").length if is_dir
         | 
| 70 | 
            +
                  is_empty = true if dir_length == 0
         | 
| 71 | 
            +
                  
         | 
| 72 | 
            +
                  return if is_empty
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                  date = Time.now.strftime("%Y-%m-%d_%Hh%Mm%Ss")
         | 
| 75 | 
            +
                  new_dir_name = path
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                  if is_dir
         | 
| 78 | 
            +
                    new_dir_name = "#{path}_#{date}"        
         | 
| 79 | 
            +
                  end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                  if not is_dir
         | 
| 82 | 
            +
                    extension = File.extname path
         | 
| 83 | 
            +
                    base_path = File.dirname path
         | 
| 84 | 
            +
                    file_name = File.basename(path, extension)
         | 
| 85 | 
            +
                    new_dir_name = File.join base_path, "#{file_name}_#{date}#{extension}"
         | 
| 86 | 
            +
                  end
         | 
| 87 | 
            +
                  
         | 
| 88 | 
            +
                  FileUtils.mkdir_p new_dir_name if is_dir
         | 
| 89 | 
            +
                  FileUtils.mv path, new_dir_name
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                def clean_name name
         | 
| 94 | 
            +
                  require_relative 'extend_string'
         | 
| 95 | 
            +
                  name.removeaccents
         | 
| 96 | 
            +
                  name.urlize({:downcase => true, :convert_spaces => true})
         | 
| 97 | 
            +
                end
         | 
| 98 | 
            +
              
         | 
| 99 | 
            +
              end
         | 
| 100 | 
            +
            end
         | 
| 101 | 
            +
             | 
    
        data/lib/watch.rb
    ADDED
    
    | @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            module Capucine
         | 
| 2 | 
            +
              class Watchr
         | 
| 3 | 
            +
                require 'compass-sass.rb'
         | 
| 4 | 
            +
                require 'coffeescript.rb'
         | 
| 5 | 
            +
                require "templates.rb"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def initialize config_file
         | 
| 8 | 
            +
                  Capucine.settings.get_config config_file
         | 
| 9 | 
            +
                  @config = Capucine.settings.config
         | 
| 10 | 
            +
                  
         | 
| 11 | 
            +
                  Capucine::CompassSass.run_once if @config['compass_enable']
         | 
| 12 | 
            +
                  Capucine::Coffee.run_once if @config['coffeescript_enable']
         | 
| 13 | 
            +
                  Capucine::Templates.run_once if @config['templates_enable']
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  self.watch
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                def watch
         | 
| 19 | 
            +
                  
         | 
| 20 | 
            +
                  compass_proc = Capucine::CompassSass.proc_watch if @config['compass_enable']
         | 
| 21 | 
            +
                  coffeescript_proc = Capucine::Coffee.proc_watch if @config['coffeescript_enable']
         | 
| 22 | 
            +
                  templates_proc = Capucine::Templates.proc_watch if @config['templates_enable']
         | 
| 23 | 
            +
                  
         | 
| 24 | 
            +
                  main_thread = Thread.new {
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                    compass_proc.join if compass_proc
         | 
| 27 | 
            +
                    coffeescript_proc.join if coffeescript_proc
         | 
| 28 | 
            +
                    templates_proc.join if templates_proc
         | 
| 29 | 
            +
                  }
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  main_thread.join
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,153 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: capucine
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
              prerelease: 
         | 
| 6 | 
            +
            platform: ruby
         | 
| 7 | 
            +
            authors:
         | 
| 8 | 
            +
            - Damian Le Nouaille
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
            date: 2011-12-04 00:00:00.000000000Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            +
              name: fssm
         | 
| 16 | 
            +
              requirement: &70236637554700 !ruby/object:Gem::Requirement
         | 
| 17 | 
            +
                none: false
         | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - ! '>='
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: '0'
         | 
| 22 | 
            +
              type: :runtime
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              version_requirements: *70236637554700
         | 
| 25 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 26 | 
            +
              name: compass
         | 
| 27 | 
            +
              requirement: &70236637554120 !ruby/object:Gem::Requirement
         | 
| 28 | 
            +
                none: false
         | 
| 29 | 
            +
                requirements:
         | 
| 30 | 
            +
                - - ! '>='
         | 
| 31 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            +
                    version: '0'
         | 
| 33 | 
            +
              type: :runtime
         | 
| 34 | 
            +
              prerelease: false
         | 
| 35 | 
            +
              version_requirements: *70236637554120
         | 
| 36 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 37 | 
            +
              name: coffee-script
         | 
| 38 | 
            +
              requirement: &70236637553560 !ruby/object:Gem::Requirement
         | 
| 39 | 
            +
                none: false
         | 
| 40 | 
            +
                requirements:
         | 
| 41 | 
            +
                - - ! '>='
         | 
| 42 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 43 | 
            +
                    version: '0'
         | 
| 44 | 
            +
              type: :runtime
         | 
| 45 | 
            +
              prerelease: false
         | 
| 46 | 
            +
              version_requirements: *70236637553560
         | 
| 47 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 48 | 
            +
              name: uglifier
         | 
| 49 | 
            +
              requirement: &70236637552980 !ruby/object:Gem::Requirement
         | 
| 50 | 
            +
                none: false
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ! '>='
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '0'
         | 
| 55 | 
            +
              type: :runtime
         | 
| 56 | 
            +
              prerelease: false
         | 
| 57 | 
            +
              version_requirements: *70236637552980
         | 
| 58 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 59 | 
            +
              name: packr
         | 
| 60 | 
            +
              requirement: &70236637552480 !ruby/object:Gem::Requirement
         | 
| 61 | 
            +
                none: false
         | 
| 62 | 
            +
                requirements:
         | 
| 63 | 
            +
                - - ! '>='
         | 
| 64 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 65 | 
            +
                    version: '0'
         | 
| 66 | 
            +
              type: :runtime
         | 
| 67 | 
            +
              prerelease: false
         | 
| 68 | 
            +
              version_requirements: *70236637552480
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: term-ansicolor
         | 
| 71 | 
            +
              requirement: &70236637551980 !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                none: false
         | 
| 73 | 
            +
                requirements:
         | 
| 74 | 
            +
                - - ! '>='
         | 
| 75 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 76 | 
            +
                    version: '0'
         | 
| 77 | 
            +
              type: :runtime
         | 
| 78 | 
            +
              prerelease: false
         | 
| 79 | 
            +
              version_requirements: *70236637551980
         | 
| 80 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 81 | 
            +
              name: zip
         | 
| 82 | 
            +
              requirement: &70236637551420 !ruby/object:Gem::Requirement
         | 
| 83 | 
            +
                none: false
         | 
| 84 | 
            +
                requirements:
         | 
| 85 | 
            +
                - - ! '>='
         | 
| 86 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 87 | 
            +
                    version: '0'
         | 
| 88 | 
            +
              type: :runtime
         | 
| 89 | 
            +
              prerelease: false
         | 
| 90 | 
            +
              version_requirements: *70236637551420
         | 
| 91 | 
            +
            description: T
         | 
| 92 | 
            +
            email: dam@dln.name
         | 
| 93 | 
            +
            executables:
         | 
| 94 | 
            +
            - capucine
         | 
| 95 | 
            +
            extensions: []
         | 
| 96 | 
            +
            extra_rdoc_files: []
         | 
| 97 | 
            +
            files:
         | 
| 98 | 
            +
            - content/shared/coffeescript/app.js.coffee
         | 
| 99 | 
            +
            - content/shared/css/import/YOUR_OLD_CSS
         | 
| 100 | 
            +
            - content/shared/images/favicon/apple-touch-icon-114x114-precomposed.png
         | 
| 101 | 
            +
            - content/shared/images/favicon/apple-touch-icon-57x57-precomposed.png
         | 
| 102 | 
            +
            - content/shared/images/favicon/apple-touch-icon-72x72-precomposed.png
         | 
| 103 | 
            +
            - content/shared/images/favicon/apple-touch-icon-precomposed.png
         | 
| 104 | 
            +
            - content/shared/images/favicon/favicon.png
         | 
| 105 | 
            +
            - content/shared/js/app.js
         | 
| 106 | 
            +
            - content/shared/js/libs/jquery.min.js
         | 
| 107 | 
            +
            - content/shared/sass/_home.sass
         | 
| 108 | 
            +
            - content/shared/sass/_ie.sass
         | 
| 109 | 
            +
            - content/shared/sass/_print.sass
         | 
| 110 | 
            +
            - content/shared/sass/_responsive.sass
         | 
| 111 | 
            +
            - content/shared/sass/_shared.sass
         | 
| 112 | 
            +
            - content/shared/sass/all.scss
         | 
| 113 | 
            +
            - content/shared/templates/_footer.html
         | 
| 114 | 
            +
            - content/shared/templates/_header.html
         | 
| 115 | 
            +
            - content/shared/templates/index.html.erb
         | 
| 116 | 
            +
            - content/templates/capucine.yaml
         | 
| 117 | 
            +
            - content/templates/cmd_help.txt
         | 
| 118 | 
            +
            - content/templates/compass_config.erb
         | 
| 119 | 
            +
            - lib/capucine.rb
         | 
| 120 | 
            +
            - lib/coffeescript.rb
         | 
| 121 | 
            +
            - lib/commands.rb
         | 
| 122 | 
            +
            - lib/compass-sass.rb
         | 
| 123 | 
            +
            - lib/incloudr.rb
         | 
| 124 | 
            +
            - lib/settings.rb
         | 
| 125 | 
            +
            - lib/templates.rb
         | 
| 126 | 
            +
            - lib/tools.rb
         | 
| 127 | 
            +
            - lib/watch.rb
         | 
| 128 | 
            +
            - bin/capucine
         | 
| 129 | 
            +
            homepage: http://dln.name
         | 
| 130 | 
            +
            licenses: []
         | 
| 131 | 
            +
            post_install_message: 
         | 
| 132 | 
            +
            rdoc_options: []
         | 
| 133 | 
            +
            require_paths:
         | 
| 134 | 
            +
            - lib
         | 
| 135 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 136 | 
            +
              none: false
         | 
| 137 | 
            +
              requirements:
         | 
| 138 | 
            +
              - - ! '>='
         | 
| 139 | 
            +
                - !ruby/object:Gem::Version
         | 
| 140 | 
            +
                  version: '0'
         | 
| 141 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 142 | 
            +
              none: false
         | 
| 143 | 
            +
              requirements:
         | 
| 144 | 
            +
              - - ! '>='
         | 
| 145 | 
            +
                - !ruby/object:Gem::Version
         | 
| 146 | 
            +
                  version: '0'
         | 
| 147 | 
            +
            requirements: []
         | 
| 148 | 
            +
            rubyforge_project: 
         | 
| 149 | 
            +
            rubygems_version: 1.8.11
         | 
| 150 | 
            +
            signing_key: 
         | 
| 151 | 
            +
            specification_version: 3
         | 
| 152 | 
            +
            summary: .
         | 
| 153 | 
            +
            test_files: []
         |