octopress-debugger 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +30 -6
- data/lib/octopress-debugger.rb +34 -5
- data/lib/octopress-debugger/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7463b0ffbd9905868c17f0acc61818c5f0d6c337
|
4
|
+
data.tar.gz: b7cf05d2359a3f821c096f6c2dcc0fc8ca4749ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c91d450b9a341f77af542252ccf62529edbd8c6c5c86b584285fd981a1a15f37b67fc85681239be9d95f3c99b354e31380ba9ce2b32e3783f9779f099d58c84b
|
7
|
+
data.tar.gz: 0fa3961ef081f06cd4973cf5f0d6d81d1a031a29ca7b6cb9349b2fa7c986983653d4f8a3e529c11a55a3c5e56ff4ccedf2b2da34549b13d6bfb503e868ec7385
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -28,14 +28,38 @@ Then add the gem to your Jekyll configuration.
|
|
28
28
|
|
29
29
|
## Usage
|
30
30
|
|
31
|
-
Add the `{% debug %}` tag to any page to get access to the
|
31
|
+
Add the `{% debug %}` tag to any page to get access to the debugger console when that page is generated.
|
32
32
|
|
33
33
|
This will launch an interactive debugging console where you can do some cool things.
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
-
|
38
|
-
-
|
35
|
+
Some useful debugger commands:
|
36
|
+
|
37
|
+
- `continue` - to go to the next `{% debug %}` tag, or step through a loop.
|
38
|
+
- `abort` - to exit the debugger.
|
39
|
+
- `help` - show manual for the debugger and learn other commands.
|
40
|
+
|
41
|
+
I've added some convenience methods for working with the Liquid context.
|
42
|
+
|
43
|
+
- `c` - Liquid's context
|
44
|
+
- `site` - Jekyll's Site class instance.
|
45
|
+
- `page` - Current Page class instance.
|
46
|
+
- `scopes` - Scopes for local variables.
|
47
|
+
|
48
|
+
You can pass strings to the `c` method to inspect variables.
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
c 'site' # => current site payload hash
|
52
|
+
c 'page' # => current page payload hash
|
53
|
+
```
|
54
|
+
|
55
|
+
Dot notation works too:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
c 'site.pages' # => Array of site posts
|
59
|
+
c 'site.posts.first' # => First post instance in site posts array
|
60
|
+
c 'page.layout' # => Read data from current page
|
61
|
+
c 'foo' # => Read locally assigned vars
|
62
|
+
```
|
39
63
|
|
40
64
|
### Example:
|
41
65
|
|
@@ -66,7 +90,7 @@ In the debugger you can type `scopes` to see a hash representing variables in th
|
|
66
90
|
You can see the value of post and interact with the post instance with `scopes.first['post']` and even see all the available data on
|
67
91
|
the for loop.
|
68
92
|
|
69
|
-
Then you can
|
93
|
+
Then you can type `continue` to step through the loop or go to the next `{% debug %}` tag.
|
70
94
|
|
71
95
|
## Contributing
|
72
96
|
|
data/lib/octopress-debugger.rb
CHANGED
@@ -11,14 +11,43 @@ module Octopress
|
|
11
11
|
module Debugger
|
12
12
|
class Tag < Liquid::Tag
|
13
13
|
def render(context)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
@context = context
|
15
|
+
|
16
|
+
# HELP: How does this work?
|
17
|
+
#
|
18
|
+
# Try these commands:
|
19
|
+
# site => Jekyll's Site instance
|
20
|
+
# page => Current Page instance
|
21
|
+
# scopes => View local variable scopes
|
22
|
+
#
|
23
|
+
# Use `c` to read variables from Liquid's context
|
24
|
+
# c 'site' => site hash
|
25
|
+
# c 'page' => page hash
|
26
|
+
#
|
27
|
+
# Dot notation works too:
|
28
|
+
# c 'site.posts.first'
|
29
|
+
# c 'page.content'
|
30
|
+
# c 'post.tags'
|
18
31
|
|
19
32
|
binding.pry
|
20
33
|
|
21
|
-
return ''
|
34
|
+
return '' # Debugger halts on this line
|
35
|
+
end
|
36
|
+
|
37
|
+
def c(var=nil)
|
38
|
+
var.nil? ? @context : @context[var]
|
39
|
+
end
|
40
|
+
|
41
|
+
def site
|
42
|
+
site = @context.registers[:site]
|
43
|
+
end
|
44
|
+
|
45
|
+
def page
|
46
|
+
@page ||= site.pages.find{|p| p.url == c('page')['url'] }
|
47
|
+
end
|
48
|
+
|
49
|
+
def scopes
|
50
|
+
@context.scopes
|
22
51
|
end
|
23
52
|
end
|
24
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octopress-debugger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|