smallvictories 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/smallvictories/compiler.rb +15 -7
- data/lib/smallvictories/constants.rb +1 -1
- data/lib/smallvictories/version.rb +1 -1
- data/spec/builder_spec.rb +6 -6
- data/spec/configuration_spec.rb +1 -1
- data/src/Guardfile +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60597733d2a5b4be3a0adc354ab3b8671b93ada2
|
4
|
+
data.tar.gz: dd360b4e031c94dc9dd8a641ca65787e202e4d60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a017cf5c6ccf0594eaff8c873e24f4defb500f34c5877ef184d319bc9a93c44643750496a7023e8e4ad27d5112ac8f253f7419b6b39dbfb0adcc6981d93c660d
|
7
|
+
data.tar.gz: 46319e2de1f416c496d23be41dd12800a18b42148bfbb21b7ec94169380e6e0fbc9bc5c9f62018324aee36796350c1eecfacb32bcf27541ec1d0191d5e021d0b
|
data/README.md
CHANGED
@@ -70,13 +70,13 @@ Command: `sv watch`
|
|
70
70
|
### Default Folder Structure
|
71
71
|
|
72
72
|
The default setup for Small Victories is to have your production files in the
|
73
|
-
root and your development files in the `
|
73
|
+
root and your development files in the `_src` directory.
|
74
74
|
|
75
75
|
```text
|
76
76
|
Dropbox
|
77
77
|
└── Small Victories
|
78
78
|
└── Your Site
|
79
|
-
└──
|
79
|
+
└── _src
|
80
80
|
│ ├── _includes
|
81
81
|
│ │ └── _head.liquid
|
82
82
|
│ ├── _layout.liquid
|
@@ -90,7 +90,7 @@ Dropbox
|
|
90
90
|
```
|
91
91
|
|
92
92
|
You would then run `sv watch` from within `Your Site` and Small Victories will
|
93
|
-
watch for changes in `
|
93
|
+
watch for changes in `_src` and compile them to the `Your Site` folder.
|
94
94
|
|
95
95
|
## How does it work with Small Victories?
|
96
96
|
|
@@ -141,7 +141,7 @@ You can set the following options:
|
|
141
141
|
### Default Configuration
|
142
142
|
|
143
143
|
```yaml
|
144
|
-
source: '
|
144
|
+
source: '_src'
|
145
145
|
destination: ''
|
146
146
|
source_stylesheet: 'application.css'
|
147
147
|
source_javascript: 'application.js'
|
@@ -40,14 +40,22 @@ module SmallVictories
|
|
40
40
|
return
|
41
41
|
end
|
42
42
|
|
43
|
-
Dir.glob([File.join(config.full_source_path, '
|
43
|
+
Dir.glob([File.join(config.full_source_path, '**/*.html'), File.join(config.full_source_path, '**/*.liquid')]) do |path|
|
44
44
|
begin
|
45
|
-
|
45
|
+
pathname = Pathname.new(path)
|
46
|
+
file_name = pathname.basename.to_s.split('.').first
|
47
|
+
folder_path = pathname.dirname.to_s.gsub(config.full_source_path, '')
|
48
|
+
full_output_path = File.join(config.full_destination_path, folder_path)
|
49
|
+
|
46
50
|
next if file_name =~ /^_/ # do not render partials
|
47
51
|
|
48
52
|
file = File.open(path).read
|
49
53
|
liquid = Liquid::Template.parse(file)
|
50
|
-
|
54
|
+
stylesheet_path = Pathname.new(config.full_destination_path)
|
55
|
+
file_path = Pathname.new(full_output_path)
|
56
|
+
relative_path = stylesheet_path.relative_path_from(file_path)
|
57
|
+
|
58
|
+
data = { 'config' => { 'stylesheet' => File.join(relative_path, config.stylesheets.last), 'javascript' => File.join(relative_path, config.javascripts.last) } }
|
51
59
|
content = liquid.render(data)
|
52
60
|
output_file_name = file_name.concat('.html')
|
53
61
|
output_path = File.join(config.full_destination_path, output_file_name)
|
@@ -56,9 +64,9 @@ module SmallVictories
|
|
56
64
|
else
|
57
65
|
html = liquid.render(data)
|
58
66
|
end
|
59
|
-
Dir.mkdir(
|
60
|
-
File.open(File.join(
|
61
|
-
SmallVictories.logger.info "compiled #{config.destination
|
67
|
+
Dir.mkdir(full_output_path) unless File.exists?(full_output_path)
|
68
|
+
File.open(File.join(full_output_path, output_file_name), 'w') { |file| file.write(html) }
|
69
|
+
SmallVictories.logger.info "compiled #{File.join(config.destination, folder_path, output_file_name)}"
|
62
70
|
rescue => e
|
63
71
|
SmallVictories.logger.error "#{path}\n#{e}\n#{e.backtrace.first}"
|
64
72
|
end
|
@@ -117,7 +125,7 @@ module SmallVictories
|
|
117
125
|
end
|
118
126
|
|
119
127
|
def premail
|
120
|
-
Dir.glob([File.join(config.full_destination_path, '
|
128
|
+
Dir.glob([File.join(config.full_destination_path, '**/*.html')]) do |path|
|
121
129
|
begin
|
122
130
|
premailer = Premailer.new(path, warn_level: Premailer::Warnings::SAFE)
|
123
131
|
File.open(path, 'w') { |file| file.write(premailer.to_inline_css) }
|
data/spec/builder_spec.rb
CHANGED
@@ -8,15 +8,15 @@ describe SmallVictories do
|
|
8
8
|
builder.setup 'spec/fixtures/new'
|
9
9
|
expect(File.exists?('fixtures/new/_sv_config.yml')).to eq true
|
10
10
|
expect(File.exists?('fixtures/new/.sv_guardfile')).to eq true
|
11
|
-
expect(File.exists?('fixtures/new/
|
12
|
-
expect(File.exists?('fixtures/new/
|
13
|
-
expect(File.exists?('fixtures/new/
|
14
|
-
expect(File.exists?('fixtures/new/
|
15
|
-
expect(File.exists?('fixtures/new/
|
11
|
+
expect(File.exists?('fixtures/new/_src/_layout.liquid')).to eq true
|
12
|
+
expect(File.exists?('fixtures/new/_src/index.liquid')).to eq true
|
13
|
+
expect(File.exists?('fixtures/new/_src/_includes/_head.liquid')).to eq true
|
14
|
+
expect(File.exists?('fixtures/new/_src/application.js')).to eq true
|
15
|
+
expect(File.exists?('fixtures/new/_src/application.css')).to eq true
|
16
16
|
end
|
17
17
|
|
18
18
|
after do
|
19
|
-
%w(fixtures/new/_sv_config.yml fixtures/new/.sv_guardfile fixtures/new/
|
19
|
+
%w(fixtures/new/_sv_config.yml fixtures/new/.sv_guardfile fixtures/new/_src/index.liquid fixtures/new/_src/application.css fixtures/new/_src/application.js fixtures/new/_src/_includes/_head.liquid fixtures/new/_src/_layout.liquid).each { |path| clean_file(path) }
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/spec/configuration_spec.rb
CHANGED
data/src/Guardfile
CHANGED