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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 645eeae3478242e8e50693c5c870569981900c6d
4
- data.tar.gz: 51c13ab7acb1edace8fea0023e73b1e338cf6baf
3
+ metadata.gz: 60597733d2a5b4be3a0adc354ab3b8671b93ada2
4
+ data.tar.gz: dd360b4e031c94dc9dd8a641ca65787e202e4d60
5
5
  SHA512:
6
- metadata.gz: 601dbb360a1113f48516f974500cdf7d36f46eb2cf90d8ff1c06034be1019718eaba42bb143817d9b08ab86ee6034be2e7431a93ab5506383fd78224dffe52e0
7
- data.tar.gz: 102454bbde1a782a7003f606c76fe71cd84602762c1c44e0dd8b6795a7142658bef8b687c828b70d5310e3a24bc866d4c590738a02fae943664943eda891b955
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 `src` directory.
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
- └── src
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 `src` and compile them to the `Your Site` folder.
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: 'src'
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, '*.html'), File.join(config.full_source_path, '*.liquid')]) do |path|
43
+ Dir.glob([File.join(config.full_source_path, '**/*.html'), File.join(config.full_source_path, '**/*.liquid')]) do |path|
44
44
  begin
45
- file_name = Pathname.new(path).basename.to_s.split('.').first
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
- data = { 'config' => { 'stylesheet' => config.stylesheets.last, 'javascript' => config.javascripts.last } }
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(config.full_destination_path) unless File.exists?(config.full_destination_path)
60
- File.open(File.join(config.full_destination_path, output_file_name), 'w') { |file| file.write(html) }
61
- SmallVictories.logger.info "compiled #{config.destination}/#{output_file_name}"
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, '*.html')]) do |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) }
@@ -1,6 +1,6 @@
1
1
  module SmallVictories
2
2
  CONFIG_FILE = '_sv_config.yml'
3
- DEFAULT_SOURCE = 'src'
3
+ DEFAULT_SOURCE = '_src'
4
4
  DEFAULT_DESTINATION = ''
5
5
  DEFAULT_SOURCE_STYLESHEET = 'application.css'
6
6
  DEFAULT_SOURCE_JAVASCRIPT = 'application.js'
@@ -1,3 +1,3 @@
1
1
  module SmallVictories
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -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/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
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/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) }
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
@@ -5,7 +5,7 @@ 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 'src'
8
+ expect(configuration.source).to eq '_src'
9
9
  end
10
10
 
11
11
  it 'defaults to destination directory' do
@@ -2,7 +2,7 @@
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
4
  guard 'livereload' do
5
- watch(%r{.+\.(css|js|html)})
5
+ watch(%r{[^\/]*.(css|js|html)})
6
6
  end
7
7
 
8
8
  logger level: :warn
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smallvictories
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Dijkstra