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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c131591fc3151c379b8e994522ae21562e2ad2e
4
- data.tar.gz: cfdd31bb6f9f2bfc89444a8b53613ab0c0f1acb6
3
+ metadata.gz: 7463b0ffbd9905868c17f0acc61818c5f0d6c337
4
+ data.tar.gz: b7cf05d2359a3f821c096f6c2dcc0fc8ca4749ac
5
5
  SHA512:
6
- metadata.gz: d976963a417013811726685d5d9fd4c129202a9585d0619b9c354787689eadc90daa2932fd1ea1ad3d8de971e42199711dd8af55f1cc0b1d8df97fc70c4ea65d
7
- data.tar.gz: dbb5ab3b0c1141e77a207941229af982d385bf4d57887b457c3ce329712810e9c0e81b9c4b60373bd7e80464f979ab857fe84dae902a925473b6093738290141
6
+ metadata.gz: c91d450b9a341f77af542252ccf62529edbd8c6c5c86b584285fd981a1a15f37b67fc85681239be9d95f3c99b354e31380ba9ce2b32e3783f9779f099d58c84b
7
+ data.tar.gz: 0fa3961ef081f06cd4973cf5f0d6d81d1a031a29ca7b6cb9349b2fa7c986983653d4f8a3e529c11a55a3c5e56ff4ccedf2b2da34549b13d6bfb503e868ec7385
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.0.2 (2015-01-12)
4
+ - New convenience methods
5
+ - Documentation improvements
6
+
3
7
  ### 1.0.1 (2015-01-12)
4
8
  - Added scopes quick var
5
9
  - Improved docs
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 `site` and `page` instance from the debugger console.
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
- - Type `site` to interact with the site instance.
36
- - Type `page` to interact with the current page instance.
37
- - Type `page_hash` to view the page instance as a hash.
38
- - Type `scopes` to view current template variables.
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 enter `continue` or `c` to step through the loop.
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
 
@@ -11,14 +11,43 @@ module Octopress
11
11
  module Debugger
12
12
  class Tag < Liquid::Tag
13
13
  def render(context)
14
- site = context.registers[:site]
15
- page_hash = context.registers[:page]
16
- page = site.pages.find{|p| p.url == page_hash['url'] }
17
- scopes = context.scopes
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
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Debugger
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  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.1
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-01-12 00:00:00.000000000 Z
11
+ date: 2015-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll