guard-sass 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Joshua Hawxwell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,13 @@
1
+ # Guard-Sass
2
+
3
+ A guard extension that allows you to easily rebuild .sass (or .scss) files when changed.
4
+
5
+ guard 'sass' do
6
+ watch('^sass/(.*)')
7
+ end
8
+
9
+ Defaults to writing to 'css/' but this can be changed....
10
+
11
+ guard 'sass', :output => 'styles' do
12
+ watch('^sass/(.*)')
13
+ end
@@ -0,0 +1,60 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+
4
+ require 'sass'
5
+
6
+ module Guard
7
+ class Sass < Guard
8
+
9
+ VERSION = '0.0.2'
10
+ attr_accessor :options
11
+
12
+
13
+ # Builds the sass or scss. Determines engine to use by extension
14
+ # of path given.
15
+ #
16
+ # @param file [String] path to file to build
17
+ # @return [String] the output css
18
+ #
19
+ def build_sass(file)
20
+ content = File.new(file).read
21
+ # sass or scss?
22
+ type = file[-4..-1].to_sym
23
+ engine = ::Sass::Engine.new(content, {:syntax => type, :load_paths => @options[:load_paths]})
24
+ engine.render
25
+ end
26
+
27
+ # Get the file path to output the css based on the file being
28
+ # built.
29
+ #
30
+ # @param file [String] path to file being built
31
+ # @return [String] path to file where output should be written
32
+ #
33
+ def get_output(file)
34
+ folder = File.join File.dirname(file), '..', @options[:output]
35
+ FileUtils.mkdir_p folder
36
+ r = File.join folder, File.basename(file).split('.')[0]
37
+ r << '.css'
38
+ end
39
+
40
+
41
+ # ================
42
+ # = Guard method =
43
+ # ================
44
+
45
+ def start
46
+ @options[:output] = options[:output] || 'css'
47
+ @options[:load_paths] = Dir.glob('*')
48
+ end
49
+
50
+ # Build the files given
51
+ def run_on_change(paths)
52
+ paths.each do |file|
53
+ unless File.basename(file)[0] == "_"
54
+ File.open(get_output(file), 'w') {|f| f.write(build_sass(file)) }
55
+ end
56
+ end
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,5 @@
1
+ guard 'sass' do
2
+ watch('^sass/(.*)')
3
+ # watch('^_sass/(.*)')
4
+ # watch('^scss/(.*))
5
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-sass
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
10
+ platform: ruby
11
+ authors:
12
+ - Joshua Hawxwell
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-10-17 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: guard
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 1
30
+ - 0
31
+ version: 0.1.0
32
+ type: :runtime
33
+ prerelease: false
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: haml
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 3
44
+ - 0
45
+ - 0
46
+ version: 3.0.0
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: bundler
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 1
59
+ - 0
60
+ - 2
61
+ version: 1.0.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: rspec
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ~>
71
+ - !ruby/object:Gem::Version
72
+ segments:
73
+ - 2
74
+ - 0
75
+ - 0
76
+ - rc
77
+ version: 2.0.0.rc
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *id004
81
+ description: Guard::Sass automatically rebuilds sass (like sass --watch)
82
+ email:
83
+ - m@hawx.me
84
+ executables: []
85
+
86
+ extensions: []
87
+
88
+ extra_rdoc_files: []
89
+
90
+ files:
91
+ - lib/guard/sass/templates/Guardfile
92
+ - lib/guard/sass.rb
93
+ - LICENSE
94
+ - README.md
95
+ has_rdoc: true
96
+ homepage: http://rubygems.org/gems/guard-sass
97
+ licenses: []
98
+
99
+ post_install_message:
100
+ rdoc_options: []
101
+
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ segments:
118
+ - 1
119
+ - 3
120
+ - 6
121
+ version: 1.3.6
122
+ requirements: []
123
+
124
+ rubyforge_project: guard-sass
125
+ rubygems_version: 1.3.7
126
+ signing_key:
127
+ specification_version: 3
128
+ summary: Guard gem for Sass
129
+ test_files: []
130
+