dimples 1.9.1 → 2.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2916d2b04bf83413a9c36bcc832d51a4d493812b
4
- data.tar.gz: 9f7eb9920b06ab7e0542638ad9430279d0ab6bc6
3
+ metadata.gz: 2f30fbd75e775cf280a833ceb82d300e49a50d9a
4
+ data.tar.gz: afe74aa069759f960a01dc4aac48ceb562123964
5
5
  SHA512:
6
- metadata.gz: ddb5631780c2491feb92e9b88adfe08ae319d31d1ad9e5b5a766ae703689099d538081b0896d2c68d94eca25626926e673a8d01ee21a1f08dbc829cb4084b58f
7
- data.tar.gz: 7123c381e0df2304609c14b7d5d9d31466d96edd0625364151e8cf5908db6d89719fc294630fb050e96dfdf1dbace002b61754190c4f5c23e4e3d2eb31e072c4
6
+ metadata.gz: 70a4771af0e75ee3fa7cca7eaaded26f5a3fe22869dc76e5d58e6310f47838d8db3f2d8437fd44ba56ec0c41a466d9a4a7af9d43979366d7263fd97831e9a83a
7
+ data.tar.gz: dfdfebedfb6e403a86f58d6cd3b76d47a55933ac6579318b480de6a1f1eca46577fcaf16d3c13ded38283cc9a5594d253456c11ea91cd109ea736fa43dda1e0d
data/bin/dimples ADDED
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'dimples'
4
+ require 'dimples/version'
5
+ require 'trollop'
6
+
7
+ valid_commands = %w[build]
8
+
9
+ options = Trollop::options do
10
+ version "dimples v#{Dimples::VERSION}"
11
+ banner <<EOS
12
+ A very, very simple static site generator.
13
+
14
+ Usage:
15
+ dimples [#{valid_commands.join('|')}] [options]
16
+
17
+ Options:
18
+ EOS
19
+ opt :config, "Config file path", default: File.join('config', 'site.yml')
20
+ opt :lib, "Library file path", default: 'lib'
21
+ end
22
+
23
+ Trollop::educate if ARGV.empty?
24
+ command = ARGV[0]
25
+
26
+ unless valid_commands.include?(command)
27
+ Trollop::die "Command must be '#{valid_commands.join('\', \'')}'"
28
+ end
29
+
30
+ config_path = File.join(Dir.pwd, options[:config])
31
+ lib_path = File.join(Dir.pwd, options[:lib])
32
+
33
+ unless File.exist?(config_path)
34
+ Trollop::die "Missing config file (#{config_path})"
35
+ end
36
+
37
+ if Dir.exist?(lib_path)
38
+ Dir.glob(File.join(lib_path, '**', '*')) do |path|
39
+ require path
40
+ end
41
+ end
42
+
43
+ begin
44
+ config_hash = YAML.load_file(config_path)
45
+ config = Dimples::Configuration.new(config_hash)
46
+ rescue
47
+ Trollop::die "Invalid or malformed YAML config file"
48
+ end
49
+
50
+ site_klass = config.class_override(:site) || Dimples::Site
51
+ site = site_klass.new(config)
52
+
53
+ case command.to_sym
54
+ when :build
55
+ puts "Generating site at #{site.output_paths[:site]}"
56
+ site.generate
57
+ end
@@ -16,12 +16,18 @@ module Dimples
16
16
  @settings[key]
17
17
  end
18
18
 
19
+ def class_override(type)
20
+ klass = @settings['class_overrides']["#{type}"]
21
+ Object.const_get(klass) unless klass.nil?
22
+ end
23
+
19
24
  def self.default_settings
20
25
  current_path = Dir.pwd
21
26
 
22
27
  {
23
28
  'source_path' => current_path,
24
29
  'destination_path' => File.join(current_path, 'site'),
30
+ 'class_overrides' => { site: nil, post: nil, page: nil },
25
31
  'rendering' => {},
26
32
  'category_names' => {},
27
33
  'paths' => default_paths,
@@ -31,15 +31,15 @@ module Dimples
31
31
  end
32
32
 
33
33
  def renderer
34
- proc = proc { contents }
34
+ callback = proc { contents }
35
35
 
36
36
  if @path
37
37
  extension = File.extname(@path)[1..-1]
38
38
  options = @site.config['rendering'][extension] || {}
39
39
 
40
- Tilt.new(@path, options, &proc)
40
+ Tilt.new(@path, options, &callback)
41
41
  else
42
- Tilt::StringTemplate.new(&proc)
42
+ Tilt::StringTemplate.new(&callback)
43
43
  end
44
44
  end
45
45
  end
data/lib/dimples/site.rb CHANGED
@@ -12,7 +12,7 @@ module Dimples
12
12
  attr_accessor :page_class
13
13
  attr_accessor :post_class
14
14
 
15
- def initialize(config = {})
15
+ def initialize(config)
16
16
  @source_paths = {}
17
17
  @output_paths = {}
18
18
  @templates = {}
@@ -24,10 +24,10 @@ module Dimples
24
24
 
25
25
  @latest_post = false
26
26
 
27
- @page_class = Dimples::Page
28
- @post_class = Dimples::Post
27
+ @config = config
29
28
 
30
- @config = Dimples::Configuration.new(config)
29
+ @page_class = @config.class_override(:page) || Dimples::Page
30
+ @post_class = @config.class_override(:post) || Dimples::Post
31
31
 
32
32
  @source_paths[:root] = File.expand_path(@config['source_path'])
33
33
  @output_paths[:site] = File.expand_path(@config['destination_path'])
@@ -1,3 +1,3 @@
1
1
  module Dimples
2
- VERSION = '1.9.1'.freeze
2
+ VERSION = '2.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dimples
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bogan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-05 00:00:00.000000000 Z
11
+ date: 2017-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tilt
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: trollop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.1'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -97,10 +111,12 @@ dependencies:
97
111
  description: A very, very, very simple gem for building static websites.
98
112
  email:
99
113
  - d+dimples@waferbaby.com
100
- executables: []
114
+ executables:
115
+ - dimples
101
116
  extensions: []
102
117
  extra_rdoc_files: []
103
118
  files:
119
+ - bin/dimples
104
120
  - lib/dimples.rb
105
121
  - lib/dimples/configuration.rb
106
122
  - lib/dimples/errors.rb