jing 0.1.2 → 0.1.3

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
  SHA256:
3
- metadata.gz: fce7b39e1004372eaf049d7239ac73f0bcef8d09a6146c94faa94aac758672c5
4
- data.tar.gz: 99b7422b582c7dba5d64c0185a222f8625b4812c4068b0f5965b9e4fbbf1872e
3
+ metadata.gz: c0109a16bd2e74f10edbe5aa725d5e8b63ff68e1ba1c5b5668641f351a2f172f
4
+ data.tar.gz: f5c8d6cf786cfc9032d3f06c1a8c4361e7a612a3b8927c11b1e45256981ce3dc
5
5
  SHA512:
6
- metadata.gz: ca1c466311c5750a14212b17c5091f26c21eec30bd27c6e81aff7d92013bdb34a9c6b2a9363a7f14b2ab5c48b3da90ea811f09afdf35bb586f3b1cefc29978cf
7
- data.tar.gz: '08cf948f3d7f3fd3b145680fab41bcb28127d1bb007e28696f36a5d2f20025bfc06fc26d53f298cfbdb4f9c5b05026523018842535ea2e4dcfe901ae2d0ef894'
6
+ metadata.gz: d2bb4d26c9d2371c680f347e1ffec482c83a2179a750063a252791ffb70c0440027991f398ca40d6cd65a4b1e0c9e5097a9a67fdb244b99ca1f0bb9f8528c104
7
+ data.tar.gz: 23ed2e92a0df6b52bd94c0c48a81ba5364125a4e1e0380e2c47cff09f929f11e0837cc21c6a306f47680c991ecf936657f68f5dc167a30dd31f59d663d010242
data/.gitignore CHANGED
@@ -6,4 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /examples/**/_dst/
9
10
  *.gem
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jing (0.1.0)
4
+ jing (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -47,6 +47,8 @@ Serves the current project folder on `http://0.0.0.0:8000`:
47
47
 
48
48
  $ jing serve
49
49
 
50
+ File endings work like Russian dolls: They get converted from outer to inner. Rails folks should be somewhat familiar with that but here it's a bit stricter.
51
+
50
52
  Folders starting with `_` have special meaning, they generally won't get copied into the destination folder `_dst`.
51
53
 
52
54
  `_partials` holds partials (TODO: explanation)
@@ -55,8 +57,7 @@ Folders starting with `_` have special meaning, they generally won't get copied
55
57
 
56
58
  `.meta.yml` holds global meta variables available in templates when not overwritten
57
59
 
58
- I'll try and add a basic example project soon. If you feel like wanting to giving this a try in the meantime feel free to open an issue or reach out otherwise.
59
-
60
+ ~~I'll try and add a basic example project soon.~~ Check out the examples folder. If you feel like giving this a try and have questions feel free to open an issue or reach out otherwise. Pull requests welcome too.
60
61
 
61
62
  ## Development
62
63
 
@@ -0,0 +1,5 @@
1
+ # Examples
2
+
3
+ In each example folder you will have to run `jing build` and `jing serve` then go to `http://localhost:8000`
4
+
5
+
@@ -0,0 +1,4 @@
1
+ ---
2
+ generator: jing
3
+ name: simplepage
4
+ ---
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE HTML>
2
+ <html lang="en-US">
3
+ <head>
4
+ <title><%= meta[:name] %></title>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
7
+ </head>
8
+ <body>
9
+ <%= body %>
10
+ </body>
11
+ </html>
@@ -0,0 +1 @@
1
+ <pre><%= meta[:message] || 'no message' %></pre>
@@ -0,0 +1,11 @@
1
+ ---
2
+ layout: main
3
+ some_var: 999
4
+ another_var: bottles of beer on the wall
5
+ ---
6
+
7
+ <h1>not much to do here except .. </h1>
8
+ <p><%= meta[:some_var]%> ... <%= meta[:another_var] %> ... take one down ...</p>
9
+ <p>a little song teaser</p>
10
+
11
+ <a href="/index.html">back to index</a>
@@ -0,0 +1,12 @@
1
+ ---
2
+ layout: main
3
+ ---
4
+ # Hello world!
5
+
6
+ This is a simple example page
7
+
8
+ <%= render('some_partial', message: 'hello again') %>
9
+
10
+ ![image](/images/lenna.jpg)
11
+
12
+ [another page](/another.html)
@@ -31,7 +31,7 @@ module Jing
31
31
  }},
32
32
  {extensions: %w[js], handler: ->(body, meta, ctx){
33
33
  load_gem 'uglifier'
34
- Uglifier.compile(body, harmony: true)
34
+ Uglifier.compile(body, harmony: true, output: {ascii_only: true})
35
35
  }},
36
36
  {extensions: %w[md markdown], handler: ->(body, meta, ctx){
37
37
  load_gem 'kramdown'
@@ -79,7 +79,7 @@ module Jing
79
79
  puts "Error\t#{file[@src.size+1..-1]}\n\t#{e.message}\n#{e.backtrace.map{|x| "\t#{x}"}.join("\n")}"
80
80
  end
81
81
 
82
- def build!
82
+ def build!(opts={})
83
83
  t = Time.now
84
84
  FileUtils.rm_r(@dst) if File.exist?(@dst)
85
85
  Dir.mkdir(@dst)
@@ -95,24 +95,30 @@ module Jing
95
95
  puts "#{'%.4fs' % (Time.now-t)} total"
96
96
  end
97
97
 
98
- def watch!
98
+ def watch!(opts={})
99
99
  @converter_extensions.delete('js')
100
- build!
100
+ build!(opts)
101
101
  load_gem('filewatcher')
102
102
  Filewatcher.new([@src, '**', '*']).watch do |filename, event|
103
- puts "WATCHED #{filename}\t#{event}"
104
- build!
103
+ unless File.expand_path(filename) == @dst
104
+ puts "WATCHED #{filename}\t#{event}"
105
+ build!(opts)
106
+ end
105
107
  end
106
108
  end
107
109
 
108
- def serve!
109
- WEBrick::HTTPServer.new(Port: 8000, DocumentRoot: @dst).start
110
+ def serve!(opts={})
111
+ WEBrick::HTTPServer.new(Port: opts[:port] || 8000, DocumentRoot: opts[:root] || @dst).start
110
112
  end
111
113
 
112
- def create!
113
- abort("usage: #{File.basename($0)} create <name/path>") unless ARGV[1]
114
- %w[_layouts _partials].each { |e| FileUtils.mkdir_p(File.join(ARGV[1], e)) }
115
- File.write(File.join(ARGV[1], '.meta.yml'), "---\ngenerator: jing\nname: #{File.basename(ARGV[1])}\n---\n")
114
+ def create!(opts={})
115
+ abort("usage: #{File.basename($0)} create -name <pathname>") unless opts[:name]
116
+ %w[_layouts _partials].each { |e| FileUtils.mkdir_p(File.join(opts[:name], e)) }
117
+ File.write(File.join(opts[:name], '.meta.yml'), "---\ngenerator: jing\nname: #{File.basename(opts[:name])}\n---\n")
118
+ end
119
+
120
+ def version!(opts={})
121
+ puts VERSION
116
122
  end
117
123
  end
118
124
 
@@ -120,7 +126,8 @@ module Jing
120
126
  cmd = ARGV[0]
121
127
  commands = Jing.instance_methods(false).grep(/!$/).map{|e| e[0..-2]}
122
128
  abort("usage: #{File.basename($0)} <#{commands.join('|')}>") unless commands.include?(cmd)
123
- jing = Jing.new()
124
- jing.send(:"#{cmd}!")
129
+ opts = ARGV[1..-1].each_slice(2).reduce({}){|s,(k,v)| s[k.match(/^\-*(.*)$/)[1].to_sym] = v; s}
130
+ jing = Jing.new(opts)
131
+ jing.send(:"#{cmd}!", opts)
125
132
  end
126
133
  end
@@ -1,3 +1,3 @@
1
1
  module Jing
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - pachacamac
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-15 00:00:00.000000000 Z
11
+ date: 2019-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -57,6 +57,13 @@ files:
57
57
  - bin/console
58
58
  - bin/jing
59
59
  - bin/setup
60
+ - examples/README.md
61
+ - examples/simplepage/.meta.yml
62
+ - examples/simplepage/_layouts/main.html.erb
63
+ - examples/simplepage/_partials/some_partial.html.erb
64
+ - examples/simplepage/another.html.erb
65
+ - examples/simplepage/images/lenna.jpg
66
+ - examples/simplepage/index.html.md.erb
60
67
  - jing.gemspec
61
68
  - lib/jing.rb
62
69
  - lib/jing/version.rb