wp-fire 0.0.7 → 0.1.0
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/lib/wp_fire/compiler.rb +27 -8
- data/lib/wp_fire/main_command.rb +3 -2
- metadata +3 -3
data/lib/wp_fire/compiler.rb
CHANGED
@@ -1,28 +1,39 @@
|
|
1
1
|
require 'coffee-script'
|
2
2
|
require 'sass'
|
3
|
+
require 'colorize'
|
3
4
|
|
4
5
|
module WpFire
|
5
6
|
class Compiler
|
6
7
|
|
7
|
-
def self.compile(filename, build_path, root_path)
|
8
|
+
def self.compile(filename, build_path, root_path, raise_on_exception=false)
|
8
9
|
extname = File.extname(filename)
|
9
10
|
basename = File.basename(filename, extname)
|
10
11
|
if not basename[0].eql?"_" and extname.eql?".scss"
|
11
12
|
sass_engine = Sass::Engine.for_file filename, {}
|
12
|
-
|
13
|
-
|
13
|
+
begin
|
14
|
+
css_content = sass_engine.to_css
|
15
|
+
File.open File.join(build_path, basename), "w" do |f|
|
16
|
+
f.puts css_content
|
17
|
+
end
|
18
|
+
rescue Exception => e
|
19
|
+
manage_exception(e,raise_on_exception)
|
14
20
|
end
|
15
21
|
elsif basename[0].eql?"_" and extname.eql?".scss"
|
16
22
|
parents_filename = []
|
17
23
|
find_scss_parents(filename,parents_filename)
|
18
24
|
parents_filename.uniq.each do |parent|
|
19
|
-
compile parent, build_path, root_path
|
25
|
+
compile parent, build_path, root_path, raise_on_exception
|
20
26
|
end
|
21
27
|
elsif extname.eql?".css"
|
22
28
|
FileUtils.cp filename, File.join(build_path, File.basename(filename))
|
23
29
|
elsif extname.eql?".coffee"
|
24
|
-
|
25
|
-
|
30
|
+
begin
|
31
|
+
js_content = CoffeeScript.compile File.read(filename)
|
32
|
+
File.open File.join(build_path, basename), "w" do |f|
|
33
|
+
f.puts js_content
|
34
|
+
end
|
35
|
+
rescue Exception => e
|
36
|
+
manage_exception(e,raise_on_exception)
|
26
37
|
end
|
27
38
|
elsif extname.eql?".js"
|
28
39
|
FileUtils.cp filename, File.join(build_path, File.basename(filename))
|
@@ -39,7 +50,7 @@ module WpFire
|
|
39
50
|
|
40
51
|
end
|
41
52
|
|
42
|
-
def self.compile_all(filenames, build_path, root_path)
|
53
|
+
def self.compile_all(filenames, build_path, root_path, raise_on_exception=false)
|
43
54
|
files = []
|
44
55
|
filenames.each do |filename|
|
45
56
|
if(File.directory?(filename))
|
@@ -50,7 +61,7 @@ module WpFire
|
|
50
61
|
end
|
51
62
|
end
|
52
63
|
files.each do |f|
|
53
|
-
compile f, build_path, root_path
|
64
|
+
compile f, build_path, root_path, raise_on_exception
|
54
65
|
end
|
55
66
|
end
|
56
67
|
|
@@ -60,6 +71,14 @@ module WpFire
|
|
60
71
|
Dir[ subdirs ? File.join(dir.split(/\\/), "**", filename) : File.join(dir.split(/\\/), filename) ]
|
61
72
|
end
|
62
73
|
|
74
|
+
def self.manage_exception(e,raise_on_exception)
|
75
|
+
unless raise_on_exception
|
76
|
+
puts e.message.colorize(:red)
|
77
|
+
else
|
78
|
+
raise e
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
63
82
|
def self.find_scss_parents(filename,parents_array)
|
64
83
|
directory = File.dirname(filename)
|
65
84
|
Dir["#{directory}/*.scss"].each do |f|
|
data/lib/wp_fire/main_command.rb
CHANGED
@@ -37,6 +37,7 @@ module WpFire
|
|
37
37
|
|
38
38
|
parameter "DIR", "The theme root path"
|
39
39
|
option ["-p","--build-path"], "BUILD_PATH", "Build path. The default is the theme root path", :default => nil
|
40
|
+
option "--raise-on-exception", :flag, "Raise exception if scss compiler fails"
|
40
41
|
|
41
42
|
def execute
|
42
43
|
@assets_path = File.join(dir,"source","assets")
|
@@ -58,10 +59,10 @@ module WpFire
|
|
58
59
|
end
|
59
60
|
end
|
60
61
|
watch_directories = [@assets_path,@templates_path,@functions_path]
|
61
|
-
WpFire::Compiler.compile_all watch_directories, @build_path, @root_path
|
62
|
+
WpFire::Compiler.compile_all watch_directories, @build_path, @root_path, raise_on_exception?
|
62
63
|
|
63
64
|
FileWatcher.new(watch_directories,"Watching files:").watch do |filename|
|
64
|
-
WpFire::Compiler.compile filename, @build_path, @root_path
|
65
|
+
WpFire::Compiler.compile filename, @build_path, @root_path, raise_on_exception?
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wp-fire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clamp
|
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
144
|
rubyforge_project:
|
145
|
-
rubygems_version: 1.8.
|
145
|
+
rubygems_version: 1.8.25
|
146
146
|
signing_key:
|
147
147
|
specification_version: 3
|
148
148
|
summary: Wordpress theme generator with Coffee Script and Sass support
|