jsonml-rb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a9bb04fee01e3262383a282a2bcec1da6b4c36c7
4
+ data.tar.gz: 5eb0c1a904af8158d31b2947a114b06dfadc6ed3
5
+ SHA512:
6
+ metadata.gz: 6d920683320cd88242351a89fad23268471fd50cc4e3b545da6b6d0acc4fb975026189e80cf03c91534f0efc1516afef483ccf6ca0a1567fb39cb3fb25a4b673
7
+ data.tar.gz: 1926d2340b6b5e95fdb9f065da7ff36aee5676710cbff5b82ed0357543fcd0286d9189da04f63067e6465f118fdc7ac1f680f3cbac4642a387a26ef890253194
@@ -0,0 +1,3 @@
1
+ # 2015-02-12
2
+
3
+ * One major enhancement: Birthday!
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'http://rubygems.org'
2
+
3
+ #gemspec
4
+
5
+ group :development do
6
+ gem "rake", "~> 10.0"
7
+ gem "bundler", "~> 1.0"
8
+ gem "rspec", "~> 3.0"
9
+ end
@@ -0,0 +1,22 @@
1
+ # The MIT Licence
2
+
3
+ Copyright (c) 2015 - Bernard Lambeau
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,10 @@
1
+ CHANGELOG.md
2
+ Gemfile
3
+ lib/**/*
4
+ LICENCE.md
5
+ jsonml.gemspec
6
+ Manifest.txt
7
+ Rakefile
8
+ README.md
9
+ spec/**/*
10
+ tasks/**/*
@@ -0,0 +1,10 @@
1
+ # JsonML, in Ruby
2
+
3
+ Simply.
4
+
5
+ ## Example
6
+
7
+ ```ruby
8
+ require 'jsonml'
9
+ JsonML.toHtmlText([ 'html', ['body', { class: "small" }, 'Hello World' ]])
10
+ ```
@@ -0,0 +1,11 @@
1
+ # We run tests by default
2
+ task :default => :test
3
+
4
+ #
5
+ # Install all tasks found in tasks folder
6
+ #
7
+ # See .rake files there for complete documentation.
8
+ #
9
+ Dir["tasks/*.rake"].each do |taskfile|
10
+ load taskfile
11
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'htmldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('diff-lcs', 'htmldiff')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'ldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('diff-lcs', 'ldiff')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rake', 'rake')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'rspec')
@@ -0,0 +1,185 @@
1
+ # We require your library, mainly to have access to the VERSION number.
2
+ # Feel free to set $version manually.
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
4
+ require "jsonml/version"
5
+ $version = JsonML::Version.to_s
6
+
7
+ #
8
+ # This is your Gem specification. Default values are provided so that your library
9
+ # should be correctly packaged given what you have described in the .noespec file.
10
+ #
11
+ Gem::Specification.new do |s|
12
+
13
+ ################################################################### ABOUT YOUR GEM
14
+
15
+ # Gem name (required)
16
+ s.name = "jsonml-rb"
17
+
18
+ # Gem version (required)
19
+ s.version = $version
20
+
21
+ # A short summary of this gem
22
+ #
23
+ # This is displayed in `gem list -d`.
24
+ s.summary = "JsonML, in Ruby"
25
+
26
+ # A long description of this gem (required)
27
+ #
28
+ # The description should be more detailed than the summary. For example,
29
+ # you might wish to copy the entire README into the description.
30
+ s.description = "JsonML is about HTMl/XML encoded in JSON. jsonml-rb is about ruby tools around that idea."
31
+
32
+ # The URL of this gem home page (optional)
33
+ s.homepage = "http://github.com/blambeau/jsonml-rb"
34
+
35
+ # Gem publication date (required but auto)
36
+ #
37
+ # Today is automatically used by default, uncomment only if
38
+ # you know what you do!
39
+ #
40
+ # s.date = Time.now.strftime('%Y-%m-%d')
41
+
42
+ # The license(s) for the library. Each license must be a short name, no
43
+ # more than 64 characters.
44
+ #
45
+ # s.licences = %w{}
46
+
47
+ # The rubyforge project this gem lives under (optional)
48
+ #
49
+ # s.rubyforge_project = nil
50
+
51
+ ################################################################### ABOUT THE AUTHORS
52
+
53
+ # The list of author names who wrote this gem.
54
+ #
55
+ # If you are providing multiple authors and multiple emails they should be
56
+ # in the same order.
57
+ #
58
+ s.authors = ["Bernard Lambeau"]
59
+
60
+ # Contact emails for this gem
61
+ #
62
+ # If you are providing multiple authors and multiple emails they should be
63
+ # in the same order.
64
+ #
65
+ # NOTE: Somewhat strangly this attribute is always singular!
66
+ # Don't replace by s.emails = ...
67
+ s.email = ["blambeau@gmail.com"]
68
+
69
+ ################################################################### PATHS, FILES, BINARIES
70
+
71
+ # Paths in the gem to add to $LOAD_PATH when this gem is
72
+ # activated (required).
73
+ #
74
+ # The default 'lib' is typically sufficient.
75
+ s.require_paths = ["lib"]
76
+
77
+ # Files included in this gem.
78
+ #
79
+ # By default, we take all files included in the Manifest.txt file on root
80
+ # of the project. Entries of the manifest are interpreted as Dir[...]
81
+ # patterns so that lazy people may use wilcards like lib/**/*
82
+ #
83
+ here = File.expand_path(File.dirname(__FILE__))
84
+ s.files = File.readlines(File.join(here, 'Manifest.txt')).
85
+ inject([]){|files, pattern| files + Dir[File.join(here, pattern.strip)]}.
86
+ collect{|x| x[(1+here.size)..-1]}
87
+
88
+ # Test files included in this gem.
89
+ #
90
+ s.test_files = Dir["test/**/*"] + Dir["spec/**/*"]
91
+
92
+ # The path in the gem for executable scripts (optional)
93
+ #
94
+ s.bindir = "bin"
95
+
96
+ # Executables included in the gem.
97
+ #
98
+ s.executables = (Dir["bin/*"]).collect{|f| File.basename(f)}
99
+
100
+ ################################################################### REQUIREMENTS & INSTALL
101
+ # Remember the gem version requirements operators and schemes:
102
+ # = Equals version
103
+ # != Not equal to version
104
+ # > Greater than version
105
+ # < Less than version
106
+ # >= Greater than or equal to
107
+ # <= Less than or equal to
108
+ # ~> Approximately greater than
109
+ #
110
+ # Don't forget to have a look at http://lmgtfy.com/?q=Ruby+Versioning+Policies
111
+ # for setting your gem version.
112
+ #
113
+ # For your requirements to other gems, remember that
114
+ # ">= 2.2.0" (optimistic: specify minimal version)
115
+ # ">= 2.2.0", "< 3.0" (pessimistic: not greater than the next major)
116
+ # "~> 2.2" (shortcut for ">= 2.2.0", "< 3.0")
117
+ # "~> 2.2.0" (shortcut for ">= 2.2.0", "< 2.3.0")
118
+ #
119
+
120
+ #
121
+ # One call to add_dependency('gem_name', 'gem version requirement') for each
122
+ # runtime dependency. These gems will be installed with your gem.
123
+ # One call to add_development_dependency('gem_name', 'gem version requirement')
124
+ # for each development dependency. These gems are required for developers
125
+ #
126
+ s.add_development_dependency("rake", "~> 10.0")
127
+ s.add_development_dependency("rspec", "~> 3.0")
128
+
129
+ # The version of ruby required by this gem
130
+ #
131
+ # Uncomment and set this if your gem requires specific ruby versions.
132
+ #
133
+ # s.required_ruby_version = ">= 0"
134
+
135
+ # The RubyGems version required by this gem
136
+ #
137
+ # s.required_rubygems_version = ">= 0"
138
+
139
+ # The platform this gem runs on. See Gem::Platform for details.
140
+ #
141
+ # s.platform = nil
142
+
143
+ # Extensions to build when installing the gem.
144
+ #
145
+ # Valid types of extensions are extconf.rb files, configure scripts
146
+ # and rakefiles or mkrf_conf files.
147
+ #
148
+ s.extensions = []
149
+
150
+ # External (to RubyGems) requirements that must be met for this gem to work.
151
+ # It’s simply information for the user.
152
+ #
153
+ s.requirements = nil
154
+
155
+ # A message that gets displayed after the gem is installed
156
+ #
157
+ # Uncomment and set this if you want to say something to the user
158
+ # after gem installation
159
+ #
160
+ s.post_install_message = nil
161
+
162
+ ################################################################### SECURITY
163
+
164
+ # The key used to sign this gem. See Gem::Security for details.
165
+ #
166
+ # s.signing_key = nil
167
+
168
+ # The certificate chain used to sign this gem. See Gem::Security for
169
+ # details.
170
+ #
171
+ # s.cert_chain = []
172
+
173
+ ################################################################### RDOC
174
+
175
+ # An ARGV style array of options to RDoc
176
+ #
177
+ # See 'rdoc --help' about this
178
+ #
179
+ s.rdoc_options = []
180
+
181
+ # Extra files to add to RDoc such as README
182
+ #
183
+ s.extra_rdoc_files = Dir["README.md"] + Dir["CHANGELOG.md"] + Dir["LICENCE.md"]
184
+
185
+ end
@@ -0,0 +1,30 @@
1
+ module JsonML
2
+
3
+ def self.to_html_text(src, out = "")
4
+ has_attrs = src[1].is_a?(Hash)
5
+ first_child = has_attrs ? 2 : 1
6
+
7
+ case src
8
+ when Array
9
+ out << "<#{src.first}"
10
+ out << " " << attrs2html(src[1]) if has_attrs
11
+ out << ">"
12
+ src[first_child..-1].each{|child| to_html_text(child, out) }
13
+ out << "</#{src.first}>"
14
+ when String
15
+ out << src
16
+ else
17
+ raise "Unexpected node `#{src}`"
18
+ end
19
+ end
20
+
21
+ def self.attrs2html(attrs)
22
+ attrs.each_pair.map{|pair| attr2html(*pair) }.join(" ")
23
+ end
24
+
25
+ def self.attr2html(key, value)
26
+ %Q{#{key}="#{value}"}
27
+ end
28
+
29
+ end
30
+ require "jsonml/version"
@@ -0,0 +1,14 @@
1
+ module JsonML
2
+ module Version
3
+
4
+ MAJOR = 0
5
+ MINOR = 1
6
+ TINY = 0
7
+
8
+ def self.to_s
9
+ [ MAJOR, MINOR, TINY ].join('.')
10
+ end
11
+
12
+ end
13
+ VERSION = Version.to_s
14
+ end
@@ -0,0 +1,2 @@
1
+ require 'jsonml'
2
+ require 'rspec'
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ describe "JsonML#.to_html_text" do
3
+
4
+ let(:ml) {
5
+ [ 'html',
6
+ { lang: 'en' },
7
+ [
8
+ 'body',
9
+ [
10
+ 'p',
11
+ 'Hello world'
12
+ ]
13
+ ]
14
+ ]
15
+ }
16
+
17
+ subject{
18
+ JsonML.to_html_text(ml)
19
+ }
20
+
21
+ let(:expected) {
22
+ %Q{<html lang="en"><body><p>Hello world</p></body></html>}
23
+ }
24
+
25
+ it 'works' do
26
+ expect(subject).to eql(expected)
27
+ end
28
+
29
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+ describe JsonML do
3
+
4
+ it 'has a version number' do
5
+ expect(JsonML::VERSION).not_to be_nil
6
+ end
7
+
8
+ end
@@ -0,0 +1,24 @@
1
+ begin
2
+ require 'rubygems/package_task'
3
+ gemspec_file = File.expand_path('../../jsonml.gemspec', __FILE__)
4
+ gemspec = Kernel.eval(File.read(gemspec_file))
5
+ Gem::PackageTask.new(gemspec) do |t|
6
+ t.name = gemspec.name
7
+ t.version = gemspec.version
8
+ t.package_dir = "pkg"
9
+ t.need_tar = false
10
+ t.need_tar_gz = false
11
+ t.need_tar_bz2 = false
12
+ t.need_zip = false
13
+ t.package_files = gemspec.files
14
+ t.tar_command = "tar"
15
+ t.zip_command = "zip"
16
+ end
17
+ rescue LoadError
18
+ task :gem do
19
+ abort 'rubygems/package_task is not available. You should verify your rubygems installation'
20
+ end
21
+ task :package do
22
+ abort 'rubygems/package_task is not available. You should verify your rubygems installation'
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ begin
2
+ require "rspec/core/rake_task"
3
+ desc "Run RSpec code examples"
4
+ RSpec::Core::RakeTask.new(:spec_test) do |t|
5
+ t.pattern = "spec/**/test_*.rb"
6
+ t.fail_on_error = true
7
+ t.failure_message = nil
8
+ t.verbose = true
9
+ t.ruby_opts = []
10
+ t.rspec_path = "bin/rspec"
11
+ t.rspec_opts = ["--color", "--backtrace"]
12
+ end
13
+ rescue LoadError => ex
14
+ task :spec_test do
15
+ abort 'rspec is not available. In order to run spec, you must: gem install rspec'
16
+ end
17
+ ensure
18
+ task :spec => [:spec_test]
19
+ task :test => [:spec_test]
20
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jsonml-rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bernard Lambeau
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '10.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '10.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ description: JsonML is about HTMl/XML encoded in JSON. jsonml-rb is about ruby tools
42
+ around that idea.
43
+ email:
44
+ - blambeau@gmail.com
45
+ executables:
46
+ - htmldiff
47
+ - ldiff
48
+ - rake
49
+ - rspec
50
+ extensions: []
51
+ extra_rdoc_files:
52
+ - README.md
53
+ - CHANGELOG.md
54
+ - LICENCE.md
55
+ files:
56
+ - CHANGELOG.md
57
+ - Gemfile
58
+ - LICENCE.md
59
+ - Manifest.txt
60
+ - README.md
61
+ - Rakefile
62
+ - bin/htmldiff
63
+ - bin/ldiff
64
+ - bin/rake
65
+ - bin/rspec
66
+ - jsonml.gemspec
67
+ - lib/jsonml.rb
68
+ - lib/jsonml/version.rb
69
+ - spec/spec_helper.rb
70
+ - spec/test_to_html_text.rb
71
+ - spec/test_version.rb
72
+ - tasks/gem.rake
73
+ - tasks/spec_test.rake
74
+ homepage: http://github.com/blambeau/jsonml-rb
75
+ licenses: []
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.4.5
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: JsonML, in Ruby
97
+ test_files:
98
+ - spec/spec_helper.rb
99
+ - spec/test_to_html_text.rb
100
+ - spec/test_version.rb