diff --git a/README.md b/README.md index 7376226..47428c6 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,31 @@ -# Sprockets::Assistant +# Sprockets Assistant -TODO: Write a gem description - -## Installation - -Add this line to your application's Gemfile: - - gem 'sprockets-assistant' - -And then execute: - - $ bundle - -Or install it yourself as: - - $ gem install sprockets-assistant +An upgraded `Sprockets::Secretary`. A simple way to let me build little libraries and widgets and +things for various projects, while still taking advantage of all the Sprockets libraries and goodness +that I use elsewhere. ## Usage -TODO: Write usage instructions here + gem install sprockets-assistant + sprockets-assistant create my_project + cd my_project + bundle exec sprockets-assistant -## Contributing +This starts a server on localhost:8080. Hack away. + +## `assistant_config.rb` + +Prett simple DSL: + +### `middleware` + +Define a middleware stack. + +### `app` + +This is the guts of a `Sinatra::Base` app. + +### `compile` + +A list of files to compile with `sprockets-assistant compile`. -1. Fork it -2. Create your feature branch (`git checkout -b my-new-feature`) -3. Commit your changes (`git commit -am 'Added some feature'`) -4. Push to the branch (`git push origin my-new-feature`) -5. Create new Pull Request diff --git a/lib/sprockets-assistant.rb b/lib/sprockets-assistant.rb index f2c0bce..e69de29 100644 --- a/lib/sprockets-assistant.rb +++ b/lib/sprockets-assistant.rb @@ -1 +0,0 @@ -require "sprockets/assistant" diff --git a/lib/sprockets/assistant.rb b/lib/sprockets/assistant.rb deleted file mode 100644 index 0da8391..0000000 --- a/lib/sprockets/assistant.rb +++ /dev/null @@ -1,6 +0,0 @@ -module Sprockets - module Assistant - - end -end - diff --git a/lib/sprockets/assistant/app_builder.rb b/lib/sprockets/assistant/app_builder.rb index 092706e..e2d2007 100644 --- a/lib/sprockets/assistant/app_builder.rb +++ b/lib/sprockets/assistant/app_builder.rb @@ -6,8 +6,10 @@ require 'sprockets/assistant/compiler' module Sprockets module Assistant class AppBuilder + ASSISTANT_CONFIG_FILE = Pathname('assistant_config.rb') + def initialize - instance_eval(File.read('assistant_config.rb')) + instance_eval(ASSISTANT_CONFIG_FILE.read) end def app(&block) diff --git a/lib/sprockets/assistant/cli.rb b/lib/sprockets/assistant/cli.rb index bd8778b..6653f81 100644 --- a/lib/sprockets/assistant/cli.rb +++ b/lib/sprockets/assistant/cli.rb @@ -1,4 +1,3 @@ -require 'sprockets/assistant/server' require 'rack' require 'thor' @@ -10,18 +9,28 @@ module Sprockets desc "server", "server" def server + require 'sprockets/assistant/server' + Rack::Handler.default.run(Sprockets::Assistant::Server.app) end desc "compile", "compile things" def compile + require 'sprockets/assistant/app_builder' + Sprockets::Assistant::AppBuilder.new.compile end desc "create NAME", "initialize a new assistant project" def create(name) directory 'skel', name + + Dir.chdir(name) do + Bundler.with_clean_env { system %{bundle} } + end end + + default_task :server end end end diff --git a/lib/sprockets/assistant/compass.rb b/lib/sprockets/assistant/compass.rb new file mode 100644 index 0000000..d63a79d --- /dev/null +++ b/lib/sprockets/assistant/compass.rb @@ -0,0 +1,12 @@ +module Sprockets + module Assistant + class Compass + require 'compass' + + ::Compass.configuration do |c| + c.images_path = 'assets/images' + end + end + end +end + diff --git a/lib/sprockets/assistant/compiler.rb b/lib/sprockets/assistant/compiler.rb index ac2598d..3e48018 100644 --- a/lib/sprockets/assistant/compiler.rb +++ b/lib/sprockets/assistant/compiler.rb @@ -2,6 +2,8 @@ require 'sprockets' require 'sprockets-vendor_gems/extend_all' require 'pathname' require 'sprockets/assistant/output' +require 'sprockets-sass' +require 'sprockets/assistant/compass' module Sprockets module Assistant @@ -16,6 +18,10 @@ module Sprockets end def compile + ::Compass.configuration do |c| + c.output_style = :compressed + end + @env = Sprockets::Environment.new @env.append_path('assets/javascripts') @env.append_path('assets/stylesheets') diff --git a/lib/sprockets/assistant/server.rb b/lib/sprockets/assistant/server.rb index e3648f1..5447704 100644 --- a/lib/sprockets/assistant/server.rb +++ b/lib/sprockets/assistant/server.rb @@ -9,6 +9,8 @@ module Sprockets def initialize require 'sprockets/assistant/app_builder' + require 'sprockets-sass' + require 'sprockets/assistant/compass' @app_builder = AppBuilder.new end @@ -27,8 +29,6 @@ module Sprockets instance_eval(&_app_builder.middleware) map "/#{Sinatra::Sprockets.config.prefix}" do - $stderr.puts Sinatra::Sprockets.environment.inspect - run Sinatra::Sprockets.environment end diff --git a/skel/Gemfile b/skel/Gemfile index 95bbfc0..769efc6 100644 --- a/skel/Gemfile +++ b/skel/Gemfile @@ -1,5 +1,10 @@ +source :rubygems + gem 'sprockets-assistant' +gem 'jquery-rails', :require => nil gem 'thin' gem 'compass' +# haml.js +# gem 'cshaml-sprockets' diff --git a/skel/assistant_config.rb b/skel/assistant_config.rb index 573be8c..198bb22 100644 --- a/skel/assistant_config.rb +++ b/skel/assistant_config.rb @@ -1,3 +1,6 @@ +# haml +# require 'cshaml-sprockets' + middleware do # use Rack::LiveReload end diff --git a/sprockets-assistant.gemspec b/sprockets-assistant.gemspec index ac43262..4770c82 100644 --- a/sprockets-assistant.gemspec +++ b/sprockets-assistant.gemspec @@ -4,8 +4,8 @@ require File.expand_path('../lib/sprockets/assistant/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["John Bintz"] gem.email = ["john@coswellproductions.com"] - gem.description = %q{TODO: Write a gem description} - gem.summary = %q{TODO: Write a gem summary} + gem.description = %q{A modern replacement for Sprockets::Secretary.} + gem.summary = %q{A modern replacement for Sprockets::Secretary.} gem.homepage = "" gem.files = `git ls-files`.split($\) @@ -20,6 +20,8 @@ Gem::Specification.new do |gem| gem.add_dependency 'sinatra-sprockets-ext' gem.add_dependency 'coffee-script' gem.add_dependency 'sass' + gem.add_dependency 'compass' gem.add_dependency 'sprockets-vendor_gems' + gem.add_dependency 'sprockets-sass' end