jekyll-code-example-tag 0.0.2 → 0.0.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 +4 -4
- data/.ruby-version +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +101 -0
- data/README.md +11 -0
- data/jekyll-code-example-tag.gemspec +1 -1
- data/lib/jekyll-code-example-tag.rb +28 -0
- data/lib/js/jekyll-code-example-buttons.js +17 -0
- data/spec/all_page_code_examples_spec.rb +45 -0
- data/spec/code_example_spec.rb +42 -0
- data/spec/spec_helper.rb +9 -0
- metadata +14 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 271a0085affcfa80d82b34157ff70007cbda6db5
|
4
|
+
data.tar.gz: adb5ee89ce47a1a63981d7dfc7a2f39b18de72e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6a5c56e9af55ef23b5c36557fd52bd046069848c6b3933b4c32346a44da47245ec7b8856e7b5e8dfc8069af70800cffa85e70317db1793f61d513a4e0657b2e
|
7
|
+
data.tar.gz: dbbe4a7bc8f2bd7d46440c0031781db957818a9a10885a9f582466e0952b942e18b5ee0822621bb532ce75387ef6d4aa376e56c1b4b8dcfa62b54f98f1ac903e
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jekyll-code-example-tag (0.0.3)
|
5
|
+
jekyll
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
blankslate (2.1.2.4)
|
11
|
+
celluloid (0.16.0)
|
12
|
+
timers (~> 4.0.0)
|
13
|
+
classifier-reborn (2.0.3)
|
14
|
+
fast-stemmer (~> 1.0)
|
15
|
+
coderay (1.1.0)
|
16
|
+
coffee-script (2.3.0)
|
17
|
+
coffee-script-source
|
18
|
+
execjs
|
19
|
+
coffee-script-source (1.9.0)
|
20
|
+
colorator (0.1)
|
21
|
+
diff-lcs (1.2.5)
|
22
|
+
execjs (2.3.0)
|
23
|
+
fakefs (0.6.5)
|
24
|
+
fast-stemmer (1.0.2)
|
25
|
+
ffi (1.9.6)
|
26
|
+
hitimes (1.2.2)
|
27
|
+
jekyll (2.5.3)
|
28
|
+
classifier-reborn (~> 2.0)
|
29
|
+
colorator (~> 0.1)
|
30
|
+
jekyll-coffeescript (~> 1.0)
|
31
|
+
jekyll-gist (~> 1.0)
|
32
|
+
jekyll-paginate (~> 1.0)
|
33
|
+
jekyll-sass-converter (~> 1.0)
|
34
|
+
jekyll-watch (~> 1.1)
|
35
|
+
kramdown (~> 1.3)
|
36
|
+
liquid (~> 2.6.1)
|
37
|
+
mercenary (~> 0.3.3)
|
38
|
+
pygments.rb (~> 0.6.0)
|
39
|
+
redcarpet (~> 3.1)
|
40
|
+
safe_yaml (~> 1.0)
|
41
|
+
toml (~> 0.1.0)
|
42
|
+
jekyll-coffeescript (1.0.1)
|
43
|
+
coffee-script (~> 2.2)
|
44
|
+
jekyll-gist (1.1.0)
|
45
|
+
jekyll-paginate (1.1.0)
|
46
|
+
jekyll-sass-converter (1.3.0)
|
47
|
+
sass (~> 3.2)
|
48
|
+
jekyll-watch (1.2.1)
|
49
|
+
listen (~> 2.7)
|
50
|
+
kramdown (1.5.0)
|
51
|
+
liquid (2.6.2)
|
52
|
+
listen (2.8.5)
|
53
|
+
celluloid (>= 0.15.2)
|
54
|
+
rb-fsevent (>= 0.9.3)
|
55
|
+
rb-inotify (>= 0.9)
|
56
|
+
mercenary (0.3.5)
|
57
|
+
method_source (0.8.2)
|
58
|
+
parslet (1.5.0)
|
59
|
+
blankslate (~> 2.0)
|
60
|
+
posix-spawn (0.3.9)
|
61
|
+
pry (0.10.1)
|
62
|
+
coderay (~> 1.1.0)
|
63
|
+
method_source (~> 0.8.1)
|
64
|
+
slop (~> 3.4)
|
65
|
+
pygments.rb (0.6.2)
|
66
|
+
posix-spawn (~> 0.3.6)
|
67
|
+
yajl-ruby (~> 1.2.0)
|
68
|
+
rb-fsevent (0.9.4)
|
69
|
+
rb-inotify (0.9.5)
|
70
|
+
ffi (>= 0.5.0)
|
71
|
+
redcarpet (3.2.2)
|
72
|
+
rspec (3.2.0)
|
73
|
+
rspec-core (~> 3.2.0)
|
74
|
+
rspec-expectations (~> 3.2.0)
|
75
|
+
rspec-mocks (~> 3.2.0)
|
76
|
+
rspec-core (3.2.0)
|
77
|
+
rspec-support (~> 3.2.0)
|
78
|
+
rspec-expectations (3.2.0)
|
79
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
80
|
+
rspec-support (~> 3.2.0)
|
81
|
+
rspec-mocks (3.2.0)
|
82
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
83
|
+
rspec-support (~> 3.2.0)
|
84
|
+
rspec-support (3.2.0)
|
85
|
+
safe_yaml (1.0.4)
|
86
|
+
sass (3.4.11)
|
87
|
+
slop (3.6.0)
|
88
|
+
timers (4.0.1)
|
89
|
+
hitimes
|
90
|
+
toml (0.1.2)
|
91
|
+
parslet (~> 1.5.0)
|
92
|
+
yajl-ruby (1.2.1)
|
93
|
+
|
94
|
+
PLATFORMS
|
95
|
+
ruby
|
96
|
+
|
97
|
+
DEPENDENCIES
|
98
|
+
fakefs
|
99
|
+
jekyll-code-example-tag!
|
100
|
+
pry
|
101
|
+
rspec
|
data/README.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
[](https://travis-ci.org/govdelivery/jekyll-code-example-tag)
|
2
|
+
[](http://badge.fury.io/rb/jekyll-code-example-tag)
|
3
|
+
|
1
4
|
jekyll-code-example-tag
|
2
5
|
=======================
|
3
6
|
|
@@ -19,6 +22,14 @@ Or install it manually:
|
|
19
22
|
|
20
23
|
gem install jekyll-code-example-tag
|
21
24
|
|
25
|
+
Then, include a script tag in your page or layout to fetch the required
|
26
|
+
javascript:
|
27
|
+
|
28
|
+
<script type="text/javascript" src="/js/jekyll-code-example-buttons.js"></script>
|
29
|
+
|
30
|
+
You may also overwrite the provided javascript by writing a `jekyll-code-example-buttons.js`
|
31
|
+
file in the `/js/` directory of your Jekyll project.
|
32
|
+
|
22
33
|
## Usage
|
23
34
|
|
24
35
|
### code_example
|
@@ -97,6 +97,34 @@ EOF
|
|
97
97
|
output = Jekyll::CodeExampleTags::wrap_examples_div(output)
|
98
98
|
end
|
99
99
|
end
|
100
|
+
|
101
|
+
class CodeExamplesJsFile < Jekyll::StaticFile
|
102
|
+
def write(dest)
|
103
|
+
|
104
|
+
if File.file?(File.join(FileUtils.pwd, @dir, @name))
|
105
|
+
in_path = File.join(FileUtils.pwd, @dir, @name)
|
106
|
+
else
|
107
|
+
in_path = File.join(File.dirname(__FILE__), @dir, @name)
|
108
|
+
end
|
109
|
+
dest_path = File.join(dest, @dir, @name)
|
110
|
+
|
111
|
+
FileUtils.mkdir_p(File.dirname(dest_path))
|
112
|
+
content = File.read(in_path)
|
113
|
+
File.open(dest_path, 'w') do |f|
|
114
|
+
f.write(content)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
class CodeExamplesJsGenerator < Jekyll::Generator
|
120
|
+
safe true
|
121
|
+
|
122
|
+
def generate(site)
|
123
|
+
name = 'jekyll-code-example-buttons.js'
|
124
|
+
destination = '/js/'
|
125
|
+
site.static_files << CodeExamplesJsFile.new(site, site.source, destination, name)
|
126
|
+
end
|
127
|
+
end
|
100
128
|
end
|
101
129
|
end
|
102
130
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
jQuery(function(){
|
4
|
+
jQuery('.buttons.examples .button').click(function(e){
|
5
|
+
e.preventDefault();
|
6
|
+
var parent = jQuery(this).closest('body');
|
7
|
+
var target = jQuery(this).attr('target');
|
8
|
+
|
9
|
+
parent.find('.example').hide();
|
10
|
+
parent.find('.example.'+target).show();
|
11
|
+
parent.find('.buttons.examples .button.active').removeClass('active');
|
12
|
+
parent.find('.buttons.examples .button[target="'+target+'"]').addClass('active');
|
13
|
+
});
|
14
|
+
|
15
|
+
|
16
|
+
jQuery('.buttons.examples li:first-child .button').click();
|
17
|
+
});
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative './spec_helper.rb'
|
2
|
+
|
3
|
+
describe 'all_page_code_examples', fakefs: true do
|
4
|
+
|
5
|
+
# TODO: Make this soo much better
|
6
|
+
let(:page) do
|
7
|
+
page = <<EOF
|
8
|
+
{% code_example hello_world %}
|
9
|
+
{% code_example goodbye_world %}
|
10
|
+
{% all_page_code_examples %}
|
11
|
+
EOF
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:page_markup) do
|
15
|
+
page_markup = <<EOF
|
16
|
+
<div class='code-examples'> <div class="buttons examples">
|
17
|
+
<ul>
|
18
|
+
<li><a href='#' class='button' target='python'>Python</a></li>
|
19
|
+
</ul>
|
20
|
+
</div>
|
21
|
+
<div class="highlight example python">
|
22
|
+
<pre><code class="language-python" data-lang="python">print "Hello World"print "Goodbye World"</code></pre>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
EOF
|
26
|
+
page_markup.rstrip
|
27
|
+
end
|
28
|
+
|
29
|
+
before(:all) do
|
30
|
+
FakeFS.activate!
|
31
|
+
FileUtils.mkdir_p('code_examples/python')
|
32
|
+
File.open('code_examples/python/hello_world', 'w') { |f| f << 'print "Hello World"'}
|
33
|
+
File.open('code_examples/python/goodbye_world', 'w') { |f| f << 'print "Goodbye World"'}
|
34
|
+
end
|
35
|
+
|
36
|
+
after(:all) do
|
37
|
+
FakeFS.deactivate!
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'can be used' do
|
41
|
+
t = Liquid::Template.parse(page)
|
42
|
+
o = t.render!({'site' => {}, 'page' => {'content' => page}})
|
43
|
+
expect(o).to include(page_markup)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative './spec_helper.rb'
|
2
|
+
|
3
|
+
describe 'code_example', fakefs: true do
|
4
|
+
|
5
|
+
# TODO: Make this soo much better
|
6
|
+
let(:page) { "{% code_example hello_world %}" }
|
7
|
+
let(:page_markup) do
|
8
|
+
page_markup = <<EOF
|
9
|
+
<div class='code-examples'> <div class="buttons examples">
|
10
|
+
<ul>
|
11
|
+
<li><a href='#' class='button' target='ruby'>Ruby</a></li><li><a href='#' class='button' target='python'>Python</a></li>
|
12
|
+
</ul>
|
13
|
+
</div>
|
14
|
+
<div class="highlight example ruby">
|
15
|
+
<pre><code class="language-ruby" data-lang="ruby">puts "Hello World"</code></pre>
|
16
|
+
</div>
|
17
|
+
<div class="highlight example python">
|
18
|
+
<pre><code class="language-python" data-lang="python">print "Hello World"</code></pre>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
EOF
|
22
|
+
page_markup.rstrip
|
23
|
+
end
|
24
|
+
|
25
|
+
before(:all) do
|
26
|
+
FakeFS.activate!
|
27
|
+
FileUtils.mkdir_p('code_examples/ruby')
|
28
|
+
FileUtils.mkdir_p('code_examples/python')
|
29
|
+
File.open('code_examples/ruby/hello_world', 'w') { |f| f << 'puts "Hello World"'}
|
30
|
+
File.open('code_examples/python/hello_world', 'w') { |f| f << 'print "Hello World"'}
|
31
|
+
end
|
32
|
+
|
33
|
+
after(:all) do
|
34
|
+
FakeFS.deactivate!
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'can be used' do
|
38
|
+
t = Liquid::Template.parse(page)
|
39
|
+
o = t.render!({'site' => {}})
|
40
|
+
expect(o).to eq(page_markup)
|
41
|
+
end
|
42
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-code-example-tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GovDelivery
|
@@ -14,14 +14,14 @@ dependencies:
|
|
14
14
|
name: jekyll
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: "Provides a tag that allows you to include in your posts \n and
|
@@ -33,10 +33,18 @@ executables: []
|
|
33
33
|
extensions: []
|
34
34
|
extra_rdoc_files: []
|
35
35
|
files:
|
36
|
+
- ".ruby-version"
|
37
|
+
- ".travis.yml"
|
38
|
+
- Gemfile
|
39
|
+
- Gemfile.lock
|
36
40
|
- LICENSE.md
|
37
41
|
- README.md
|
38
42
|
- jekyll-code-example-tag.gemspec
|
39
43
|
- lib/jekyll-code-example-tag.rb
|
44
|
+
- lib/js/jekyll-code-example-buttons.js
|
45
|
+
- spec/all_page_code_examples_spec.rb
|
46
|
+
- spec/code_example_spec.rb
|
47
|
+
- spec/spec_helper.rb
|
40
48
|
homepage: https://github.com/govdelivery/jekyll-code-example-tag
|
41
49
|
licenses:
|
42
50
|
- BSD-3-Clause
|
@@ -47,17 +55,17 @@ require_paths:
|
|
47
55
|
- lib
|
48
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
49
57
|
requirements:
|
50
|
-
- -
|
58
|
+
- - ">="
|
51
59
|
- !ruby/object:Gem::Version
|
52
60
|
version: '0'
|
53
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
62
|
requirements:
|
55
|
-
- -
|
63
|
+
- - ">="
|
56
64
|
- !ruby/object:Gem::Version
|
57
65
|
version: '0'
|
58
66
|
requirements: []
|
59
67
|
rubyforge_project:
|
60
|
-
rubygems_version: 2.
|
68
|
+
rubygems_version: 2.4.5
|
61
69
|
signing_key:
|
62
70
|
specification_version: 4
|
63
71
|
summary: Tags for including code examples in posts and pages.
|