smallvictories 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +82 -82
- data/bin/sv +1 -8
- data/lib/smallvictories/builder.rb +14 -9
- data/lib/smallvictories/compiler.rb +26 -16
- data/lib/smallvictories/configuration.rb +12 -4
- data/lib/smallvictories/constants.rb +3 -3
- data/lib/smallvictories/version.rb +1 -1
- data/lib/smallvictories/watcher.rb +5 -1
- data/smallvictories.gemspec +7 -3
- data/spec/builder_spec.rb +8 -7
- data/spec/compiler_spec.rb +16 -2
- data/spec/configuration_spec.rb +3 -3
- data/spec/fixtures/destination_sv_custom.css +1 -0
- data/spec/fixtures/destination_sv_custom.js +1 -0
- data/spec/fixtures/destinationindex.html +5 -0
- data/spec/fixtures/source/{_config.yml → _sv_config.yml} +0 -0
- data/spec/spec_helper.rb +1 -1
- data/src/Guardfile +37 -0
- metadata +67 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57b412c22c3ddab3b928e36a80fcd757bfedfa0c
|
4
|
+
data.tar.gz: 4860dd4466e9b09a7e7c9b39e1c3d9c7a30d25d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90e8d86e01b61fb7ebbd515f676a776c2da4a6223c8015a35cb2d8ee4e0dcfc9d78146079b1897206d3a18b8cc83e2d94198a151a93bacd5084e6984fc7024e7
|
7
|
+
data.tar.gz: 9e51ce950e5513e3ad7bebefee87aa44ad659891b6cdc0677057e626efd3fd87c547c317d1f85d064fd168561d347a26b0c5733c370c0780fd3b4833e2267cd4
|
data/README.md
CHANGED
@@ -18,82 +18,113 @@ renders all HTML and Liquid files through this, including snippets from the
|
|
18
18
|
includes folder.
|
19
19
|
|
20
20
|
You don't have to use a layout file if you don't want to, the files will still
|
21
|
-
be copied
|
21
|
+
be copied to the destination folder.
|
22
22
|
|
23
|
-
|
23
|
+
[Guard LiveReload](https://github.com/guard/guard-livereload) is used to notify
|
24
|
+
the browser to automatically reload. It needs to be used with
|
25
|
+
the [LiveReload Safari/Chrome/Firefox extension](http://livereload.com/extensions#installing-sections).
|
26
|
+
|
27
|
+
## Installation
|
24
28
|
|
25
|
-
```
|
26
|
-
|
27
|
-
├── _includes
|
28
|
-
│ └── _head.liquid
|
29
|
-
├── _layout.liquid
|
30
|
-
├── _sv_custom.css
|
31
|
-
├── _sv_custom.js
|
32
|
-
└── index.liquid
|
33
|
-
prod
|
34
|
-
├── _sv_custom.css
|
35
|
-
├── _sv_custom.js
|
36
|
-
└── index.html
|
29
|
+
```
|
30
|
+
gem install smallvictories
|
37
31
|
```
|
38
32
|
|
39
|
-
##
|
33
|
+
## Commands
|
40
34
|
|
41
|
-
|
42
|
-
version directly into a Small Victories folder.
|
35
|
+
### Bootstrap
|
43
36
|
|
44
|
-
|
45
|
-
|
37
|
+
Sets up default files in a folder.
|
38
|
+
|
46
39
|
|
47
|
-
|
48
|
-
|
40
|
+
Pass no name to setup in the current folder:
|
41
|
+
|
42
|
+
Command: `sv bootstrap`
|
43
|
+
|
44
|
+
Pass a folder name to setup in a new/existing folder:
|
45
|
+
|
46
|
+
Command: `sv bootstrap my-folder`
|
47
|
+
|
49
48
|
|
50
|
-
###
|
49
|
+
### Compile
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
includes: '_includes'
|
59
|
-
```
|
51
|
+
Compile files.
|
52
|
+
|
53
|
+
Renders Sass/CSS, JavaScript/CoffeeScript, HTML/Liquid in the destination
|
54
|
+
folder.
|
55
|
+
|
56
|
+
Command: `sv compile`
|
60
57
|
|
61
|
-
###
|
58
|
+
### Watch
|
62
59
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
├── _config.yml
|
69
|
-
├── _layout.liquid
|
70
|
-
├── _sv_custom.css
|
71
|
-
├── _sv_custom.js
|
72
|
-
└── index.liquid
|
60
|
+
Watch for changes then compile files and notify LiveReload.
|
61
|
+
|
62
|
+
Command: `sv watch`
|
63
|
+
|
64
|
+
### Default Folder Structure
|
73
65
|
|
66
|
+
The default setup for Small Victories is to have your production files in the
|
67
|
+
root and your development files in the `_` directory.
|
68
|
+
|
69
|
+
```text
|
74
70
|
Dropbox
|
75
71
|
└── Small Victories
|
76
|
-
└──
|
72
|
+
└── Your Site
|
73
|
+
└── _
|
74
|
+
│ ├── _includes
|
75
|
+
│ │ └── _head.liquid
|
76
|
+
│ ├── _layout.liquid
|
77
|
+
│ ├── _sv_custom.css
|
78
|
+
│ ├── _sv_custom.js
|
79
|
+
│ └── index.liquid
|
80
|
+
│
|
77
81
|
├── _sv_custom.css
|
78
82
|
├── _sv_custom.js
|
79
83
|
└── index.html
|
80
84
|
```
|
81
85
|
|
82
|
-
|
86
|
+
You would then run `sv watch` from within `Your Site` and Small Victories will
|
87
|
+
watch for changes in `_` and compile them to the `Your Site` folder.
|
83
88
|
|
84
|
-
|
89
|
+
## How does it work with Small Victories?
|
85
90
|
|
86
|
-
|
91
|
+
This gem allows you to build a site using the tools you're used to and compile a
|
92
|
+
version directly into a Small Victories folder.
|
87
93
|
|
88
|
-
|
89
|
-
|
90
|
-
|
94
|
+
When you watch or build your site it will output the files into your Dropbox
|
95
|
+
folder, which in turn will trigger Small Victories to rebuild your site.
|
96
|
+
|
97
|
+
### Getting Started
|
98
|
+
|
99
|
+
First, create a new Small Victories site either through your Small Victories
|
100
|
+
admin or by creating a new folder in Dropbox/Small Victories.
|
101
|
+
|
102
|
+
In terminal, cd into the directory and run:
|
103
|
+
|
104
|
+
`sv bootstrap`
|
105
|
+
|
106
|
+
Then:
|
107
|
+
|
108
|
+
`sv compile`
|
109
|
+
|
110
|
+
And finally:
|
111
|
+
|
112
|
+
`sv watch`
|
113
|
+
|
114
|
+
With the default config, Small Victories will watch and compile your files into
|
115
|
+
the root of your site folder.
|
116
|
+
|
117
|
+
## Why is there now web server?
|
118
|
+
|
119
|
+
There are other static site generators (like [Jekyll](http://jekyllrb.com/) or [Middleman](https://middlemanapp.com/)) that you can use to fire up a web server (and more!), Small Victories helps you build a static site for hosting on Small Victories, so if you don't need anything more than a static HTML file that can be dropped into your Small Victories folder.
|
91
120
|
|
92
121
|
## Config
|
93
122
|
|
94
|
-
Small Victories
|
123
|
+
You can override Small Victories config by including a `_sv_config.yml` file in the directory where `sv` is
|
95
124
|
run from.
|
96
125
|
|
126
|
+
You can set the following options:
|
127
|
+
|
97
128
|
+ `source`: Relative path to find and watch files for compiling and compiling.
|
98
129
|
+ `destination`: Relative path for where to save final files.
|
99
130
|
+ `stylesheet`: Main stylesheet (Sass or CSS) to be compiled into destination.
|
@@ -104,45 +135,14 @@ run from.
|
|
104
135
|
### Default Configuration
|
105
136
|
|
106
137
|
```yaml
|
107
|
-
source: '
|
108
|
-
destination: '
|
138
|
+
source: '_'
|
139
|
+
destination: ''
|
109
140
|
stylesheet: '_sv_custom.css'
|
110
141
|
javascript: '_sv_custom.js'
|
111
142
|
layout: '_layout.liquid'
|
112
143
|
includes: '_includes'
|
113
144
|
```
|
114
145
|
|
115
|
-
## Commands
|
116
|
-
|
117
|
-
### Bootstrap
|
118
|
-
|
119
|
-
Sets up default files in a folder.
|
120
|
-
|
121
|
-
|
122
|
-
Pass no name to setup in the current folder:
|
123
|
-
|
124
|
-
Command: `sv bootstrap`
|
125
|
-
|
126
|
-
Pass a folder name to setup in a new/existing folder:
|
127
|
-
|
128
|
-
Command: `sv bootstrap my-folder`
|
129
|
-
|
130
|
-
|
131
|
-
### Compile
|
132
|
-
|
133
|
-
Compile files.
|
134
|
-
|
135
|
-
Renders Sass/CSS, JavaScript/CoffeeScript, HTML/Liquid in the destination
|
136
|
-
folder.
|
137
|
-
|
138
|
-
Command: `sv compile`
|
139
|
-
|
140
|
-
### Watch
|
141
|
-
|
142
|
-
Watch for changes and compile files.
|
143
|
-
|
144
|
-
Command: `sv watch`
|
145
|
-
|
146
146
|
## Building Locally
|
147
147
|
|
148
148
|
1. Clone it
|
data/bin/sv
CHANGED
@@ -9,7 +9,6 @@ def help
|
|
9
9
|
Commands:
|
10
10
|
bootstrap, bootstrap FOLDER Setup folder with default files
|
11
11
|
compile Compile files
|
12
|
-
open Open index.html in destination folder
|
13
12
|
watch Watch for changes and compile files
|
14
13
|
help Prints this help document
|
15
14
|
version Prints the small victories gem version
|
@@ -26,6 +25,7 @@ def bootstrap folder=nil
|
|
26
25
|
config = SmallVictories::Configuration.new
|
27
26
|
builder = SmallVictories::Builder.new(config: config)
|
28
27
|
builder.setup folder
|
28
|
+
compile
|
29
29
|
end
|
30
30
|
|
31
31
|
def compile
|
@@ -36,11 +36,6 @@ def compile
|
|
36
36
|
compiler.compile_html
|
37
37
|
end
|
38
38
|
|
39
|
-
def open
|
40
|
-
config = SmallVictories::Configuration.new
|
41
|
-
system("open #{config.full_destination_path}index.html")
|
42
|
-
end
|
43
|
-
|
44
39
|
def watch
|
45
40
|
config = SmallVictories::Configuration.new
|
46
41
|
compiler = SmallVictories::Compiler.new(config: config)
|
@@ -57,8 +52,6 @@ when 'bootstrap'
|
|
57
52
|
bootstrap ARGV[1]
|
58
53
|
when 'compile'
|
59
54
|
compile
|
60
|
-
when 'open'
|
61
|
-
open
|
62
55
|
when 'watch'
|
63
56
|
watch
|
64
57
|
else
|
@@ -14,6 +14,7 @@ module SmallVictories
|
|
14
14
|
setup_directory folder_path
|
15
15
|
setup_directory folder_source_path
|
16
16
|
setup_config
|
17
|
+
setup_guardfile
|
17
18
|
setup_stylesheet
|
18
19
|
setup_javascript
|
19
20
|
setup_html
|
@@ -24,7 +25,7 @@ module SmallVictories
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def folder_source_path
|
27
|
-
|
28
|
+
File.join(folder_path, config.source)
|
28
29
|
end
|
29
30
|
|
30
31
|
private
|
@@ -50,29 +51,33 @@ module SmallVictories
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def setup_config
|
53
|
-
d = YAML::load_file(
|
54
|
+
d = YAML::load_file(File.join(src_directory, 'config.yml'))
|
54
55
|
d['source'] = DEFAULT_SOURCE
|
55
56
|
d['destination'] = DEFAULT_DESTINATION
|
56
57
|
d['stylesheet'] = DEFAULT_STYLESHEET
|
57
58
|
d['javascript'] = DEFAULT_JAVASCRIPT
|
58
59
|
d['layout'] = DEFAULT_LAYOUT
|
59
60
|
d['includes'] = DEFAULT_INCLUDES
|
60
|
-
File.open(
|
61
|
+
File.open(File.join(folder_path, CONFIG_FILE), 'w') {|f| f.write d.to_yaml }
|
62
|
+
end
|
63
|
+
|
64
|
+
def setup_guardfile
|
65
|
+
create_src_file('Guardfile', File.join(folder_path, '.sv_guardfile'))
|
61
66
|
end
|
62
67
|
|
63
68
|
def setup_stylesheet
|
64
|
-
create_src_file('stylesheet.css',
|
69
|
+
create_src_file('stylesheet.css', File.join(folder_source_path, config.stylesheet))
|
65
70
|
end
|
66
71
|
|
67
72
|
def setup_javascript
|
68
|
-
create_src_file('javascript.js',
|
73
|
+
create_src_file('javascript.js', File.join(folder_source_path, config.javascript))
|
69
74
|
end
|
70
75
|
|
71
76
|
def setup_html
|
72
|
-
setup_directory(
|
73
|
-
create_src_file('head.liquid',
|
74
|
-
create_src_file('layout.liquid',
|
75
|
-
create_src_file('index.liquid',
|
77
|
+
setup_directory(File.join(folder_source_path, config.includes))
|
78
|
+
create_src_file('head.liquid', File.join(folder_source_path, config.includes, '/_head.liquid'))
|
79
|
+
create_src_file('layout.liquid', File.join(folder_source_path, config.layout))
|
80
|
+
create_src_file('index.liquid', File.join(folder_source_path, 'index.liquid'))
|
76
81
|
end
|
77
82
|
end
|
78
83
|
end
|
@@ -12,7 +12,6 @@ module SmallVictories
|
|
12
12
|
|
13
13
|
def compile_css
|
14
14
|
package [config.stylesheet]
|
15
|
-
prefix_css
|
16
15
|
end
|
17
16
|
|
18
17
|
def compile_js
|
@@ -25,8 +24,8 @@ module SmallVictories
|
|
25
24
|
|
26
25
|
def liquid
|
27
26
|
begin
|
28
|
-
Liquid::Template.file_system = Liquid::LocalFileSystem.new(
|
29
|
-
layout_path =
|
27
|
+
Liquid::Template.file_system = Liquid::LocalFileSystem.new(config.full_includes_path)
|
28
|
+
layout_path = config.full_layout_path
|
30
29
|
if File.exists?(layout_path)
|
31
30
|
layout_file = File.open(layout_path).read
|
32
31
|
layout = Liquid::Template.parse(layout_file)
|
@@ -36,7 +35,7 @@ module SmallVictories
|
|
36
35
|
return
|
37
36
|
end
|
38
37
|
|
39
|
-
Dir.glob([
|
38
|
+
Dir.glob([File.join(config.full_source_path, '*.html'), File.join(config.full_source_path, '*.liquid')]) do |path|
|
40
39
|
begin
|
41
40
|
file_name = Pathname.new(path).basename.to_s.split('.').first
|
42
41
|
next if file_name =~ /^_/ # do not render partials
|
@@ -45,14 +44,14 @@ module SmallVictories
|
|
45
44
|
liquid = Liquid::Template.parse(file)
|
46
45
|
content = liquid.render('config' => { 'stylesheet' => config.stylesheet, 'javascript' => config.javascript })
|
47
46
|
output_file_name = file_name.concat('.html')
|
48
|
-
output_path =
|
47
|
+
output_path = File.join(config.full_destination_path, output_file_name)
|
49
48
|
if layout
|
50
49
|
html = layout.render('content_for_layout' => liquid.render, 'config' => { 'stylesheet' => config.stylesheet, 'javascript' => config.javascript })
|
51
50
|
else
|
52
51
|
html = liquid.render('config' => { 'stylesheet' => config.stylesheet, 'javascript' => config.javascript })
|
53
52
|
end
|
54
53
|
Dir.mkdir(config.full_destination_path) unless File.exists?(config.full_destination_path)
|
55
|
-
File.open(
|
54
|
+
File.open(File.join(config.full_destination_path, output_file_name), 'w') { |file| file.write(html) }
|
56
55
|
SmallVictories.logger.info "compiled #{config.destination}/#{output_file_name}"
|
57
56
|
rescue => e
|
58
57
|
SmallVictories.logger.error "#{path}\n#{e}"
|
@@ -60,10 +59,12 @@ module SmallVictories
|
|
60
59
|
end
|
61
60
|
end
|
62
61
|
|
63
|
-
def package bundles=[config.stylesheet, config.javascript]
|
62
|
+
def package bundles=[config.stylesheet, config.javascript], options={}
|
64
63
|
sprockets = Sprockets::Environment.new(ROOT) do |environment|
|
65
|
-
environment.
|
66
|
-
environment.
|
64
|
+
environment.gzip = true
|
65
|
+
environment.logger = SmallVictories.logger
|
66
|
+
environment.js_compressor = options[:js_compressor] || :uglify
|
67
|
+
environment.css_compressor = options[:css_compressor] || :sass
|
67
68
|
end
|
68
69
|
|
69
70
|
sprockets.append_path(config.full_source_path)
|
@@ -72,7 +73,7 @@ module SmallVictories
|
|
72
73
|
if assets = sprockets.find_asset(bundle)
|
73
74
|
prefix, basename = assets.pathname.to_s.split('/')[-2..-1]
|
74
75
|
FileUtils.mkpath config.full_destination_path
|
75
|
-
assets.write_to
|
76
|
+
assets.write_to File.join(config.full_destination_path, basename)
|
76
77
|
SmallVictories.logger.info "compiled #{config.destination}/#{basename}"
|
77
78
|
end
|
78
79
|
rescue => e
|
@@ -83,22 +84,31 @@ module SmallVictories
|
|
83
84
|
|
84
85
|
def prefix_css
|
85
86
|
begin
|
86
|
-
path =
|
87
|
+
path = File.join(config.full_destination_path, config.stylesheet)
|
87
88
|
css = File.open(path).read
|
88
89
|
prefixed = AutoprefixerRails.process(css, browsers: ['last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1'], cascade: false)
|
89
90
|
File.open(path, 'w') { |file| file.write(prefixed.css) }
|
90
91
|
|
91
92
|
sprockets = Sprockets::Environment.new(ROOT) do |environment|
|
92
|
-
environment.css_compressor = :
|
93
|
+
environment.css_compressor = :yui
|
93
94
|
end
|
94
95
|
sprockets.append_path(config.full_destination_path)
|
95
|
-
assets = sprockets.find_asset(config.stylesheet)
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
if assets = sprockets.find_asset(config.stylesheet)
|
97
|
+
assets.write_to File.join(config.full_destination_path, config.stylesheet)
|
98
|
+
SmallVictories.logger.info "prefixed #{config.destination}/#{config.stylesheet}"
|
99
|
+
end
|
99
100
|
rescue => e
|
100
101
|
SmallVictories.logger.error "#{path}\n#{e}"
|
101
102
|
end
|
102
103
|
end
|
104
|
+
|
105
|
+
def minify_css
|
106
|
+
package [config.stylesheet]
|
107
|
+
prefix_css
|
108
|
+
end
|
109
|
+
|
110
|
+
def minify_js
|
111
|
+
package [config.javascript], { js_compressor: :closure }
|
112
|
+
end
|
103
113
|
end
|
104
114
|
end
|
@@ -5,8 +5,8 @@ module SmallVictories
|
|
5
5
|
attr_accessor :config
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
self.config = if File.exists?(
|
9
|
-
YAML.load(File.read(
|
8
|
+
self.config = if File.exists?(CONFIG_FILE)
|
9
|
+
YAML.load(File.read(CONFIG_FILE)) || {}
|
10
10
|
else
|
11
11
|
{}
|
12
12
|
end
|
@@ -21,7 +21,7 @@ module SmallVictories
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def full_source_path
|
24
|
-
|
24
|
+
File.join(ROOT, source)
|
25
25
|
end
|
26
26
|
|
27
27
|
def destination
|
@@ -29,7 +29,7 @@ module SmallVictories
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def full_destination_path
|
32
|
-
|
32
|
+
File.join(ROOT, destination)
|
33
33
|
end
|
34
34
|
|
35
35
|
def javascript
|
@@ -44,8 +44,16 @@ module SmallVictories
|
|
44
44
|
config_file(:layout) || DEFAULT_LAYOUT
|
45
45
|
end
|
46
46
|
|
47
|
+
def full_layout_path
|
48
|
+
File.join(full_source_path, layout)
|
49
|
+
end
|
50
|
+
|
47
51
|
def includes
|
48
52
|
config_file(:includes) || DEFAULT_INCLUDES
|
49
53
|
end
|
54
|
+
|
55
|
+
def full_includes_path
|
56
|
+
File.join(full_source_path, includes)
|
57
|
+
end
|
50
58
|
end
|
51
59
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module SmallVictories
|
2
|
-
CONFIG_FILE = '
|
3
|
-
DEFAULT_SOURCE = '
|
4
|
-
DEFAULT_DESTINATION = '
|
2
|
+
CONFIG_FILE = '_sv_config.yml'
|
3
|
+
DEFAULT_SOURCE = '_'
|
4
|
+
DEFAULT_DESTINATION = ''
|
5
5
|
DEFAULT_STYLESHEET = '_sv_custom.css'
|
6
6
|
DEFAULT_JAVASCRIPT = '_sv_custom.js'
|
7
7
|
DEFAULT_LAYOUT = '_layout.liquid'
|
@@ -12,7 +12,6 @@ module SmallVictories
|
|
12
12
|
Listen.to(
|
13
13
|
compiler.config.full_source_path,
|
14
14
|
force_polling: true,
|
15
|
-
ignore: [/#{compiler.config.destination}/],
|
16
15
|
&(listen_handler)
|
17
16
|
)
|
18
17
|
end
|
@@ -38,10 +37,15 @@ module SmallVictories
|
|
38
37
|
def watch
|
39
38
|
SmallVictories.logger.debug "👋"
|
40
39
|
SmallVictories.logger.debug "👀"
|
40
|
+
|
41
|
+
pid = Process.fork { system('guard -i --guardfile .sv_guardfile') }
|
42
|
+
Process.detach(pid)
|
43
|
+
|
41
44
|
listener = build_listener
|
42
45
|
listener.start
|
43
46
|
|
44
47
|
trap("INT") do
|
48
|
+
Process.kill "TERM", pid
|
45
49
|
listener.stop
|
46
50
|
puts "✋ Halting auto-regeneration."
|
47
51
|
exit 0
|
data/smallvictories.gemspec
CHANGED
@@ -18,13 +18,17 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency 'autoprefixer-rails',
|
21
|
+
spec.add_runtime_dependency 'autoprefixer-rails', '~> 6.0'
|
22
22
|
spec.add_runtime_dependency 'coffee-script', '~> 2.4'
|
23
|
+
spec.add_runtime_dependency 'guard', '~> 2.13'
|
24
|
+
spec.add_runtime_dependency 'guard-livereload', '~> 2.5'
|
23
25
|
spec.add_runtime_dependency 'listen', '~> 3.0'
|
24
|
-
spec.add_runtime_dependency 'liquid',
|
25
|
-
spec.add_runtime_dependency 'sassc',
|
26
|
+
spec.add_runtime_dependency 'liquid', '~> 3.0'
|
27
|
+
spec.add_runtime_dependency 'sassc', '~> 1.6'
|
26
28
|
spec.add_runtime_dependency 'sprockets', '~> 3.4'
|
27
29
|
spec.add_runtime_dependency 'uglifier', '~> 2.7'
|
30
|
+
spec.add_runtime_dependency 'yui-compressor', '~> 0.12'
|
31
|
+
spec.add_runtime_dependency 'closure-compiler', '~> 1.1'
|
28
32
|
|
29
33
|
spec.add_development_dependency "bundler", "~> 1.7"
|
30
34
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/spec/builder_spec.rb
CHANGED
@@ -6,16 +6,17 @@ describe SmallVictories do
|
|
6
6
|
context 'with folder' do
|
7
7
|
it 'sets up default files' do
|
8
8
|
builder.setup 'spec/fixtures/new'
|
9
|
-
expect(File.exists?('fixtures/new/
|
10
|
-
expect(File.exists?('fixtures/new
|
11
|
-
expect(File.exists?('fixtures/new/
|
12
|
-
expect(File.exists?('fixtures/new/
|
13
|
-
expect(File.exists?('fixtures/new/
|
14
|
-
expect(File.exists?('fixtures/new/
|
9
|
+
expect(File.exists?('fixtures/new/_sv_config.yml')).to eq true
|
10
|
+
expect(File.exists?('fixtures/new/.sv_guardfile')).to eq true
|
11
|
+
expect(File.exists?('fixtures/new/_/_layout.liquid')).to eq true
|
12
|
+
expect(File.exists?('fixtures/new/_/index.liquid')).to eq true
|
13
|
+
expect(File.exists?('fixtures/new/_/_includes/_head.liquid')).to eq true
|
14
|
+
expect(File.exists?('fixtures/new/_/_sv_custom.js')).to eq true
|
15
|
+
expect(File.exists?('fixtures/new/_/_sv_custom.css')).to eq true
|
15
16
|
end
|
16
17
|
|
17
18
|
after do
|
18
|
-
%w(fixtures/new/
|
19
|
+
%w(fixtures/new/_sv_config.yml fixtures/new/.sv_guardfile fixtures/new/_/index.liquid fixtures/new/_/_sv_custom.css fixtures/new/_/_sv_custom.js fixtures/new/_/_includes/_head.liquid fixtures/new/_/_layout.liquid).each { |path| clean_file(path) }
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
data/spec/compiler_spec.rb
CHANGED
@@ -39,19 +39,33 @@ describe SmallVictories do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
describe '#compile_css' do
|
42
|
-
it '
|
42
|
+
it 'compiles the css file' do
|
43
43
|
compiler.compile_css
|
44
|
+
expect(File.open(destination_css).read).to include '.bootstrap{color:black;box-sizing:content-box}html{background:white}body div{background:red}p{font-size:30px}'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#minify_css' do
|
49
|
+
it 'compiles and prefixes the css file' do
|
50
|
+
compiler.minify_css
|
44
51
|
expect(File.open(destination_css).read).to include '.bootstrap{color:black;-webkit-box-sizing:content-box;box-sizing:content-box}html{background:white}body div{background:red}p{font-size:30px}'
|
45
52
|
end
|
46
53
|
end
|
47
54
|
|
48
55
|
describe '#compile_js' do
|
49
|
-
it '
|
56
|
+
it 'compiles the js file' do
|
50
57
|
compiler.compile_js
|
51
58
|
expect(File.open(destination_js).read).to include '(function(){alert("hi")}).call(this),console.log("hi");'
|
52
59
|
end
|
53
60
|
end
|
54
61
|
|
62
|
+
describe '#minify_js' do
|
63
|
+
it 'minifies the js file' do
|
64
|
+
compiler.minify_js
|
65
|
+
expect(File.open(destination_js).read).to include '(function(){alert("hi")}).call(this);console.log("hi");'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
55
69
|
describe '#compile_html' do
|
56
70
|
it 'compiles the liquid files' do
|
57
71
|
compiler.compile_html
|
data/spec/configuration_spec.rb
CHANGED
@@ -5,11 +5,11 @@ describe SmallVictories do
|
|
5
5
|
|
6
6
|
context 'with no config file' do
|
7
7
|
it 'defaults to source directory' do
|
8
|
-
expect(configuration.source).to eq '
|
8
|
+
expect(configuration.source).to eq '_'
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'defaults to destination directory' do
|
12
|
-
expect(configuration.destination).to eq '
|
12
|
+
expect(configuration.destination).to eq ''
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'defaults stylesheet file' do
|
@@ -31,7 +31,7 @@ describe SmallVictories do
|
|
31
31
|
|
32
32
|
context 'with config file' do
|
33
33
|
before do
|
34
|
-
FileUtils.cp('fixtures/source/
|
34
|
+
FileUtils.cp('fixtures/source/_sv_config.yml', './')
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'reads the source folder' do
|
@@ -0,0 +1 @@
|
|
1
|
+
.bootstrap{color:black;box-sizing:content-box}html{background:white}body div{background:red}p{font-size:30px}
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(){alert("hi")}).call(this),console.log("hi");
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
@@ -9,7 +9,7 @@ RSpec.configure do |config|
|
|
9
9
|
end
|
10
10
|
|
11
11
|
config.after do
|
12
|
-
%w(./fixtures/destination/_sv_custom.css ./fixtures/destination/_sv_custom.js ./fixtures/destination/index.html ./
|
12
|
+
%w(./fixtures/destination/_sv_custom.css ./fixtures/destination/_sv_custom.js ./fixtures/destination/index.html ./_sv_config.yml).each { |path| clean_file(path) }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
data/src/Guardfile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# A Small Victories Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
directories %w(.).select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
6
|
+
|
7
|
+
guard 'livereload' do
|
8
|
+
extensions = {
|
9
|
+
css: :css,
|
10
|
+
js: :js,
|
11
|
+
html: :html,
|
12
|
+
png: :png,
|
13
|
+
gif: :gif,
|
14
|
+
jpg: :jpg,
|
15
|
+
jpeg: :jpeg,
|
16
|
+
}
|
17
|
+
|
18
|
+
# file types LiveReload may optimize refresh for
|
19
|
+
compiled_exts = extensions.values.uniq
|
20
|
+
watch(%r{./.+\.(#{compiled_exts * '|'})})
|
21
|
+
|
22
|
+
extensions.each do |ext, type|
|
23
|
+
watch(%r{
|
24
|
+
(?:app|vendor)
|
25
|
+
(?:/assets/\w+/(?<path>[^.]+) # path+base without extension
|
26
|
+
(?<ext>\.#{ext})) # matching extension (must be first encountered)
|
27
|
+
(?:\.\w+|$) # other extensions
|
28
|
+
}x) do |m|
|
29
|
+
path = m[1]
|
30
|
+
"/_/#{path}.#{type}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
watch(%r{_/.+\.liquid})
|
35
|
+
end
|
36
|
+
|
37
|
+
logger level: :warn
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smallvictories
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Dijkstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: autoprefixer-rails
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: guard
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.13'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.13'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard-livereload
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.5'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.5'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: listen
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +136,34 @@ dependencies:
|
|
108
136
|
- - "~>"
|
109
137
|
- !ruby/object:Gem::Version
|
110
138
|
version: '2.7'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: yui-compressor
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.12'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.12'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: closure-compiler
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '1.1'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '1.1'
|
111
167
|
- !ruby/object:Gem::Dependency
|
112
168
|
name: bundler
|
113
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,10 +234,12 @@ files:
|
|
178
234
|
- spec/configuration_spec.rb
|
179
235
|
- spec/fixtures/_sv_custom.css
|
180
236
|
- spec/fixtures/destination/.gitkeep
|
237
|
+
- spec/fixtures/destination_sv_custom.css
|
238
|
+
- spec/fixtures/destination_sv_custom.js
|
239
|
+
- spec/fixtures/destinationindex.html
|
181
240
|
- spec/fixtures/invalid/_layout.liquid
|
182
241
|
- spec/fixtures/invalid/_sass/stylesheet.scss
|
183
242
|
- spec/fixtures/invalid/index.html
|
184
|
-
- spec/fixtures/source/_config.yml
|
185
243
|
- spec/fixtures/source/_includes/_snippet.liquid
|
186
244
|
- spec/fixtures/source/_javascripts/scripts.coffee
|
187
245
|
- spec/fixtures/source/_javascripts/scripts.js
|
@@ -189,10 +247,12 @@ files:
|
|
189
247
|
- spec/fixtures/source/_stylesheets/bootstrap.scss
|
190
248
|
- spec/fixtures/source/_stylesheets/extra.scss
|
191
249
|
- spec/fixtures/source/_stylesheets/stylesheet.scss
|
250
|
+
- spec/fixtures/source/_sv_config.yml
|
192
251
|
- spec/fixtures/source/_sv_custom.css
|
193
252
|
- spec/fixtures/source/_sv_custom.js
|
194
253
|
- spec/fixtures/source/index.html
|
195
254
|
- spec/spec_helper.rb
|
255
|
+
- src/Guardfile
|
196
256
|
- src/config.yml
|
197
257
|
- src/head.liquid
|
198
258
|
- src/index.liquid
|
@@ -229,10 +289,12 @@ test_files:
|
|
229
289
|
- spec/configuration_spec.rb
|
230
290
|
- spec/fixtures/_sv_custom.css
|
231
291
|
- spec/fixtures/destination/.gitkeep
|
292
|
+
- spec/fixtures/destination_sv_custom.css
|
293
|
+
- spec/fixtures/destination_sv_custom.js
|
294
|
+
- spec/fixtures/destinationindex.html
|
232
295
|
- spec/fixtures/invalid/_layout.liquid
|
233
296
|
- spec/fixtures/invalid/_sass/stylesheet.scss
|
234
297
|
- spec/fixtures/invalid/index.html
|
235
|
-
- spec/fixtures/source/_config.yml
|
236
298
|
- spec/fixtures/source/_includes/_snippet.liquid
|
237
299
|
- spec/fixtures/source/_javascripts/scripts.coffee
|
238
300
|
- spec/fixtures/source/_javascripts/scripts.js
|
@@ -240,6 +302,7 @@ test_files:
|
|
240
302
|
- spec/fixtures/source/_stylesheets/bootstrap.scss
|
241
303
|
- spec/fixtures/source/_stylesheets/extra.scss
|
242
304
|
- spec/fixtures/source/_stylesheets/stylesheet.scss
|
305
|
+
- spec/fixtures/source/_sv_config.yml
|
243
306
|
- spec/fixtures/source/_sv_custom.css
|
244
307
|
- spec/fixtures/source/_sv_custom.js
|
245
308
|
- spec/fixtures/source/index.html
|