munge 0.16.0 → 0.17.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: 21f94ee6721dd5a6248f8cc682e7c20b25e37c3c
4
- data.tar.gz: 4bc2576726939c6ec80482b94fdb05d700dfeab2
3
+ metadata.gz: 94019c2c419a44b2c4be2aca94cbc587e7875439
4
+ data.tar.gz: b8113ced2804eb5b33093ba9a33da97324fbbb7a
5
5
  SHA512:
6
- metadata.gz: b5953027d4225360dfe10436c2c65956cdffe57657e766709b753948f6a212295bcf6aeb198127719749c15db09cdb19fd27cce7eb7b16887cf47a7d75e36d8b
7
- data.tar.gz: 38649c10faff0d936d49b72f2f72a2a05e2fd134f599030f6d7ac589b05758699b9098e3cce14c2035d069333290cdb9145690d6c134236d96277db674863231
6
+ metadata.gz: a75c4565e8cf70ca137a5516b5d320300dc51d181f28fa5c18b69c68aee7fe2e0d9f86a353c152b89552a1979a85059fb7025279e1aada0e2150597d1ed51d51
7
+ data.tar.gz: b1a255bde2c32b711c5751261a5eb2c5545a5f3aeb1e433c151059fb8549d9202eeb3a157b2cc0733caf54679de8a79f8d8c396d4f748248cfb7acfde75ba943
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in munge.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -6,6 +6,9 @@
6
6
 
7
7
  Munge is a static site generator aiming to simplify complex build rules.
8
8
 
9
+ It's built partially to emulate unix pipes and scripts; small transformations
10
+ can be joined, composed, and applied to create almost any site you can think up.
11
+
9
12
  SemVer will be followed once 1.0.0 is released.
10
13
  Until then,
11
14
  the API should be considered experimental.
@@ -13,16 +16,22 @@ the API should be considered experimental.
13
16
 
14
17
  ## Features
15
18
 
19
+ - No DSL
16
20
  - No metaprogramming
17
- - Suitable for large, complex sites (e.g., multiple blogs with different templates, a single blog with multiple data sources)
21
+ - LiveReload
22
+ - Optional frontmatter
23
+ - Suitable for large, complex sites (e.g., multiple blogs with different
24
+ templates, a single blog with multiple data sources)
25
+ - Very configurable
18
26
  - Concise rule definition
19
- - Rules defined by iterating through arrays and modifying objects
27
+ - Rules defined by iterating through arrays and modifying matching objects
20
28
 
21
29
 
22
30
  ## Caveats
23
31
 
24
- - Not optimized (Pull requests welcome, gradual optimizations preferred)
25
- - Rules can seem pretty dense (because of its conciseness)
32
+ - Not yet optimized (Pull requests welcome, gradual optimizations preferred)
33
+ - User facing API has mostly stabilized, but plugins have yet to be fully worked
34
+ out
26
35
 
27
36
 
28
37
  ## Installation
@@ -30,7 +39,7 @@ the API should be considered experimental.
30
39
  Add this line to your application's Gemfile:
31
40
 
32
41
  ```ruby
33
- gem 'munge'
42
+ gem "munge"
34
43
  ```
35
44
 
36
45
  And then execute:
@@ -49,8 +58,9 @@ After installing your gem, you can start a project using the command line client
49
58
  ```bash
50
59
  munge init path/to/project # create a barebones project
51
60
  cd path/to/project
52
- munge build # compiles your project
53
- munge view # open http://localhost:7000/ to see output
61
+ munge server # starts auto-compiling dev server http://localhost:7000/
62
+ munge build # compiles your project for production
63
+ munge view # preview production build on http://localhost:7000/
54
64
  ```
55
65
 
56
66
  The three main files of your application are `config.yml`, `data.yml`, and `rules.rb`.
@@ -8,8 +8,8 @@ module Munge
8
8
  end
9
9
 
10
10
  desc "build", "Build site"
11
- method_option :reporter, desc: "Set reporting formatter", default: "Default", type: :string
12
- method_option :dry_run, desc: "Run without writing files", default: false, type: :boolean
11
+ method_option :reporter, desc: "Set reporting formatter", default: "Default", type: :string
12
+ method_option :dry_run, desc: "Run without writing files", default: false, type: :boolean
13
13
  method_option :verbosity, aliases: "-v", desc: "Preferred amount of output", enum: %w(all written silent), default: "written", type: :string
14
14
  def build
15
15
  ENV["MUNGE_ENV"] ||= "production"
@@ -16,10 +16,13 @@ module Munge
16
16
  socket << @messaging.reload(file)
17
17
  end
18
18
  rescue Reel::SocketError
19
+ print_error("error pushing livereload notification to browser")
19
20
  end
20
21
  end
21
22
  end
22
23
 
24
+ private
25
+
23
26
  def on_connection(connection)
24
27
  connection.each_request do |request|
25
28
  if request.websocket?
@@ -41,6 +44,7 @@ module Munge
41
44
  end
42
45
  end
43
46
  rescue Reel::SocketError
47
+ print_error("error with livereload socket")
44
48
  end
45
49
 
46
50
  def handle_request(request)
@@ -51,6 +55,10 @@ module Munge
51
55
  request.respond(:not_found, "not found")
52
56
  end
53
57
  end
58
+
59
+ def print_error(message)
60
+ $stderr.puts(message)
61
+ end
54
62
  end
55
63
  end
56
64
  end
data/lib/munge/item.rb CHANGED
@@ -41,6 +41,14 @@ module Munge
41
41
  Munge::Util::Path.basename_no_extension(@relpath)
42
42
  end
43
43
 
44
+ # @return [String] relpath, without extensions
45
+ def basepath
46
+ dirname = Munge::Util::Path.dirname(@relpath)
47
+ basename = Munge::Util::Path.basename_no_extension(@relpath)
48
+
49
+ Munge::Util::Path.join(dirname, basename)
50
+ end
51
+
44
52
  # @return [Array<String>] extensions (everything following the first ".")
45
53
  def extensions
46
54
  Munge::Util::Path.extnames(@relpath)
data/lib/munge/runner.rb CHANGED
@@ -39,8 +39,6 @@ module Munge
39
39
  @written_items.push(route)
40
40
  when :double_write_error
41
41
  raise Errors::DoubleWriteError, item.route
42
- when :identical
43
- # Defer to the reporter
44
42
  end
45
43
 
46
44
  @reporter.call(item, relpath, write_status)
@@ -60,14 +60,14 @@ module Munge
60
60
  private
61
61
 
62
62
  def item_file_type(abspath)
63
- if has_text_extension?(abspath)
63
+ if text_file_extension?(abspath)
64
64
  :text
65
65
  else
66
66
  :binary
67
67
  end
68
68
  end
69
69
 
70
- def has_text_extension?(filepath)
70
+ def text_file_extension?(filepath)
71
71
  extensions = Munge::Util::Path.extnames(filepath)
72
72
  intersection = extensions & @text_extensions
73
73
 
data/lib/munge/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Munge
2
- VERSION = "0.16.0".freeze
2
+ VERSION = "0.17.0".freeze
3
3
  end
data/seeds/Gemfile.tt CHANGED
@@ -1,3 +1,3 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gem 'munge', '~> <%= Munge::VERSION %>'
3
+ gem "munge", "~> <%= Munge::VERSION %>"
@@ -0,0 +1,5 @@
1
+ <% layout("default") do %>
2
+ <h1>Blog</h1>
3
+
4
+ <%= yield %>
5
+ <% end %>
@@ -1,4 +1,4 @@
1
- <% layout("default") do %>
1
+ <% layout("blog") do %>
2
2
  <ul>
3
3
  <% posts.each do |post| %>
4
4
  <li><a href="<%= path_to(post) %>"><%= post.basename %></a></li>
@@ -1,7 +1,6 @@
1
- <% layout("default") do %>
2
- <h1>Blog</h1>
3
-
1
+ <% layout("blog") do %>
4
2
  <% posts.each do |post| %>
5
3
  <%= render(post) %>
4
+ <%= link_to(post, "Permalink") %>
6
5
  <% end %>
7
6
  <% end %>
@@ -1,3 +1,3 @@
1
- <% layout("default") do %>
1
+ <% layout("blog") do %>
2
2
  <%= yield %>
3
3
  <% end %>
data/seeds/rules.rb CHANGED
@@ -32,7 +32,8 @@ app.create("blog-archive.html.erb", "", posts: blog_public_items)
32
32
  # Home page rules
33
33
  app.nonrouted
34
34
  .select { |item| item.relpath?("home") }
35
- .each { |item| item.route = "#{item.id.sub(%r{^home/}, "")}" }
35
+ .select { |item| item.type == :text }
36
+ .each { |item| item.route = "#{item.basepath.sub(%r{^home/}, "")}" }
36
37
  .each { |item| item.layout = "default" }
37
38
  .each(&transform)
38
39
 
@@ -0,0 +1,3 @@
1
+ <h2>First Post</h2>
2
+
3
+ <p>I love using munge!</p>
@@ -0,0 +1,3 @@
1
+ <h2>Wow!</h2>
2
+
3
+ <p>This is really cool!</p>
@@ -0,0 +1,3 @@
1
+ <h2>This is a draft</h2>
2
+
3
+ <p>This file is hidden from the primary view, but it is still compiled.</p>
@@ -22,10 +22,11 @@ title: Woohoo!
22
22
  </p>
23
23
 
24
24
  <p>
25
- <strong><code>config.yml</code>:</strong>
25
+ <strong><code>config.rb</code>:</strong>
26
26
  The keys defined here are used to change the behavior of the app.
27
27
  Many of the keys are passed directly into the initializers in
28
- <code>setup.rb</code>.
28
+ <code>setup.rb</code>. It is possible to create arbitrary configuration keys
29
+ and use them in custom plugins, etc.
29
30
  </p>
30
31
 
31
32
  <h2>Example Links</h2>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: munge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Ahn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-24 00:00:00.000000000 Z
11
+ date: 2017-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -302,7 +302,7 @@ dependencies:
302
302
  - - "~>"
303
303
  - !ruby/object:Gem::Version
304
304
  version: '0.6'
305
- description: Documentation for this release is located in https://github.com/zachahn/munge/blob/v0.16.0/README.md
305
+ description: Documentation for this release is located in https://github.com/zachahn/munge/blob/v0.17.0/README.md
306
306
  email:
307
307
  - zach.ahn@gmail.com
308
308
  executables:
@@ -376,6 +376,7 @@ files:
376
376
  - seeds/Gemfile.tt
377
377
  - seeds/config.rb
378
378
  - seeds/data.yml
379
+ - seeds/layouts/blog.html.erb
379
380
  - seeds/layouts/blog_archives.html.erb
380
381
  - seeds/layouts/blog_index.html.erb
381
382
  - seeds/layouts/blog_show.html.erb
@@ -392,9 +393,9 @@ files:
392
393
  - seeds/src/assets/javascripts/.empty_directory
393
394
  - seeds/src/assets/stylesheets/_vars.scss
394
395
  - seeds/src/assets/stylesheets/basic.css.scss
395
- - seeds/src/blog/01-first-post.md
396
- - seeds/src/blog/02-second-post.md
397
- - seeds/src/blog/03-third-post.draft.md
396
+ - seeds/src/blog/01-first-post.html
397
+ - seeds/src/blog/02-second-post.html
398
+ - seeds/src/blog/03-third-post.draft.html
398
399
  - seeds/src/home/about.html.erb
399
400
  - seeds/src/home/index.html.erb
400
401
  homepage: https://github.com/zachahn/munge
@@ -1,3 +0,0 @@
1
- ## First Post
2
-
3
- I love using munge!
@@ -1,3 +0,0 @@
1
- ## Wow!
2
-
3
- This is really cool!
@@ -1,3 +0,0 @@
1
- ## This is a draft
2
-
3
- This file is hidden from the primary view, but it is still compiled.