literate_maruku 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +15 -16
- data/bin/literate_maruku +6 -1
- data/lib/literate_maruku/version.rb +3 -0
- data/lib/literate_maruku.rb +77 -89
- metadata +81 -72
- data/.gitignore +0 -3
- data/History.txt +0 -20
- data/License.txt +0 -20
- data/Rakefile +0 -44
- data/literate_maruku.gemspec +0 -63
- data/test/literate_maruku_test.rb +0 -72
- data/test/test_document.mkd +0 -25
- data/test/test_helper.rb +0 -2
- data/version.yml +0 -4
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d1b58fde3c100182fae8c73127c6f8469db3ef2c299a74b78867368563b3785a
|
4
|
+
data.tar.gz: e1c89c044a416f8da07702a5cc6a16c8bcf2f5849a0e1a7bbc6057d730bf720e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6920c9f8d281682ca94876824b5dc4dca5e100b48406173a58e443438c0d4502887a648660eed6fb95e1bfb1327fa0aaafdbf041c1e0304b49f1c2b80460d230
|
7
|
+
data.tar.gz: ef2030ced99deeeb0392d62bcb98695549b8f7ba648c76c415b0d7a1dfc0fbf1f9bd361e04a25129422cb2b92b0af7bf46caa8151b83f41d5ac1c9ba63af6779
|
data/README.rdoc
CHANGED
@@ -5,13 +5,13 @@ libary maruku. This is basically what the name say, isn't it?
|
|
5
5
|
|
6
6
|
== The Basics
|
7
7
|
|
8
|
-
There are two possible accesses to the libary. A programming API and a command
|
9
|
-
line interface. The first may be used to write better documented tests,
|
8
|
+
There are two possible accesses to the libary. A programming API and a command
|
9
|
+
line interface. The first may be used to write better documented tests,
|
10
10
|
for example. Just write a little bit of code in your test_helper and call
|
11
11
|
Literate Maruku there and your markdown formatted tests will be executed.
|
12
12
|
|
13
13
|
The command line interface may the be used inside of a rake task, e.g. to
|
14
|
-
generate some html files out of your test files demonstrating their usage.
|
14
|
+
generate some html files out of your test files demonstrating their usage.
|
15
15
|
We have used this approach in ContextR, so have a look there to get some input.
|
16
16
|
|
17
17
|
|
@@ -42,7 +42,7 @@ Wanna see examples? Okay, here they are:
|
|
42
42
|
end
|
43
43
|
{: execute}
|
44
44
|
|
45
|
-
And, finally, the following block will be executed and its output will be
|
45
|
+
And, finally, the following block will be executed and its output will be
|
46
46
|
rendered as well.
|
47
47
|
|
48
48
|
echo_block("hallo")
|
@@ -61,7 +61,7 @@ And the following code block will not only be rendered, but also executed.
|
|
61
61
|
(0...(text.size)).map{|i| text[0..i]}.reverse.join(" ... ")
|
62
62
|
end
|
63
63
|
|
64
|
-
And, finally, the following block will be executed and its output will be
|
64
|
+
And, finally, the following block will be executed and its output will be
|
65
65
|
rendered as well.
|
66
66
|
|
67
67
|
echo_block("hallo")
|
@@ -76,17 +76,17 @@ It basically works like a simpe <tt>ruby filename.rb</tt> call, but without all
|
|
76
76
|
the command line parameters the +ruby+ command supports.
|
77
77
|
|
78
78
|
If you like to generate some html files, append an additional parameter, which
|
79
|
-
tells literate_maruku where to put the output.
|
80
|
-
<tt>literate_maruku --output_path=test filename.mkd</tt> would file the output
|
79
|
+
tells literate_maruku where to put the output.
|
80
|
+
<tt>literate_maruku --output_path=test filename.mkd</tt> would file the output
|
81
81
|
of <tt>filename.mkd</tt> to <tt>test/filename.html</tt>. That's all, folks.
|
82
82
|
|
83
83
|
== The Programming Interface
|
84
84
|
|
85
|
-
To use Literate Maruku in your own special way simply use the
|
85
|
+
To use Literate Maruku in your own special way simply use the
|
86
86
|
<tt>LiterateMaruku#require</tt> method.
|
87
87
|
|
88
88
|
require 'literate_maruku'
|
89
|
-
|
89
|
+
|
90
90
|
LiterateMaruku.require('filename.mkd') # or
|
91
91
|
LiterateMaruku.require('filename.mkd', :output => "test")
|
92
92
|
|
@@ -94,7 +94,7 @@ These will have the same result as the command line examples.
|
|
94
94
|
|
95
95
|
If you are unhappy with these little possibilities, no problem: You may still
|
96
96
|
use the standard maruku interface to do with your markdown string, what you like
|
97
|
-
after require'ing literate_maruku the maruku code base is extended for the
|
97
|
+
after require'ing literate_maruku the maruku code base is extended for the
|
98
98
|
literate programming style.
|
99
99
|
|
100
100
|
|
@@ -102,18 +102,17 @@ literate programming style.
|
|
102
102
|
|
103
103
|
gem install literate_maruku
|
104
104
|
|
105
|
-
Literate Maruku is currently only tested and known to work with
|
105
|
+
Literate Maruku is currently only tested and known to work with
|
106
106
|
|
107
|
-
* Ruby
|
108
|
-
* Ruby 1.9.1 (YARV)
|
109
|
-
* JRuby 1.x
|
107
|
+
* Ruby 2.7, 3.0, 3.1
|
110
108
|
|
111
109
|
|
112
110
|
== Additional Resources
|
113
111
|
|
114
112
|
* {Project's website}[http://github.com/schmidt/literate_maruku/]
|
113
|
+
* {Introductory Talk about literate_maruku}[http://www.slideshare.net/schmidt/literate-maruku] (contains outdated URLs)
|
115
114
|
* {API doc}[http://rdoc.info/projects/schmidt/literate_maruku]
|
116
|
-
* {Build Status on
|
115
|
+
* {Build Status on GitHub Actions}[https://github.com/schmidt/literate_maruku/actions]
|
117
116
|
|
118
117
|
|
119
118
|
== How to submit patches
|
@@ -128,6 +127,6 @@ Bug reports or general feature requests should be added using GitHub Issues.
|
|
128
127
|
|
129
128
|
== License
|
130
129
|
|
131
|
-
This code is free to use under the terms of the MIT license.
|
130
|
+
This code is free to use under the terms of the MIT license.
|
132
131
|
|
133
132
|
:include: License.txt
|
data/bin/literate_maruku
CHANGED
@@ -49,9 +49,14 @@ begin
|
|
49
49
|
rescue LoadError
|
50
50
|
require File.dirname(__FILE__) + "/../lib/literate_maruku"
|
51
51
|
end
|
52
|
+
require "pathname"
|
52
53
|
|
53
54
|
if OPTIONS[:output_path]
|
54
|
-
|
55
|
+
if Pathname(OPTIONS[:output_path]).absolute?
|
56
|
+
path = OPTIONS[:output_path]
|
57
|
+
else
|
58
|
+
path = File.join(Dir.pwd, OPTIONS[:output_path])
|
59
|
+
end
|
55
60
|
puts "Generating output to \"#{OPTIONS[:output_path]}\""
|
56
61
|
LiterateMaruku.require(ARGV[0], :output => path)
|
57
62
|
else
|
data/lib/literate_maruku.rb
CHANGED
@@ -1,89 +1,98 @@
|
|
1
|
-
|
1
|
+
require 'literate_maruku/version'
|
2
2
|
|
3
|
-
require
|
4
|
-
|
5
|
-
require "maruku"
|
3
|
+
require 'rexml'
|
4
|
+
require 'maruku'
|
6
5
|
|
6
|
+
# The public interface to Literate Maruku
|
7
|
+
#
|
8
|
+
# Besides these methods, maruku itself is exented to handle the new meta-data
|
9
|
+
# keywords. In your Markdown code use <tt>{: execute}</tt> to evaluate the
|
10
|
+
# code block and <tt>{: execute attach_output}</tt> to evaluate the code and
|
11
|
+
# attach the result to the generated document. If you need to execute code
|
12
|
+
# that should not be rendered attach <tt>{: execute hide}</tt>.
|
7
13
|
module LiterateMaruku
|
8
|
-
|
14
|
+
extend self
|
15
|
+
|
16
|
+
# This accessor stores the binding, in which the code will be executed. By
|
17
|
+
# default, this is the root context. Use the setter to change it, if you
|
18
|
+
# would like to have all your code in a special context, a module for
|
19
|
+
# example.
|
20
|
+
attr_accessor :binding
|
21
|
+
|
22
|
+
# <tt>file</tt> has to have a <tt>.mkd</tt> extension. The
|
23
|
+
# <tt>LOAD_PATH</tt> will be used to find the file. It will be simply
|
24
|
+
# executed. If called with <tt>:output => dir</tt>, html generated from the
|
25
|
+
# markdown document will be stored in the given directory. The resulting
|
26
|
+
# file name will include the basename of <tt>file</tt> and the
|
27
|
+
# <tt>.html</tt> file extension.
|
9
28
|
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
# <tt>.html</tt> file extension.
|
28
|
-
#
|
29
|
-
# Additionally default values, that influence the code generation and
|
30
|
-
# execution may be set.
|
31
|
-
#
|
32
|
-
# LiterateMaruku.require("file.mkd", :output => ".",
|
33
|
-
# :attributes => {:execute => true})
|
34
|
-
#
|
35
|
-
# will enable execution for all code block per default, for example. Other
|
36
|
-
# options are <tt>:attach_output</tt> and <tt>:hide</tt>.
|
37
|
-
def require(file, options = {})
|
38
|
-
document = generate_output(file)
|
39
|
-
|
40
|
-
document.attributes.merge!(options[:attributes] || {})
|
41
|
-
content = options[:inline] ? document.to_html : document.to_html_document
|
42
|
-
store_in_file(File.basename(file, ".mkd"), content, options[:output])
|
43
|
-
|
44
|
-
content
|
45
|
-
end
|
29
|
+
# Additionally default values, that influence the code generation and
|
30
|
+
# execution may be set.
|
31
|
+
#
|
32
|
+
# LiterateMaruku.require("file.mkd", :output => ".",
|
33
|
+
# :attributes => {:execute => true})
|
34
|
+
#
|
35
|
+
# will enable execution for all code block per default, for example. Other
|
36
|
+
# options are <tt>:attach_output</tt> and <tt>:hide</tt>.
|
37
|
+
def require(file, options = {})
|
38
|
+
document = generate_output(file)
|
39
|
+
|
40
|
+
document.attributes.merge!(options[:attributes] || {})
|
41
|
+
content = options[:inline] ? document.to_html : document.to_html_document
|
42
|
+
store_in_file(File.basename(file, ".mkd"), content, options[:output])
|
43
|
+
|
44
|
+
content
|
45
|
+
end
|
46
46
|
|
47
47
|
private
|
48
|
-
def generate_output(file)
|
49
|
-
Maruku.new(markdown_string(file))
|
50
|
-
end
|
51
48
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
else
|
56
|
-
dir = $:.find{ |load_dir| File.exist?(File.join(load_dir, file)) }
|
57
|
-
raise LoadError, "no such file to load -- #{file}" if dir.nil?
|
49
|
+
def generate_output(file)
|
50
|
+
Maruku.new(markdown_string(file))
|
51
|
+
end
|
58
52
|
|
59
|
-
|
60
|
-
|
61
|
-
|
53
|
+
def markdown_string(file)
|
54
|
+
if File.exist?(file)
|
55
|
+
filename = file
|
56
|
+
else
|
57
|
+
dir = $:.find{ |load_dir| File.exist?(File.join(load_dir, file)) }
|
58
|
+
raise LoadError, "no such file to load -- #{file}" if dir.nil?
|
59
|
+
|
60
|
+
filename = File.join(dir, file)
|
62
61
|
end
|
62
|
+
File.open(filename) { |f| f.readlines.join }
|
63
|
+
end
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
65
|
+
def store_in_file(file_base_name, string, directory)
|
66
|
+
if directory
|
67
|
+
File.open(File.join(directory, file_base_name + ".html"), "w") do |f|
|
68
|
+
f.puts(string)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
|
74
|
-
|
73
|
+
module MaRuKuExtension
|
74
|
+
def to_html_code_using_pre(source, code_lang=nil)
|
75
|
+
is_true = -> (key) { get_setting(key) && get_setting(key) != "false" }
|
75
76
|
|
76
|
-
|
77
|
+
if is_true.call(:execute)
|
78
|
+
value = eval(source, LiterateMaruku.binding)
|
79
|
+
source += "\n>> " + value.inspect if is_true.call(:attach_output)
|
80
|
+
end
|
81
|
+
|
82
|
+
super(source, code_lang) unless is_true.call(:hide)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
77
86
|
|
78
87
|
# This is the basic module provided by Maruku, but Literate Maruku added three
|
79
88
|
# parameters to configure its behaviour.
|
80
89
|
#
|
81
|
-
# Set <tt>MaRuKu::Globals[:execute]</tt> to true, if you like to execute code
|
82
|
-
# block by default. To disable the execution for single blocks, add
|
90
|
+
# Set <tt>MaRuKu::Globals[:execute]</tt> to true, if you like to execute code
|
91
|
+
# block by default. To disable the execution for single blocks, add
|
83
92
|
# <tt>{: execute=false}</tt>.
|
84
93
|
#
|
85
|
-
# Set <tt>MaRuKu::Globals[:attach_output]</tt> to true, if you like to attach
|
86
|
-
# the results of code blocks by default. To disable this option for single
|
94
|
+
# Set <tt>MaRuKu::Globals[:attach_output]</tt> to true, if you like to attach
|
95
|
+
# the results of code blocks by default. To disable this option for single
|
87
96
|
# blocks, add <tt>{: attach_output=false}</tt>.
|
88
97
|
#
|
89
98
|
# *Note*: These settings may also be configured on an instance basis, when
|
@@ -92,28 +101,7 @@ module MaRuKu
|
|
92
101
|
Globals[:execute] = false
|
93
102
|
Globals[:attach_output] = false
|
94
103
|
Globals[:hide] = false
|
95
|
-
|
96
|
-
module Out # :nodoc: all
|
97
|
-
module HTML
|
98
|
-
unless instance_methods.include? "to_html_code_using_pre_with_literate"
|
99
|
-
def to_html_code_using_pre_with_literate(source)
|
100
|
-
if is_true?(:execute)
|
101
|
-
value = eval(source, LiterateMaruku.binding)
|
102
|
-
source += "\n>> " + value.inspect if is_true?(:attach_output)
|
103
|
-
end
|
104
|
-
to_html_code_using_pre_without_literate(source) if !is_true?(:hide)
|
105
|
-
end
|
106
|
-
|
107
|
-
alias_method :to_html_code_using_pre_without_literate,
|
108
|
-
:to_html_code_using_pre
|
109
|
-
alias_method :to_html_code_using_pre,
|
110
|
-
:to_html_code_using_pre_with_literate
|
111
|
-
|
112
|
-
private
|
113
|
-
def is_true?(key)
|
114
|
-
get_setting(key) && get_setting(key) != "false"
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
104
|
end
|
105
|
+
|
106
|
+
LiterateMaruku.binding = binding
|
107
|
+
MaRuKu::MDElement.include LiterateMaruku::MaRuKuExtension
|
metadata
CHANGED
@@ -1,96 +1,105 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: literate_maruku
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Gregor Schmidt
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
date: 2022-10-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rexml
|
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
|
16
28
|
name: maruku
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.0
|
17
34
|
type: :runtime
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
21
38
|
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.7.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
26
42
|
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
27
48
|
type: :development
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: test-unit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
31
59
|
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: jeweler
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
37
62
|
type: :development
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
41
66
|
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version:
|
44
|
-
|
45
|
-
|
46
|
-
email:
|
47
|
-
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Given Ruby's open classes and Maruku's powerful parser architecture,
|
70
|
+
literate_maruku provides a basic literate programming environment for Ruby.
|
71
|
+
email:
|
72
|
+
- schmidt@nach-vorne.eu
|
73
|
+
executables:
|
48
74
|
- literate_maruku
|
49
75
|
extensions: []
|
50
|
-
|
51
|
-
|
52
|
-
- README.rdoc
|
53
|
-
files:
|
54
|
-
- .gitignore
|
55
|
-
- History.txt
|
56
|
-
- License.txt
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
57
78
|
- README.rdoc
|
58
|
-
- Rakefile
|
59
79
|
- bin/literate_maruku
|
60
80
|
- lib/literate_maruku.rb
|
61
|
-
- literate_maruku.
|
62
|
-
- test/literate_maruku_test.rb
|
63
|
-
- test/test_document.mkd
|
64
|
-
- test/test_helper.rb
|
65
|
-
- version.yml
|
66
|
-
has_rdoc: true
|
81
|
+
- lib/literate_maruku/version.rb
|
67
82
|
homepage: http://github.com/schmidt/literate_maruku
|
68
|
-
licenses:
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
require_paths:
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
74
89
|
- lib
|
75
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
-
requirements:
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
77
92
|
- - ">="
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version:
|
80
|
-
|
81
|
-
|
82
|
-
requirements:
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
83
97
|
- - ">="
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version:
|
86
|
-
version:
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
87
100
|
requirements: []
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
signing_key:
|
92
|
-
specification_version: 3
|
101
|
+
rubygems_version: 3.1.6
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
93
104
|
summary: Literate programming for Ruby based on Maruku.
|
94
|
-
test_files:
|
95
|
-
- test/literate_maruku_test.rb
|
96
|
-
- test/test_helper.rb
|
105
|
+
test_files: []
|
data/.gitignore
DELETED
data/History.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
== 0.1.2 2009-11-28
|
2
|
-
|
3
|
-
* major enhancements
|
4
|
-
* moved to gemcutter
|
5
|
-
* minor enhancements
|
6
|
-
* removed all old cruft
|
7
|
-
|
8
|
-
== 0.1.1 2007-10-05
|
9
|
-
|
10
|
-
* minor enhancement:
|
11
|
-
* Removed global variable to fetch the root binding, use class variable
|
12
|
-
instead
|
13
|
-
* Configurable default values for execute, attach_output and hide
|
14
|
-
* looking for the file to load in current directory as well
|
15
|
-
* updated docs
|
16
|
-
|
17
|
-
== 0.1.0 2007-09-30
|
18
|
-
|
19
|
-
* 1 major enhancement:
|
20
|
-
* Initial release
|
data/License.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2007 Gregor Schmidt
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/rdoctask'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gemspec|
|
7
|
-
gemspec.name = "literate_maruku"
|
8
|
-
gemspec.summary = "Literate programming for Ruby based on Maruku."
|
9
|
-
gemspec.description = "Given Ruby's open classes and Maruku's powerful " +
|
10
|
-
"parser architecture, literate_maruku provides a basic literate " +
|
11
|
-
"programming environment for Ruby."
|
12
|
-
gemspec.email = "ruby@schmidtwisser.de"
|
13
|
-
gemspec.homepage = "http://github.com/schmidt/literate_maruku"
|
14
|
-
gemspec.authors = ["Gregor Schmidt"]
|
15
|
-
|
16
|
-
gemspec.executable = "literate_maruku"
|
17
|
-
|
18
|
-
gemspec.add_dependency('maruku', '>= 0.6.0')
|
19
|
-
|
20
|
-
gemspec.add_development_dependency('rake')
|
21
|
-
gemspec.add_development_dependency('jeweler', '>= 1.4.0')
|
22
|
-
end
|
23
|
-
|
24
|
-
Jeweler::GemcutterTasks.new
|
25
|
-
rescue LoadError
|
26
|
-
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
27
|
-
end
|
28
|
-
|
29
|
-
desc "Run all tests"
|
30
|
-
task :test do
|
31
|
-
require 'rake/runtest'
|
32
|
-
Rake.run_tests 'test/**/*_test.rb'
|
33
|
-
end
|
34
|
-
|
35
|
-
desc 'Generate documentation for the literate_maruku gem.'
|
36
|
-
Rake::RDocTask.new(:doc) do |doc|
|
37
|
-
doc.rdoc_dir = 'doc'
|
38
|
-
doc.title = 'literate_maruku'
|
39
|
-
doc.options << '--line-numbers' << '--inline-source'
|
40
|
-
doc.rdoc_files.include('README.rdoc')
|
41
|
-
doc.rdoc_files.include('lib/**/*.rb')
|
42
|
-
end
|
43
|
-
|
44
|
-
task :default => :test
|
data/literate_maruku.gemspec
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{literate_maruku}
|
8
|
-
s.version = "0.1.2"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Gregor Schmidt"]
|
12
|
-
s.date = %q{2009-11-28}
|
13
|
-
s.default_executable = %q{literate_maruku}
|
14
|
-
s.description = %q{Given Ruby's open classes and Maruku's powerful parser architecture, literate_maruku provides a basic literate programming environment for Ruby.}
|
15
|
-
s.email = %q{ruby@schmidtwisser.de}
|
16
|
-
s.executables = ["literate_maruku"]
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"README.rdoc"
|
19
|
-
]
|
20
|
-
s.files = [
|
21
|
-
".gitignore",
|
22
|
-
"History.txt",
|
23
|
-
"License.txt",
|
24
|
-
"README.rdoc",
|
25
|
-
"Rakefile",
|
26
|
-
"bin/literate_maruku",
|
27
|
-
"lib/literate_maruku.rb",
|
28
|
-
"literate_maruku.gemspec",
|
29
|
-
"test/literate_maruku_test.rb",
|
30
|
-
"test/test_document.mkd",
|
31
|
-
"test/test_helper.rb",
|
32
|
-
"version.yml"
|
33
|
-
]
|
34
|
-
s.homepage = %q{http://github.com/schmidt/literate_maruku}
|
35
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
-
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = %q{1.3.5}
|
38
|
-
s.summary = %q{Literate programming for Ruby based on Maruku.}
|
39
|
-
s.test_files = [
|
40
|
-
"test/literate_maruku_test.rb",
|
41
|
-
"test/test_helper.rb"
|
42
|
-
]
|
43
|
-
|
44
|
-
if s.respond_to? :specification_version then
|
45
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
-
s.specification_version = 3
|
47
|
-
|
48
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
49
|
-
s.add_runtime_dependency(%q<maruku>, [">= 0.6.0"])
|
50
|
-
s.add_development_dependency(%q<rake>, [">= 0"])
|
51
|
-
s.add_development_dependency(%q<jeweler>, [">= 1.4.0"])
|
52
|
-
else
|
53
|
-
s.add_dependency(%q<maruku>, [">= 0.6.0"])
|
54
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
55
|
-
s.add_dependency(%q<jeweler>, [">= 1.4.0"])
|
56
|
-
end
|
57
|
-
else
|
58
|
-
s.add_dependency(%q<maruku>, [">= 0.6.0"])
|
59
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
60
|
-
s.add_dependency(%q<jeweler>, [">= 1.4.0"])
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
@@ -1,72 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
|
3
|
-
class MaRuKuTest < Test::Unit::TestCase
|
4
|
-
def test_should_not_execute_each_and_every_code_environment
|
5
|
-
doc = Maruku.new(%q{ THIS_CONSTANT_WILL_NOT_BE_DEFINED = true})
|
6
|
-
|
7
|
-
output = %q{<pre><code>THIS_CONSTANT_WILL_NOT_BE_DEFINED = true</code></pre>}
|
8
|
-
|
9
|
-
assert_equal output, doc.to_html
|
10
|
-
assert !Object.const_defined?("THIS_CONSTANT_WILL_NOT_BE_DEFINED")
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_should_execute_code_with_metadata
|
14
|
-
doc = Maruku.new(%q{
|
15
|
-
TEST_WORKS = true
|
16
|
-
{: execute}})
|
17
|
-
|
18
|
-
output = %q{<pre><code>TEST_WORKS = true</code></pre>}
|
19
|
-
|
20
|
-
assert_equal output, doc.to_html
|
21
|
-
assert Object.const_defined?("TEST_WORKS")
|
22
|
-
assert TEST_WORKS
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_should_attach_output_if_requested
|
26
|
-
doc = Maruku.new(%q{
|
27
|
-
1 + 1 == 2
|
28
|
-
{: execute attach_output}})
|
29
|
-
|
30
|
-
output = %q{<pre><code>1 + 1 == 2
|
31
|
-
>> true</code></pre>}
|
32
|
-
|
33
|
-
assert_equal output, doc.to_html
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
class LiterateMarukuTest < Test::Unit::TestCase
|
38
|
-
def setup
|
39
|
-
@dirname = File.dirname(__FILE__)
|
40
|
-
@base_filename = "test_document"
|
41
|
-
|
42
|
-
@mkd_filename = File.join(@dirname, @base_filename + ".mkd")
|
43
|
-
@html_filename = File.join(@dirname, @base_filename + ".html")
|
44
|
-
|
45
|
-
teardown
|
46
|
-
end
|
47
|
-
|
48
|
-
def teardown
|
49
|
-
File.delete(@html_filename) if File.exists?(@html_filename)
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_require_should_execute_annotated_code_environments
|
53
|
-
LiterateMaruku.require(@mkd_filename)
|
54
|
-
assert $this_code_block_will_be_executed
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_require_should_not_execute_every_code_environment
|
58
|
-
LiterateMaruku.require(@mkd_filename)
|
59
|
-
assert !$this_code_block_will_not_be_executed
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_require_should_generate_an_html_file
|
63
|
-
LiterateMaruku.require(@mkd_filename, :output => @dirname)
|
64
|
-
assert File.exists?(@html_filename)
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_require_should_raise_load_error_for_missing_files
|
68
|
-
assert_raise(LoadError) do
|
69
|
-
LiterateMaruku.require("missing_file.mkd")
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
data/test/test_document.mkd
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
Test Literate Maruku Document
|
2
|
-
=============================
|
3
|
-
|
4
|
-
This contains some code examples, that are used for testing.
|
5
|
-
|
6
|
-
Normal markdown code environments are simply rendered
|
7
|
-
|
8
|
-
$this_code_block_will_not_be_executed = true
|
9
|
-
|
10
|
-
Annotated code environments are rendered and executed - in the root context.
|
11
|
-
|
12
|
-
$this_code_block_will_be_executed = true
|
13
|
-
{: execute}
|
14
|
-
|
15
|
-
Code definitions also work across code environments, of course.
|
16
|
-
|
17
|
-
a_test_method = lambda do |string|
|
18
|
-
string
|
19
|
-
end
|
20
|
-
{: execute}
|
21
|
-
|
22
|
-
And you may automatically attach the output of your code blocks.
|
23
|
-
|
24
|
-
a_test_method.call("a test string")
|
25
|
-
{: execute attach_output}
|
data/test/test_helper.rb
DELETED
data/version.yml
DELETED