liquid-pry 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0d9747dc63c9436ee4bcf2cb85fc51b89fefeaf442708c30d0acb3910643bf13
4
+ data.tar.gz: b2a64764e8f320d52605b62f19d5a6db8cf4707762f5f7909660ac19b1c8110b
5
+ SHA512:
6
+ metadata.gz: de236b237a9d9741760b0accdd08a740b58e5daff8aa9c8ac4386dc68965e73390e7e8a0fdee5365cb209f693e27315ad534c646972a3919d03fad9c947e0b53
7
+ data.tar.gz: 74762c11ac13274016cb0b168f4807d1bfb8e25bf9e452b97a42d19e8a4c76385c5f22ca96f52ff52b69a0a4ad166be9caa875147596861b0d7a60ccc4761474
data/.editorconfig ADDED
@@ -0,0 +1,15 @@
1
+ # EditorConfig is awesome: http://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ # Unix-style newlines with a newline ending every file
7
+ [*]
8
+ charset = utf-8
9
+ end_of_line = lf
10
+
11
+ [*.{adoc,md,rb}]
12
+ indent_style = space
13
+ indent_size = 2
14
+ insert_final_newline = true
15
+ trim_trailing_whitespace = true
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in liquid-pry.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Sebastian Skałacki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.adoc ADDED
@@ -0,0 +1,136 @@
1
+ = Liquid::Pry
2
+
3
+ :jekyll: https://jekyllrb.com/
4
+ :jekyll_plugin_install: https://jekyllrb.com/docs/plugins/installation/
5
+ :pry: https://pry.github.io/
6
+ :ribose: https://www.ribose.com
7
+
8
+ ifndef::env-github[]
9
+ [quote, Pry home page]
10
+ Pry is a runtime developer console with powerful introspection capabilities.
11
+ endif::[]
12
+ ifdef::env-github[]
13
+ “Pry is a runtime developer console with powerful introspection capabilities.”
14
+ -- Pry home page
15
+ endif::[]
16
+
17
+ Liquid::Pry brings {pry}[Pry] to Liquid templates and to Jekyll-powered sites.
18
+
19
+ == Installation
20
+
21
+ === Without Jekyll
22
+
23
+ Add following to the `Gemfile`:
24
+
25
+ ----
26
+ gem "liquid-pry"
27
+ ----
28
+
29
+ === With Jekyll
30
+
31
+ If you want to integrate Liquid::Pry with Jekyll, it's probably the easiest
32
+ to add following to the `Gemfile`, so that Jekyll will automatically load and
33
+ enable Liquid::Pry:
34
+
35
+ ----
36
+ group :jekyll_plugins do
37
+ gem "liquid-pry"
38
+ end
39
+ ----
40
+
41
+ For other options, read {jekyll_plugin_install}[Jekyll documentation].
42
+
43
+ == Usage
44
+
45
+ This gem provides a Liquid filter and a Liquid tag.
46
+
47
+ === Filter
48
+
49
+ The `pry` filter hooks Pry into filter chain in a Liquid template, helping user
50
+ to debug Jekyll's front matter or any other data available in given template.
51
+ For example following could be used to debug `page.title`:
52
+
53
+ ----
54
+ You are on page {{ page.title | pry }}.
55
+ ----
56
+
57
+ When Liquid renderer encounters `pry` filter, then Pry console is launched.
58
+ A convenience local variable named `input` is defined, which contains filter
59
+ input (value of `page.title` in above example), allowing site developer to
60
+ inspect or alter that value. Another local variable `context` provides access
61
+ to rendering context.
62
+
63
+ The filter returns its input, hence it does not affect rendered page. Also, it
64
+ can be placed anywhere in the filter chain, not necessarily at the end.
65
+ For example, in a following example `pry` filter is placed before `upcase`,
66
+ allowing user to inspect `page.title` value before the `upcase` filter is
67
+ applied.
68
+
69
+ ----
70
+ You are on page {{ page.title | pry | upcase }}.
71
+ ----
72
+
73
+ However, if user modify the value of `input` variable, then modified version is
74
+ returned. This may be used for experimenting.
75
+
76
+ The `pry` filter is typically more useful than the `pry` tag, especially for
77
+ novice users.
78
+
79
+ === Tag
80
+
81
+ The `pry` tag interrupts Liquid rendering, allowing user to inspect or modify
82
+ the rendering context. For example:
83
+
84
+ ----
85
+ {% pry %}
86
+ ----
87
+
88
+ When Liquid renderer encounters `pry` tag, then Pry console is launched
89
+ and rendering context is available via `context` local variable.
90
+
91
+ ==== Using with `once` option
92
+
93
+ If `pry` tag is supplied with `once` option, then Pry console is launched only
94
+ for the first time that tag is encountered on given page. In following example:
95
+
96
+ ----
97
+ {% for product in collection.products %}
98
+ {% pry once %}
99
+ {{ product.title }}
100
+ {% endfor %}
101
+ ----
102
+
103
+ Pry will be launched only once, no matter if `collection.products` contains one
104
+ item or a hundred.
105
+
106
+ Still, in following example Pry will be launched twice, because `pry` tag is
107
+ placed that many times in the template:
108
+
109
+ ----
110
+ {% pry once %}
111
+ {% pry once %}
112
+ ----
113
+
114
+ === Using Pry console
115
+
116
+ See {pry}[Pry documentation].
117
+
118
+ == Credits
119
+
120
+ This gem is developed, maintained and funded by {ribose}[Ribose Inc.]
121
+
122
+ == License
123
+
124
+ The gem is available as open source under the terms of the
125
+ https://opensource.org/licenses/MIT[MIT License].
126
+
127
+ == See also
128
+
129
+ This gem is tiny but quite comprehensive. However, there are some other ones
130
+ you may want to try:
131
+
132
+ - https://github.com/gemfarmer/jekyll-debug[jekyll-debug]
133
+ - https://github.com/zhongxiang117/jekyll-liquid-debug[jekyll-liquid-debug]
134
+ (a very different approach)
135
+ - https://github.com/octopress/debugger[octopress-debugger]
136
+ (seems unmaintained as of Jan 2021)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jekyll/pry"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/liquid-pry.rb ADDED
@@ -0,0 +1,4 @@
1
+ # (c) Copyright 2020 Ribose Inc.
2
+ #
3
+
4
+ require_relative "liquid/pry"
data/lib/liquid/pry.rb ADDED
@@ -0,0 +1,15 @@
1
+ # (c) Copyright 2020 Ribose Inc.
2
+ #
3
+
4
+ require_relative "pry/version"
5
+
6
+ require "liquid"
7
+ require "pry"
8
+
9
+ require_relative "pry/filter"
10
+ require_relative "pry/tag"
11
+
12
+ module Liquid
13
+ module Pry
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ # (c) Copyright 2020 Ribose Inc.
2
+ #
3
+
4
+ module Liquid
5
+ module Pry
6
+ # +pry+ filter hooks Pry into filter chain in a Liquid template. User can
7
+ # inspect or modify filter input and rendering context via convenient
8
+ # +input+ and +context+ local variables.
9
+ #
10
+ # The filter returns its input, hence it can be placed anywhere in the
11
+ # filter chain, not necessarily at the end. If user alters the +input+
12
+ # variable, then modified version is returned.
13
+ #
14
+ # @example
15
+ # Today is {{ site.time | pry | date_to_string }}
16
+ module Filter
17
+ # @param input filter input
18
+ def pry(input)
19
+ context = @context
20
+ binding.pry
21
+ input
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ Liquid::Template.register_filter(Liquid::Pry::Filter)
@@ -0,0 +1,47 @@
1
+ # (c) Copyright 2020 Ribose Inc.
2
+ #
3
+
4
+ module Liquid
5
+ module Pry
6
+ # Interrupts rendering, allowing user to inspect or modify the context.
7
+ #
8
+ # @example
9
+ # {% pry %}
10
+ class Tag < Liquid::Tag
11
+ attr_reader :once
12
+ attr_reader :visited
13
+
14
+ def initialize(tag_name, text, tokens)
15
+ super
16
+ @visited = false
17
+ parse_args(text)
18
+ end
19
+
20
+ def parse_args(args_str)
21
+ case args_str.strip
22
+ when ""
23
+ return
24
+ when "once"
25
+ set_once
26
+ else
27
+ raise(
28
+ ArgumentError,
29
+ "Arguments passed to pry tag could not be recognized: #{args_str}",
30
+ )
31
+ end
32
+ end
33
+
34
+ def set_once
35
+ @once = true
36
+ end
37
+
38
+ def render(context)
39
+ binding.pry unless once && visited
40
+ @visited = true
41
+ ""
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ Liquid::Template.register_tag("pry", Liquid::Pry::Tag)
@@ -0,0 +1,8 @@
1
+ # (c) Copyright 2020 Ribose Inc.
2
+ #
3
+
4
+ module Liquid
5
+ module Pry
6
+ VERSION = "1.0.0"
7
+ end
8
+ end
@@ -0,0 +1,25 @@
1
+ require_relative 'lib/liquid/pry/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "liquid-pry"
5
+ spec.version = Liquid::Pry::VERSION
6
+ spec.authors = ["Ribose Inc."]
7
+ spec.email = ["open.source@ribose.com"]
8
+
9
+ spec.summary = "Brings Pry to Liquid templates."
10
+ spec.homepage = "https://github.com/geolexica/liquid-pry"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ all_files_in_git = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
15
+
16
+ spec.files = all_files_in_git.reject { |f| f.match(%r{^(test|spec|features|.github)/}) }
17
+ spec.executables = all_files_in_git.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.bindir = "exe"
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency("liquid")
22
+ spec.add_runtime_dependency("pry")
23
+
24
+ spec.add_development_dependency("rspec", "~> 3.9")
25
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: liquid-pry
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ribose Inc.
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-02-05 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: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.9'
55
+ description:
56
+ email:
57
+ - open.source@ribose.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".editorconfig"
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.adoc
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - lib/liquid-pry.rb
72
+ - lib/liquid/pry.rb
73
+ - lib/liquid/pry/filter.rb
74
+ - lib/liquid/pry/tag.rb
75
+ - lib/liquid/pry/version.rb
76
+ - liquid-pry.gemspec
77
+ homepage: https://github.com/geolexica/liquid-pry
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 2.3.0
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubygems_version: 3.1.4
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Brings Pry to Liquid templates.
100
+ test_files: []