CodeWriter 0.1.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
+ SHA1:
3
+ metadata.gz: 40e63fede9abfa26d00bf2a5df5e672cdf21eb51
4
+ data.tar.gz: 6e9475984b060efd04ba61b018a6a8b09073f154
5
+ SHA512:
6
+ metadata.gz: de54ba8f4b49b94a319e9088eab0cec641253d21e3b8e8307a6793c4ca513d7bdaf0e26fab9a7aacc28fedf32e843a8e39bc1ef3f1393944c6bef7e60014a8ee
7
+ data.tar.gz: 0e0f4b5b4976aeffa7981f264460918d2eae41cbe5e67633d8347b2c54797b38835ad1f96a8be15759c0a50703b41830f9817d7756b1fb3fad56776f87f7324c
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Rodrigo Botafogo
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ Announcement
2
+ ============
3
+
4
+ CodeWriter is a small Gem to help writing about code. Writing about code is a tedious process.
5
+ First the writer writes in a text editor the text and some piece of code, then to verify the code, it
6
+ needs to write this code on some IDE, then execute the code and copy and paste the result of the
7
+ executed code. Later, if the author wants to change/add to the code already writen she needs to change
8
+ the code in the IDE, execute it, copy it back to the word processing and the copy the returned value. In
9
+ a large text, with many small code excerpt keeping track of the piece of code and the text is tedious
10
+ and often in texts about code, the code in the text has error because it was not executed properly.
11
+
12
+ CodeWriter tries to reduce this problem for Ruby code. It is based on the concept of Latex in which
13
+ the writer marks the text with tags, but in this case, the marking is actually a Ruby function and the
14
+ author is actually writing a Ruby script.
15
+
16
+ Here is an example of a CodeWriter text:
17
+
18
+ ====
19
+ # coding: utf-8
20
+ # File writer.rb
21
+
22
+ require 'codewriter'
23
+
24
+ title("CodeWriter Example")
25
+
26
+ author("Rodrigo Botafogo")
27
+
28
+ body(<<-EOT)
29
+ This is a short example of CodeWriter
30
+ EOT
31
+ ====
32
+
33
+ When writer.rb is executed, it will output a Markdown text.
data/Rakefile ADDED
@@ -0,0 +1,75 @@
1
+ require 'rbconfig'
2
+ require 'rake/testtask'
3
+
4
+ require './version'
5
+
6
+ $env = `uname -o`.strip
7
+
8
+ ##########################################################################################
9
+ # Prepare environment to work inside Cygwin
10
+ ##########################################################################################
11
+
12
+ if $env == 'Cygwin'
13
+
14
+ #---------------------------------------------------------------------------------------
15
+ # Return the cygpath (windows format) of a path in POSIX format, i.e., /home/...
16
+ #---------------------------------------------------------------------------------------
17
+
18
+ def set_path(path)
19
+ `cygpath -a -w #{path}`.tr("\n", "")
20
+ end
21
+
22
+ else
23
+
24
+ #---------------------------------------------------------------------------------------
25
+ # Return the given path. When not in cygwin then just use the given path
26
+ #---------------------------------------------------------------------------------------
27
+
28
+ def set_path(path)
29
+ path
30
+ end
31
+
32
+ end
33
+ ##########################################################################################
34
+
35
+ name = "#{$gem_name}-#{$version}.gem"
36
+
37
+ desc 'Makes a Gem'
38
+ task :make_gem do
39
+ sh "gem build #{$gem_name}.gemspec"
40
+ end
41
+
42
+ desc 'Install the gem in the standard location'
43
+ task :install_gem => [:make_gem] do
44
+ sh "gem install #{$gem_name}-#{$version}-java.gem"
45
+ end
46
+
47
+ desc 'Make documentation'
48
+ task :make_doc do
49
+ sh "yard doc lib/*.rb lib/**/*.rb"
50
+ end
51
+
52
+ desc 'Push project to github'
53
+ task :push do
54
+ sh "git push origin master"
55
+ end
56
+
57
+ desc 'Push gem to rubygem'
58
+ task :push_gem do
59
+ sh "push #{name} -p $http_proxy"
60
+ end
61
+
62
+ desc 'Counts the number of lines of ruby code'
63
+ task :count do
64
+ sh "find . -name '*.rb' | xargs wc -l"
65
+ end
66
+
67
+ Rake::TestTask.new do |t|
68
+ t.libs << "test"
69
+ t.test_files = FileList['test/complete.rb']
70
+ t.ruby_opts = ["--server", "-Xinvokedynamic.constants=true", "-J-Xmn512m",
71
+ "-J-Xms1024m", "-J-Xmx1024m"]
72
+ t.verbose = true
73
+ t.warning = true
74
+ end
75
+
data/config.rb ADDED
@@ -0,0 +1,62 @@
1
+ require 'rbconfig'
2
+
3
+ #
4
+ # In principle should not be in this file. The right way of doing this is by executing
5
+ # bundler exec, but I don't know how to do this from inside emacs. So, should comment
6
+ # the next line before publishing the GEM. If not commented, this should be harmless
7
+ # anyway.
8
+ #
9
+
10
+ begin
11
+ require 'bundler/setup'
12
+ rescue LoadError
13
+ end
14
+
15
+ ##########################################################################################
16
+
17
+ # the platform
18
+ @platform =
19
+ case RUBY_PLATFORM
20
+ when /mswin/ then 'windows'
21
+ when /mingw/ then 'windows'
22
+ when /bccwin/ then 'windows'
23
+ when /cygwin/ then 'windows-cygwin'
24
+ when /java/
25
+ require 'java' #:nodoc:
26
+ if java.lang.System.getProperty("os.name") =~ /[Ww]indows/
27
+ 'windows-java'
28
+ else
29
+ 'default-java'
30
+ end
31
+ else 'default'
32
+ end
33
+
34
+ #---------------------------------------------------------------------------------------
35
+ # Set the project directories
36
+ #---------------------------------------------------------------------------------------
37
+
38
+ class CodeWriter
39
+
40
+ @home_dir = File.expand_path File.dirname(__FILE__)
41
+
42
+ class << self
43
+ attr_reader :home_dir
44
+ end
45
+
46
+ @project_dir = CodeWriter.home_dir + "/.."
47
+ @doc_dir = CodeWriter.home_dir + "/doc"
48
+ @lib_dir = CodeWriter.home_dir + "/lib"
49
+ @test_dir = CodeWriter.home_dir + "/test"
50
+
51
+ class << self
52
+ attr_reader :project_dir
53
+ attr_reader :doc_dir
54
+ attr_reader :lib_dir
55
+ attr_reader :test_dir
56
+ end
57
+
58
+ end
59
+
60
+ ##########################################################################################
61
+ # Load necessary jar files
62
+ ##########################################################################################
@@ -0,0 +1,201 @@
1
+ =begin
2
+ class Markdown
3
+
4
+ def get_binding
5
+ return binding()
6
+ end
7
+
8
+ end
9
+
10
+ $mk = Markdown.new
11
+ =end
12
+
13
+ ###########################################################################################
14
+ # In some cases, there is the need to redirect standard output to a string. In general
15
+ # class StIO will do it without any problem. However, when integrating with some libraries,
16
+ # for instace, Renjin, Renjin standard output and Ruby standard output are different, so
17
+ # we need to redirect both standard outputs to the same string. The integrating library
18
+ # will have to implement methods set_std_out, set_std_err, set_default_std_out and
19
+ # set_default_std_err.
20
+ ###########################################################################################
21
+
22
+ class StIO
23
+
24
+ attr_reader :alternate_out
25
+ attr_reader :alternate_err
26
+
27
+ def set_std_out(buffer)
28
+ $stdout = StringIO.new(buffer)
29
+ @alternate_out = buffer
30
+ end
31
+
32
+ def set_std_err(buffer)
33
+ $stderr = StringIO.new(buffer)
34
+ @alternate_err = buffer
35
+ end
36
+
37
+ def set_default_std_out
38
+ $stdout = STDOUT
39
+ end
40
+
41
+ def set_default_std_out
42
+ $stdout = STDOUT
43
+ end
44
+
45
+ end
46
+
47
+ ###########################################################################################
48
+ #
49
+ ###########################################################################################
50
+
51
+ #------------------------------------------------------------------------------------------
52
+ #
53
+ #------------------------------------------------------------------------------------------
54
+
55
+ def set_output(output = StIO.new)
56
+ $output = output
57
+ end
58
+
59
+ set_output
60
+
61
+ #------------------------------------------------------------------------------------------
62
+ #
63
+ #------------------------------------------------------------------------------------------
64
+
65
+ def title(text)
66
+ print "# #{text}\n\n"
67
+ end
68
+
69
+ #------------------------------------------------------------------------------------------
70
+ #
71
+ #------------------------------------------------------------------------------------------
72
+
73
+ def author(text)
74
+ print "Author: #{text}\n\n"
75
+ end
76
+
77
+ #------------------------------------------------------------------------------------------
78
+ #
79
+ #------------------------------------------------------------------------------------------
80
+
81
+ def chapter(text)
82
+ print "# #{text}\n\n"
83
+ end
84
+
85
+ #------------------------------------------------------------------------------------------
86
+ #
87
+ #------------------------------------------------------------------------------------------
88
+
89
+ def section(text)
90
+ print "## #{text}\n\n"
91
+ end
92
+
93
+ #------------------------------------------------------------------------------------------
94
+ #
95
+ #------------------------------------------------------------------------------------------
96
+
97
+ def subsection(text)
98
+ print "### #{text}\n\n"
99
+ end
100
+
101
+ #------------------------------------------------------------------------------------------
102
+ #
103
+ #------------------------------------------------------------------------------------------
104
+
105
+ def subsubsection(text)
106
+ print "#### #{text}\n\n"
107
+ end
108
+
109
+ #------------------------------------------------------------------------------------------
110
+ #
111
+ #------------------------------------------------------------------------------------------
112
+
113
+ def paragraph(text)
114
+ puts text
115
+ end
116
+
117
+ #------------------------------------------------------------------------------------------
118
+ #
119
+ #------------------------------------------------------------------------------------------
120
+
121
+ def subparagraph(text)
122
+ puts text
123
+ end
124
+
125
+ #------------------------------------------------------------------------------------------
126
+ #
127
+ #------------------------------------------------------------------------------------------
128
+
129
+ def body(text)
130
+ print "#{text}\n\n"
131
+ end
132
+
133
+ #------------------------------------------------------------------------------------------
134
+ #
135
+ #------------------------------------------------------------------------------------------
136
+
137
+ def code(script)
138
+
139
+ # Let's capture the output of Renjin script in our own string.
140
+ $output.set_std_out(String.new)
141
+
142
+ puts script
143
+ begin
144
+ eval(script, TOPLEVEL_BINDING)
145
+ rescue Exception => e
146
+ puts e.message
147
+ end
148
+
149
+ $output.set_default_std_out
150
+ puts $output.alternate_out.align_left.indent(4)
151
+ puts
152
+
153
+ end
154
+
155
+ #------------------------------------------------------------------------------------------
156
+ #
157
+ #------------------------------------------------------------------------------------------
158
+
159
+ def console(script)
160
+
161
+ print(script.align_left.prefix("+ ", "> ").indent(4))
162
+
163
+ # Let's capture the output of Renjin script in our own string.
164
+ $output.set_std_out(String.new)
165
+
166
+ begin
167
+ print("\n\n")
168
+ eval(script, TOPLEVEL_BINDING)
169
+ rescue Exception => e
170
+ puts e.message
171
+ end
172
+
173
+ $output.set_default_std_out
174
+ puts $output.alternate_out.align_left.indent(4)
175
+ puts
176
+
177
+ end
178
+
179
+ #------------------------------------------------------------------------------------------
180
+ #
181
+ #------------------------------------------------------------------------------------------
182
+
183
+ def comment_code(text)
184
+ puts text.align_left.indent(4)
185
+ end
186
+
187
+ #------------------------------------------------------------------------------------------
188
+ #
189
+ #------------------------------------------------------------------------------------------
190
+
191
+ def ref(title, publication)
192
+ "*#{title}*, #{publication}"
193
+ end
194
+
195
+ #------------------------------------------------------------------------------------------
196
+ #
197
+ #------------------------------------------------------------------------------------------
198
+
199
+ def list(text)
200
+ puts text.align_left.prefix("* ", paragraph: true).indent(2)
201
+ end
@@ -0,0 +1,139 @@
1
+
2
+ ###########################################################################################
3
+ #
4
+ ###########################################################################################
5
+
6
+ class String
7
+
8
+ #----------------------------------------------------------------------------------------
9
+ # Return an indented copy of this string
10
+ # Arguments:
11
+ # * num - How many of the specified indentation to use.
12
+ # Default for spaces is 2. Default for other is 1.
13
+ # If set to a negative value, removes that many of the specified indentation character,
14
+ # tabs, or spaces from the beginning of the string
15
+ # * i_char - Character (or string) to use for indentation
16
+ #----------------------------------------------------------------------------------------
17
+
18
+ def indent(num = nil, i_char = ' ')
19
+ _indent(num, i_char)
20
+ end
21
+
22
+ #----------------------------------------------------------------------------------------
23
+ # Indents this string
24
+ # Arguments:
25
+ # * num - How many of the specified indentation to use.
26
+ # Default for spaces is 2. Default for other is 1.
27
+ # If set to a negative value, removes that many of the specified indentation character,
28
+ # tabs, or spaces from the beginning of the string
29
+ # * i_char - Character (or string) to use for indentation
30
+ #----------------------------------------------------------------------------------------
31
+
32
+ def indent!(num = nil, i_char = ' ')
33
+ replace(_indent(num, i_char))
34
+ end
35
+
36
+ #----------------------------------------------------------------------------------------
37
+ # Split across newlines and return the fewest number of indentation characters found on
38
+ # each line
39
+ #----------------------------------------------------------------------------------------
40
+
41
+ def find_least_indentation(options = {:ignore_blank_lines => true, :ignore_empty_lines => true})
42
+ # Cannot ignore empty lines unless we're also ignoring blank lines
43
+ options[:ignore_blank_lines] = options[:ignore_empty_lines] ? true : options[:ignore_blank_lines]
44
+ empty? ? 0 : split("\n", -1).reject{|line|
45
+ if options[:ignore_empty_lines]
46
+ line.strip.empty?
47
+ elsif options[:ignore_blank_lines]
48
+ line.empty?
49
+ else
50
+ false
51
+ end
52
+ }.collect{|substr| substr.match(/^[ \t]*/).to_s.length}.min
53
+ end
54
+
55
+ #----------------------------------------------------------------------------------------
56
+ # Find the least indentation of all lines within this string and remove that amount (if any)
57
+ # Can pass an optional modifier that changes the indentation amount removed
58
+ #----------------------------------------------------------------------------------------
59
+
60
+ def reset_indentation(modifier = 0)
61
+ indent(-find_least_indentation + modifier)
62
+ end
63
+
64
+ #----------------------------------------------------------------------------------------
65
+ # Replaces the current string with one that has had its indentation reset
66
+ # Can pass an optional modifier that changes the indentation amount removed
67
+ #----------------------------------------------------------------------------------------
68
+
69
+ def reset_indentation!(modifier = 0)
70
+ indent!(-find_least_indentation + modifier)
71
+ end
72
+
73
+ #----------------------------------------------------------------------------------------
74
+ #
75
+ #----------------------------------------------------------------------------------------
76
+
77
+ def align_left
78
+ string = dup
79
+ relevant_lines = string.split(/\r\n|\r|\n/).select { |line| line.size > 0 }
80
+ indentation_levels = relevant_lines.map do |line|
81
+ match = line.match(/^( +)[^ ]+/)
82
+ match ? match[1].size : 0
83
+ end
84
+ indentation_level = indentation_levels.min
85
+ string.gsub! /^#{' ' * indentation_level}/, '' if indentation_level && indentation_level > 0
86
+ string
87
+ end
88
+
89
+ #----------------------------------------------------------------------------------------
90
+ # Adds a prefix to every line of the string. If prefix_1 is given, then the first line
91
+ # will have prefix_1 as its prefix.
92
+ #----------------------------------------------------------------------------------------
93
+
94
+ def prefix(prefix, prefix_1 = prefix, paragraph: false)
95
+
96
+ split_type = (paragraph)? "\n\n" : "\n"
97
+
98
+ split(split_type).map
99
+ .with_index { |line, i| (i == 0)? prefix_1 + line : prefix + line }.join("\n")
100
+
101
+ end
102
+
103
+ #----------------------------------------------------------------------------------------
104
+ #
105
+ #----------------------------------------------------------------------------------------
106
+
107
+ private
108
+
109
+ #----------------------------------------------------------------------------------------
110
+ #
111
+ #----------------------------------------------------------------------------------------
112
+
113
+ def _indent(num = nil, i_char = ' ')
114
+
115
+ # Define number of indentations to use
116
+ number = num
117
+ # Default number to 2 if spaces or 1 if other
118
+ number ||= (i_char == ' ') ? 2 : 1
119
+
120
+ str_arr = []
121
+ case
122
+ when number >= 0
123
+ split("\n", -1).collect{|line| (i_char * number) + line}.join("\n")
124
+ else
125
+ i_regexp = Regexp.new("^([ \t]|#{i_char})")
126
+ split("\n", -1).collect do |line|
127
+ ret_str = String.new(line)
128
+ number.abs.times do
129
+ match = ret_str.sub!(i_regexp, '')
130
+ break unless match
131
+ end
132
+ ret_str
133
+ end.join("\n")
134
+
135
+ end
136
+
137
+ end
138
+
139
+ end
data/lib/codewriter.rb ADDED
@@ -0,0 +1,26 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ ##########################################################################################
4
+ # @author Rodrigo Botafogo
5
+ #
6
+ # Copyright © 2016 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
7
+ # and distribute this software and its documentation, without fee and without a signed
8
+ # licensing agreement, is hereby granted, provided that the above copyright notice, this
9
+ # paragraph and the following two paragraphs appear in all copies, modifications, and
10
+ # distributions.
11
+ #
12
+ # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
13
+ # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
14
+ # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
15
+ # POSSIBILITY OF SUCH DAMAGE.
16
+ #
17
+ # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
19
+ # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
20
+ # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
21
+ # OR MODIFICATIONS.
22
+ ##########################################################################################
23
+
24
+ require_relative '../config'
25
+ require_relative 'code_writer/rbmarkdown'
26
+ require_relative 'code_writer/string_mod'
@@ -0,0 +1,31 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ ##########################################################################################
4
+ # @author Rodrigo Botafogo
5
+ #
6
+ # Copyright © 2016 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
7
+ # and distribute this software and its documentation, without fee and without a signed
8
+ # licensing agreement, is hereby granted, provided that the above copyright notice, this
9
+ # paragraph and the following two paragraphs appear in all copies, modifications, and
10
+ # distributions.
11
+ #
12
+ # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
13
+ # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
14
+ # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
15
+ # POSSIBILITY OF SUCH DAMAGE.
16
+ #
17
+ # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
19
+ # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
20
+ # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
21
+ # OR MODIFICATIONS.
22
+ ##########################################################################################
23
+
24
+ require 'rubygems'
25
+ require "test/unit"
26
+ require 'shoulda'
27
+
28
+ require '../config' if @platform == nil
29
+ require 'code_writer'
30
+
31
+ require_relative 'test_markdown'
@@ -0,0 +1,76 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ ##########################################################################################
4
+ # Copyright © 2016 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
5
+ # and distribute this software and its documentation, without fee and without a signed
6
+ # licensing agreement, is hereby granted, provided that the above copyright notice, this
7
+ # paragraph and the following two paragraphs appear in all copies, modifications, and
8
+ # distributions.
9
+ #
10
+ # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
11
+ # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
12
+ # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
13
+ # POSSIBILITY OF SUCH DAMAGE.
14
+ #
15
+ # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
17
+ # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
18
+ # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
19
+ # OR MODIFICATIONS.
20
+ ##########################################################################################
21
+
22
+ require 'rubygems'
23
+ require "test/unit"
24
+ require 'shoulda'
25
+
26
+ require '../config' if @platform == nil
27
+ require 'codewriter'
28
+
29
+ class CodeWriterTest < Test::Unit::TestCase
30
+
31
+ context "CodeWriter environment" do
32
+
33
+ #--------------------------------------------------------------------------------------
34
+ #
35
+ #--------------------------------------------------------------------------------------
36
+
37
+ setup do
38
+
39
+ end
40
+
41
+ #--------------------------------------------------------------------------------------
42
+ #
43
+ #--------------------------------------------------------------------------------------
44
+
45
+ should "create markdown code" do
46
+
47
+ section("This is a section")
48
+
49
+ code(<<-EOC)
50
+ def new_func
51
+ puts "hello World"
52
+ end
53
+ EOC
54
+
55
+ console(<<-EOT)
56
+ new_func
57
+ new_func
58
+ EOT
59
+
60
+ list(<<-EOT)
61
+ First Item
62
+
63
+ Second Item
64
+
65
+ Third Item
66
+
67
+ Fourth Item
68
+
69
+ Fifth Item
70
+ EOT
71
+
72
+ end
73
+
74
+ end
75
+
76
+ end
data/version.rb ADDED
@@ -0,0 +1,2 @@
1
+ $gem_name = "CodeWriter"
2
+ $version="0.1.0"
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: CodeWriter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rodrigo Botafogo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '3.5'
19
+ name: shoulda
20
+ prerelease: false
21
+ type: :development
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.5'
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.11'
33
+ name: simplecov
34
+ prerelease: false
35
+ type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.11'
41
+ - !ruby/object:Gem::Dependency
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.8'
47
+ name: yard
48
+ prerelease: false
49
+ type: :development
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.8'
55
+ - !ruby/object:Gem::Dependency
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.0'
61
+ name: kramdown
62
+ prerelease: false
63
+ type: :development
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '10.3'
75
+ name: rake
76
+ prerelease: false
77
+ type: :development
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.3'
83
+ description: 'This is a simple Gem to help authors write about code
84
+
85
+ '
86
+ email: rodrigo.a.botafogo@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - LICENSE
92
+ - README.md
93
+ - Rakefile
94
+ - config.rb
95
+ - lib/code_writer/rbmarkdown.rb
96
+ - lib/code_writer/string_mod.rb
97
+ - lib/codewriter.rb
98
+ - test/test_complete.rb
99
+ - test/test_markdown.rb
100
+ - version.rb
101
+ homepage: http://github.com/rbotafogo/CodeWriter/wiki
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.4.8
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Simple Gem for helping writing about code
125
+ test_files:
126
+ - test/test_complete.rb
127
+ - test/test_markdown.rb
128
+ has_rdoc: