initial commit, still kinda hacking on it
This commit is contained in:
commit
d8e565524f
19
.gitignore
vendored
Normal file
19
.gitignore
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
*.gem
|
||||
*.rbc
|
||||
.bundle
|
||||
.config
|
||||
.yardoc
|
||||
Gemfile.lock
|
||||
InstalledFiles
|
||||
_yardoc
|
||||
coverage
|
||||
doc/
|
||||
lib/bundler/man
|
||||
pkg
|
||||
rdoc
|
||||
spec/reports
|
||||
test/tmp
|
||||
test/version_tmp
|
||||
tmp
|
||||
.sass-cache/
|
||||
|
4
Gemfile
Normal file
4
Gemfile
Normal file
@ -0,0 +1,4 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
# Specify your gem's dependencies in sprockets-assistant.gemspec
|
||||
gemspec
|
22
LICENSE
Normal file
22
LICENSE
Normal file
@ -0,0 +1,22 @@
|
||||
Copyright (c) 2012 John Bintz
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
29
README.md
Normal file
29
README.md
Normal file
@ -0,0 +1,29 @@
|
||||
# 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
|
||||
|
||||
## Usage
|
||||
|
||||
TODO: Write usage instructions here
|
||||
|
||||
## Contributing
|
||||
|
||||
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
|
9
bin/sprockets-assistant
Executable file
9
bin/sprockets-assistant
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
$: << File.expand_path('../../lib', __FILE__)
|
||||
|
||||
require 'sprockets/assistant/cli'
|
||||
|
||||
Sprockets::Assistant::CLI.start
|
||||
|
||||
# vim: filetype=ruby
|
1
lib/sprockets-assistant.rb
Normal file
1
lib/sprockets-assistant.rb
Normal file
@ -0,0 +1 @@
|
||||
require "sprockets/assistant"
|
6
lib/sprockets/assistant.rb
Normal file
6
lib/sprockets/assistant.rb
Normal file
@ -0,0 +1,6 @@
|
||||
module Sprockets
|
||||
module Assistant
|
||||
|
||||
end
|
||||
end
|
||||
|
49
lib/sprockets/assistant/app_builder.rb
Normal file
49
lib/sprockets/assistant/app_builder.rb
Normal file
@ -0,0 +1,49 @@
|
||||
require 'sprockets-vendor_gems/extend_all'
|
||||
require 'sinatra/base'
|
||||
require 'sinatra/sprockets'
|
||||
require 'sprockets/assistant/compiler'
|
||||
|
||||
module Sprockets
|
||||
module Assistant
|
||||
class AppBuilder
|
||||
def initialize
|
||||
instance_eval(File.read('assistant_config.rb'))
|
||||
end
|
||||
|
||||
def app(&block)
|
||||
if block
|
||||
@app = block
|
||||
else
|
||||
_app = @app
|
||||
|
||||
Class.new(Sinatra::Base) do
|
||||
set :root, Dir.pwd
|
||||
|
||||
register Sinatra::Sprockets
|
||||
|
||||
set :views, 'views'
|
||||
|
||||
class_eval(&_app)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def middleware(&block)
|
||||
if block
|
||||
@middleware = block
|
||||
else
|
||||
@middleware
|
||||
end
|
||||
end
|
||||
|
||||
def compile(&block)
|
||||
if block
|
||||
@compile = block
|
||||
else
|
||||
Compiler.new(@compile).compile
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
27
lib/sprockets/assistant/cli.rb
Normal file
27
lib/sprockets/assistant/cli.rb
Normal file
@ -0,0 +1,27 @@
|
||||
require 'sprockets/assistant/server'
|
||||
require 'rack'
|
||||
require 'thor'
|
||||
|
||||
module Sprockets
|
||||
module Assistant
|
||||
class CLI < Thor
|
||||
include Thor::Actions
|
||||
source_root File.expand_path('../../../..', __FILE__)
|
||||
|
||||
desc "server", "server"
|
||||
def server
|
||||
Rack::Handler.default.run(Sprockets::Assistant::Server.app)
|
||||
end
|
||||
|
||||
desc "compile", "compile things"
|
||||
def compile
|
||||
Sprockets::Assistant::AppBuilder.new.compile
|
||||
end
|
||||
|
||||
desc "create NAME", "initialize a new assistant project"
|
||||
def create(name)
|
||||
directory 'skel', name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
40
lib/sprockets/assistant/compiler.rb
Normal file
40
lib/sprockets/assistant/compiler.rb
Normal file
@ -0,0 +1,40 @@
|
||||
require 'sprockets'
|
||||
require 'sprockets-vendor_gems/extend_all'
|
||||
require 'pathname'
|
||||
require 'sprockets/assistant/output'
|
||||
|
||||
module Sprockets
|
||||
module Assistant
|
||||
class Compiler
|
||||
include Sprockets::Assistant::Output
|
||||
|
||||
DEFAULT_TARGET = "compiled"
|
||||
|
||||
def initialize(settings)
|
||||
@settings = settings
|
||||
@target = DEFAULT_TARGET
|
||||
end
|
||||
|
||||
def compile
|
||||
@env = Sprockets::Environment.new
|
||||
@env.append_path('assets/javascripts')
|
||||
@env.append_path('assets/stylesheets')
|
||||
|
||||
instance_eval(&@settings)
|
||||
end
|
||||
|
||||
def file(name)
|
||||
file_target = target.join(name)
|
||||
say "#{name} => #{file_target}"
|
||||
|
||||
file_target.parent.mkpath
|
||||
target.join(name).open('w') { |fh| fh.print @env[name].to_s }
|
||||
end
|
||||
|
||||
def target
|
||||
Pathname(@target)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
10
lib/sprockets/assistant/output.rb
Normal file
10
lib/sprockets/assistant/output.rb
Normal file
@ -0,0 +1,10 @@
|
||||
module Sprockets
|
||||
module Assistant
|
||||
module Output
|
||||
def say(*args)
|
||||
$stdout.puts(*args)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
41
lib/sprockets/assistant/server.rb
Normal file
41
lib/sprockets/assistant/server.rb
Normal file
@ -0,0 +1,41 @@
|
||||
require 'rack'
|
||||
|
||||
module Sprockets
|
||||
module Assistant
|
||||
class Server
|
||||
def self.app
|
||||
new.app
|
||||
end
|
||||
|
||||
def initialize
|
||||
require 'sprockets/assistant/app_builder'
|
||||
|
||||
@app_builder = AppBuilder.new
|
||||
end
|
||||
|
||||
def call(env)
|
||||
app.call(env)
|
||||
end
|
||||
|
||||
def app
|
||||
_app_builder = @app_builder
|
||||
_app = @app_builder.app
|
||||
|
||||
Rack::Builder.app do
|
||||
use Rack::CommonLogger, $stdout
|
||||
|
||||
instance_eval(&_app_builder.middleware)
|
||||
|
||||
map "/#{Sinatra::Sprockets.config.prefix}" do
|
||||
$stderr.puts Sinatra::Sprockets.environment.inspect
|
||||
|
||||
run Sinatra::Sprockets.environment
|
||||
end
|
||||
|
||||
run _app
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
6
lib/sprockets/assistant/version.rb
Normal file
6
lib/sprockets/assistant/version.rb
Normal file
@ -0,0 +1,6 @@
|
||||
module Sprockets
|
||||
module Assistant
|
||||
VERSION = '0.0.1'
|
||||
end
|
||||
end
|
||||
|
5
skel/Gemfile
Normal file
5
skel/Gemfile
Normal file
@ -0,0 +1,5 @@
|
||||
gem 'sprockets-assistant'
|
||||
|
||||
gem 'thin'
|
||||
gem 'compass'
|
||||
|
2
skel/assets/javascripts/application.js.coffee
Normal file
2
skel/assets/javascripts/application.js.coffee
Normal file
@ -0,0 +1,2 @@
|
||||
alert "hello"
|
||||
|
5
skel/assets/stylesheets/application.css.scss
Normal file
5
skel/assets/stylesheets/application.css.scss
Normal file
@ -0,0 +1,5 @@
|
||||
$color: green;
|
||||
|
||||
body {
|
||||
background-color: green;
|
||||
}
|
14
skel/assistant_config.rb
Normal file
14
skel/assistant_config.rb
Normal file
@ -0,0 +1,14 @@
|
||||
middleware do
|
||||
# use Rack::LiveReload
|
||||
end
|
||||
|
||||
app do
|
||||
get '/' do
|
||||
erb :index
|
||||
end
|
||||
end
|
||||
|
||||
compile do
|
||||
file "application.js"
|
||||
file "application.css"
|
||||
end
|
11
skel/views/index.erb
Normal file
11
skel/views/index.erb
Normal file
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Sprockets-assistant project</title>
|
||||
<%= javascript_include_tag :application %>
|
||||
<%= stylesheet_link_tag :application %>
|
||||
</head>
|
||||
<body>
|
||||
<h1>It works!</h1>
|
||||
</body>
|
||||
</html>
|
||||
|
25
sprockets-assistant.gemspec
Normal file
25
sprockets-assistant.gemspec
Normal file
@ -0,0 +1,25 @@
|
||||
# -*- encoding: utf-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.homepage = ""
|
||||
|
||||
gem.files = `git ls-files`.split($\)
|
||||
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
||||
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
||||
gem.name = "sprockets-assistant"
|
||||
gem.require_paths = ["lib"]
|
||||
gem.version = Sprockets::Assistant::VERSION
|
||||
|
||||
gem.add_dependency 'thor'
|
||||
gem.add_dependency 'sinatra'
|
||||
gem.add_dependency 'sinatra-sprockets-ext'
|
||||
gem.add_dependency 'coffee-script'
|
||||
gem.add_dependency 'sass'
|
||||
gem.add_dependency 'sprockets-vendor_gems'
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user