Skip to content

Commit

Permalink
Added compatibility with guard-jekyll-plus and jekyll-stitch-plus
Browse files Browse the repository at this point in the history
  • Loading branch information
imathis committed Aug 22, 2013
1 parent b3b24a6 commit 2115026
Show file tree
Hide file tree
Showing 15 changed files with 161 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -17,3 +17,4 @@ test/version_tmp
tmp
.DS_Store
test/javascripts/*.js
_site
9 changes: 9 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,9 @@
# Changelog

## 1.0.0
- initial release

## 1.1.0
- Added compatibility with jekyll-stitch-plus
- Added compatibility with guard-jekyll-plus
- Changed default Guardfile to expect a config yaml file
22 changes: 17 additions & 5 deletions lib/guard/stitch-plus.rb
Expand Up @@ -6,23 +6,35 @@ class Stitchplus < Guard

def initialize (watchers=[], options={})
super
@stitcher = ::StitchPlus.new(options.merge({guard: true}))
@options = options
end

def start
@stitcher.write
@stitcher = ::StitchPlus.new(@options.merge({guard: true}))
ENV['GUARD_STITCH_PLUS'] = 'true'
ENV['GUARD_STITCH_PLUS_FILES'] = @stitcher.all_files.join(',')
write
end

def reload
@stitcher.write
write
end

def run_all
@stitcher.write
write
end

def run_on_changes(paths)
if @options[:config] and paths.include? @options[:config]
start
elsif (paths & @stitcher.all_files).size > 0
write
end
end

def run_on_changes(_)
def write
@stitcher.write
ENV['GUARD_STITCH_PLUS_OUTPUT'] = @stitcher.last_write
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/guard/stitch-plus/templates/Guardfile
@@ -1,4 +1,4 @@
guard 'stitch-plus', :dependencies => ['javascripts/dependencies/**/*'], :paths => ['javascripts/modules'] do
watch /^javascripts/
guard 'stitch-plus', config: '_config.yml' do
watch %r{^javascripts/|_config\.yml}
end

9 changes: 6 additions & 3 deletions test/Gemfile
@@ -1,6 +1,9 @@
source 'https://rubygems.org'

gem 'guard-stitch-plus', :path => "../"
gem 'coffee-script'
gem 'jekyll'
gem 'guard-jekyll-plus'
gem 'jekyll-stitch-plus'
gem 'guard-stitch-plus', path: '../'
gem 'uglifier'

gem 'coffee-script'
gem 'redcarpet'
10 changes: 8 additions & 2 deletions test/Guardfile
@@ -1,7 +1,13 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'stitch-plus', config: 'stitch.yml' do
watch /^javascripts/

guard 'stitch-plus', config: '_config.yml' do
watch %r{^js/|_config.yml}
end

guard "jekyll-plus" do
watch /.*/
ignore %r{^_site/}
end

15 changes: 15 additions & 0 deletions test/_config.yml
@@ -0,0 +1,15 @@
name: Your New Jekyll Site
markdown: redcarpet
pygments: true

env: 'production'

stitch:
dependencies:
- 'js/lib/jquery.js'
- 'js/lib/underscore.js'
- 'js/lib' # globs the js/lib dir
paths: 'js/modules' # globs the js/modules dir
output: 'js/site.js'
#fingerprint: true

12 changes: 12 additions & 0 deletions test/_layouts/default.html
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{ page.title }}</title>
<meta name="viewport" content="width=device-width">
{% stitch_js_tag %}
</head>
<body>
{{ content }}
</body>
</html>
1 change: 1 addition & 0 deletions test/_plugins/stitch-plus.rb
@@ -0,0 +1 @@
require 'jekyll-stitch-plus'
13 changes: 13 additions & 0 deletions test/index.html
@@ -0,0 +1,13 @@
---
layout: default
title: Your New Jekyll Site
---

<div id="home">
<h1>Blog Posts</h1>
<ul class="posts">
{% for post in site.posts %}
<li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</div>
File renamed without changes.
File renamed without changes.
File renamed without changes.
77 changes: 77 additions & 0 deletions test/js/site.js
@@ -0,0 +1,77 @@
/* Build fingerprint: f151aec45877432b66dcc540907291fa */
(function() {
if (window.awesome == null) {
console.log('hi guys');
}

}).call(this);

var test = function (message){
console.log(message || 'test');
}


(function(/*! Stitch !*/) {
if (!this.require) {
var modules = {}, cache = {};
var require = function(name, root) {
var path = expand(root, name), indexPath = expand(path, './index'), module, fn;
module = cache[path] || cache[indexPath];
if (module) {
return module;
} else if (fn = modules[path] || modules[path = indexPath]) {
module = {id: path, exports: {}};
cache[path] = module.exports;
fn(module.exports, function(name) {
return require(name, dirname(path));
}, module);
return cache[path] = module.exports;
} else {
throw 'module ' + name + ' not found';
}
};
var expand = function(root, name) {
var results = [], parts, part;
// If path is relative
if (/^\.\.?(\/|$)/.test(name)) {
parts = [root, name].join('/').split('/');
} else {
parts = name.split('/');
}
for (var i = 0, length = parts.length; i < length; i++) {
part = parts[i];
if (part == '..') {
results.pop();
} else if (part != '.' && part != '') {
results.push(part);
}
}
return results.join('/');
};
var dirname = function(path) {
return path.split('/').slice(0, -1).join('/');
};
this.require = function(name) {
return require(name, '');
};
this.require.define = function(bundle) {
for (var key in bundle) {
modules[key] = bundle[key];
}
};
this.require.modules = modules;
this.require.cache = cache;
}
return this.require.define;
}).call(this)({
"test-module": function(exports, require, module) {
var Widget = {
init: function(){
console.log('new widget!');
}
}

module.exports = Widget;

}
});
5 changes: 0 additions & 5 deletions test/stitch.yml

This file was deleted.

0 comments on commit 2115026

Please sign in to comment.