mark_maker 0.5.1 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fd856055ec57459656c6963b82423f55febfe440
4
- data.tar.gz: 355e6e14d071a9d53a9f2fd4333896ab1e0253b7
2
+ SHA256:
3
+ metadata.gz: bd5c7e729e819e15b9796cd57242afd832bd913f1545184cda35cee9e1c07db1
4
+ data.tar.gz: 43156be3f04d2bba8789bd9c80452bc8c468b30074a26acc5335468fc9af1c6b
5
5
  SHA512:
6
- metadata.gz: 95a31758ca8963bebd1080210c333c0ffc7d29767ffeaed3151a7cf92c5cd8bbacaa7788ad359c73efb9db943c735d5e8564eb7ddb2a2cbf47c1d6986203b075
7
- data.tar.gz: 351deb838b05b55f91f1a40991de02e297ed08bbc795a7ffb73cf7d9dad0c74648f26337fb88dcf9cd8a012aa860be5402be3e2906331ae1b136f7053f73f383
6
+ metadata.gz: 797cf2e44e772f2e6501efe9d8bcb4a32ef349862c3b67e19f173ac3ecf34d477b50737fd9fec40d0e1db6384ca2c6800d1b384aad9c5404e372066093124303
7
+ data.tar.gz: e7872ccacd0ed4b3c06975522899c92adde7c9c3142bf2e0d140fbd4082702290a81ab37ac312620de402a66ece8d13b009d1b44879df8c88679731e1d9927db
@@ -1 +1,2 @@
1
- 2.2.1
1
+ 2.6
2
+
@@ -1,3 +1,12 @@
1
+ before_install:
2
+ - gem install bundler
3
+
1
4
  language: ruby
5
+
6
+ bundler_args: --without dev_tooling
7
+
2
8
  rvm:
3
- - 2.2.0
9
+ - ruby-head
10
+ - 2.7
11
+ - 2.6
12
+ - 2.3
@@ -1,3 +1,27 @@
1
+ 1.0.0
2
+ -----
3
+
4
+ - just tidied up the README
5
+ - clarified the supported ruby versions (all now 2.x variations)
6
+
7
+ 0.9.0
8
+ -----
9
+
10
+ - addressing security vulnerability associated with rake
11
+ - dropping support for ruby 1.x versions
12
+ - now calls for bundler 2
13
+
14
+ 0.8.0
15
+ -----
16
+ - added header 4 thru 6 support
17
+ - fixed a bug in the image generation when using a title
18
+ - noted supported ruby versions in the readme, per travis config
19
+
20
+ 0.7.0
21
+ -----
22
+ - added support for images
23
+ - now support ruby 1.9.3, 2.2.4 and 2.3.0
24
+
1
25
  0.3.0
2
26
  -----
3
27
 
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in mark_maker.gemspec
4
4
  gemspec
5
+
6
+ group :dev_tooling do
7
+ gem 'rubocop'
8
+ end
data/README.md CHANGED
@@ -1,37 +1,10 @@
1
+ ![MarkMaker build status](https://travis-ci.org/sn1de/mark_maker.svg?branch=master "Build Status")
2
+
1
3
  MarkMaker
2
4
  =========
3
5
 
4
6
  Programatically generate markdown documents.
5
7
 
6
- Intended Use
7
- ------------
8
-
9
- The mark_maker gem provides a set of methods that take text content and
10
- convert it to various markdown elements. The primary use case is simple
11
- conversion of something like a JSON document into a markdown document.
12
-
13
- The initial development goal is to provide
14
- support for all of the markdown supported operations, at least in their basic form. What
15
- I mean by basic is that you provide a 'chunk' of content and the mark_maker `Generator`
16
- will return that content in the corresponding markdown format. For grouped content, variable
17
- parameters will be provided on the method call to allow for things like correctly numbered
18
- bullet lists. Each call to the generator is treated as a separate
19
- markdown operation. So things like link definitions aren't going to be supported,
20
- at least not in 1.0
21
-
22
- Speaking of versioning, I'll use semantic versioning to indicate when new markdown
23
- capabilities are added. I'll release 1.0 when I feel like it supports set
24
- of markdown capabilites that fulfill the intended use. This will also include some
25
- extended capabilities from expanded syntaxes like GitHub flavored markdown. Methods
26
- generating non-core markdown will be noted in the documentation for that method.
27
-
28
- If all goes well, and it appears anyone is using this gem, then a 2.0 release is
29
- envisioned that will add a `Document` class that will provide a
30
- more holistic layer of capabilities. For example, the aformentioned reference style
31
- links would be nice. As would the ability to have an arbitrarily long string broken
32
- down into nicely formatted hard break paragraphs. Same goes for nicely indented multi-line
33
- bullets, etc.
34
-
35
8
  Installation
36
9
  ------------
37
10
 
@@ -51,19 +24,53 @@ Usage
51
24
  -----
52
25
 
53
26
  MarkMaker provides line oriented conversion of content to markdown elements. It
54
- currently supports first, second and third level headings, links, bullets, numbered
27
+ currently supports headings, links, bullets, numbered
55
28
  bullets, *emphasis*, **strong**, code
56
- and basic table markdown. See bin/generate_readme.rb for the code used to generate this
29
+ and table markdown. See bin/generate_readme.rb for the code used to generate this
57
30
  document and a sample of all these markdown generators in action.
58
31
 
32
+ Simple markdown generation is handled by extensions to the ruby String class. Headers,
33
+ code, emphasis, and strong are all handled by String methods.
34
+
35
+ Multi line and more complex conversions are handled by a Generator class.
36
+
59
37
  ### Header Example
60
- gen = MarkMaker::Generator.new
61
- gen.header1('Let It Begin'')
62
38
 
63
- Produces
39
+ The following ruby code ...
40
+
41
+ ```ruby
42
+ h = "Let It Begin"
43
+ puts h.header1
44
+ puts h.header2
45
+ puts h.header3
46
+ puts h.header4
47
+ puts h.header5
48
+ puts h.header6
49
+ ```
50
+
51
+ Results in this generated markdown ...
52
+ ```
53
+ Let It Begin
54
+ ============
55
+ Let It Begin
56
+ ------------
57
+ ### Let It Begin
58
+ #### Let It Begin
59
+ ##### Let It Begin
60
+ ###### Let It Begin
61
+ ```
62
+
63
+ Ultimately looking something like this (if your are viewing this on github or through some other markdown viewing method) ...
64
+
65
+ Let It Begin
66
+ ============
67
+ Let It Begin
68
+ ------------
69
+ ### Let It Begin
70
+ #### Let It Begin
71
+ ##### Let It Begin
72
+ ###### Let It Begin
64
73
 
65
- Let It Begin
66
- ============
67
74
 
68
75
  ### Bulleted List Example
69
76
 
@@ -151,14 +158,16 @@ puts total
151
158
 
152
159
  ### Table Example
153
160
 
154
- header, separator = gen.table_header("Col One", "Col Two", "Col Three")
155
- puts header
156
- puts separator
157
- puts gen.table_row("First", "A", "$3.99")
158
- puts gen.table_row("Second", "BC", "$14.00")
159
- puts gen.table_row("Third", "DEFGH", "$1,034.50")
161
+ ```ruby
162
+ header, separator = gen.table_header("Col One", "Col Two", "Col Three")
163
+ puts header
164
+ puts separator
165
+ puts gen.table_row("First", "A", "$3.99")
166
+ puts gen.table_row("Second", "BC", "$14.00")
167
+ puts gen.table_row("Third", "DEFGH", "$1,034.50")
168
+ ```
160
169
 
161
- Produces this terribly ugly markdown ...
170
+ Produces this terribly ugly markdown (but standby, there is a better way below) ...
162
171
 
163
172
  ```
164
173
  |Col One|Col Two|Col Three|
@@ -242,3 +251,27 @@ existing README.md
242
251
 
243
252
  I'm calling this Extreme [Readme Driven Development](http://tom.preston-werner.com/2010/08/23/readme-driven-development.html).
244
253
  It's kind of like [Inception](http://en.wikipedia.org/wiki/Inception) ;)
254
+
255
+ Supported Ruby Versions
256
+ -----------------------
257
+
258
+ The following ruby versions are explicitly supported and exercised via TravisCI (see .travis.yml)
259
+
260
+ - ruby-head
261
+ - 2.7
262
+ - 2.6
263
+ - 2.3
264
+
265
+ Release Process
266
+ ---------------
267
+
268
+ Document release changes in `CHANGELOG.md`
269
+
270
+ Increment the VERSION number in `lib/mark_maker/version.rb`
271
+
272
+ Run `rake release` which will:
273
+
274
+ - build the gem into the `pkg/` director
275
+ - create a git tag for the version
276
+ - push to github
277
+ - push the packaged gem to rubygems
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
- require 'rubocop/rake_task'
3
+ require 'rubocop/rake_task' unless ENV['CI'] == 'true'
4
4
 
5
5
  Rake::TestTask.new(:test) do |t|
6
6
  t.libs << "test"
@@ -13,12 +13,13 @@ task :console do
13
13
  exec "irb -r mark_maker -I ./lib"
14
14
  end
15
15
 
16
- RuboCop::RakeTask.new(:rubocop) do |task|
17
- task.patterns = ['lib/**/*.rb']
16
+ if ENV['CI'] != 'true'
17
+ RuboCop::RakeTask.new(:rubocop) do |task|
18
+ task.patterns = ['lib/**/*.rb']
19
+ end
18
20
  end
19
21
 
20
22
  desc "generate the readme file for the project programatically using MarkMaker"
21
23
  task :readme do
22
24
  exec "ruby -Ilib bin/generate_readme.rb > README.md"
23
25
  end
24
-
@@ -11,7 +11,7 @@
11
11
  # would be a good way to eat my own dogfood and provide
12
12
  # a solid example.
13
13
  #
14
- # examples. So here goes ... extreme readme driven development!
14
+ # So here goes ... extreme readme driven development!
15
15
 
16
16
  require 'mark_maker'
17
17
 
@@ -25,90 +25,85 @@ ensure
25
25
  end
26
26
 
27
27
  gen = MarkMaker::Generator.new
28
- puts gen.header1("MarkMaker")
28
+ puts gen.image("MarkMaker build status", "https://travis-ci.org/sn1de/mark_maker.svg?branch=master", "Build Status")
29
+ puts ""
30
+ puts "MarkMaker".header1
29
31
  puts ""
30
32
  puts "Programatically generate markdown documents."
31
33
  puts ""
32
- puts gen.header2("Intended Use")
33
- puts ""
34
- puts "The mark_maker gem provides a set of methods that take text content and"
35
- puts "convert it to various markdown elements. The primary use case is simple"
36
- puts "conversion of something like a JSON document into a markdown document."
37
- puts ""
38
- puts "The initial development goal is to provide"
39
- puts "support for all of the markdown supported operations, at least in their basic form. What"
40
- puts "I mean by basic is that you provide a 'chunk' of content and the mark_maker #{ gen.code_span('Generator') }"
41
- puts "will return that content in the corresponding markdown format. For grouped content, variable"
42
- puts "parameters will be provided on the method call to allow for things like correctly numbered"
43
- puts "bullet lists. Each call to the generator is treated as a separate"
44
- puts "markdown operation. So things like link definitions aren't going to be supported,"
45
- puts "at least not in 1.0"
46
- puts ""
47
- puts "Speaking of versioning, I'll use semantic versioning to indicate when new markdown"
48
- puts "capabilities are added. I'll release 1.0 when I feel like it supports set"
49
- puts "of markdown capabilites that fulfill the intended use. This will also include some"
50
- puts "extended capabilities from expanded syntaxes like GitHub flavored markdown. Methods"
51
- puts "generating non-core markdown will be noted in the documentation for that method."
52
- puts ""
53
- puts "If all goes well, and it appears anyone is using this gem, then a 2.0 release is"
54
- puts "envisioned that will add a #{ gen.code_span('Document') } class that will provide a"
55
- puts "more holistic layer of capabilities. For example, the aformentioned reference style"
56
- puts "links would be nice. As would the ability to have an arbitrarily long string broken"
57
- puts "down into nicely formatted hard break paragraphs. Same goes for nicely indented multi-line"
58
- puts "bullets, etc."
59
- puts ""
60
- puts gen.header2("Installation")
34
+ puts "Installation".header2
61
35
  puts ""
62
36
  puts "Add this line to your application's Gemfile:"
63
37
  puts ""
64
- puts gen.code("gem 'mark_maker'")
38
+ puts "gem 'mark_maker'".code
65
39
  puts ""
66
40
  puts "And then execute:"
67
41
  puts ""
68
- puts gen.code("$ bundle")
42
+ puts "$ bundle".code
69
43
  puts ""
70
44
  puts "Or install it yourself as:"
71
45
  puts ""
72
- puts gen.code("$ gem install mark_maker")
46
+ puts "$ gem install mark_maker".code
73
47
  puts ""
74
- puts gen.header2("Usage")
48
+ puts "Usage".header2
75
49
  puts ""
76
50
  puts "MarkMaker provides line oriented conversion of content to markdown elements. It"
77
- puts "currently supports first, second and third level headings, links, bullets, numbered"
78
- puts "bullets, #{gen.emphasis('emphasis')}, #{gen.strong('strong')}, code"
79
- puts "and basic table markdown. See #{__FILE__} for the code used to generate this"
51
+ puts "currently supports headings, links, bullets, numbered"
52
+ puts "bullets, #{'emphasis'.emphasis}, #{'strong'.strong}, code"
53
+ puts "and table markdown. See #{__FILE__} for the code used to generate this"
80
54
  puts "document and a sample of all these markdown generators in action."
81
55
  puts ""
82
- puts gen.header3("Header Example")
83
- example_header = "Let It Begin"
84
- puts gen.code("gen = MarkMaker::Generator.new")
85
- puts gen.code("gen.header1('#{example_header}'')")
86
- puts "\nProduces\n\n"
87
- gen.header1(example_header).lines.map { |l| puts gen.code(l) }
56
+ puts "Simple markdown generation is handled by extensions to the ruby String class. Headers,"
57
+ puts "code, emphasis, and strong are all handled by String methods."
58
+ puts ""
59
+ puts "Multi line and more complex conversions are handled by a Generator class."
60
+ puts ""
61
+ puts "Header Example".header3
62
+ puts ""
63
+ puts "The following ruby code ..."
64
+ puts ""
65
+ header_code = <<-EOT
66
+ h = "Let It Begin"
67
+ puts h.header1
68
+ puts h.header2
69
+ puts h.header3
70
+ puts h.header4
71
+ puts h.header5
72
+ puts h.header6
73
+ EOT
74
+ puts gen.fenced_code_language('ruby', *header_code.lines)
75
+ puts ""
76
+ puts "Results in this generated markdown ..."
77
+ header_markdown = capture_stdout do
78
+ eval(header_code)
79
+ end
80
+ puts gen.fenced_code_block(*header_markdown.string.lines)
81
+ puts "\nUltimately looking something like this (if your are viewing this on github or through some other markdown viewing method) ...\n\n"
82
+ puts eval(header_code)
88
83
  puts ""
89
- puts gen.header3("Bulleted List Example")
84
+ puts "Bulleted List Example".header3
90
85
  list_content = ['gold', 'silver', 'bronze']
91
86
  puts ""
92
- puts gen.code("list_content = ['gold', 'silver', 'bronze']")
93
- puts gen.code("gen.bullets(*list_content)")
87
+ puts "list_content = ['gold', 'silver', 'bronze']".code
88
+ puts "gen.bullets(*list_content)".code
94
89
  puts "\nProduces\n\n"
95
90
  puts gen.code_block(*gen.bullets(*list_content))
96
91
  puts ""
97
92
  puts "Or a numbered list with..."
98
93
  puts ""
99
94
  numbered_code = "gen.numbers(*list_content)"
100
- puts gen.code(numbered_code)
95
+ puts numbered_code.code
101
96
  puts ""
102
97
  puts "Produces"
103
98
  puts ""
104
99
  puts gen.code_block(*eval(numbered_code))
105
100
  puts ""
106
- puts gen.header3("Code Examples")
101
+ puts "Code Examples".header3
107
102
  puts ""
108
- puts "Standard markdown code blocks and #{gen.code_span('code span')} are supported, as well as github"
103
+ puts "Standard markdown code blocks and #{'code span'.code_span} are supported, as well as github"
109
104
  puts "flavored markdown fenced code blocks."
110
105
  puts ""
111
- sample_block = <<-EOT.lines
106
+ sample_block = <<-EOT.lines.to_a
112
107
  some_code = [ "# add it up",
113
108
  "total = [1, 2, 3, 4].inject do |sum, i|",
114
109
  " sum += i",
@@ -125,7 +120,7 @@ puts ""
125
120
  puts "You can also generate a github flavored markdown fenced code version."
126
121
  fenced_code = "gen.fenced_code_block(*some_code)"
127
122
  puts ""
128
- puts gen.code(fenced_code)
123
+ puts fenced_code.code
129
124
  puts ""
130
125
  puts "Produces"
131
126
  puts ""
@@ -134,7 +129,7 @@ puts ""
134
129
  puts "You can also include a language in a fenced code block."
135
130
  puts ""
136
131
  fenced_code_language = "gen.fenced_code_language('ruby', *some_code)"
137
- puts gen.code(fenced_code_language)
132
+ puts fenced_code_language.code
138
133
  puts ""
139
134
  puts "Produces"
140
135
  puts ""
@@ -144,7 +139,7 @@ puts "Rendering beautifully highlighted code like so, if you are viewing this on
144
139
  puts ""
145
140
  puts eval("#{sample_block.join}\n#{fenced_code_language}")
146
141
  puts ""
147
- puts gen.header3("Table Example")
142
+ puts "Table Example".header3
148
143
  puts ""
149
144
  table_code = <<-EOT
150
145
  header, separator = gen.table_header("Col One", "Col Two", "Col Three")
@@ -154,9 +149,9 @@ table_code = <<-EOT
154
149
  puts gen.table_row("Second", "BC", "$14.00")
155
150
  puts gen.table_row("Third", "DEFGH", "$1,034.50")
156
151
  EOT
157
- puts gen.code_block(*table_code.lines)
152
+ puts gen.fenced_code_language('ruby', *table_code.lines)
158
153
  puts ""
159
- puts "Produces this terribly ugly markdown ..."
154
+ puts "Produces this terribly ugly markdown (but standby, there is a better way below) ..."
160
155
  puts ""
161
156
  table_markdown = capture_stdout do
162
157
  eval(table_code)
@@ -185,7 +180,7 @@ puts "Which gives you this stunning HTML table ..."
185
180
  puts ""
186
181
  puts eval(pretty_table_code)
187
182
  puts ""
188
- puts gen.header3("Block Quotes Example")
183
+ puts "Block Quotes Example".header3
189
184
  puts ""
190
185
  block_quote_code = <<-EOT
191
186
  content = <<-QUOTE
@@ -208,7 +203,7 @@ puts "Which looks like this when viewed as HTML..."
208
203
  puts ""
209
204
  puts eval(block_quote_code)
210
205
  puts ""
211
- puts gen.header2("Contributing")
206
+ puts "Contributing".header2
212
207
  puts ""
213
208
  puts gen.numbers(gen.link("Fork it", "https://github.com/sn1de/mark_maker/fork"),
214
209
  "Create your feature branch (`git checkout -b my-new-feature`)",
@@ -216,14 +211,34 @@ puts gen.numbers(gen.link("Fork it", "https://github.com/sn1de/mark_maker/fork")
216
211
  "Push to the branch (`git push origin my-new-feature`)",
217
212
  "Create a new Pull Request")
218
213
  puts ""
219
- puts gen.header2("About This README")
214
+ puts "About This README".header2
220
215
  puts ""
221
216
  puts "This readme document is created using MarkMaker. To modify it, edit the code"
222
217
  puts "in #{__FILE__} and then run the 'readme' rake task to generate and overwrite the"
223
218
  puts "existing README.md"
224
219
  puts ""
225
- puts gen.code("vi #{__FILE__}")
226
- puts gen.code("rake readme")
220
+ puts "vi #{__FILE__}".code
221
+ puts "rake readme".code
227
222
  puts ""
228
223
  puts "I'm calling this Extreme #{gen.link("Readme Driven Development", "http://tom.preston-werner.com/2010/08/23/readme-driven-development.html")}."
229
224
  puts "It's kind of like #{gen.link("Inception", "http://en.wikipedia.org/wiki/Inception")} ;)"
225
+ puts ""
226
+ puts "Supported Ruby Versions".header2
227
+ puts ""
228
+ puts "The following ruby versions are explicitly supported and exercised via TravisCI (see .travis.yml)"
229
+ puts ""
230
+ puts gen.bullets("ruby-head", "2.7", "2.6", "2.3")
231
+ puts ""
232
+ puts "Release Process".header2
233
+ puts ""
234
+ puts "Document release changes in `CHANGELOG.md`"
235
+ puts ""
236
+ puts "Increment the VERSION number in `lib/mark_maker/version.rb`"
237
+ puts ""
238
+ puts "Run `rake release` which will:"
239
+ puts ""
240
+ puts gen.bullets("build the gem into the `pkg/` director",
241
+ "create a git tag for the version",
242
+ "push to github",
243
+ "push the packaged gem to rubygems")
244
+
@@ -1,20 +1,9 @@
1
+ require 'mark_maker_string'
2
+
1
3
  module MarkMaker
2
4
  # Generator is the workhorse of the MarkMaker utility. It provides
3
5
  # line by line generation of markdown output.
4
6
  class Generator
5
- def line_for(underscore, content)
6
- underscore * content.size
7
- end
8
-
9
- def line_for_left
10
- end
11
-
12
- def line_for_right
13
- end
14
-
15
- def line_for_center
16
- end
17
-
18
7
  # Justification indicators are a bit of a special case, because the way
19
8
  # they actually work is the colon's proximity to the vertical | bars marking
20
9
  # the table cells. This means that the center justification indicator, for
@@ -42,49 +31,24 @@ module MarkMaker
42
31
  justification?(c) ? '-' : fill
43
32
  end
44
33
 
45
- def header1(title)
46
- "#{title}\n#{line_for('=', title)}"
47
- end
48
-
49
- def header2(title)
50
- "#{title}\n#{line_for('-', title)}"
51
- end
52
-
53
- def header3(title)
54
- "### #{title}"
55
- end
56
-
57
- def bullet(content)
58
- " - #{content}"
59
- end
60
-
61
34
  def bullets(*content)
62
- content.map { |li| bullet(li) }
63
- end
64
-
65
- def number(content, number = 1)
66
- " #{number}. #{content}"
35
+ content.map(&:bullet)
67
36
  end
68
37
 
69
38
  def numbers(*content)
70
- current_number = 0
71
- content.map { |li| number(li, current_number += 1) }
39
+ content.each.with_index(1).map { |l, i| l.number(i) }
72
40
  end
73
41
 
74
42
  def link(label, url)
75
43
  "[#{label}](#{url})"
76
44
  end
77
45
 
78
- def code(content)
79
- " #{content}"
80
- end
81
-
82
- def code_span(content)
83
- "#{CODE_TIC}#{content}#{CODE_TIC}"
46
+ def image(alt, path, title = "")
47
+ %Q(![#{alt}](#{path} "#{title}"))
84
48
  end
85
49
 
86
50
  def code_block(*content)
87
- content.map { |c| code(c) }
51
+ content.map(&:code)
88
52
  end
89
53
 
90
54
  # creates a github flavored markdown fenced code block
@@ -102,14 +66,6 @@ module MarkMaker
102
66
  block << FENCE
103
67
  end
104
68
 
105
- def emphasis(content)
106
- "#{EMPHASIS}#{content}#{EMPHASIS}"
107
- end
108
-
109
- def strong(content)
110
- EMPHASIS * 2 + content + EMPHASIS * 2
111
- end
112
-
113
69
  def table_header(*content)
114
70
  [
115
71
  content.inject("|") { |a, e| a + "#{e}|" },
@@ -200,8 +156,7 @@ module MarkMaker
200
156
  end
201
157
 
202
158
  def column_width(*content)
203
- longest = content.reduce { |a, e| a.length > e.length ? a : e }
204
- longest.length
159
+ content.reduce { |a, e| a.length > e.length ? a : e } .length
205
160
  end
206
161
 
207
162
  def centered_margins(width, content)
@@ -1,4 +1,4 @@
1
1
  # version management
2
2
  module MarkMaker
3
- VERSION = "0.5.1"
3
+ VERSION = "1.0.0"
4
4
  end
@@ -0,0 +1,55 @@
1
+
2
+ # adds several basic string to markdown conversion methods
3
+ class String
4
+ def line_for(underscore)
5
+ underscore * size
6
+ end
7
+
8
+ def header1
9
+ "#{self}\n#{line_for('=')}"
10
+ end
11
+
12
+ def header2
13
+ "#{self}\n#{line_for('-')}"
14
+ end
15
+
16
+ def header3
17
+ "### #{self}"
18
+ end
19
+
20
+ def header4
21
+ "#### #{self}"
22
+ end
23
+
24
+ def header5
25
+ "##### #{self}"
26
+ end
27
+
28
+ def header6
29
+ "###### #{self}"
30
+ end
31
+
32
+ def bullet
33
+ " - #{self}"
34
+ end
35
+
36
+ def number(number = 1)
37
+ " #{number}. #{self}"
38
+ end
39
+
40
+ def code
41
+ " #{self}"
42
+ end
43
+
44
+ def code_span
45
+ "#{MarkMaker::CODE_TIC}#{self}#{MarkMaker::CODE_TIC}"
46
+ end
47
+
48
+ def emphasis
49
+ "#{MarkMaker::EMPHASIS}#{self}#{MarkMaker::EMPHASIS}"
50
+ end
51
+
52
+ def strong
53
+ MarkMaker::EMPHASIS * 2 + self + MarkMaker::EMPHASIS * 2
54
+ end
55
+ end
@@ -12,17 +12,18 @@ Gem::Specification.new do |spec|
12
12
  spec.description = %q{Programatically generate markdown documents.}
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
15
+ spec.required_ruby_version = '>= 1.9.3'
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0")
17
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
20
  spec.require_paths = ["lib"]
20
21
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "bundler", ">= 2"
23
+ spec.add_development_dependency "rake", ">= 12.3.3"
23
24
  spec.add_development_dependency "minitest"
24
25
  spec.add_development_dependency "pry"
25
- spec.add_development_dependency "rubocop"
26
- spec.add_development_dependency "activesupport"
26
+ spec.add_development_dependency "unindent"
27
27
  spec.add_development_dependency "simplecov"
28
+ spec.add_development_dependency "minitest-reporters", '~> 1.1', '>= 1.1.8'
28
29
  end
@@ -1,6 +1,6 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
  require 'mark_maker'
3
- require 'active_support/core_ext/string'
3
+ require 'mark_maker_string'
4
4
  require 'minitest/autorun'
5
5
  require 'minitest/reporters'
6
6
  Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new
@@ -0,0 +1,47 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'minitest_helper'
5
+
6
+ class TestHeaders < Minitest::Test
7
+ def test_header1_generation
8
+ title = "abc123"
9
+ markup = title.header1
10
+ assert_match(/^={#{title.size}}$/, markup)
11
+ assert_match(/^#{title}$/, markup)
12
+ assert_match(/^#{title}\n={#{title.size}}$/, markup)
13
+ end
14
+
15
+ def test_header2_generation
16
+ title = "abc123"
17
+ markup = title.header2
18
+ assert_match(/^-{#{title.size}}$/, markup)
19
+ assert_match(/^#{title}$/, markup)
20
+ assert_match(/^#{title}\n-{#{title.size}}$/, markup)
21
+ end
22
+
23
+ def test_header3_generation
24
+ title = "abc123"
25
+ markup = title.header3
26
+ assert_match(/###\s#{title}/, markup)
27
+ end
28
+
29
+ def test_header4_generation
30
+ title = "abc123"
31
+ markup = title.header4
32
+ assert_match(/####\s#{title}/, markup)
33
+ end
34
+
35
+ def test_header5_generation
36
+ title = "abc123"
37
+ markup = title.header5
38
+ assert_match(/#####\s#{title}/, markup)
39
+ end
40
+
41
+ def test_header6_generation
42
+ title = "abc123"
43
+ markup = title.header6
44
+ assert_match(/######\s#{title}/, markup)
45
+ end
46
+
47
+ end
@@ -1,3 +1,4 @@
1
+ require 'unindent'
1
2
  require 'simplecov'
2
3
  SimpleCov.start
3
4
 
@@ -8,38 +9,6 @@ class TestMarkMaker < Minitest::Test
8
9
  refute_nil ::MarkMaker::VERSION
9
10
  end
10
11
 
11
- def test_header1_generation
12
- title = "abc123"
13
- gen = MarkMaker::Generator.new
14
- markup = gen.header1(title)
15
- assert_match(/^={#{title.size}}$/, markup)
16
- assert_match(/^#{title}$/, markup)
17
- assert_match(/^#{title}\n={#{title.size}}$/, markup)
18
- end
19
-
20
- def test_header2_generation
21
- title = "abc123"
22
- gen = MarkMaker::Generator.new
23
- markup = gen.header2(title)
24
- assert_match(/^-{#{title.size}}$/, markup)
25
- assert_match(/^#{title}$/, markup)
26
- assert_match(/^#{title}\n-{#{title.size}}$/, markup)
27
- end
28
-
29
- def test_header3_generation
30
- title = "abc123"
31
- gen = MarkMaker::Generator.new
32
- markup = gen.header3(title)
33
- assert_match(/###\s#{title}/, markup)
34
- end
35
-
36
- def test_bullet_generation
37
- content = "This is a bullet"
38
- gen = MarkMaker::Generator.new
39
- markup = gen.bullet(content)
40
- assert_match(/^ - #{content}$/, markup)
41
- end
42
-
43
12
  def test_bulleted_list_generation
44
13
  content = ["gold", "silver", "bronze"]
45
14
  gen = MarkMaker::Generator.new
@@ -49,12 +18,6 @@ class TestMarkMaker < Minitest::Test
49
18
  assert_match(/^\s-\s#{c}$/, m)
50
19
  end
51
20
  end
52
- def test_number_generation
53
- content = "Number this line"
54
- gen = MarkMaker::Generator.new
55
- markup = gen.number(content)
56
- assert_match(/^\s\d\.\s#{content}$/, markup)
57
- end
58
21
 
59
22
  def test_numbered_list_generation
60
23
  content = ["1", "2", "3"]
@@ -74,17 +37,13 @@ class TestMarkMaker < Minitest::Test
74
37
  assert_match(/^\[#{label}\]\(#{url}\)$/, markup)
75
38
  end
76
39
 
77
- def test_code_generation
78
- content = "var = code()"
40
+ def test_image_generation
41
+ path = "https://travis-ci.org/sn1de/mark_maker.svg?branch=master"
42
+ alt = "Mark Maker build status from Travis continuous integration"
43
+ title = "Build Status"
79
44
  gen = MarkMaker::Generator.new
80
- markup = gen.code(content)
81
- assert_match(/\s{4}var = code\(\)$/, markup)
82
- end
83
-
84
- def test_code_span_generation
85
- gen = MarkMaker::Generator.new
86
- markup = "Some #{gen.code_span('a = b + c')} here."
87
- assert_match(/^Some #{MarkMaker::CODE_TIC}a = b \+ c#{MarkMaker::CODE_TIC} here.$/, markup)
45
+ markup = gen.image(alt, path, title)
46
+ assert_match(/^!\[#{Regexp.quote(alt)}\]\(#{Regexp.quote(path)}\s"#{Regexp.quote(title)}"\)/, markup)
88
47
  end
89
48
 
90
49
  def test_code_block_generation
@@ -118,20 +77,6 @@ class TestMarkMaker < Minitest::Test
118
77
  assert(markup.last == MarkMaker::FENCE, "Markup should end with the code fence.")
119
78
  end
120
79
 
121
- def test_emphasis_generation
122
- content = "emphasize this"
123
- gen = MarkMaker::Generator.new
124
- markup = gen.emphasis(content)
125
- assert_match(/^#{Regexp.quote(MarkMaker::EMPHASIS)}#{content}#{Regexp.quote(MarkMaker::EMPHASIS)}$/, markup)
126
- end
127
-
128
- def test_strong_generation
129
- content = "strong stuff"
130
- gen = MarkMaker::Generator.new
131
- markup = gen.strong(content)
132
- assert_match(/^#{Regexp.quote(MarkMaker::EMPHASIS * 2)}#{content}#{Regexp.quote(MarkMaker::EMPHASIS * 2)}$/, markup)
133
- end
134
-
135
80
  def test_table_header_generation
136
81
  content = ["Col One", "Col Two", "Col 3"]
137
82
  gen = MarkMaker::Generator.new
@@ -160,22 +105,26 @@ class TestMarkMaker < Minitest::Test
160
105
  # usage of a heredoc as a test method
161
106
 
162
107
  def test_heredoc_method
163
- desired_output = <<-EOS.strip_heredoc
164
- This should contain no intents.
108
+ desired_output = <<-EOS.unindent
109
+ This should contain no indents.
165
110
 
166
111
  It should be 3 lines long.
167
112
  EOS
168
- test_output = "This should contain no intents.\n\nIt should be 3 lines long.\n"
113
+ test_output = "This should contain no indents.\n\nIt should be 3 lines long.\n"
169
114
  assert_equal(desired_output, test_output, "Output must exactly match.")
170
115
  end
171
116
 
117
+ def test_join
118
+ assert_equal("abc", ["a", "b", "c"].join)
119
+ end
120
+
172
121
  def test_column_width
173
122
  gen = MarkMaker::Generator.new
174
123
  assert_equal(5, gen.column_width("One", "Two", "12345", "Four"))
175
124
  end
176
125
 
177
126
  def test_pretty_table_generation
178
- pretty_table = <<-EOS.strip_heredoc
127
+ pretty_table = <<-EOS.unindent
179
128
  |Col One|Col Two|Col Three|
180
129
  |:------|:-----:|--------:|
181
130
  |First | A | $3.99|
@@ -215,12 +164,6 @@ class TestMarkMaker < Minitest::Test
215
164
  assert_equal(test_justified, gen_justified)
216
165
  end
217
166
 
218
- def test_column_width
219
- gen = MarkMaker::Generator.new
220
- width = gen.column_width("a", "bbb", "ccccc", "dd")
221
- assert_equal(5, width)
222
- end
223
-
224
167
  def test_centered_margins
225
168
  gen = MarkMaker::Generator.new
226
169
  left, right = gen.centered_margins(5, "cc")
@@ -305,7 +248,7 @@ class TestMarkMaker < Minitest::Test
305
248
  # end
306
249
 
307
250
  # def test_right_justify_table_column
308
- # right_justified = <<-EOS.strip_heredoc
251
+ # right_justified = <<-EOS.unindent
309
252
  # | Justified|
310
253
  # |----------:|
311
254
  # | a|
@@ -319,7 +262,7 @@ class TestMarkMaker < Minitest::Test
319
262
 
320
263
 
321
264
  # def test_pretty_table_justified_generation
322
- # pretty_table = <<-EOS.strip_heredoc
265
+ # pretty_table = <<-EOS.unindent
323
266
  # |Col One|Col Two|Col Three |Data Sized |
324
267
  # |-------|-------|----------|-------------|
325
268
  # |First | A | $3.99|xxxxxxxxxxxxx|
@@ -0,0 +1,41 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'minitest_helper'
5
+
6
+ class TestMarkMakerString < Minitest::Test
7
+ def test_bullet_generation
8
+ content = "This is a bullet"
9
+ markup = content.bullet
10
+ assert_match(/^ - #{content}$/, markup)
11
+ end
12
+
13
+ def test_number_generation
14
+ content = "Number this line"
15
+ markup = content.number
16
+ assert_match(/^\s\d\.\s#{content}$/, markup)
17
+ end
18
+
19
+ def test_code_generation
20
+ content = "var = code()"
21
+ markup = content.code
22
+ assert_match(/\s{4}var = code\(\)$/, markup)
23
+ end
24
+
25
+ def test_code_span_generation
26
+ markup = "Some #{'a = b + c'.code_span} here."
27
+ assert_match(/^Some #{MarkMaker::CODE_TIC}a = b \+ c#{MarkMaker::CODE_TIC} here.$/, markup)
28
+ end
29
+
30
+ def test_emphasis_generation
31
+ content = "emphasize this"
32
+ markup = content.emphasis
33
+ assert_match(/^#{Regexp.quote(MarkMaker::EMPHASIS)}#{content}#{Regexp.quote(MarkMaker::EMPHASIS)}$/, markup)
34
+ end
35
+
36
+ def test_strong_generation
37
+ content = "strong stuff"
38
+ markup = content.strong
39
+ assert_match(/^#{Regexp.quote(MarkMaker::EMPHASIS * 2)}#{content}#{Regexp.quote(MarkMaker::EMPHASIS * 2)}$/, markup)
40
+ end
41
+ end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mark_maker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Schneider
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-21 00:00:00.000000000 Z
11
+ date: 2020-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.7'
19
+ version: '2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.7'
26
+ version: '2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rubocop
70
+ name: unindent
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: activesupport
84
+ name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,19 +95,25 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: simplecov
98
+ name: minitest-reporters
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.1'
101
104
  - - ">="
102
105
  - !ruby/object:Gem::Version
103
- version: '0'
106
+ version: 1.1.8
104
107
  type: :development
105
108
  prerelease: false
106
109
  version_requirements: !ruby/object:Gem::Requirement
107
110
  requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '1.1'
108
114
  - - ">="
109
115
  - !ruby/object:Gem::Version
110
- version: '0'
116
+ version: 1.1.8
111
117
  description: Programatically generate markdown documents.
112
118
  email:
113
119
  - brad.schneider@me.com
@@ -129,14 +135,17 @@ files:
129
135
  - lib/mark_maker.rb
130
136
  - lib/mark_maker/generator.rb
131
137
  - lib/mark_maker/version.rb
138
+ - lib/mark_maker_string.rb
132
139
  - mark_maker.gemspec
133
140
  - test/minitest_helper.rb
141
+ - test/test_headers.rb
134
142
  - test/test_mark_maker.rb
143
+ - test/test_mark_maker_string.rb
135
144
  homepage: ''
136
145
  licenses:
137
146
  - MIT
138
147
  metadata: {}
139
- post_install_message:
148
+ post_install_message:
140
149
  rdoc_options: []
141
150
  require_paths:
142
151
  - lib
@@ -144,18 +153,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
153
  requirements:
145
154
  - - ">="
146
155
  - !ruby/object:Gem::Version
147
- version: '0'
156
+ version: 1.9.3
148
157
  required_rubygems_version: !ruby/object:Gem::Requirement
149
158
  requirements:
150
159
  - - ">="
151
160
  - !ruby/object:Gem::Version
152
161
  version: '0'
153
162
  requirements: []
154
- rubyforge_project:
155
- rubygems_version: 2.4.6
156
- signing_key:
163
+ rubygems_version: 3.0.6
164
+ signing_key:
157
165
  specification_version: 4
158
166
  summary: Markdown generator.
159
167
  test_files:
160
168
  - test/minitest_helper.rb
169
+ - test/test_headers.rb
161
170
  - test/test_mark_maker.rb
171
+ - test/test_mark_maker_string.rb