static_watcher 0.2.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.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in static_watcher.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Matt Scott
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,59 @@
1
+ # StaticWatcher
2
+
3
+ Watch and compile Haml, Sass, Scss, and Coffeescript.
4
+
5
+ ## Installation
6
+
7
+ Static Watcher requires coffeescript to be installed. See http:coffeescript.org for instructions.
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'static_watcher'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install static_watcher
20
+
21
+ In a new project run:
22
+
23
+ $ static_watcher:install
24
+
25
+ or
26
+
27
+ $ bundle exec static_watcher:install
28
+
29
+ as appropriate. This will generate the folders which Static Watcher compiles from/into. The directory structure is:
30
+
31
+ /src/haml
32
+ /src/sass
33
+ /src/coffeescripts
34
+
35
+ which compile, respectively, into:
36
+
37
+ /public
38
+ /public/stylesheets
39
+ /public/javascripts
40
+
41
+ ## Usage
42
+
43
+ Simply execute
44
+
45
+ $ static_watcher
46
+
47
+ or:
48
+
49
+ $ bundle exec static_watcher
50
+
51
+ and use ctrl-c to stop.
52
+
53
+ ## Contributing
54
+
55
+ 1. Fork it
56
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
57
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
58
+ 4. Push to the branch (`git push origin my-new-feature`)
59
+ 5. Create new Pull Request
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ desc "watch"
5
+ task :watch do
6
+ puts "watching for changes"
7
+
8
+ FSSM.monitor do
9
+ path './src/haml' do
10
+ glob '**/*.haml'
11
+
12
+ update { |b, r| compile_haml(b,r) }
13
+ delete { |b, r| puts "HAML Delete in #{b} to #{r}" }
14
+ create { |b, r| compile_haml(b,r) }
15
+ end
16
+
17
+ path './src/sass' do
18
+ glob '**/*'
19
+
20
+ update { |b, r| compile_sass(b,r) }
21
+ delete { |b, r| puts "SASS Delete in #{b} to #{r}" }
22
+ create { |b, r| compile_sass(b,r) }
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path("../../lib", __FILE__)
4
+
5
+ require "static_watcher"
6
+
7
+ StaticWatcher::watch
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path("../../lib", __FILE__)
4
+
5
+ require "static_watcher"
6
+
7
+ StaticWatcher::install
@@ -0,0 +1,103 @@
1
+ # require "static_watcher/version"
2
+ require "haml"
3
+ require "sass"
4
+ require "fssm"
5
+
6
+ PATH = Dir.pwd
7
+
8
+ module StaticWatcher
9
+
10
+ def self.install
11
+ puts "Creating directory structure..."
12
+ folders = ['/public', '/public/stylesheets', '/public/javascripts', '/src', '/src/haml', '/src/sass', '/src/coffeescripts']
13
+ folders.each do |folder|
14
+ if FileTest::directory?(PATH + folder)
15
+ puts "Folder #{PATH + folder} already exists!"
16
+ else
17
+ puts "Creating folder #{PATH + folder}"
18
+ Dir::mkdir(PATH + folder)
19
+ end
20
+ end
21
+ puts "Complete!"
22
+ end
23
+
24
+ def self.watch
25
+ puts "watching for changes"
26
+
27
+ FSSM.monitor do
28
+ path PATH + '/src/haml' do
29
+ glob '**/*.haml'
30
+
31
+ update { |b, r| StaticWatcher::compile_haml(b,r) }
32
+ delete { |b, r| puts "HAML Delete in #{b} to #{r}" }
33
+ create { |b, r| StaticWatcher::compile_haml(b,r) }
34
+ end
35
+
36
+ path PATH + '/src/sass' do
37
+ glob '**/*'
38
+
39
+ update { |b, r| StaticWatcher::compile_sass(b,r) }
40
+ delete { |b, r| puts "SASS Delete in #{b} to #{r}" }
41
+ create { |b, r| StaticWatcher::compile_sass(b,r) }
42
+ end
43
+
44
+ path PATH + '/src/coffeescripts' do
45
+ glob '**/*.coffee'
46
+
47
+ update { |b, r| StaticWatcher::compile_coffeescript(b,r) }
48
+ delete { |b, r| puts "Coffeescript Delete in #{b} to #{r}" }
49
+ create { |b, r| StaticWatcher::compile_coffeescript(b,r) }
50
+ end
51
+ end
52
+ end
53
+
54
+ def self.compile_haml(b,r)
55
+ file = "#{b}/#{r}"
56
+ puts "Compiling #{file} ... "
57
+ content = File.new(file).read
58
+ begin
59
+ engine = ::Haml::Engine.new(content)
60
+ output = engine.render
61
+ rescue StandardError => error
62
+ puts "Error in HAML compilation of #{r}"
63
+ end
64
+ output_filename = r.gsub('.haml', '')
65
+ output_file = PATH + "/public/#{output_filename}.html"
66
+ FileUtils.mkdir_p File.dirname(output_file)
67
+ File.open(output_file, 'w') { |f| f.write(output) }
68
+ puts "done!"
69
+ end
70
+
71
+ def self.compile_sass(b,r)
72
+ file = "#{b}/#{r}"
73
+ output_split = r.split('.')
74
+ output_filename = output_split[0]
75
+ filetype = output_split[1]
76
+ if filetype == "scss"
77
+ sass_options = {:syntax => :scss}
78
+ end
79
+ puts "Compiling #{file} ... "
80
+ content = File.new(file).read
81
+ begin
82
+ engine = ::Sass::Engine.new(content, (sass_options || {}))
83
+ output = engine.render
84
+ rescue StandardError => error
85
+ puts "Error in SASS compilation of #{r}"
86
+ end
87
+ output_file = PATH + "/public/stylesheets/#{output_filename}.css"
88
+ FileUtils.mkdir_p File.dirname(output_file)
89
+ File.open(output_file, 'w') { |f| f.write(output) }
90
+ puts "done!"
91
+ end
92
+
93
+ def self.compile_coffeescript(b,r)
94
+ file = "#{b}/#{r}"
95
+ puts "Compiling #{file} ..."
96
+ begin
97
+ %x[ coffee -o #{PATH + '/public/javascripts'} -c #{file} ]
98
+ puts "done!"
99
+ rescue
100
+ puts "Error in Coffeescript Compilation"
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,3 @@
1
+ module StaticWatcher
2
+ VERSION = "0.2.0"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/static_watcher/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Matt Scott"]
6
+ gem.email = ["mdms.scott@gmail.com"]
7
+ gem.description = "Watches for changes and compiles Haml, Sass, Scss, and Coffeescript"
8
+ gem.summary = "Watches for changes and compiles Haml, Sass, Scss, and Coffeescript. Requires you to have coffeescript installed, and thus node.js."
9
+ gem.homepage = "https://github.com/mdms-scott/static_watcher"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "static_watcher"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = StaticWatcher::VERSION
17
+
18
+ gem.add_runtime_dependency "haml"
19
+ gem.add_runtime_dependency "sass"
20
+ gem.add_runtime_dependency "fssm"
21
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: static_watcher
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Matt Scott
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: haml
16
+ requirement: &70189916474760 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70189916474760
25
+ - !ruby/object:Gem::Dependency
26
+ name: sass
27
+ requirement: &70189916474320 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70189916474320
36
+ - !ruby/object:Gem::Dependency
37
+ name: fssm
38
+ requirement: &70189916473840 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70189916473840
47
+ description: Watches for changes and compiles Haml, Sass, Scss, and Coffeescript
48
+ email:
49
+ - mdms.scott@gmail.com
50
+ executables:
51
+ - static_watcher
52
+ - static_watcher:install
53
+ extensions: []
54
+ extra_rdoc_files: []
55
+ files:
56
+ - .gitignore
57
+ - Gemfile
58
+ - LICENSE
59
+ - README.md
60
+ - Rakefile
61
+ - bin/static_watcher
62
+ - bin/static_watcher:install
63
+ - lib/static_watcher.rb
64
+ - lib/static_watcher/version.rb
65
+ - static_watcher.gemspec
66
+ homepage: https://github.com/mdms-scott/static_watcher
67
+ licenses: []
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 1.8.10
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Watches for changes and compiles Haml, Sass, Scss, and Coffeescript. Requires
90
+ you to have coffeescript installed, and thus node.js.
91
+ test_files: []