CodeWriter 0.1.0 → 0.1.1

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: 40e63fede9abfa26d00bf2a5df5e672cdf21eb51
4
- data.tar.gz: 6e9475984b060efd04ba61b018a6a8b09073f154
3
+ metadata.gz: 8add6e9b4b54013623d99ad61a15fbe6375b2e4f
4
+ data.tar.gz: 1da219de002b3d861fe8b44549cd222871d28890
5
5
  SHA512:
6
- metadata.gz: de54ba8f4b49b94a319e9088eab0cec641253d21e3b8e8307a6793c4ca513d7bdaf0e26fab9a7aacc28fedf32e843a8e39bc1ef3f1393944c6bef7e60014a8ee
7
- data.tar.gz: 0e0f4b5b4976aeffa7981f264460918d2eae41cbe5e67633d8347b2c54797b38835ad1f96a8be15759c0a50703b41830f9817d7756b1fb3fad56776f87f7324c
6
+ metadata.gz: 3b1b3037ab2a22f3bbd3d0f8798757fdbe656192928df93e21880fe71f7eed56990e8ce5576548944a40436917452e69a514de4a4253a3c343f028e400b54f2b
7
+ data.tar.gz: b36da35dc9b56a0069f85e860ee012f5a3aa7b99b3d8036378dc0242e9a4093cc1d98f1e1fa34a552c39f65a7e41793f13d1f5d35c72774fdfdf67cfcd8bd04d
@@ -1,14 +1,23 @@
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
1
+ # coding: utf-8
2
+
3
+ ##########################################################################################
4
+ # Copyright © 2013 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
+ ##########################################################################################
12
21
 
13
22
  ###########################################################################################
14
23
  # In some cases, there is the need to redirect standard output to a string. In general
@@ -20,7 +29,7 @@ $mk = Markdown.new
20
29
  ###########################################################################################
21
30
 
22
31
  class StIO
23
-
32
+
24
33
  attr_reader :alternate_out
25
34
  attr_reader :alternate_err
26
35
 
@@ -33,7 +42,7 @@ class StIO
33
42
  $stderr = StringIO.new(buffer)
34
43
  @alternate_err = buffer
35
44
  end
36
-
45
+
37
46
  def set_default_std_out
38
47
  $stdout = STDOUT
39
48
  end
@@ -41,161 +50,186 @@ class StIO
41
50
  def set_default_std_out
42
51
  $stdout = STDOUT
43
52
  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"
53
+
131
54
  end
132
55
 
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)
56
+ module Markdown
57
+
58
+ ###########################################################################################
59
+ #
60
+ ###########################################################################################
141
61
 
142
- puts script
143
- begin
144
- eval(script, TOPLEVEL_BINDING)
145
- rescue Exception => e
146
- puts e.message
62
+ #------------------------------------------------------------------------------------------
63
+ #
64
+ #------------------------------------------------------------------------------------------
65
+
66
+ def set_output(output = StIO.new)
67
+ $output = output
147
68
  end
148
69
 
149
- $output.set_default_std_out
150
- puts $output.alternate_out.align_left.indent(4)
151
- puts
70
+ #------------------------------------------------------------------------------------------
71
+ #
72
+ #------------------------------------------------------------------------------------------
152
73
 
153
- end
154
-
155
- #------------------------------------------------------------------------------------------
156
- #
157
- #------------------------------------------------------------------------------------------
158
-
159
- def console(script)
160
-
161
- print(script.align_left.prefix("+ ", "> ").indent(4))
74
+ def title(text)
75
+ print "# #{text}\n\n"
76
+ end
162
77
 
163
- # Let's capture the output of Renjin script in our own string.
164
- $output.set_std_out(String.new)
78
+ #------------------------------------------------------------------------------------------
79
+ #
80
+ #------------------------------------------------------------------------------------------
165
81
 
166
- begin
167
- print("\n\n")
168
- eval(script, TOPLEVEL_BINDING)
169
- rescue Exception => e
170
- puts e.message
82
+ def author(text)
83
+ print "Author: #{text}\n\n"
171
84
  end
172
-
173
- $output.set_default_std_out
174
- puts $output.alternate_out.align_left.indent(4)
175
- puts
176
85
 
177
- end
178
-
179
- #------------------------------------------------------------------------------------------
180
- #
181
- #------------------------------------------------------------------------------------------
86
+ #------------------------------------------------------------------------------------------
87
+ #
88
+ #------------------------------------------------------------------------------------------
89
+
90
+ def chapter(text)
91
+ print "# #{text}\n\n"
92
+ end
93
+
94
+ #------------------------------------------------------------------------------------------
95
+ #
96
+ #------------------------------------------------------------------------------------------
97
+
98
+ def section(text)
99
+ print "## #{text}\n\n"
100
+ end
101
+
102
+ #------------------------------------------------------------------------------------------
103
+ #
104
+ #------------------------------------------------------------------------------------------
105
+
106
+ def subsection(text)
107
+ print "### #{text}\n\n"
108
+ end
109
+
110
+ #------------------------------------------------------------------------------------------
111
+ #
112
+ #------------------------------------------------------------------------------------------
113
+
114
+ def subsubsection(text)
115
+ print "#### #{text}\n\n"
116
+ end
117
+
118
+ #------------------------------------------------------------------------------------------
119
+ #
120
+ #------------------------------------------------------------------------------------------
121
+
122
+ def paragraph(text)
123
+ puts text
124
+ end
125
+
126
+ #------------------------------------------------------------------------------------------
127
+ #
128
+ #------------------------------------------------------------------------------------------
129
+
130
+ def subparagraph(text)
131
+ puts text
132
+ end
133
+
134
+ #------------------------------------------------------------------------------------------
135
+ #
136
+ #------------------------------------------------------------------------------------------
137
+
138
+ def body(text)
139
+ print "#{text.align_left}\n\n"
140
+ end
141
+
142
+ #------------------------------------------------------------------------------------------
143
+ #
144
+ #------------------------------------------------------------------------------------------
145
+
146
+ def code(script)
147
+
148
+ # Let's capture the output of Renjin script in our own string.
149
+ $output.set_std_out(String.new)
150
+
151
+ puts script.align_left
152
+ puts
153
+
154
+ begin
155
+ # eval(script, TOPLEVEL_BINDING)
156
+ eval(script, $binding)
157
+ rescue Exception => e
158
+ puts "#{e.class}: #{e.message}"
159
+ end
160
+
161
+ $output.set_default_std_out
162
+ puts $output.alternate_out.align_left.indent(4)
163
+
164
+ end
165
+
166
+ #------------------------------------------------------------------------------------------
167
+ #
168
+ #------------------------------------------------------------------------------------------
169
+
170
+ def console(script)
171
+
172
+ print(script.align_left.prefix("+ ", "> ").indent(4))
173
+
174
+ # Let's capture the output of Renjin script in our own string.
175
+ $output.set_std_out(String.new)
176
+
177
+ begin
178
+ print("\n\n")
179
+ # eval(script, TOPLEVEL_BINDING)
180
+ eval(script, $binding)
181
+ rescue Exception => e
182
+ puts "#{e.class}: #{e.message}"
183
+ end
184
+
185
+ $output.set_default_std_out
186
+ puts
187
+ puts $output.alternate_out.align_left.indent(4)
188
+ puts
189
+
190
+ end
191
+
192
+ #------------------------------------------------------------------------------------------
193
+ #
194
+ #------------------------------------------------------------------------------------------
195
+
196
+ def comment_code(text)
197
+ puts text.align_left.indent(4)
198
+ puts
199
+ end
200
+
201
+ #------------------------------------------------------------------------------------------
202
+ #
203
+ #------------------------------------------------------------------------------------------
204
+
205
+ def ref(title, publication)
206
+ "*#{title}*, #{publication}"
207
+ end
208
+
209
+ #------------------------------------------------------------------------------------------
210
+ #
211
+ #------------------------------------------------------------------------------------------
212
+
213
+ def list(text)
214
+ puts text.align_left.prefix("* ", paragraph: true).indent(2)
215
+ puts
216
+ end
217
+
218
+ #------------------------------------------------------------------------------------------
219
+ #
220
+ #------------------------------------------------------------------------------------------
182
221
 
183
- def comment_code(text)
184
- puts text.align_left.indent(4)
185
- end
222
+ def italic(text)
223
+ print "*#{text}*"
224
+ end
225
+ #------------------------------------------------------------------------------------------
226
+ #
227
+ #------------------------------------------------------------------------------------------
186
228
 
187
- #------------------------------------------------------------------------------------------
188
- #
189
- #------------------------------------------------------------------------------------------
190
229
 
191
- def ref(title, publication)
192
- "*#{title}*, #{publication}"
230
+ $output = StIO.new
231
+ $binding = binding()
232
+
193
233
  end
194
234
 
195
- #------------------------------------------------------------------------------------------
196
- #
197
- #------------------------------------------------------------------------------------------
198
235
 
199
- def list(text)
200
- puts text.align_left.prefix("* ", paragraph: true).indent(2)
201
- end
@@ -24,9 +24,11 @@ require "test/unit"
24
24
  require 'shoulda'
25
25
 
26
26
  require '../config' if @platform == nil
27
- require 'codewriter'
27
+ # require 'codewriter'
28
+ require_relative '../../CodeWriter/lib/codewriter'
28
29
 
29
30
  class CodeWriterTest < Test::Unit::TestCase
31
+ include Markdown
30
32
 
31
33
  context "CodeWriter environment" do
32
34
 
@@ -44,6 +46,8 @@ class CodeWriterTest < Test::Unit::TestCase
44
46
 
45
47
  should "create markdown code" do
46
48
 
49
+ set_output
50
+
47
51
  section("This is a section")
48
52
 
49
53
  code(<<-EOC)
data/version.rb CHANGED
@@ -1,2 +1,2 @@
1
1
  $gem_name = "CodeWriter"
2
- $version="0.1.0"
2
+ $version="0.1.1"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CodeWriter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Botafogo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-01 00:00:00.000000000 Z
11
+ date: 2016-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.4.8
121
+ rubygems_version: 2.6.4
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Simple Gem for helping writing about code