mbrao 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -4
  3. data/.rubocop.yml +51 -3
  4. data/.travis-gemfile +5 -5
  5. data/.travis.yml +5 -3
  6. data/CHANGELOG.md +5 -0
  7. data/Gemfile +10 -9
  8. data/README.md +1 -2
  9. data/Rakefile +22 -6
  10. data/doc/ActionView.html +3 -3
  11. data/doc/ActionView/Template.html +3 -3
  12. data/doc/ActionView/Template/Handlers.html +3 -3
  13. data/doc/ActionView/Template/Handlers/MbraoTemplate.html +3 -3
  14. data/doc/HTML.html +3 -3
  15. data/doc/HTML/Pipeline.html +3 -3
  16. data/doc/HTML/Pipeline/KramdownFilter.html +3 -3
  17. data/doc/Mbrao.html +5 -5
  18. data/doc/Mbrao/Author.html +10 -10
  19. data/doc/Mbrao/Content.html +825 -844
  20. data/doc/Mbrao/ContentInterface.html +5 -5
  21. data/doc/Mbrao/ContentInterface/ClassMethods.html +4 -4
  22. data/doc/Mbrao/Exceptions.html +3 -3
  23. data/doc/Mbrao/Exceptions/InvalidDate.html +3 -3
  24. data/doc/Mbrao/Exceptions/InvalidMetadata.html +3 -3
  25. data/doc/Mbrao/Exceptions/Parsing.html +3 -3
  26. data/doc/Mbrao/Exceptions/Rendering.html +3 -3
  27. data/doc/Mbrao/Exceptions/UnavailableLocalization.html +3 -3
  28. data/doc/Mbrao/Exceptions/Unimplemented.html +3 -3
  29. data/doc/Mbrao/Exceptions/UnknownEngine.html +3 -3
  30. data/doc/Mbrao/Parser.html +3 -3
  31. data/doc/Mbrao/ParserInterface.html +3 -3
  32. data/doc/Mbrao/ParserInterface/ClassMethods.html +35 -95
  33. data/doc/Mbrao/ParserValidations.html +3 -3
  34. data/doc/Mbrao/ParserValidations/ClassMethods.html +3 -3
  35. data/doc/Mbrao/ParsingEngines.html +3 -3
  36. data/doc/Mbrao/ParsingEngines/Base.html +3 -3
  37. data/doc/Mbrao/ParsingEngines/PlainText.html +11 -17
  38. data/doc/Mbrao/RenderingEngines.html +3 -3
  39. data/doc/Mbrao/RenderingEngines/Base.html +3 -3
  40. data/doc/Mbrao/RenderingEngines/HtmlPipeline.html +24 -92
  41. data/doc/Mbrao/Version.html +4 -4
  42. data/doc/_index.html +8 -8
  43. data/doc/class_list.html +5 -1
  44. data/doc/file.README.html +5 -6
  45. data/doc/file_list.html +5 -1
  46. data/doc/frames.html +1 -1
  47. data/doc/index.html +5 -6
  48. data/doc/js/full_list.js +4 -1
  49. data/doc/method_list.html +75 -53
  50. data/doc/top-level-namespace.html +3 -3
  51. data/lib/mbrao/author.rb +1 -1
  52. data/lib/mbrao/content.rb +47 -65
  53. data/lib/mbrao/content_interface.rb +5 -17
  54. data/lib/mbrao/parser.rb +4 -10
  55. data/lib/mbrao/parser_interface.rb +9 -19
  56. data/lib/mbrao/parsing_engines/plain_text.rb +22 -58
  57. data/lib/mbrao/rendering_engines/html_pipeline.rb +9 -26
  58. data/lib/mbrao/version.rb +1 -1
  59. data/mbrao.gemspec +9 -9
  60. data/spec/mbrao/content_spec.rb +4 -4
  61. data/spec/mbrao/integrations/rails_spec.rb +4 -4
  62. data/spec/mbrao/parser_spec.rb +15 -15
  63. data/spec/spec_helper.rb +19 -5
  64. metadata +17 -19
  65. data/spec/coverage_helper.rb +0 -20
@@ -26,7 +26,7 @@ module Mbrao
26
26
  # @param context [Hash] A context for rendering.
27
27
  def render(content, options = {}, context = {})
28
28
  options = sanitize_options(options)
29
- context = context.ensure_hash(:symbols)
29
+ context = context.ensure_hash(accesses: :symbols)
30
30
 
31
31
  begin
32
32
  create_pipeline(options, context).call(get_body(content, options))[:output].to_s
@@ -48,7 +48,7 @@ module Mbrao
48
48
  #
49
49
  # @return [Array] The default pipeline.
50
50
  def default_pipeline=(value)
51
- @default_pipeline = value.ensure_array(nil, false, false) { |v| v.ensure_array(nil, true, true, true) { |p| p.ensure_string.to_sym } }
51
+ @default_pipeline = value.ensure_array { |v| v.ensure_array(no_duplicates: true, compact: true, flatten: true) { |p| p.ensure_string.to_sym } }
52
52
  end
53
53
 
54
54
  # Gets the default options.
@@ -67,33 +67,22 @@ module Mbrao
67
67
 
68
68
  private
69
69
 
70
- # Sanitizes options.
71
- #
72
- # @param options [Hash] The options to sanitize.
73
- # @return [Hash] The sanitized options.
70
+ # :nodoc:
74
71
  def sanitize_options(options)
75
- options = options.ensure_hash(:symbols)
72
+ options = options.ensure_hash(accesses: :symbols)
76
73
  options = filter_filters(options)
77
- options[:pipeline_options] = default_options.merge(options[:pipeline_options].ensure_hash(:symbols))
74
+ options[:pipeline_options] = default_options.merge(options[:pipeline_options].ensure_hash(accesses: :symbols))
78
75
 
79
76
  options
80
77
  end
81
78
 
82
- # Get body of a content.
83
- #
84
- # @param content [Content|String] The content to sanitize.
85
- # @param options [Hash] A list of options for renderer.
86
- # @return [Array] The body to parse.
79
+ # :nodoc:
87
80
  def get_body(content, options)
88
81
  content = ::Mbrao::Content.create(nil, content.ensure_string) unless content.is_a?(::Mbrao::Content)
89
82
  content.get_body(options.fetch(:locales, ::Mbrao::Parser.locale).ensure_string)
90
83
  end
91
84
 
92
- # Creates the pipeline for rendering.
93
- #
94
- # @param options [Hash] A list of options for renderer.
95
- # @param context [Hash] A context for rendering.
96
- # @return [HTML::Pipeline] The pipeline
85
+ # :nodoc:
97
86
  def create_pipeline(options, context)
98
87
  ::HTML::Pipeline.new(
99
88
  options[:pipeline].map { |f| ::Lazier.find_class(f, "::HTML::Pipeline::%CLASS%Filter", true) },
@@ -101,10 +90,7 @@ module Mbrao
101
90
  )
102
91
  end
103
92
 
104
- # Filters pipeline filters basing on the options provided.
105
- #
106
- # @param options [Hash] The original options.
107
- # @return [Hash] The options with the new set of filters.
93
+ # :nodoc:
108
94
  def filter_filters(options)
109
95
  options[:pipeline] = get_pipeline(options)
110
96
 
@@ -115,10 +101,7 @@ module Mbrao
115
101
  options
116
102
  end
117
103
 
118
- # Gets the pipeline for the current options.
119
- #
120
- # @param options [Hash] The options to parse.
121
- # @return [Array] The pipeline to process.
104
+ # :nodoc:
122
105
  def get_pipeline(options)
123
106
  options.fetch(:pipeline, default_pipeline.map(&:first)).map(&:to_sym)
124
107
  end
@@ -14,7 +14,7 @@ module Mbrao
14
14
  MAJOR = 1
15
15
 
16
16
  # The minor version.
17
- MINOR = 5
17
+ MINOR = 6
18
18
 
19
19
  # The patch version.
20
20
  PATCH = 0
@@ -4,12 +4,12 @@
4
4
  # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
5
  #
6
6
 
7
- require File.expand_path('../lib/mbrao/version', __FILE__)
7
+ require File.expand_path("../lib/mbrao/version", __FILE__)
8
8
 
9
9
  Gem::Specification.new do |gem|
10
10
  gem.name = "mbrao"
11
11
  gem.version = Mbrao::Version::STRING
12
- gem.homepage = "http://github.com/ShogunPanda/mbrao"
12
+ gem.homepage = "http://sw.cowtech.it/mbrao"
13
13
  gem.summary = "A content parser and renderer with embedded metadata support."
14
14
  gem.description = "A content parser and renderer with embedded metadata support."
15
15
  gem.rubyforge_project = "mbrao"
@@ -23,12 +23,12 @@ Gem::Specification.new do |gem|
23
23
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
24
24
  gem.require_paths = ["lib"]
25
25
 
26
- gem.required_ruby_version = ">= 1.9.3"
26
+ gem.required_ruby_version = ">= 2.3.0"
27
27
 
28
- gem.add_dependency("lazier", "~> 3.5.5")
29
- gem.add_dependency("html-pipeline", "~> 1.8.0")
30
- gem.add_dependency("slim", "~> 2.0.2")
31
- gem.add_dependency("kramdown", "~> 1.3.3")
32
- gem.add_dependency("rinku", "~> 1.7.3")
33
- gem.add_dependency("gemoji", "~> 1.5.0")
28
+ gem.add_dependency("lazier", "~> 4.2")
29
+ gem.add_dependency("html-pipeline", "~> 2.3")
30
+ gem.add_dependency("slim", "~> 3.0")
31
+ gem.add_dependency("kramdown", "~> 1.10")
32
+ gem.add_dependency("rinku", "~> 1.7")
33
+ gem.add_dependency("gemoji", "~> 2.1")
34
34
  end
@@ -283,10 +283,10 @@ describe Mbrao::Content do
283
283
  describe "#enabled_for_locales?" do
284
284
  it "correctly check availability for certain locales" do
285
285
  subject.locales = [:en, :it]
286
- expect(subject.enabled_for_locales?).to be_true
287
- expect(subject.enabled_for_locales?(:en)).to be_true
288
- expect(subject.enabled_for_locales?(:it, :es)).to be_true
289
- expect(subject.enabled_for_locales?(:es, :de)).to be_false
286
+ expect(subject.enabled_for_locales?).to be_truthy
287
+ expect(subject.enabled_for_locales?(:en)).to be_truthy
288
+ expect(subject.enabled_for_locales?(:it, :es)).to be_truthy
289
+ expect(subject.enabled_for_locales?(:es, :de)).to be_falsey
290
290
  end
291
291
  end
292
292
 
@@ -5,8 +5,8 @@
5
5
  #
6
6
 
7
7
  require "spec_helper"
8
- require "action_view"
9
8
  require "mbrao/integrations/rails"
9
+ require "action_view"
10
10
 
11
11
  describe ActionView::Template::Handlers::MbraoTemplate do
12
12
  class Rails
@@ -77,12 +77,12 @@ describe ActionView::Template::Handlers::MbraoTemplate do
77
77
  renderer = DummyRenderer.new
78
78
  allow(renderer).to receive(:controller).and_return(controller)
79
79
 
80
- expect(controller.respond_to?(:mbrao_content)).to be_false
80
+ expect(controller.respond_to?(:mbrao_content)).to be_falsey
81
81
  expect(::Mbrao::Parser).to receive(:parse).and_call_original
82
82
  expect(controller.class).to receive(:helper_method).with(:mbrao_content)
83
83
  ActionView::Template::Handlers::MbraoTemplate.instance.render(renderer, "CONTENT")
84
84
 
85
- expect(controller.respond_to?(:mbrao_content)).to be_true
85
+ expect(controller.respond_to?(:mbrao_content)).to be_truthy
86
86
  expect(controller.mbrao_content.body).to eq("CONTENT")
87
87
  end
88
88
 
@@ -101,7 +101,7 @@ describe ActionView::Template::Handlers::MbraoTemplate do
101
101
 
102
102
  describe "#supports_streaming?" do
103
103
  it "should be true" do
104
- expect(ActionView::Template::Handlers::MbraoTemplate.instance.supports_streaming?).to be_true
104
+ expect(ActionView::Template::Handlers::MbraoTemplate.instance.supports_streaming?).to be_truthy
105
105
  end
106
106
  end
107
107
  end
@@ -20,7 +20,7 @@ describe Mbrao::Parser do
20
20
  end
21
21
 
22
22
  it "should correctly setup datetime JSON serialization" do
23
- expect(ActiveSupport.use_standard_json_time_format).to be_true
23
+ expect(ActiveSupport.use_standard_json_time_format).to be_truthy
24
24
  end
25
25
 
26
26
  shared_examples_for("attribute_with_default") do |attribute, default, sanitizer|
@@ -102,25 +102,25 @@ describe Mbrao::Parser do
102
102
 
103
103
  describe ".email?" do
104
104
  it "should check for valid emails" do
105
- expect(Mbrao::Parser.email?("valid@email.com")).to be_true
106
- expect(Mbrao::Parser.email?("valid@localhost")).to be_false
107
- expect(Mbrao::Parser.email?("this.is.9@email.com")).to be_true
108
- expect(Mbrao::Parser.email?("INVALID")).to be_false
109
- expect(Mbrao::Parser.email?(nil)).to be_false
110
- expect(Mbrao::Parser.email?([])).to be_false
111
- expect(Mbrao::Parser.email?("this.is.9@email.com.uk")).to be_true
105
+ expect(Mbrao::Parser.email?("valid@email.com")).to be_truthy
106
+ expect(Mbrao::Parser.email?("valid@localhost")).to be_falsey
107
+ expect(Mbrao::Parser.email?("this.is.9@email.com")).to be_truthy
108
+ expect(Mbrao::Parser.email?("INVALID")).to be_falsey
109
+ expect(Mbrao::Parser.email?(nil)).to be_falsey
110
+ expect(Mbrao::Parser.email?([])).to be_falsey
111
+ expect(Mbrao::Parser.email?("this.is.9@email.com.uk")).to be_truthy
112
112
  end
113
113
  end
114
114
 
115
115
  describe ".url?" do
116
116
  it "should check for valid URLs" do
117
- expect(Mbrao::Parser.url?("http://google.it")).to be_true
118
- expect(Mbrao::Parser.url?("ftp://ftp.google.com")).to be_true
119
- expect(Mbrao::Parser.url?("http://google.it/?q=FOO+BAR")).to be_true
120
- expect(Mbrao::Parser.url?("INVALID")).to be_false
121
- expect(Mbrao::Parser.url?([])).to be_false
122
- expect(Mbrao::Parser.url?(nil)).to be_false
123
- expect(Mbrao::Parser.url?({})).to be_false
117
+ expect(Mbrao::Parser.url?("http://google.it")).to be_truthy
118
+ expect(Mbrao::Parser.url?("ftp://ftp.google.com")).to be_truthy
119
+ expect(Mbrao::Parser.url?("http://google.it/?q=FOO+BAR")).to be_truthy
120
+ expect(Mbrao::Parser.url?("INVALID")).to be_falsey
121
+ expect(Mbrao::Parser.url?([])).to be_falsey
122
+ expect(Mbrao::Parser.url?(nil)).to be_falsey
123
+ expect(Mbrao::Parser.url?({})).to be_falsey
124
124
  end
125
125
  end
126
126
 
@@ -4,12 +4,26 @@
4
4
  # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
5
  #
6
6
 
7
- require "rubygems"
8
7
  require "bundler/setup"
9
- require "mbrao"
10
8
 
11
- RSpec.configure do |config|
12
- config.expect_with :rspec do |c|
13
- c.syntax = :expect
9
+ if ENV["COVERAGE"]
10
+ require "simplecov"
11
+ require "coveralls"
12
+
13
+ Coveralls.wear! if ENV["CI"]
14
+
15
+ SimpleCov.start do
16
+ root = Pathname.new(File.dirname(__FILE__)) + ".."
17
+
18
+ add_filter do |src_file|
19
+ path = Pathname.new(src_file.filename).relative_path_from(root).to_s
20
+ path !~ /^lib/
21
+ end
14
22
  end
15
23
  end
24
+
25
+ require "i18n"
26
+ ::I18n.enforce_available_locales = false
27
+ require File.dirname(__FILE__) + "/../lib/mbrao"
28
+
29
+ Lazier::I18n.default_locale = :en
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mbrao
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shogun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-12 00:00:00.000000000 Z
11
+ date: 2016-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lazier
@@ -16,84 +16,84 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.5.5
19
+ version: '4.2'
20
20
  type: :runtime
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: 3.5.5
26
+ version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: html-pipeline
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.8.0
33
+ version: '2.3'
34
34
  type: :runtime
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: 1.8.0
40
+ version: '2.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: slim
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 2.0.2
47
+ version: '3.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 2.0.2
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: kramdown
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.3.3
61
+ version: '1.10'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.3.3
68
+ version: '1.10'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rinku
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.7.3
75
+ version: '1.7'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.7.3
82
+ version: '1.7'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: gemoji
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.5.0
89
+ version: '2.1'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.5.0
96
+ version: '2.1'
97
97
  description: A content parser and renderer with embedded metadata support.
98
98
  email:
99
99
  - shogun@cowtech.it
@@ -177,7 +177,6 @@ files:
177
177
  - lib/mbrao/rendering_engines/html_pipeline/kramdown_filter.rb
178
178
  - lib/mbrao/version.rb
179
179
  - mbrao.gemspec
180
- - spec/coverage_helper.rb
181
180
  - spec/mbrao/author_spec.rb
182
181
  - spec/mbrao/content_spec.rb
183
182
  - spec/mbrao/integrations/rails_spec.rb
@@ -188,7 +187,7 @@ files:
188
187
  - spec/mbrao/rendering_engines/html_pipeline/kramdown_filter_spec.rb
189
188
  - spec/mbrao/rendering_engines/html_pipeline_spec.rb
190
189
  - spec/spec_helper.rb
191
- homepage: http://github.com/ShogunPanda/mbrao
190
+ homepage: http://sw.cowtech.it/mbrao
192
191
  licenses:
193
192
  - MIT
194
193
  metadata: {}
@@ -200,7 +199,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
199
  requirements:
201
200
  - - ">="
202
201
  - !ruby/object:Gem::Version
203
- version: 1.9.3
202
+ version: 2.3.0
204
203
  required_rubygems_version: !ruby/object:Gem::Requirement
205
204
  requirements:
206
205
  - - ">="
@@ -208,12 +207,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
207
  version: '0'
209
208
  requirements: []
210
209
  rubyforge_project: mbrao
211
- rubygems_version: 2.2.2
210
+ rubygems_version: 2.5.1
212
211
  signing_key:
213
212
  specification_version: 4
214
213
  summary: A content parser and renderer with embedded metadata support.
215
214
  test_files:
216
- - spec/coverage_helper.rb
217
215
  - spec/mbrao/author_spec.rb
218
216
  - spec/mbrao/content_spec.rb
219
217
  - spec/mbrao/integrations/rails_spec.rb
@@ -1,20 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # This file is part of the mbrao gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
4
- # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
- #
6
-
7
- require "pathname"
8
- require "simplecov"
9
- require "coveralls"
10
-
11
- Coveralls.wear! if ENV["CI"] || ENV["JENKINS_URL"]
12
-
13
- SimpleCov.start do
14
- root = Pathname.new(File.dirname(__FILE__)) + ".."
15
-
16
- add_filter do |src_file|
17
- path = Pathname.new(src_file.filename).relative_path_from(root).to_s
18
- path !~ /^(lib)/
19
- end
20
- end