mindful_sass 0.0.1
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/bin/mindful_sass +35 -0
- data/lib/directory_runner.rb +20 -0
- data/lib/mindful_watcher.rb +36 -0
- data/lib/not_observable_exception.rb +2 -0
- metadata +76 -0
data/bin/mindful_sass
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#--
|
4
|
+
# Copyright (c) 2003, 2004, 2005, 2006, 2007 Jim Weirich
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to
|
8
|
+
# deal in the Software without restriction, including without limitation the
|
9
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
10
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
22
|
+
# IN THE SOFTWARE.
|
23
|
+
#++
|
24
|
+
|
25
|
+
begin
|
26
|
+
require 'rubygems'
|
27
|
+
rescue LoadError
|
28
|
+
end
|
29
|
+
|
30
|
+
require 'mindful_watcher'
|
31
|
+
require 'directory_runner'
|
32
|
+
|
33
|
+
args = ARGV.dup
|
34
|
+
watcher = MindfulWatcher.new(args)
|
35
|
+
watcher.observe_folder
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class DirectoryRunner
|
2
|
+
EXCLUDE_FILES = %w{. .. .sass-cache}.freeze
|
3
|
+
|
4
|
+
def initialize root_dir
|
5
|
+
@root_dir = root_dir
|
6
|
+
raise "FileNotFound" if @root_dir.nil?
|
7
|
+
end
|
8
|
+
|
9
|
+
def process(dir = nil, &block)
|
10
|
+
dir ||= @root_dir
|
11
|
+
|
12
|
+
Dir.foreach(dir) do |filename|
|
13
|
+
unless EXCLUDE_FILES.include? filename
|
14
|
+
act_path = File.join(dir, filename)
|
15
|
+
block.call act_path
|
16
|
+
self.process act_path, &block if File.directory? act_path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class MindfulWatcher
|
2
|
+
|
3
|
+
def initialize(args=[])
|
4
|
+
puts "initializing sass_watcher"
|
5
|
+
args.delete_if { |a| a == '--watch' }
|
6
|
+
@args = args
|
7
|
+
path_args = args.select { |a| a =~ /.+\:.+/ }.first || ""
|
8
|
+
sources = path_args.gsub(/\:.+/, ' ')
|
9
|
+
@dir2observe = File.realdirpath(File.dirname(sources)) if sources
|
10
|
+
|
11
|
+
raise NotObservableException, :msg => 'cannot find folder in arguments' if @dir2observe.nil?
|
12
|
+
end
|
13
|
+
|
14
|
+
def observe_folder
|
15
|
+
fm = DirectoryRunner.new(@dir2observe)
|
16
|
+
while true do
|
17
|
+
fm.process do |filename|
|
18
|
+
if @last_change.nil? || File.mtime(filename).to_s > @last_change.to_s
|
19
|
+
@last_change = Time.now
|
20
|
+
update_files(filename)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
sleep 2
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def update_files(filename)
|
28
|
+
files_converted = system("sass #{@args.join(' ')}")
|
29
|
+
if files_converted
|
30
|
+
puts "#{@last_change} file changed: #{filename}"
|
31
|
+
else
|
32
|
+
raise "SassNotFoundException", :msg => "please run 'gem install sass'"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mindful_sass
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- ! '''Falk'
|
9
|
+
- Hoppe'
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2011-08-01 00:00:00.000000000Z
|
14
|
+
dependencies: []
|
15
|
+
description: ! "\n Sass or the much better approach of scss is really helpful and
|
16
|
+
a big silver bullet for my css structuring in \n ruby projects.\n \n Standard
|
17
|
+
sass command works for whole directories or single files only. In general it gets
|
18
|
+
the jobs we want done, \n but in practical usage i think the sass command tool
|
19
|
+
is a little bit unconvinient. A common scenario for me is, \n that you have whole
|
20
|
+
bunch of sass files, which you want to compile to a single compressed output file.\n
|
21
|
+
\ But if you have splitted your sass files in component based modules and you
|
22
|
+
want to watch the complete folder you \n have to care for dependency handling
|
23
|
+
in each file, because each file will be compiled for its own.\n \n # compiling
|
24
|
+
a complete folder with scss\n ~ $ sass css/scss:css/compiled\n \n So converting
|
25
|
+
the whole folder is not what i want, because i don\\'t want to import for example
|
26
|
+
my color.sass config file\n in each module again. Compiling a single file seems
|
27
|
+
to be the better solution, and it works in general, as expected,\n but the devil
|
28
|
+
is in the detail. \n \n # compiling a single file where the other files are
|
29
|
+
imported.\n ~ $ sass css/scss/main.scss:css/compiled/main.css\n \n If we
|
30
|
+
change a file with impact to our main.sass file, the --watch handle will not get
|
31
|
+
it, because it observes only\n the timestamp of the given main.sass.\n \n Here
|
32
|
+
is it, where mindful_sass tries to help out. You use it according to the single
|
33
|
+
file variant of \n sass, but it tries to observe the whole folder the given sass
|
34
|
+
file is placed. If a timestamp of file in the sass folder\n or its children changes
|
35
|
+
it will compile the specified main.sass again.\n \n This gem is not aimed to
|
36
|
+
replace anything in the sass universe. It is only a wrapper to avoid the described
|
37
|
+
unconvinience, \n and i hope that it gets useless as fast as possible, because
|
38
|
+
the sass development gets this feature done for themselves.\n \n Thanks anyway
|
39
|
+
to the sass developer team. \n "
|
40
|
+
email: info@systems-engineer.net
|
41
|
+
executables:
|
42
|
+
- mindful_sass
|
43
|
+
extensions: []
|
44
|
+
extra_rdoc_files: []
|
45
|
+
files:
|
46
|
+
- lib/directory_runner.rb
|
47
|
+
- lib/mindful_watcher.rb
|
48
|
+
- lib/not_observable_exception.rb
|
49
|
+
- bin/mindful_sass
|
50
|
+
homepage:
|
51
|
+
licenses:
|
52
|
+
- GPL-3
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.8.6
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: provides a recursive observer for sass command line tool. Takes the same
|
75
|
+
arguments as sass, using the sass single file syntax.
|
76
|
+
test_files: []
|