paperwrap 0.0.1

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.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ paperwrap (0.0.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.1.3)
10
+ rake (0.9.2.2)
11
+ rspec (2.8.0)
12
+ rspec-core (~> 2.8.0)
13
+ rspec-expectations (~> 2.8.0)
14
+ rspec-mocks (~> 2.8.0)
15
+ rspec-core (2.8.0)
16
+ rspec-expectations (2.8.0)
17
+ diff-lcs (~> 1.1.2)
18
+ rspec-mocks (2.8.0)
19
+
20
+ PLATFORMS
21
+ java
22
+
23
+ DEPENDENCIES
24
+ paperwrap!
25
+ rake
26
+ rspec
data/README.md ADDED
@@ -0,0 +1,6 @@
1
+ Paperwrap
2
+ =========
3
+
4
+ A JRuby wrapper around the [MarkdownPapers](https://github.com/lruiz/MarkdownPapers) Java library.
5
+
6
+ This wrapper was created so it could be used as a Markdown processor in the [jrucco](https://github.com/mindscratch/jrucco) documentation library.
data/Rakefile ADDED
@@ -0,0 +1,141 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'date'
4
+
5
+ #############################################################################
6
+ #
7
+ # Helper functions
8
+ #
9
+ #############################################################################
10
+
11
+ def name
12
+ @name ||= Dir['*.gemspec'].first.split('.').first
13
+ end
14
+
15
+ def version
16
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
17
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
18
+ end
19
+
20
+ def date
21
+ Date.today.to_s
22
+ end
23
+
24
+ def rubyforge_project
25
+ name
26
+ end
27
+
28
+ def gemspec_file
29
+ "#{name}.gemspec"
30
+ end
31
+
32
+ def gem_file
33
+ "#{name}-#{version}.gem"
34
+ end
35
+
36
+ def replace_header(head, header_name)
37
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
38
+ end
39
+
40
+ #############################################################################
41
+ #
42
+ # Standard tasks
43
+ #
44
+ #############################################################################
45
+
46
+ require 'rspec'
47
+ require 'rspec/core/rake_task'
48
+
49
+ desc "Run all specs"
50
+ task RSpec::Core::RakeTask.new('spec')
51
+
52
+ task :default => "spec"
53
+
54
+ desc "Open an irb session preloaded with this library"
55
+ task :console do
56
+ SPEC = eval(File.read(gemspec_file))
57
+ require_paths = SPEC.require_paths.map {|path| "-I #{path.strip}"}.join(" ")
58
+ sh "irb -rubygems #{require_paths} -r ./lib/#{name}.rb"
59
+ end
60
+
61
+ #############################################################################
62
+ #
63
+ # Custom tasks (add your own tasks here)
64
+ #
65
+ #############################################################################
66
+
67
+
68
+
69
+ #############################################################################
70
+ #
71
+ # Packaging tasks
72
+ #
73
+ #############################################################################
74
+
75
+ desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
76
+ task :release => :build do
77
+ unless `git branch` =~ /^\* master$/
78
+ puts "You must be on the master branch to release!"
79
+ exit!
80
+ end
81
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
82
+ sh "git tag v#{version}"
83
+ sh "git push origin master"
84
+ sh "git push origin v#{version}"
85
+ sh "gem push pkg/#{name}-#{version}.gem"
86
+ end
87
+
88
+ desc "Build #{gem_file} into the pkg directory"
89
+ task :build => [:gemspec, :update_bundle] do
90
+ sh "mkdir -p pkg"
91
+ sh "gem build #{gemspec_file}"
92
+ sh "mv #{gem_file} pkg"
93
+ end
94
+
95
+ desc "Generate #{gemspec_file}"
96
+ task :gemspec => :validate do
97
+ # read spec file and split out manifest section
98
+ spec = File.read(gemspec_file)
99
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
100
+
101
+ # replace name version and date
102
+ replace_header(head, :name)
103
+ replace_header(head, :version)
104
+ replace_header(head, :date)
105
+ #comment this out if your rubyforge_project has a different name
106
+ replace_header(head, :rubyforge_project)
107
+
108
+ # determine file list from git ls-files
109
+ files = `git ls-files`.
110
+ split("\n").
111
+ sort.
112
+ reject { |file| file =~ /^\./ }.
113
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
114
+ map { |file| " #{file}" }.
115
+ join("\n")
116
+
117
+ # piece file back together and write
118
+ manifest = " s.files = %w[\n#{files}\n ]\n"
119
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
120
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
121
+ puts "Updated #{gemspec_file}"
122
+ end
123
+
124
+ desc "Update #{name} in bundle"
125
+ task :update_bundle => :validate do
126
+ `bundle update #{name}`
127
+ puts "Bundled #{name} version #{version}"
128
+ end
129
+
130
+ desc "Validate #{gemspec_file}"
131
+ task :validate do
132
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
133
+ unless libfiles.empty?
134
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
135
+ exit!
136
+ end
137
+ unless Dir['VERSION*'].empty?
138
+ puts "A `VERSION` file at root level violates Gem best practices."
139
+ exit!
140
+ end
141
+ end
@@ -0,0 +1,28 @@
1
+ require 'java'
2
+
3
+ jars_path = File.join(File.dirname(__FILE__), '..', '..', 'ext', 'java', 'jar')
4
+ Dir.glob("#{jars_path}/**/*.jar").each {|jar| require jar}
5
+
6
+ module Paperwrap
7
+ class Markdown
8
+ def initialize(text, *extensions)
9
+ @text = text
10
+ # TODO support extensions (such as :smarty)
11
+ end
12
+
13
+ def to_html
14
+ reader = java.io.StringReader.new @text
15
+ writer = java.io.StringWriter.new
16
+ html = ''
17
+ begin
18
+ m = org.tautua.markdownpapers.Markdown.new
19
+ m.transform reader, writer
20
+ writer.flush
21
+ ensure
22
+ reader.close if reader
23
+ writer.close if writer
24
+ end
25
+ html = writer.to_string
26
+ end
27
+ end
28
+ end
data/lib/paperwrap.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'java'
2
+ require 'paperwrap/markdown'
3
+
4
+ module Paperwrap
5
+ VERSION = '0.0.1'
6
+ end
data/paperwrap.gemspec ADDED
@@ -0,0 +1,72 @@
1
+ ## This is the rakegem gemspec template. Make sure you read and understand
2
+ ## all of the comments. Some sections require modification, and others can
3
+ ## be deleted if you don't need them. Once you understand the contents of
4
+ ## this file, feel free to delete any comments that begin with two hash marks.
5
+ ## You can find comprehensive Gem::Specification documentation, at
6
+ ## http://docs.rubygems.org/read/chapter/20
7
+ Gem::Specification.new do |s|
8
+ s.specification_version = 2 if s.respond_to? :specification_version=
9
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.rubygems_version = '1.3.5'
11
+
12
+ ## Leave these as is they will be modified for you by the rake gemspec task.
13
+ ## If your rubyforge_project name is different, then edit it and comment out
14
+ ## the sub! line in the Rakefile
15
+ s.name = 'paperwrap'
16
+ s.version = '0.0.1'
17
+ s.date = '2012-02-25'
18
+ s.rubyforge_project = 'paperwrap'
19
+
20
+ ## Make sure your summary is short. The description may be as long
21
+ ## as you like.
22
+ s.summary = "A JRuby wrapper around [MarkdownPapers](https://github.com/lruiz/MarkdownPapers)."
23
+ s.description = "A JRuby wrapper around [MarkdownPapers](https://github.com/lruiz/MarkdownPapers)."
24
+
25
+ ## List the primary authors. If there are a bunch of authors, it's probably
26
+ ## better to set the email to an email list or something. If you don't have
27
+ ## a custom homepage, consider using your GitHub URL or the like.
28
+ s.authors = ["Craig Wickesser"]
29
+ s.email = 'craig@mindscratch.org'
30
+ s.homepage = 'https://github.com/mindscratch/paperwrap'
31
+
32
+ ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
33
+ ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
34
+ s.require_paths = %w[lib ext/java/jar]
35
+
36
+ ## Specify any RDoc options here. You'll want to add your README and
37
+ ## LICENSE files to the extra_rdoc_files list.
38
+ ## s.rdoc_options = ["--charset=UTF-8"]
39
+ ## s.extra_rdoc_files = %w[README LICENSE]
40
+
41
+ ## List your runtime dependencies here. Runtime dependencies are those
42
+ ## that are needed for an end user to actually USE your code.
43
+ ## s.add_dependency('DEPNAME', [">= 1.1.0", "< 2.0.0"])
44
+
45
+ ## List your development dependencies here. Development dependencies are
46
+ ## those that are only needed during development
47
+ ## s.add_development_dependency('DEVDEPNAME', [">= 1.1.0", "< 2.0.0"])
48
+ s.add_development_dependency 'rake'
49
+ s.add_development_dependency 'rspec'
50
+
51
+ ## Leave this section as-is. It will be automatically generated from the
52
+ ## contents of your Git repository via the gemspec task. DO NOT REMOVE
53
+ ## THE MANIFEST COMMENTS, they are used as delimiters by the task.
54
+ # = MANIFEST =
55
+ s.files = %w[
56
+ Gemfile
57
+ Gemfile.lock
58
+ README.md
59
+ Rakefile
60
+ ext/java/jar/markdownpapers-core-1.2.3.jar
61
+ lib/paperwrap.rb
62
+ lib/paperwrap/markdown.rb
63
+ paperwrap.gemspec
64
+ spec/paperwrap/markdown_spec.rb
65
+ spec/spec_helper.rb
66
+ ]
67
+ # = MANIFEST =
68
+
69
+ ## Test files will be grabbed from the file list. Make sure the path glob
70
+ ## matches what you actually use.
71
+ s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
72
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ require 'paperwrap/markdown'
3
+
4
+ module Paperwrap
5
+ describe Markdown do
6
+
7
+ context "given Markdown formatted text" do
8
+ it "generates HTML" do
9
+ m = Paperwrap::Markdown.new "* foo\n* bar"
10
+ html = m.to_html
11
+ match = html.match /(<li>)+/
12
+
13
+ match.should_not be_nil
14
+ match.size.should eq 2
15
+ end
16
+ end
17
+
18
+ context "given plain text" do
19
+ it "generates paragraph html tags" do
20
+ input = "hello world"
21
+ m = Paperwrap::Markdown.new input
22
+ html = m.to_html
23
+ html.should eq("<p>#{input}</p>\n")
24
+ end
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,4 @@
1
+ require 'rspec/autorun'
2
+ ROOT = File.expand_path('../..', __FILE__)
3
+ Dir[File.join(ROOT, "spec/support/**/*.rb")].each {|f| require f}
4
+ $LOAD_PATH.unshift(File.expand_path('lib', ROOT))
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paperwrap
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Craig Wickesser
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-02-25 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :development
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :development
36
+ version_requirements: *id002
37
+ description: A JRuby wrapper around [MarkdownPapers](https://github.com/lruiz/MarkdownPapers).
38
+ email: craig@mindscratch.org
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - Gemfile
47
+ - Gemfile.lock
48
+ - README.md
49
+ - Rakefile
50
+ - ext/java/jar/markdownpapers-core-1.2.3.jar
51
+ - lib/paperwrap.rb
52
+ - lib/paperwrap/markdown.rb
53
+ - paperwrap.gemspec
54
+ - spec/paperwrap/markdown_spec.rb
55
+ - spec/spec_helper.rb
56
+ homepage: https://github.com/mindscratch/paperwrap
57
+ licenses: []
58
+
59
+ post_install_message:
60
+ rdoc_options: []
61
+
62
+ require_paths:
63
+ - lib
64
+ - ext/java/jar
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: "0"
77
+ requirements: []
78
+
79
+ rubyforge_project: paperwrap
80
+ rubygems_version: 1.8.15
81
+ signing_key:
82
+ specification_version: 2
83
+ summary: A JRuby wrapper around [MarkdownPapers](https://github.com/lruiz/MarkdownPapers).
84
+ test_files: []
85
+