liquid-cli 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ed92e8ceabc303126a0a200532e1f247e2854c26
4
+ data.tar.gz: 923d8913d5a97d4a58b18f70a220beec25405299
5
+ SHA512:
6
+ metadata.gz: 9fa4a6825737828685bd9e91f06596c29a6c1e93f93c871e986eb0a24248ad68855eedc4dba5c17bb487c4d51c2db49449424171dd796f897d70cc84c7f8f52f
7
+ data.tar.gz: 4a2089a87a19fe35a6d2e024cf40154210836126d9baf6d770316eaed862c89cac862034d00e3ff9688353c2577cc5ad0435cd98bde67cb55319ceab7d0b7328
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in liquid-cli.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 patrick brisbin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # Liquid-CLI
2
+
3
+ A command-line wrapper over the [liquid][] ruby library by Shopify.
4
+
5
+ [liquid]: https://github.com/Shopify/liquid
6
+
7
+ ## Installation
8
+
9
+ $ gem install liquid-cli
10
+
11
+ ## Usage
12
+
13
+ Supply a template on `stdin` and an optional context as JSON.
14
+
15
+ $ echo 'Hi, my name is {{ name }}.' | liquid '{ "name": "Pat" }'
16
+ Hi, my name is Pat.
17
+
18
+ Use shell redirection to make handling larger templates and contexts
19
+ easier:
20
+
21
+ $ cat context.json
22
+ {
23
+ "title": "A title",
24
+ "posts": [
25
+ {
26
+ "link": "/posts/foo",
27
+ "content": "Foo"
28
+ },
29
+ {
30
+ "link": "/posts/bar",
31
+ "content": "Bar"
32
+ }
33
+ ]
34
+ }
35
+
36
+ $ liquid "$(< context.json)" <<EOF
37
+ <h1>{{ title }}</h1>
38
+ {% for post in posts %}
39
+ <a href="{{ post.link }}">{{ post.content }}</a>
40
+ {% endfor %}
41
+ EOF
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # pbrisbin 2013
4
+ #
5
+ ###
6
+ require 'liquid/cli'
7
+
8
+ $stdout.write(
9
+ Liquid::Cli.new(ARGV.first || '{}').render($stdin.read)
10
+ )
@@ -0,0 +1,19 @@
1
+ require 'json'
2
+ require 'liquid'
3
+ require 'liquid/cli/version'
4
+
5
+ module Liquid
6
+ class Cli
7
+ def initialize(json_context)
8
+ @context = JSON.parse(json_context)
9
+ end
10
+
11
+ def render(input)
12
+ Template.parse(input).render(context)
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :context
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ module Liquid
2
+ class Cli
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'liquid/cli/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "liquid-cli"
8
+ spec.version = Liquid::Cli::VERSION
9
+ spec.authors = ["patrick brisbin"]
10
+ spec.email = ["pbrisbin@gmail.com"]
11
+ spec.description = %q{Command line interface to the Liquid gem by Shopify}
12
+ spec.summary = %q{Render liquid templates on the command line.}
13
+ spec.homepage = "https://github.com/pbrisbin/liquid-cli"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'liquid'
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Liquid::Cli do
4
+ it "works" do
5
+ liquid = described_class.new(<<-EOJSON)
6
+ {
7
+ "products": [
8
+ {
9
+ "name": "Product One",
10
+ "price": "$19.99",
11
+ "description": "The first description"
12
+ },
13
+ {
14
+ "name": "Product Two",
15
+ "price": "$29.99",
16
+ "description": "The second description"
17
+ }
18
+ ]
19
+ }
20
+ EOJSON
21
+
22
+ rendered = liquid.render(<<-EOTEMPLATE)
23
+ <ul id="products">
24
+ {% for product in products %}
25
+ <li>
26
+ <h2>{{ product.name }}</h2>
27
+ Only {{ product.price }}
28
+
29
+ {{ product.description }}
30
+ </li>
31
+ {% endfor %}
32
+ </ul>
33
+ EOTEMPLATE
34
+
35
+ expect(rendered).to eq <<-EOOUTPUT
36
+ <ul id="products">
37
+
38
+ <li>
39
+ <h2>Product One</h2>
40
+ Only $19.99
41
+
42
+ The first description
43
+ </li>
44
+
45
+ <li>
46
+ <h2>Product Two</h2>
47
+ Only $29.99
48
+
49
+ The second description
50
+ </li>
51
+
52
+ </ul>
53
+ EOOUTPUT
54
+ end
55
+ end
@@ -0,0 +1 @@
1
+ require 'liquid/cli'
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: liquid-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - patrick brisbin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: liquid
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Command line interface to the Liquid gem by Shopify
56
+ email:
57
+ - pbrisbin@gmail.com
58
+ executables:
59
+ - liquid
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/liquid
69
+ - lib/liquid/cli.rb
70
+ - lib/liquid/cli/version.rb
71
+ - liquid-cli.gemspec
72
+ - spec/liquid/cli_spec.rb
73
+ - spec/spec_helper.rb
74
+ homepage: https://github.com/pbrisbin/liquid-cli
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.1.5
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Render liquid templates on the command line.
98
+ test_files:
99
+ - spec/liquid/cli_spec.rb
100
+ - spec/spec_helper.rb