Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #15 from jfoley/fix_generate

Fix deploy:generate task
  • Loading branch information...
commit 2913a97f7040b9a5de0a6ac13bb138c9e582ad0c 2 parents 187803b + 97b067c
@mustardamus mustardamus authored
View
132 app/jqapi.rb
@@ -1,82 +1,84 @@
require 'bundler'; Bundler.require
-class Jqapi < Sinatra::Base
- set :root, File.join(File.dirname(__FILE__), '..')
- set :views, File.join(root, 'app/views')
- set :sprockets, Sprockets::Environment.new(root)
- set :precompile, [/\w+\.(?!js|css).+/, /bundle.(css|js)$/]
- set :assets_prefix, 'assets'
- set :assets_path, File.join(root, 'public', assets_prefix)
-
- asset_paths = [
- 'app/assets/javascripts',
- 'app/assets/stylesheets',
- 'app/assets/images',
- 'vendor/assets/javascripts',
- 'vendor/assets/stylesheets',
- 'vendor/assets/images'
- ]
-
- configure do
- asset_paths.each do |path|
- sprockets.append_path(File.join(root, path))
+module Jqapi
+ ASSET_PATHS = [
+ 'app/assets/javascripts',
+ 'app/assets/stylesheets',
+ 'app/assets/images',
+ 'vendor/assets/javascripts',
+ 'vendor/assets/stylesheets',
+ 'vendor/assets/images'
+ ].freeze
+
+ class Server < Sinatra::Base
+ set :root, File.join(File.dirname(__FILE__), '..')
+ set :views, File.join(root, 'app/views')
+ set :sprockets, Sprockets::Environment.new(root)
+ set :precompile, [/\w+\.(?!js|css).+/, /bundle.(css|js)$/]
+ set :assets_prefix, 'assets'
+ set :assets_path, File.join(root, 'public', assets_prefix)
+
+ configure do
+ ASSET_PATHS.each do |path|
+ sprockets.append_path(File.join(root, path))
+ end
end
- end
- before do
- content_type :json
- end
-
- get '/docs/categories.json' do
- serve_file('docs', 'categories.json')
- end
+ before do
+ content_type :json
+ end
- get '/docs/index.json' do
- serve_file('docs', 'index.json')
- end
+ get '/docs/categories.json' do
+ serve_file('docs', 'categories.json')
+ end
- get '/docs/versions.json' do
- serve_file('docs', 'versions.json')
- end
+ get '/docs/index.json' do
+ serve_file('docs', 'index.json')
+ end
- get '/docs/entries/*.json' do
- serve_file('docs/entries', "#{params[:splat][0]}.json")
- end
+ get '/docs/versions.json' do
+ serve_file('docs', 'versions.json')
+ end
- get 'resources/*.png' do
- content_type 'image/png'
- serve_file('docs/resources', "#{params[:splat][0]}.png")
- end
+ get '/docs/entries/*.json' do
+ serve_file('docs/entries', "#{params[:splat][0]}.json")
+ end
- get 'resources/*.jpg' do
- content_type 'image/jpeg'
- serve_file('docs/resources', "#{params[:splat][0]}.jpg")
- end
+ get 'resources/*.png' do
+ content_type 'image/png'
+ serve_file('docs/resources', "#{params[:splat][0]}.png")
+ end
- get 'resources/*.gif' do
- content_type 'image/gif'
- serve_file('docs/resources', "#{params[:splat][0]}.gif")
- end
+ get 'resources/*.jpg' do
+ content_type 'image/jpeg'
+ serve_file('docs/resources', "#{params[:splat][0]}.jpg")
+ end
- get 'LICENSE' do
- content_type 'text'
- serve_file('', 'LICENSE')
- end
+ get 'resources/*.gif' do
+ content_type 'image/gif'
+ serve_file('docs/resources', "#{params[:splat][0]}.gif")
+ end
- get '/' do
- content_type :html
- haml :index
- end
+ get 'LICENSE' do
+ content_type 'text'
+ serve_file('', 'LICENSE')
+ end
+
+ get '/' do
+ content_type :html
+ haml :index
+ end
- private
- def serve_file(path, filename)
- filepath = File.join(settings.root, path, filename)
+ private
+ def serve_file(path, filename)
+ filepath = File.join(settings.root, path, filename)
- if File.exists?(filepath)
- File.open(filepath).read
- else
- 404
+ if File.exists?(filepath)
+ File.open(filepath).read
+ else
+ 404
+ end
end
end
-end
+end
View
6 config.ru
@@ -1,9 +1,9 @@
require "#{File.dirname(__FILE__)}/app/jqapi.rb"
map '/assets' do
- run Jqapi.sprockets
+ run Jqapi::Server.sprockets
end
map '/' do
- run Jqapi
-end
+ run Jqapi::Server
+end
View
38 tasks/deploy.thor
@@ -1,31 +1,18 @@
-require 'bundler'
-Bundler.require
-
class Deploy < Thor
desc 'generate', 'copys all documentation files and the framework, minifies css and js'
+
def generate
- sprockets = Sprockets::Environment.new('')
+ sprockets = Sprockets::Environment.new('')
deploy_path = 'public'
assets_path = "#{deploy_path}/assets"
- asset_paths = [ # todo: move that to a seperate file, dev server is unsing this too
- 'app/assets/javascripts',
- 'app/assets/stylesheets',
- 'app/assets/images',
- 'vendor/assets/javascripts',
- 'vendor/assets/stylesheets',
- 'vendor/assets/images'
- ]
-
- configure do
- asset_paths.each do |path|
- sprockets.append_path(path)
- end
+ Jqapi::ASSET_PATHS.each do |path|
+ sprockets.append_path(path)
end
unless File.directory?(deploy_path)
- Dir.mkdir(deploy_path)
- Dir.mkdir(assets_path)
+ Dir.mkdir(deploy_path)
+ Dir.mkdir(assets_path)
end
sprockets.find_asset('bundle.css').write_to "#{assets_path}/bundle.css"
@@ -35,10 +22,10 @@ class Deploy < Thor
puts "Generated (and minified) bundle.js"
sprockets.find_asset('jquery.js').write_to "#{assets_path}/jquery.js"
- puts "Keep a copy of jquery.js for offline demos"
+ puts "Keep a copy of jquery.js for offline demos"
FileUtils.rm_rf "#{deploy_path}/docs"
- FileUtils.cp_r 'docs', "#{deploy_path}/"
+ FileUtils.cp_r 'docs', "#{deploy_path}/"
puts 'Copied docs directory'
FileUtils.rm_rf "#{deploy_path}/resources"
@@ -46,10 +33,9 @@ class Deploy < Thor
puts 'Copied resources directory' # you like to juggle?
%x[cp -r app/assets/images/** #{assets_path}/]
- #%x[cp -r vendor/assets/images/** #{assets_path}/]
puts 'Copied images'
- index_haml = File.read("app/views/index.haml")
+ index_haml = File.read("app/views/index.haml")
index_markup = Haml::Engine.new(index_haml).render
File.open("#{deploy_path}/index.html", 'w').write(index_markup)
@@ -59,10 +45,11 @@ class Deploy < Thor
puts "Copied License File"
FileUtils.cp 'README.md', "#{deploy_path}/"
- puts "Copied Readme File"
+ puts "Copied Readme File"
end
desc 'pack', 'creates a .zip of the standalone version, saved to public/'
+
def pack
FileUtils.rm_f 'public/jqapi.zip'
%x[cd public/ && zip -r jqapi.zip .]
@@ -70,10 +57,11 @@ class Deploy < Thor
end
desc 'air', 'builds a AIR application wrapper, saved to public/'
+
def air
puts "Build AIR wrapper..."
puts "Cert password: "
%x[adt -package -storetype pkcs12 -keystore air/jqapi.cert -target air public/jqapi.air air/application.xml -C ./ public/assets public/docs public/resources public/index.html public/LICENSE app/assets/images air/loader.html]
puts "Done."
end
-end
+end
View
7 tasks/documentation.thor
@@ -1,8 +1,3 @@
-require 'bundler'
-Bundler.require
-
-ROOT_DIR = File.join(File.dirname(__FILE__), '..')
-
class Docs < Thor
desc 'download', 'pull the official documentation from github'
def download
@@ -292,4 +287,4 @@ class Docs < Thor
puts 'Generated index.json'
end
-end
+end
View
9 tasks/requires.thor
@@ -0,0 +1,9 @@
+# HORRIBLE HACK ALERT
+# This file is loaded and parsed every time thor is invoked
+# meaning all other .thor files are implicitly dependent on it.
+# Gross, but it works.
+
+ROOT_DIR = File.join(File.dirname(__FILE__), '..')
+$LOAD_PATH.unshift(File.join(ROOT_DIR, 'app'))
+
+require 'jqapi'
Please sign in to comment.
Something went wrong with that request. Please try again.