render-as-markdown 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZGU0Zjg0ZGRlYjJkOGJiNDg4ZDkwNTM4NmMzOWNiNGRjYTQzYmU4OQ==
5
- data.tar.gz: !binary |-
6
- NzEyZTI2OWNmZGE5NmUwYzI3MDk3NGI1NDY2YTVmYWNjMTcyMGU4Mw==
2
+ SHA1:
3
+ metadata.gz: 369136336c55adb924638c56b5be83edd38d899f
4
+ data.tar.gz: f260b72482f1eb9196aae8d30e8544f00e890922
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MWJjZTM3YjNiOGZlZDg4N2EwMGQ4ZGNhMTg0MjNlZjcyYzc3NjVmMGFkNDgw
10
- OTI3NmY3NjgwMGMyNTk3ODU1NDZlZmVmZGVmNTNhZWMzM2Y5NmZkZTY4OTM2
11
- ZDVkODM0YTVjMjUwN2I1MDYzOWUxMThlZWRmODEyM2FlOWJjNjc=
12
- data.tar.gz: !binary |-
13
- NTUwYjQzODliZGJkMGEyMzMwMzFiODA0MjdkOTI5OWFkYWZlOGI2YTE0NTMy
14
- NzFmNGZhMWE3ZDU3ZjNlMGM5MWE0ZGU5MzQ2ZmFjOTlmODI0OTI3NDRlZGI4
15
- MWE5ZTQ4NDFmMGRkYTI0MDEzZDhjNWQwMWU2YmQ1OWU4OWMzOWE=
6
+ metadata.gz: b0754af7eeaf6480acfbc133126555a05a542675074c7e34f4cc0b784ebfb05c3527c4403a7266fcaf8fdd485febdd173f33e11ce2ab1eda71ab677cf1987bce
7
+ data.tar.gz: 817ec7d1d91b8cd414f7d10a8dff2a78251b7c7122c9ab23e1d0239aa755f35bbf5f18dac652a5db19ed386e17cf3453be87ab6447a8fd905b5ba591235a118d
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  # A sample Gemfile
2
2
  source "https://rubygems.org"
3
3
 
4
- gemspec
4
+ gemspec
5
+
6
+ gem 'coveralls', require: false
data/HISTORY.md CHANGED
@@ -1,22 +1,27 @@
1
1
  HISTORY
2
2
  =======
3
3
 
4
- [2012-10-16]
4
+ __[2012-10-19]__
5
+ - refactor table.rb
6
+
7
+ __[2012-10-16]__
5
8
  - Readme: what is Markdown?
6
9
  - added Link class
7
10
  - added Image class
11
+ - [v0.0.5](https://github.com/rmetzler/render-as-markdown/tree/v0.0.5)
12
+ - renamed files
8
13
 
9
- [2012-10-15]
14
+ __[2012-10-15]__
10
15
  - added List class
11
16
  - added simple Code class with 4 spaces indentation
12
17
 
13
- [2013-10-13]
18
+ __[2013-10-13]__
14
19
  - wrote tests for Table class and fixed problems (nil, Numbers, etc)
15
20
  - wrote classes and tests for H1 and H2 with Markdown underline notation (h1: ===, h2: ----)
16
- - v0.0.4
21
+ - [v0.0.4](https://github.com/rmetzler/render-as-markdown/tree/v0.0.4)
17
22
 
18
- [2013-10-06]
23
+ __[2013-10-06]__
19
24
  - some bugfixes
20
25
 
21
- [2013-10-06]
26
+ __[2013-10-06]__
22
27
  - created gem render-as-markdown, because I wanted a better Table for GitHub and GitHub renders Markdown pretty well
data/README.md CHANGED
@@ -1,9 +1,16 @@
1
1
  RenderAsMarkdown
2
2
  ================
3
3
 
4
+
4
5
  RenderAsMarkdown is a small Ruby gem featuring simple to use classes to turn
5
6
  data into Markdown.
6
7
 
8
+ [![Gem Version](https://badge.fury.io/rb/render-as-markdown.png)](http://badge.fury.io/rb/render-as-markdown)
9
+ [![Build Status](https://travis-ci.org/rmetzler/render-as-markdown.png?branch=master)](https://travis-ci.org/rmetzler/render-as-markdown)
10
+ [![Code Climate](https://codeclimate.com/github/rmetzler/render-as-markdown.png)](https://codeclimate.com/github/rmetzler/render-as-markdown)
11
+ [![Coverage Status](https://coveralls.io/repos/rmetzler/render-as-markdown/badge.png)](https://coveralls.io/r/rmetzler/render-as-markdown)
12
+ [![Dependency Status](https://gemnasium.com/rmetzler/render-as-markdown.png)](https://gemnasium.com/rmetzler/render-as-markdown)
13
+
7
14
  This project started when [rmetzler](//github.com/rmetzler) tried to render
8
15
  data into a Markdown table. While this was easy to achive with templating, a
9
16
  dedicated helper gem was more reuseable and produced output that was also
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ require "json"
1
2
  require "bundler/gem_tasks"
2
3
  require "rake/testtask"
3
4
 
@@ -7,3 +8,17 @@ Rake::TestTask.new do |t|
7
8
  end
8
9
 
9
10
  task :default => :test
11
+
12
+ desc "copy README.md into gh-page content"
13
+ task :readme_to_ghpage do
14
+ File.open "params.json", "w" do |file|
15
+ params = {
16
+ name: "RenderAsMarkdown",
17
+ tagline: "This gem is a Markdown helper that renders well formatted Markdown for bigger Markdown elements like tables",
18
+ body: File.read('README.md'),
19
+ google: "UA-44998391-1",
20
+ note: "Don't delete this file! It's used internally to help with page regeneration."
21
+ }
22
+ file.write params.to_json
23
+ end
24
+ end
data/TODO.md CHANGED
@@ -1,6 +1,51 @@
1
- # TODO
1
+ TODO
2
+ ====
2
3
 
3
- - rename files (markdown-heder.rb -> header.rb)
4
+ - create image link (img_url, href)
5
+ - create [Tasklists](https://help.github.com/articles/github-flavored-markdown#task-lists)
6
+ - create TOC (table of contents) structur (see github anchor links)
7
+ - create link references
8
+ - create document from hash (Document)
4
9
  - create DSL methods like table(titles) instead of Table.new
5
10
  - Readme: better examples
6
11
  - create example folder
12
+ - include files (code, multimarkdown, version number, etc)
13
+ - show typical Github project signs of life like travis build image, code climate, versioneye
14
+ - auto-numbering of headers (h2, h3, h4) so TOC works with numbers (Document walker)
15
+ - create InvoiceTable class for invoices (currency, items description, time, rate, item total, total, tax(Umsatzsteuer Germany), total+tax)
16
+ - create changelog like https://raw.github.com/mitchellh/vagrant/master/CHANGELOG.md
17
+
18
+ Option Hash
19
+ -----------
20
+
21
+ - an option hash could be a good thing to implement http://blog.rlmflores.me/blog/2012/07/16/method-with-options/
22
+ - also splats may be useful http://www.paperplanes.de/2012/2/16/fun-with-ruby-block-parameters.html
23
+
24
+
25
+ Ideas for DSL
26
+ -------------
27
+
28
+ ```ruby
29
+ "<url>".link # => create link
30
+ "<url>".img # => create image
31
+ "<url>".ref # => create reference
32
+ "markdown".tag # => create tag #markdown, should work with arrays too
33
+ ```
34
+
35
+ ```ruby
36
+ DSL.markdown do |md|
37
+
38
+ md.options :link_urls => :as_references, :link_images => true, :toc => true, :auto_numbering => [:h2. :h3]
39
+ md.meta # date, author (name, email for multiple authors)
40
+
41
+ md.h1 "This is the main title"
42
+ md.chapter "title for chapter 1" do |c1| # put this title in h2, add numbering, add it to TOC
43
+ c1.paragraph "paragraph1"
44
+ c1.img "http://...jpeg"
45
+ c1.list ["item 1", "item2", "item3"]
46
+ c1.table #...
47
+ c1.ref text, "<url>"
48
+ c1.code :ruby, File.open "examples/example-dsl.rb"
49
+ end
50
+ end # => renders title, toc, references etc
51
+ ```
@@ -1,6 +1,6 @@
1
- require File.expand_path '../render-as-markdown/markdown-table', __FILE__
2
- require File.expand_path '../render-as-markdown/markdown-header', __FILE__
3
- require File.expand_path '../render-as-markdown/markdown-list', __FILE__
4
- require File.expand_path '../render-as-markdown/markdown-code', __FILE__
5
- require File.expand_path '../render-as-markdown/link', __FILE__
6
- require File.expand_path '../render-as-markdown/image', __FILE__
1
+ require File.expand_path '../render-as-markdown/table', __FILE__
2
+ require File.expand_path '../render-as-markdown/header', __FILE__
3
+ require File.expand_path '../render-as-markdown/list', __FILE__
4
+ require File.expand_path '../render-as-markdown/code', __FILE__
5
+ require File.expand_path '../render-as-markdown/link', __FILE__
6
+ require File.expand_path '../render-as-markdown/image', __FILE__
@@ -1,10 +1,12 @@
1
1
  module RenderAsMarkdown
2
2
  class Code
3
3
 
4
+ # TODO: render language for code block if provided as Symbol
5
+ # TODO: add file support
6
+
4
7
  attr_accessor :code
5
8
 
6
9
  def initialize code
7
- # list_items will be an array
8
10
  @code = code.to_s
9
11
  end
10
12
 
@@ -24,23 +24,35 @@ module RenderAsMarkdown
24
24
 
25
25
  alias_method '<<', :add_row
26
26
 
27
+
27
28
  def render
29
+ render_head << render_seperator << render_body
30
+ end
31
+
32
+ alias_method :to_s, :render
33
+
34
+ def render_head
28
35
  # join all column headers
29
- table = @columns.map(&:render_title).join( '|' ) << "\n"
36
+ @columns.map(&:render_title).join( '|' ) << "\n"
37
+ end
30
38
 
39
+ def render_seperator
31
40
  # join all column lines
32
- table << @columns.map(&:render_line).join( '|' ) << "\n"
41
+ @columns.map(&:render_line).join( '|' ) << "\n"
42
+ end
33
43
 
44
+ def render_body
34
45
  # join all columns for all rows
46
+ body =''
35
47
  @rows.each_with_index do |row, i|
36
- table << @columns.map {|col| col.render_row i}.join( '|' ) << "\n"
48
+ body << render_row( i )
37
49
  end
50
+ body
51
+ end
38
52
 
39
- # return table
40
- table
53
+ def render_row row
54
+ @columns.map {|col| col.render_row row}.join( '|' ) << "\n"
41
55
  end
42
-
43
- alias_method :to_s, :render
44
56
 
45
57
  end
46
58
 
@@ -1,6 +1,6 @@
1
1
  module RenderAsMarkdown
2
2
  GEM = 'render-as-markdown'
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
4
4
  end
5
5
 
6
6
  #puts "This is version #{RenderAsMarkdown::VERSION} of gem #{RenderAsMarkdown::GEM}"
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+
3
+ git checkout gh-pages
4
+ git pull origin gh-pages
5
+ git checkout master README.md
6
+ rake readme_to_ghpage
7
+ git commit -am"update gh-pages with README.md"
8
+ git push origin gh-pages
9
+ git checkout master
@@ -3,4 +3,9 @@ require "minitest/autorun"
3
3
  require "minitest/reporters"
4
4
  Minitest::Reporters.use!
5
5
 
6
+ require 'json'
7
+ require 'coveralls'
8
+ Coveralls.wear!
9
+
10
+
6
11
  require_relative '../lib/render-as-markdown'
metadata CHANGED
@@ -1,80 +1,82 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render-as-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Metzler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-16 00:00:00.000000000 Z
11
+ date: 2013-11-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
19
  version: '0'
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
26
  version: '0'
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
33
  version: '0'
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
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest-reporters
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: ! "\n RenderAsMarkdown is a small Ruby gem featuring simple to use
70
- objects to turn data into Markdown.\n "
69
+ description: "\n RenderAsMarkdown is a small Ruby gem featuring simple to use objects
70
+ to turn data into Markdown.\n "
71
71
  email:
72
72
  - richard@launchco.com
73
73
  executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
+ - .coveralls.yml
77
78
  - .gitignore
79
+ - .travis.yml
78
80
  - Gemfile
79
81
  - HISTORY.md
80
82
  - LICENSE.txt
@@ -82,16 +84,16 @@ files:
82
84
  - Rakefile
83
85
  - TODO.md
84
86
  - lib/render-as-markdown.rb
87
+ - lib/render-as-markdown/code.rb
85
88
  - lib/render-as-markdown/dsl.rb
89
+ - lib/render-as-markdown/header.rb
86
90
  - lib/render-as-markdown/image.rb
87
91
  - lib/render-as-markdown/link.rb
88
- - lib/render-as-markdown/markdown-code.rb
89
- - lib/render-as-markdown/markdown-header.rb
90
- - lib/render-as-markdown/markdown-list.rb
91
- - lib/render-as-markdown/markdown-table.rb
92
- - lib/render-as-markdown/md-link.rb
92
+ - lib/render-as-markdown/list.rb
93
+ - lib/render-as-markdown/table.rb
93
94
  - lib/render-as-markdown/version.rb
94
95
  - render-as-markdown.gemspec
96
+ - scripts/gh-pages
95
97
  - test/code_test.rb
96
98
  - test/header_test.rb
97
99
  - test/image_test.rb
@@ -109,17 +111,17 @@ require_paths:
109
111
  - lib
110
112
  required_ruby_version: !ruby/object:Gem::Requirement
111
113
  requirements:
112
- - - ! '>='
114
+ - - '>='
113
115
  - !ruby/object:Gem::Version
114
116
  version: '0'
115
117
  required_rubygems_version: !ruby/object:Gem::Requirement
116
118
  requirements:
117
- - - ! '>='
119
+ - - '>='
118
120
  - !ruby/object:Gem::Version
119
121
  version: '0'
120
122
  requirements: []
121
123
  rubyforge_project:
122
- rubygems_version: 2.1.5
124
+ rubygems_version: 2.0.6
123
125
  signing_key:
124
126
  specification_version: 4
125
127
  summary: Currently implemented is a table in GitHub-flavoured Markdown. It works perfectly
@@ -1,11 +0,0 @@
1
- module RenderAsMarkdown
2
- class Link
3
-
4
- attr_accessor :columns, :rows
5
-
6
- def initialize url, text, hint=''
7
- end
8
-
9
-
10
- end
11
-