spinebox 0.0.2 → 0.0.3

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/README.textile CHANGED
@@ -13,10 +13,14 @@ bc.. $ gem install spinebox
13
13
 
14
14
  h3. Usage
15
15
 
16
- bc.. $ spinebox new blog
16
+ bc.. # Create new project an start developing
17
+ $ spinebox new blog
17
18
  $ cd blog
18
19
  $ spinebox server
19
20
 
21
+ bc.. # Compile project for static serving
22
+ $ spinebox compile
23
+
20
24
  h3. Contributing
21
25
 
22
26
  1. Fork it
data/bin/spinebox CHANGED
@@ -20,7 +20,13 @@ Spinebox::Command.dispatch do
20
20
  on "new APP", "Create a new APP", :if => proc { ['new', 'n'].include?(ARGV.first) } do
21
21
  ARGV.shift
22
22
  Spinebox::Generator.new(ARGV.first)
23
- puts ">> Created new spinebox in './#{ARGV.first}'. Let's go!"
23
+ exit(0)
24
+ end
25
+
26
+ # Compile
27
+ on "compile, precompile", "Compile files to the public dir", :if => proc { ['compile', 'precompile'].include?(ARGV.first) } do
28
+ Spinebox.boot!
29
+ Spinebox::Compiler.compile
24
30
  exit(0)
25
31
  end
26
32
 
@@ -1,9 +1,41 @@
1
1
  module Spinebox
2
2
  module Compiler
3
3
 
4
- # Compiles
4
+ # Compiles the assets and the views into the public folder
5
5
  def self.compile
6
-
6
+ Spinebox.config.concatenate = true
7
+ create_directories
8
+ compile_javascripts
9
+ compile_stylesheets
10
+ compile_views
11
+ copy_images
12
+ end
13
+
14
+ private
15
+ def self.create_directories
16
+ Dir.mkdir "public" unless File.directory?("public")
17
+ Dir.mkdir "public/assets" unless File.directory?("public/assets")
18
+ end
19
+
20
+ def self.compile_javascripts
21
+ asset = Spinebox.assets["application.js"]
22
+ asset.write_to(File.join("public/assets", asset.logical_path))
23
+ end
24
+
25
+ def self.compile_stylesheets
26
+ asset = Spinebox.assets["application.css"]
27
+ asset.write_to(File.join("public/assets", asset.logical_path))
28
+ end
29
+
30
+ def self.compile_views
31
+ Spinebox.views.each_logical_path do |logical_path|
32
+ asset = Spinebox.views[logical_path]
33
+ asset.write_to(File.join("public", asset.logical_path))
34
+ end
35
+ end
36
+
37
+ def self.copy_images
38
+ FileUtils.cp_r "app/assets/images/.", "public/assets"
7
39
  end
8
40
 
9
41
  end
@@ -30,13 +30,13 @@ module Spinebox
30
30
 
31
31
  # Build a javascript tag with body options
32
32
  def javascript_tag_for asset, options = {}
33
- "<script src='/assets/#{asset.logical_path}#{"?body=1" if options[:body]}' type='text/javascript'></script>"
33
+ "<script src='assets/#{asset.logical_path}#{"?body=1" if options[:body]}' type='text/javascript'></script>"
34
34
  end
35
35
 
36
36
  # Build a stylesheet link with body options
37
37
  def stylesheet_tag_for asset, new_options = {}
38
38
  options = { :media => "all", :rel => "stylesheet" }.merge!(new_options)
39
- "<link href='/assets/#{asset.logical_path}#{"?body=1" if options[:body]}' media='#{options[:media]}' rel='#{options[:rel]}' type='text/css'>"
39
+ "<link href='assets/#{asset.logical_path}#{"?body=1" if options[:body]}' media='#{options[:media]}' rel='#{options[:rel]}' type='text/css'>"
40
40
  end
41
41
 
42
42
  end
@@ -1,3 +1,3 @@
1
1
  module Spinebox
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/spinebox.rb CHANGED
@@ -12,6 +12,7 @@ require "spinebox/config"
12
12
  require "spinebox/routes"
13
13
  require "spinebox/erb_context"
14
14
  require "spinebox/generator"
15
+ require "spinebox/compiler"
15
16
 
16
17
  module Spinebox
17
18
  class << self
@@ -0,0 +1,29 @@
1
+ require_relative "./helpers"
2
+
3
+ describe Spinebox::Compiler do
4
+
5
+ before(:each) do
6
+ Dir.chdir "#{Spinebox.root}/templates"
7
+ Spinebox.boot!
8
+ File.new("app/assets/images/test.png", "w")
9
+ end
10
+
11
+ after(:each) do
12
+ FileUtils.rm_rf "app/assets/images/test.png"
13
+ FileUtils.rm_rf "public"
14
+ end
15
+
16
+ it "should compile the assets and views to the public folder" do
17
+ Dir["public/**/*"].should be_empty
18
+
19
+ Spinebox::Compiler.compile
20
+
21
+ [
22
+ "public/assets/application.js",
23
+ "public/assets/application.css",
24
+ "public/assets/test.png",
25
+ "public/index.html"
26
+ ].each{ |file| File.exists?(file).should be_true }
27
+ end
28
+
29
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spinebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -56,10 +56,10 @@ files:
56
56
  - lib/spinebox/templates/config.ru
57
57
  - lib/spinebox/templates/config/config.rb
58
58
  - lib/spinebox/templates/config/routes.rb
59
- - lib/spinebox/templates/public/.gitignore
60
59
  - lib/spinebox/version.rb
61
60
  - spec/base_spec.rb
62
61
  - spec/command_spec.rb
62
+ - spec/compiler_spec.rb
63
63
  - spec/config_spec.rb
64
64
  - spec/erb_context_spec.rb
65
65
  - spec/generator_spec.rb
@@ -94,6 +94,7 @@ summary: Generates a rack servable app skeleton with spine.js and sprockets that
94
94
  test_files:
95
95
  - spec/base_spec.rb
96
96
  - spec/command_spec.rb
97
+ - spec/compiler_spec.rb
97
98
  - spec/config_spec.rb
98
99
  - spec/erb_context_spec.rb
99
100
  - spec/generator_spec.rb
File without changes