high_five 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/.gitignore +2 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +52 -0
- data/Rakefile +1 -0
- data/bin/hi5 +20 -0
- data/high_five.gemspec +25 -0
- data/lib/.DS_Store +0 -0
- data/lib/high_five/cli.rb +44 -0
- data/lib/high_five/config.rb +90 -0
- data/lib/high_five/deploy_task.rb +185 -0
- data/lib/high_five/init_task.rb +23 -0
- data/lib/high_five/version.rb +3 -0
- data/lib/high_five.rb +6 -0
- data/spec/init_spec.rb +26 -0
- data/spec/spec_helper.rb +19 -0
- data/template/config/high_five/app-common.js +4 -0
- data/template/config/high_five/app-platform.js +2 -0
- data/template/config/high_five/index.html.erb +26 -0
- data/template/config/high_five.rb +23 -0
- metadata +151 -0
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.ruby-gemset
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            high_five
         | 
    
        data/.ruby-version
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            1.9.3
         | 
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,52 @@ | |
| 1 | 
            +
            PATH
         | 
| 2 | 
            +
              remote: .
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                high_five (0.0.1)
         | 
| 5 | 
            +
                  compass (~> 0.12.2)
         | 
| 6 | 
            +
                  sprockets (~> 2.9.0)
         | 
| 7 | 
            +
                  thor (~> 0.17.0)
         | 
| 8 | 
            +
                  yui-compressor (~> 0.9.6)
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            GEM
         | 
| 11 | 
            +
              remote: https://rubygems.org/
         | 
| 12 | 
            +
              specs:
         | 
| 13 | 
            +
                POpen4 (0.1.4)
         | 
| 14 | 
            +
                  Platform (>= 0.4.0)
         | 
| 15 | 
            +
                  open4
         | 
| 16 | 
            +
                Platform (0.4.0)
         | 
| 17 | 
            +
                chunky_png (1.2.7)
         | 
| 18 | 
            +
                compass (0.12.2)
         | 
| 19 | 
            +
                  chunky_png (~> 1.2)
         | 
| 20 | 
            +
                  fssm (>= 0.2.7)
         | 
| 21 | 
            +
                  sass (~> 3.1)
         | 
| 22 | 
            +
                diff-lcs (1.2.1)
         | 
| 23 | 
            +
                fssm (0.2.10)
         | 
| 24 | 
            +
                hike (1.2.1)
         | 
| 25 | 
            +
                multi_json (1.7.2)
         | 
| 26 | 
            +
                open4 (1.3.0)
         | 
| 27 | 
            +
                rack (1.5.2)
         | 
| 28 | 
            +
                rspec (2.13.0)
         | 
| 29 | 
            +
                  rspec-core (~> 2.13.0)
         | 
| 30 | 
            +
                  rspec-expectations (~> 2.13.0)
         | 
| 31 | 
            +
                  rspec-mocks (~> 2.13.0)
         | 
| 32 | 
            +
                rspec-core (2.13.1)
         | 
| 33 | 
            +
                rspec-expectations (2.13.0)
         | 
| 34 | 
            +
                  diff-lcs (>= 1.1.3, < 2.0)
         | 
| 35 | 
            +
                rspec-mocks (2.13.0)
         | 
| 36 | 
            +
                sass (3.2.7)
         | 
| 37 | 
            +
                sprockets (2.9.0)
         | 
| 38 | 
            +
                  hike (~> 1.2)
         | 
| 39 | 
            +
                  multi_json (~> 1.0)
         | 
| 40 | 
            +
                  rack (~> 1.0)
         | 
| 41 | 
            +
                  tilt (~> 1.1, != 1.3.0)
         | 
| 42 | 
            +
                thor (0.17.0)
         | 
| 43 | 
            +
                tilt (1.3.6)
         | 
| 44 | 
            +
                yui-compressor (0.9.6)
         | 
| 45 | 
            +
                  POpen4 (>= 0.1.4)
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            PLATFORMS
         | 
| 48 | 
            +
              ruby
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            DEPENDENCIES
         | 
| 51 | 
            +
              high_five!
         | 
| 52 | 
            +
              rspec (~> 2.13.0)
         | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            require "bundler/gem_tasks"
         | 
    
        data/bin/hi5
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            # resolve bin path, ignoring symlinks
         | 
| 3 | 
            +
            require "pathname"
         | 
| 4 | 
            +
            bin_file = Pathname.new(__FILE__).realpath
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # add self to libpath
         | 
| 7 | 
            +
            $:.unshift File.expand_path("../../lib", bin_file)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            begin
         | 
| 10 | 
            +
              require 'high_five'
         | 
| 11 | 
            +
            rescue LoadError
         | 
| 12 | 
            +
              require 'rubygems'
         | 
| 13 | 
            +
              require 'high_five'
         | 
| 14 | 
            +
            end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            require 'high_five/cli'
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            HighFive::ROOT = Dir.pwd
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            HighFive::Cli.start
         | 
    
        data/high_five.gemspec
    ADDED
    
    | @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
            $:.push File.expand_path("../lib", __FILE__)
         | 
| 3 | 
            +
            require "high_five/version"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem::Specification.new do |s|
         | 
| 6 | 
            +
              s.name        = "high_five"
         | 
| 7 | 
            +
              s.version     = HighFive::VERSION
         | 
| 8 | 
            +
              s.platform    = Gem::Platform::RUBY
         | 
| 9 | 
            +
              s.authors     = ["Brian Samson"]
         | 
| 10 | 
            +
              s.email       = ["brian@tenforwardconsulting.com"]
         | 
| 11 | 
            +
              s.homepage    = "http://github.com/tenforwardconsulting/high_five"
         | 
| 12 | 
            +
              s.summary     = %q{HighFive is a set of build scripts and tools for packing HTML5 apps both for the web and for phonegap}
         | 
| 13 | 
            +
              s.description = %q{Write a better description}
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              s.add_runtime_dependency "thor", "~>0.17.0"
         | 
| 16 | 
            +
              s.add_runtime_dependency "compass", "~>0.12.2"
         | 
| 17 | 
            +
              s.add_runtime_dependency "yui-compressor", "~>0.9.6"
         | 
| 18 | 
            +
              s.add_runtime_dependency "sprockets", "~>2.9.0"
         | 
| 19 | 
            +
              s.add_development_dependency "rspec", "~>2.13.0"
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              s.files         = `git ls-files`.split("\n")
         | 
| 22 | 
            +
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         | 
| 23 | 
            +
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         | 
| 24 | 
            +
              s.require_paths = ["lib"]
         | 
| 25 | 
            +
            end
         | 
    
        data/lib/.DS_Store
    ADDED
    
    | Binary file | 
| @@ -0,0 +1,44 @@ | |
| 1 | 
            +
            require 'thor'
         | 
| 2 | 
            +
            require 'high_five/deploy_task'
         | 
| 3 | 
            +
            require 'high_five/init_task'
         | 
| 4 | 
            +
            require 'high_five/config'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            module HighFive
         | 
| 7 | 
            +
              class Cli < Thor
         | 
| 8 | 
            +
                include Thor::Actions
         | 
| 9 | 
            +
                include HighFive::DeployTask
         | 
| 10 | 
            +
                include HighFive::InitTask
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                # source root path for Thor::Actions commands
         | 
| 13 | 
            +
                source_root(HighFive::TEMPLATE_PATH)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                desc "deploy", "Deploy the app for a specific platform in a specific environment"
         | 
| 16 | 
            +
                method_option :environment, :aliases => "-e", :desc => "Environemnt [production|development]", :default => "development"
         | 
| 17 | 
            +
                method_option :compress, :aliases => '-c', :desc => "Compress javascript [true]", :default => false
         | 
| 18 | 
            +
                method_option :weinre_url, :aliases => '-w', :desc => "Enter your Weinre server-url including port", :default => false
         | 
| 19 | 
            +
                method_option :"copy-files", :aliases => '-f', :desc => "Copy files to eclipse/xcode directory", :default => false
         | 
| 20 | 
            +
                def deploy(target)
         | 
| 21 | 
            +
                  self.source_paths << File.join(base_config.root)
         | 
| 22 | 
            +
                  deploy_task(target)
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                desc "init", "Initialize the high_five configuration in the current working directory"
         | 
| 26 | 
            +
                def init
         | 
| 27 | 
            +
                  init_task
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                def initialize(*args)
         | 
| 31 | 
            +
                  super(*args)
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                private
         | 
| 35 | 
            +
                def base_config
         | 
| 36 | 
            +
                  begin 
         | 
| 37 | 
            +
                    @base_config ||= HighFive::Config.load
         | 
| 38 | 
            +
                  rescue StandardError => e
         | 
| 39 | 
            +
                    say e.message, :red
         | 
| 40 | 
            +
                    exit
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
            end
         | 
| @@ -0,0 +1,90 @@ | |
| 1 | 
            +
            module HighFive
         | 
| 2 | 
            +
              class Config
         | 
| 3 | 
            +
                attr_accessor :root,         # Root of the project 
         | 
| 4 | 
            +
                  :destination,  # generated folder for project('www')
         | 
| 5 | 
            +
                  :page_title,   # <title>#{page_title}</title>
         | 
| 6 | 
            +
                  :meta,          # config.meta << { http-equiv: "Content-Type" content: "text/html; charset=utf-8" }
         | 
| 7 | 
            +
                  :static_assets,
         | 
| 8 | 
            +
                  :static_javascripts,
         | 
| 9 | 
            +
                  :static_stylesheets,
         | 
| 10 | 
            +
                  :sass_files
         | 
| 11 | 
            +
             | 
| 12 | 
            +
             | 
| 13 | 
            +
                def self.configure(&block) 
         | 
| 14 | 
            +
                  @@instance = HighFive::Config.new
         | 
| 15 | 
            +
                  yield @@instance
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                def self.load
         | 
| 19 | 
            +
                  begin
         | 
| 20 | 
            +
                    require File.join(HighFive::ROOT, "config", "high_five.rb")
         | 
| 21 | 
            +
                  rescue LoadError
         | 
| 22 | 
            +
                    raise "high_five configuration not found, forgot to run 'hi5 init'?"
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
                  return @@instance 
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                def build_platform_config(platform)
         | 
| 28 | 
            +
                  if @platform_configs[platform.to_s]
         | 
| 29 | 
            +
                    new_config = HighFive::Config.new(@platform_configs[platform.to_s])
         | 
| 30 | 
            +
                    new_config.root ||= self.root
         | 
| 31 | 
            +
                    new_config.destination ||= self.destination
         | 
| 32 | 
            +
                    new_config.meta ||= self.meta
         | 
| 33 | 
            +
                    new_config.page_title ||= self.page_title
         | 
| 34 | 
            +
                    new_config.static_assets += self.static_assets
         | 
| 35 | 
            +
                    new_config.static_javascripts += self.static_javascripts
         | 
| 36 | 
            +
                    new_config.static_stylesheets += self.static_stylesheets
         | 
| 37 | 
            +
                    new_config.sass_files += self.sass_files
         | 
| 38 | 
            +
                    return new_config
         | 
| 39 | 
            +
                  else
         | 
| 40 | 
            +
                    return self
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                def initialize(config=nil)
         | 
| 45 | 
            +
                  if config
         | 
| 46 | 
            +
                    @static_assets = config.static_assets.dup
         | 
| 47 | 
            +
                    @static_javascripts = config.static_javascripts.dup
         | 
| 48 | 
            +
                    @static_stylesheets = config.static_stylesheets.dup
         | 
| 49 | 
            +
                    @sass_files = config.sass_files.dup
         | 
| 50 | 
            +
                    @meta = config.meta.dup
         | 
| 51 | 
            +
                    self.root = config.root
         | 
| 52 | 
            +
                    self.destination = config.destination
         | 
| 53 | 
            +
                    self.page_title = config.page_title
         | 
| 54 | 
            +
                    self.meta = config.meta
         | 
| 55 | 
            +
                  else
         | 
| 56 | 
            +
                    @static_assets = []
         | 
| 57 | 
            +
                    @static_javascripts = []
         | 
| 58 | 
            +
                    @static_stylesheets = []
         | 
| 59 | 
            +
                    @sass_files = []
         | 
| 60 | 
            +
                    @meta = {}
         | 
| 61 | 
            +
                    @platform_configs = {}
         | 
| 62 | 
            +
                  end
         | 
| 63 | 
            +
                end 
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                def assets(path)
         | 
| 66 | 
            +
                  @static_assets << path.dup
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                def javascripts(path)
         | 
| 70 | 
            +
                  @static_javascripts << path.dup
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                def sass(path) 
         | 
| 74 | 
            +
                  @sass_files << path.dup
         | 
| 75 | 
            +
                end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                def compass(config_file)
         | 
| 78 | 
            +
                  @compass_configs << config_file.dup
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                def stylesheets(path)
         | 
| 82 | 
            +
                  @static_stylesheets << path.dup
         | 
| 83 | 
            +
                end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                def platform(name, &block)
         | 
| 86 | 
            +
                  @platform_configs[name.to_s] = HighFive::Config.new
         | 
| 87 | 
            +
                  yield @platform_configs[name.to_s]
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
              end
         | 
| 90 | 
            +
            end
         | 
| @@ -0,0 +1,185 @@ | |
| 1 | 
            +
            require 'sprockets'
         | 
| 2 | 
            +
            require 'sass'
         | 
| 3 | 
            +
            module HighFive
         | 
| 4 | 
            +
              module DeployTask 
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                def deploy_task(target)
         | 
| 7 | 
            +
                  @environment  = options[:environment]
         | 
| 8 | 
            +
                  @platform     = target
         | 
| 9 | 
            +
                  @weinre_url   = options[:weinre_url]
         | 
| 10 | 
            +
                  @copy_files   = options[:"copy-files"]
         | 
| 11 | 
            +
                  @meta         = {}
         | 
| 12 | 
            +
                  config = base_config.build_platform_config(@platform)
         | 
| 13 | 
            +
                  @config_root = File.join("config", "high_five")
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  self.source_paths << File.join(base_config.root, @config_root)
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  raise "Please set config.destination" if config.destination.nil?
         | 
| 18 | 
            +
                  self.destination_root = config.destination
         | 
| 19 | 
            +
                  FileUtils.rm_rf(self.destination_root)
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  #todo add to config
         | 
| 22 | 
            +
                  say "Deploying app: <#{@platform}> <#{options[:environment]}>"
         | 
| 23 | 
            +
                  say "\t#{self.destination_root}"
         | 
| 24 | 
            +
                  say " -Weinre url: #{@weinre_url}" if @weinre_url
         | 
| 25 | 
            +
             | 
| 26 | 
            +
             | 
| 27 | 
            +
                  #todo customize this
         | 
| 28 | 
            +
                  # Dir.chdir File.join("assets", "sass")
         | 
| 29 | 
            +
                  # success = false
         | 
| 30 | 
            +
                  # if @environment == "production"
         | 
| 31 | 
            +
                  #   success = system("compass compile --force --no-debug-info -e production #{options[:platform]}.scss")
         | 
| 32 | 
            +
                  # else
         | 
| 33 | 
            +
                  #   success = system("compass compile --force --no-debug-info #{options[:platform]}.scss")
         | 
| 34 | 
            +
                  # end
         | 
| 35 | 
            +
                  # unless success
         | 
| 36 | 
            +
                  #   raise "Error compiling CSS, aborting build"
         | 
| 37 | 
            +
                  # end
         | 
| 38 | 
            +
                  # Dir.chdir pwd
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  # Build javascript
         | 
| 41 | 
            +
                  # inside "assets" do |assets|
         | 
| 42 | 
            +
                  #   directory "images"
         | 
| 43 | 
            +
                  #   directory "stylesheets"
         | 
| 44 | 
            +
                  #   inside "javascripts" do |dir|
         | 
| 45 | 
            +
                  #     if @compress == true
         | 
| 46 | 
            +
                  #       build_javascript :from => "app-#{@platform}", :to => 'app-all.js'
         | 
| 47 | 
            +
                  #       compress_javascript "app-all.js"
         | 
| 48 | 
            +
                  #     else      
         | 
| 49 | 
            +
                  #       bundle = builder.find_asset "app-#{@platform}"
         | 
| 50 | 
            +
                  #       @js_files = bundle.dependencies.map {|asset| File.join("assets",  asset.logical_path) }
         | 
| 51 | 
            +
                  #       copy_file "app.js"
         | 
| 52 | 
            +
                  #       directory "app"
         | 
| 53 | 
            +
                  #       directory "config"
         | 
| 54 | 
            +
                  #       directory "lib"
         | 
| 55 | 
            +
                  #       directory "platform/phonegap" unless @platform == 'web'
         | 
| 56 | 
            +
                  #       directory "platform/#{@platform}"
         | 
| 57 | 
            +
                  #     end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                  #   end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                  # Bundle is based on the provided build platformx
         | 
| 62 | 
            +
                  platform_file = File.join(@config_root, "app-#{@platform}.js")
         | 
| 63 | 
            +
                  unless File.exists? platform_file
         | 
| 64 | 
            +
                    error "#{@platform} is not a valid target.  Please create app-#{@platform}.js"
         | 
| 65 | 
            +
                  end
         | 
| 66 | 
            +
                  bundle = builder.find_asset platform_file
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                  if (@environment == "production")
         | 
| 69 | 
            +
                    appjs = File.join(self.destination_root, "app.js")
         | 
| 70 | 
            +
                    @javascripts = ["app.js"]
         | 
| 71 | 
            +
                    say "      create  #{appjs}", :green
         | 
| 72 | 
            +
                    bundle.write_to(appjs)
         | 
| 73 | 
            +
                  else
         | 
| 74 | 
            +
                    # Add each of the javascript files to the generated folder
         | 
| 75 | 
            +
                    @javascripts = bundle.dependencies.map do |asset| 
         | 
| 76 | 
            +
                      copy_file asset.logical_path
         | 
| 77 | 
            +
                      asset.logical_path
         | 
| 78 | 
            +
                    end
         | 
| 79 | 
            +
                  end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                  # Adds each of the static javascripts
         | 
| 82 | 
            +
                  config.static_javascripts.each do |javascript|
         | 
| 83 | 
            +
                    if File.directory? javascript
         | 
| 84 | 
            +
                      directory javascript
         | 
| 85 | 
            +
                      @javascripts.unshift(*Dir[File.join(javascript,'**','*.js')])
         | 
| 86 | 
            +
                    else
         | 
| 87 | 
            +
                      copy_file javascript unless javascript =~ /^https?:\/\// 
         | 
| 88 | 
            +
                      @javascripts.unshift javascript
         | 
| 89 | 
            +
                    end
         | 
| 90 | 
            +
                  end
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                  @stylesheets = []
         | 
| 93 | 
            +
                  p "SASS = #{config.sass_files}"
         | 
| 94 | 
            +
                  config.sass_files.each do |sass_file|
         | 
| 95 | 
            +
                    asset_name = File.basename(sass_file, File.extname(sass_file)) 
         | 
| 96 | 
            +
                    css_file = File.join(self.destination_root, "stylesheets", "#{asset_name}.css")
         | 
| 97 | 
            +
                    say "Compiling #{sass_file} -> #{css_file}"
         | 
| 98 | 
            +
                    Sass.compile_file sass_file, css_file
         | 
| 99 | 
            +
                    @stylesheets.push sass_file
         | 
| 100 | 
            +
                  end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                  config.static_stylesheets.each do |stylesheet|
         | 
| 103 | 
            +
                    if File.directory? stylesheet
         | 
| 104 | 
            +
                      directory stylesheet
         | 
| 105 | 
            +
                      @stylesheets.unshift(*Dir[File.join(stylesheet,'**','*.css')])
         | 
| 106 | 
            +
                    else
         | 
| 107 | 
            +
                      copy_file stylesheet
         | 
| 108 | 
            +
                      @stylesheets.unshift stylesheet
         | 
| 109 | 
            +
                    end
         | 
| 110 | 
            +
                  end
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                  # Adds each of the static assets to the generated folder (sylesheets etc)
         | 
| 113 | 
            +
                  config.static_assets.each do |asset|
         | 
| 114 | 
            +
                    if File.directory? asset
         | 
| 115 | 
            +
                      directory asset
         | 
| 116 | 
            +
                    else
         | 
| 117 | 
            +
                      copy_file asset
         | 
| 118 | 
            +
                    end
         | 
| 119 | 
            +
                  end
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                  #   inside "stylesheets" do |dir|
         | 
| 122 | 
            +
                  #     # Copy generated css
         | 
| 123 | 
            +
                  #     copy_file "#{@platform}.css", "theme.css"
         | 
| 124 | 
            +
                  #   end
         | 
| 125 | 
            +
                  # end
         | 
| 126 | 
            +
                    
         | 
| 127 | 
            +
                  # Build index.html
         | 
| 128 | 
            +
                  say "Generating index.html"
         | 
| 129 | 
            +
                  template File.join(@config_root, "index.html.erb"), File.join(self.destination_root, "index.html")
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                  # if (@copy_files) 
         | 
| 132 | 
            +
                  #   dest = nil
         | 
| 133 | 
            +
                  #   # copy to platform build directories
         | 
| 134 | 
            +
                  #   if (@platform == 'android')
         | 
| 135 | 
            +
                  #     dest = File.join(HighFive::ROOT, "..", "account_assistant-android/assets/www")
         | 
| 136 | 
            +
                  #   elsif (@platform == 'ios') 
         | 
| 137 | 
            +
                  #     dest = File.join(HighFive::ROOT, "..", "account_assistant-ios/www")
         | 
| 138 | 
            +
                  #   end
         | 
| 139 | 
            +
             | 
| 140 | 
            +
                  #   if (!dest.nil? && File.exists?(dest))
         | 
| 141 | 
            +
                  #     say "Copying to #{@platform} native project: #{dest}"
         | 
| 142 | 
            +
                  #     FileUtils.rm_rf(dest)
         | 
| 143 | 
            +
                  #     directory self.destination_root, dest
         | 
| 144 | 
            +
                  #   end
         | 
| 145 | 
            +
                  # end
         | 
| 146 | 
            +
                end
         | 
| 147 | 
            +
              
         | 
| 148 | 
            +
                private 
         | 
| 149 | 
            +
             | 
| 150 | 
            +
                def builder
         | 
| 151 | 
            +
                  @builder ||= get_builder
         | 
| 152 | 
            +
                end
         | 
| 153 | 
            +
             | 
| 154 | 
            +
                def get_builder
         | 
| 155 | 
            +
                  builder = Sprockets::Environment.new(File.join(HighFive::ROOT))
         | 
| 156 | 
            +
                  builder.append_path @config_root
         | 
| 157 | 
            +
                  builder.append_path "."
         | 
| 158 | 
            +
                  builder.append_path base_config.root
         | 
| 159 | 
            +
             | 
| 160 | 
            +
                  p builder.paths
         | 
| 161 | 
            +
                  builder
         | 
| 162 | 
            +
                end
         | 
| 163 | 
            +
             | 
| 164 | 
            +
                #TODO: this probably doesn't work on windows 
         | 
| 165 | 
            +
                def compress_javascript(file_name)
         | 
| 166 | 
            +
                  say " -Compressing #{file_name} with yuicompressor", :yellow
         | 
| 167 | 
            +
             | 
| 168 | 
            +
                  compressor = 'yuicompressor'
         | 
| 169 | 
            +
                  if `which yuicompressor`.empty?
         | 
| 170 | 
            +
                    compressor = 'yui-compressor'
         | 
| 171 | 
            +
                    if `which yui-compressor`.empty?
         | 
| 172 | 
            +
                      say "ERROR: you don't have a yuicompressor installed", :red
         | 
| 173 | 
            +
                      say " Are you sure yuicompressor is installed on your system?  Mac users, run this in console:", :red
         | 
| 174 | 
            +
                      say " $ brew install yuicompressor", :red
         | 
| 175 | 
            +
                      say " Ubuntu users: $sudo apt-get -y install yui-compressor", :red
         | 
| 176 | 
            +
                    end
         | 
| 177 | 
            +
                  end
         | 
| 178 | 
            +
                  cmd = "#{compressor} #{file_name} -o #{file_name}"
         | 
| 179 | 
            +
                  system(cmd)
         | 
| 180 | 
            +
                  unless $?.exitstatus == 0
         | 
| 181 | 
            +
                    say " ERROR: #{cmd}", :red
         | 
| 182 | 
            +
                  end
         | 
| 183 | 
            +
                end
         | 
| 184 | 
            +
              end
         | 
| 185 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            require 'fileutils'
         | 
| 2 | 
            +
            module HighFive
         | 
| 3 | 
            +
              module InitTask
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                def init_task
         | 
| 6 | 
            +
                  self.destination_root = HighFive::ROOT
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  inside "config" do
         | 
| 9 | 
            +
                    template("high_five.rb")
         | 
| 10 | 
            +
                    inside "high_five" do
         | 
| 11 | 
            +
                      copy_file "index.html.erb", :skip => true
         | 
| 12 | 
            +
                      copy_file "app-common.js", :skip => true
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                      #TODO make this a CLI argument
         | 
| 15 | 
            +
                      platforms = ["android", "ios"]
         | 
| 16 | 
            +
                      platforms.each do |platform|
         | 
| 17 | 
            +
                        copy_file "app-platform.js", "app-#{platform}.js", :skip => true
         | 
| 18 | 
            +
                      end
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
    
        data/lib/high_five.rb
    ADDED
    
    
    
        data/spec/init_spec.rb
    ADDED
    
    | @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'tmpdir'
         | 
| 3 | 
            +
            require 'fileutils'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            describe "InitTask" do 
         | 
| 6 | 
            +
              before :each do
         | 
| 7 | 
            +
                @original_dir = Dir.pwd
         | 
| 8 | 
            +
                @project_root = Dir.mktmpdir("hi5")
         | 
| 9 | 
            +
                Dir.chdir @project_root
         | 
| 10 | 
            +
                HighFive::ROOT = @project_root
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              after :each do
         | 
| 14 | 
            +
                Dir.chdir @original_dir
         | 
| 15 | 
            +
                FileUtils.rm_rf @project_root
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              it "should create high_five.rb in the config directory" do
         | 
| 19 | 
            +
                HighFive::Cli.start(["init"])
         | 
| 20 | 
            +
                Dir.exists?(File.join(@project_root, "config")).should be_true
         | 
| 21 | 
            +
                File.exists?(File.join(@project_root, "config", "high_five.rb")).should be_true
         | 
| 22 | 
            +
                Dir.exists?(File.join(@project_root, "config", "high_five")).should be_true
         | 
| 23 | 
            +
                File.exists?(File.join(@project_root, "config", "high_five", "app-common.js")).should be_true
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            require "high_five"
         | 
| 2 | 
            +
            require 'high_five/cli'
         | 
| 3 | 
            +
            # This file was generated by the `rspec --init` command. Conventionally, all
         | 
| 4 | 
            +
            # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
         | 
| 5 | 
            +
            # Require this file using `require "spec_helper"` to ensure that it is only
         | 
| 6 | 
            +
            # loaded once.
         | 
| 7 | 
            +
            #
         | 
| 8 | 
            +
            # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
         | 
| 9 | 
            +
            RSpec.configure do |config|
         | 
| 10 | 
            +
              config.treat_symbols_as_metadata_keys_with_true_values = true
         | 
| 11 | 
            +
              config.run_all_when_everything_filtered = true
         | 
| 12 | 
            +
              config.filter_run :focus
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              # Run specs in random order to surface order dependencies. If you find an
         | 
| 15 | 
            +
              # order dependency and want to debug it, you can fix the order by providing
         | 
| 16 | 
            +
              # the seed, which is printed after each run.
         | 
| 17 | 
            +
              #     --seed 1234
         | 
| 18 | 
            +
              config.order = 'random'
         | 
| 19 | 
            +
            end
         | 
| @@ -0,0 +1,4 @@ | |
| 1 | 
            +
            //This is where you define the javascripts you include and their include order for your app.
         | 
| 2 | 
            +
            //Only include app code that you want minified here, add library or remote scripts to config/high_five.rb
         | 
| 3 | 
            +
            //= require ../../javascripts/app.js
         | 
| 4 | 
            +
            //= require_tree ../../javascripts/app
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            <!doctype html>
         | 
| 2 | 
            +
            <html lang="en">
         | 
| 3 | 
            +
                <head>
         | 
| 4 | 
            +
                    <meta charset="utf-8">
         | 
| 5 | 
            +
                    <title><%= @meta[:title] %></title>
         | 
| 6 | 
            +
                    <meta name="description" content="<%= @meta[:description] %>" />
         | 
| 7 | 
            +
                    <% @stylesheets.each do |ss| -%>
         | 
| 8 | 
            +
                        <link rel="stylesheet" href="<%= ss %>" type="text/css" />
         | 
| 9 | 
            +
                    <% end -%>
         | 
| 10 | 
            +
                    <% if @platform != 'web' -%>
         | 
| 11 | 
            +
                        <% if @environment == 'development' -%>
         | 
| 12 | 
            +
                            <script type="text/javascript">
         | 
| 13 | 
            +
                                window.onerror = function(e,u,l) {
         | 
| 14 | 
            +
                                  alert("Error caught" + e + " " + u + ":" + l);
         | 
| 15 | 
            +
                                };
         | 
| 16 | 
            +
                            </script>
         | 
| 17 | 
            +
                        <% end -%>
         | 
| 18 | 
            +
                    <% end -%>
         | 
| 19 | 
            +
                    <%- @javascripts.each do |js| -%>
         | 
| 20 | 
            +
                        <script type="text/javascript" src="<%= js %>"></script>
         | 
| 21 | 
            +
                    <%- end -%>	
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                </head>
         | 
| 24 | 
            +
                <body></body>
         | 
| 25 | 
            +
            </html>
         | 
| 26 | 
            +
             | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            HighFive::Config.configure do |config|
         | 
| 2 | 
            +
              config.root = File.join(File.dirname(__FILE__), '..')
         | 
| 3 | 
            +
              config.destination = "www"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              # This will add the resources folder to all platforms (stylesheets etc.) 
         | 
| 6 | 
            +
              # config.assets "resources"
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              # Include javascript libraries
         | 
| 9 | 
            +
              # These get included before everything else in the app, and are *not* minified
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              # config.javascripts "http://maps.google.com/maps/api/js?sensor=true"
         | 
| 12 | 
            +
              # config.javascripts "lib/jquery-min.js"
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              # Configure plaform specific settings like this
         | 
| 15 | 
            +
              # config.platform :ios do |ios|
         | 
| 16 | 
            +
              #   ios.assets "resources/ios"
         | 
| 17 | 
            +
              #   ios.destination = "www-ios"
         | 
| 18 | 
            +
              # end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              # if you need platform-specific javascripts, 
         | 
| 21 | 
            +
              # simply create app-<platform>.js next too app.js
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,151 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: high_five
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
              prerelease: 
         | 
| 6 | 
            +
            platform: ruby
         | 
| 7 | 
            +
            authors:
         | 
| 8 | 
            +
            - Brian Samson
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
            date: 2013-03-28 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            +
              name: thor
         | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            +
                none: false
         | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - ~>
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: 0.17.0
         | 
| 22 | 
            +
              type: :runtime
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ~>
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: 0.17.0
         | 
| 30 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 31 | 
            +
              name: compass
         | 
| 32 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 33 | 
            +
                none: false
         | 
| 34 | 
            +
                requirements:
         | 
| 35 | 
            +
                - - ~>
         | 
| 36 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 37 | 
            +
                    version: 0.12.2
         | 
| 38 | 
            +
              type: :runtime
         | 
| 39 | 
            +
              prerelease: false
         | 
| 40 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            +
                none: false
         | 
| 42 | 
            +
                requirements:
         | 
| 43 | 
            +
                - - ~>
         | 
| 44 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            +
                    version: 0.12.2
         | 
| 46 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 47 | 
            +
              name: yui-compressor
         | 
| 48 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 | 
            +
                none: false
         | 
| 50 | 
            +
                requirements:
         | 
| 51 | 
            +
                - - ~>
         | 
| 52 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            +
                    version: 0.9.6
         | 
| 54 | 
            +
              type: :runtime
         | 
| 55 | 
            +
              prerelease: false
         | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                none: false
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ~>
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: 0.9.6
         | 
| 62 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 63 | 
            +
              name: sprockets
         | 
| 64 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                none: false
         | 
| 66 | 
            +
                requirements:
         | 
| 67 | 
            +
                - - ~>
         | 
| 68 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            +
                    version: 2.9.0
         | 
| 70 | 
            +
              type: :runtime
         | 
| 71 | 
            +
              prerelease: false
         | 
| 72 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                none: false
         | 
| 74 | 
            +
                requirements:
         | 
| 75 | 
            +
                - - ~>
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            +
                    version: 2.9.0
         | 
| 78 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 79 | 
            +
              name: rspec
         | 
| 80 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 81 | 
            +
                none: false
         | 
| 82 | 
            +
                requirements:
         | 
| 83 | 
            +
                - - ~>
         | 
| 84 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 85 | 
            +
                    version: 2.13.0
         | 
| 86 | 
            +
              type: :development
         | 
| 87 | 
            +
              prerelease: false
         | 
| 88 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 89 | 
            +
                none: false
         | 
| 90 | 
            +
                requirements:
         | 
| 91 | 
            +
                - - ~>
         | 
| 92 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 93 | 
            +
                    version: 2.13.0
         | 
| 94 | 
            +
            description: Write a better description
         | 
| 95 | 
            +
            email:
         | 
| 96 | 
            +
            - brian@tenforwardconsulting.com
         | 
| 97 | 
            +
            executables:
         | 
| 98 | 
            +
            - hi5
         | 
| 99 | 
            +
            extensions: []
         | 
| 100 | 
            +
            extra_rdoc_files: []
         | 
| 101 | 
            +
            files:
         | 
| 102 | 
            +
            - .gitignore
         | 
| 103 | 
            +
            - .rspec
         | 
| 104 | 
            +
            - .ruby-gemset
         | 
| 105 | 
            +
            - .ruby-version
         | 
| 106 | 
            +
            - Gemfile
         | 
| 107 | 
            +
            - Gemfile.lock
         | 
| 108 | 
            +
            - Rakefile
         | 
| 109 | 
            +
            - bin/hi5
         | 
| 110 | 
            +
            - high_five.gemspec
         | 
| 111 | 
            +
            - lib/.DS_Store
         | 
| 112 | 
            +
            - lib/high_five.rb
         | 
| 113 | 
            +
            - lib/high_five/cli.rb
         | 
| 114 | 
            +
            - lib/high_five/config.rb
         | 
| 115 | 
            +
            - lib/high_five/deploy_task.rb
         | 
| 116 | 
            +
            - lib/high_five/init_task.rb
         | 
| 117 | 
            +
            - lib/high_five/version.rb
         | 
| 118 | 
            +
            - spec/init_spec.rb
         | 
| 119 | 
            +
            - spec/spec_helper.rb
         | 
| 120 | 
            +
            - template/config/high_five.rb
         | 
| 121 | 
            +
            - template/config/high_five/app-common.js
         | 
| 122 | 
            +
            - template/config/high_five/app-platform.js
         | 
| 123 | 
            +
            - template/config/high_five/index.html.erb
         | 
| 124 | 
            +
            homepage: http://github.com/tenforwardconsulting/high_five
         | 
| 125 | 
            +
            licenses: []
         | 
| 126 | 
            +
            post_install_message: 
         | 
| 127 | 
            +
            rdoc_options: []
         | 
| 128 | 
            +
            require_paths:
         | 
| 129 | 
            +
            - lib
         | 
| 130 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 131 | 
            +
              none: false
         | 
| 132 | 
            +
              requirements:
         | 
| 133 | 
            +
              - - ! '>='
         | 
| 134 | 
            +
                - !ruby/object:Gem::Version
         | 
| 135 | 
            +
                  version: '0'
         | 
| 136 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 137 | 
            +
              none: false
         | 
| 138 | 
            +
              requirements:
         | 
| 139 | 
            +
              - - ! '>='
         | 
| 140 | 
            +
                - !ruby/object:Gem::Version
         | 
| 141 | 
            +
                  version: '0'
         | 
| 142 | 
            +
            requirements: []
         | 
| 143 | 
            +
            rubyforge_project: 
         | 
| 144 | 
            +
            rubygems_version: 1.8.25
         | 
| 145 | 
            +
            signing_key: 
         | 
| 146 | 
            +
            specification_version: 3
         | 
| 147 | 
            +
            summary: HighFive is a set of build scripts and tools for packing HTML5 apps both
         | 
| 148 | 
            +
              for the web and for phonegap
         | 
| 149 | 
            +
            test_files:
         | 
| 150 | 
            +
            - spec/init_spec.rb
         | 
| 151 | 
            +
            - spec/spec_helper.rb
         |