motion-html-pipeline 0.3 → 0.4.2

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
2
  SHA256:
3
- metadata.gz: a2bf83e4abe0c69678a81a1861cbb829ec6899410f07436f934c708d595b4a94
4
- data.tar.gz: abfafa964af397acada8022caa80579e8114d41f382dc26ac5f462b4dddad88a
3
+ metadata.gz: 3bcdb20531f70a01428ccebf296156c2983b173e336aaf2d91e13a7140c08058
4
+ data.tar.gz: b1910202c610ebcc89770226462a00fd80f3d1703cdc02291beab303dba3993a
5
5
  SHA512:
6
- metadata.gz: '048abc1ca29f81a1c54395eee5ab57ab07905c76ed38801846fab5c1e25ec6799cd9aa546d4850d8fae30bca6a85aae30422b2c39f562aecb7d709a26021f86e'
7
- data.tar.gz: d2e83504949146542b7ac984758587dade9cfb2d2895ca824ecd45aec5816db70aeee5039333450a85b7b484bea506624d72500cc5257077fec3451df74f5814
6
+ metadata.gz: e5c1e1b85ebdf611e50e033c5190f901f5ced19972aa97a83cfd9ac3683dbb2dbc749a4beeea307a5d956118e5fd1121709c4ef59796eb21b0df559978deadd5
7
+ data.tar.gz: a011de5dac1c3d11f8c9dcdaa3506e63083f3037556350ff194bf03c2dc6a5a504560c0746af305af81c73de5ab900cac96e4d0c73d208257833dd8dc0ce7cf7
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/motion-html-pipeline.svg)](http://badge.fury.io/rb/motion-html-pipeline)
4
4
  [![Build Status](https://travis-ci.org/digitalmoksha/motion-html-pipeline.svg?branch=master)](https://travis-ci.org/digitalmoksha/motion-html-pipeline)
5
+ [![Platform](https://img.shields.io/badge/platform-macos%20|%20ios-lightgrey.svg)](https://shields.io/)
6
+ [![Language](https://img.shields.io/badge/language-RubyMotion-red.svg)](http://www.rubymotion.com)
5
7
 
6
8
  _This gem is a port of the [`html-pipeline` gem](https://github.com/jch/html-pipeline) to RubyMotion, for use on iOS and macOS. Currently synced with `html-pipeline` release [`v.2.12.3`](https://github.com/jch/html-pipeline/releases/tag/v2.12.3)_
7
9
 
@@ -64,7 +66,7 @@ would output
64
66
 
65
67
  Filters can be combined into a pipeline which causes each filter to hand its
66
68
  output to the next filter's input. So if you wanted to have content be
67
- filtered through the `ImageFilter` and then wrap it in an `<a>` tag with
69
+ filtered through the `ImageFilter` and then wrap it in an `<a>` tag with
68
70
  a max-width inline style:
69
71
 
70
72
  ```ruby
@@ -243,7 +245,7 @@ Here are some extensions people have built:
243
245
 
244
246
  ## Instrumenting
245
247
 
246
- _Although instrumenting was ported, it has not been used real-world, and may not work
248
+ _Although instrumenting was ported, it has not been used real-world, and may not work
247
249
  properly at this time._
248
250
 
249
251
  Filters and Pipelines can be set up to be instrumented when called. The pipeline
@@ -1,16 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- unless defined?(Motion::Project::Config)
4
- raise "This file must be required within a RubyMotion project Rakefile."
5
- end
3
+ raise 'This file must be required within a RubyMotion project Rakefile.' unless defined?(Motion::Project::Config)
6
4
 
7
5
  require 'motion-cocoapods'
8
6
 
9
7
  lib_dir_path = File.dirname(File.expand_path(__FILE__))
10
8
  Motion::Project::App.setup do |app|
11
- app.files.unshift(Dir.glob(File.join(lib_dir_path, "motion-html-pipeline/**/*.rb")))
9
+ app.files.unshift(Dir.glob(File.join(lib_dir_path, 'motion-html-pipeline/**/*.rb')))
12
10
 
13
11
  app.pods do
14
- pod 'HTMLKit', '~> 3.1'
12
+ pod 'HTMLKit', '~> 4.2'
15
13
  end
16
14
  end
@@ -24,6 +24,6 @@ module MotionHTMLPipeline
24
24
  def to_html
25
25
  document.body.innerHTML
26
26
  end
27
- alias :to_s :to_html
27
+ alias to_s to_html
28
28
  end
29
29
  end
@@ -42,8 +42,10 @@ module MotionHTMLPipeline
42
42
 
43
43
  # Public: String name for this Pipeline. Defaults to Class name.
44
44
  attr_writer :instrumentation_name
45
+
45
46
  def instrumentation_name
46
47
  return @instrumentation_name if defined?(@instrumentation_name)
48
+
47
49
  @instrumentation_name = self.class.name
48
50
  end
49
51
 
@@ -54,6 +56,7 @@ module MotionHTMLPipeline
54
56
 
55
57
  def initialize(filters, default_context = {}, result_class = nil)
56
58
  raise ArgumentError, 'default_context cannot be nil' if default_context.nil?
59
+
57
60
  @filters = filters.flatten.freeze
58
61
  @default_context = default_context.freeze
59
62
  @result_class = result_class || Hash
@@ -132,12 +135,11 @@ module MotionHTMLPipeline
132
135
  # block, otherwise the block is ran without instrumentation.
133
136
  #
134
137
  # Returns the result of the provided block.
135
- def instrument(event, payload = nil)
138
+ def instrument(event, payload = nil, &block)
136
139
  payload ||= default_payload
137
140
  return yield(payload) unless instrumentation_service
138
- instrumentation_service.instrument event, payload do |payload|
139
- yield payload
140
- end
141
+
142
+ instrumentation_service.instrument event, payload, &block
141
143
  end
142
144
 
143
145
  # Internal: Default payload for instrumentation.
@@ -19,8 +19,10 @@ module MotionHTMLPipeline
19
19
  def call
20
20
  doc.css('img').each do |element|
21
21
  next if element['src'].nil? || element['src'].empty?
22
+
22
23
  src = element['src'].strip
23
24
  next if src.start_with? 'http'
25
+
24
26
  base = if src.start_with? '/'
25
27
  image_base_url
26
28
  else
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # TODO Requires Set (or something similar)
3
+ # TODO: Requires Set (or something similar)
4
4
  #------------------------------------------------------------------------------
5
5
  # require 'set'
6
6
  #
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # TODO Requires Rinku gem (or something similar)
3
+ # TODO: Requires Rinku gem (or something similar)
4
4
  #------------------------------------------------------------------------------
5
5
  # module MotionHTMLPipeline
6
6
  # class Pipeline
@@ -66,6 +66,7 @@ module MotionHTMLPipeline
66
66
  # called.
67
67
  def html
68
68
  raise InvalidDocumentException if @html.nil? && @doc.nil?
69
+
69
70
  @html || doc.to_html
70
71
  end
71
72
 
@@ -10,7 +10,7 @@ module MotionHTMLPipeline
10
10
 
11
11
  class ImageFilter < TextFilter
12
12
  def call
13
- @text.gsub(/(https|http)?:\/\/.+\.(jpg|jpeg|bmp|gif|png)(\?\S+)?/i) do |match|
13
+ @text.gsub(%r{(https|http)?://.+\.(jpg|jpeg|bmp|gif|png)(\?\S+)?}i) do |match|
14
14
  %(<img src="#{match}" alt=""/>)
15
15
  end
16
16
  end
@@ -7,6 +7,7 @@ module MotionHTMLPipeline
7
7
 
8
8
  def initialize(text, context = nil, result = nil)
9
9
  raise TypeError, 'text cannot be HTML' if text.is_a?(DocumentFragment)
10
+
10
11
  # Ensure that this is always a string
11
12
  @text = text.respond_to?(:to_str) ? text.to_str : text.to_s
12
13
  super nil, context, result
@@ -2,6 +2,6 @@
2
2
 
3
3
  module MotionHTMLPipeline
4
4
  class Pipeline
5
- VERSION = '0.3'.freeze
5
+ VERSION = '0.4.2'
6
6
  end
7
7
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  class MockedInstrumentationService
4
4
  attr_reader :events
5
+
5
6
  def initialize(event = nil, events = [])
6
7
  @events = events
7
8
  subscribe event
@@ -35,15 +35,15 @@ describe 'MotionHTMLPipeline::Pipeline::AbsoluteSourceFilterTest' do
35
35
  end
36
36
 
37
37
  it 'test_fails_when_context_is_missing' do
38
- expect{ AbsoluteSourceFilter.call('<img src="img.png">', {}) }.to raise_error(RuntimeError)
39
- expect{ AbsoluteSourceFilter.call('<img src="/img.png">', {}) }.to raise_error(RuntimeError)
38
+ expect { AbsoluteSourceFilter.call('<img src="img.png">', {}) }.to raise_error(RuntimeError)
39
+ expect { AbsoluteSourceFilter.call('<img src="/img.png">', {}) }.to raise_error(RuntimeError)
40
40
  end
41
41
 
42
42
  it 'test_tells_you_where_context_is_required' do
43
- expect{ AbsoluteSourceFilter.call('<img src="img.png">', {}) }
43
+ expect { AbsoluteSourceFilter.call('<img src="img.png">', {}) }
44
44
  .to raise_error(RuntimeError, 'MotionHTMLPipeline::Pipeline::AbsoluteSourceFilter')
45
45
 
46
- expect{ AbsoluteSourceFilter.call('<img src="/img.png">', {}) }
46
+ expect { AbsoluteSourceFilter.call('<img src="/img.png">', {}) }
47
47
  .to raise_error(RuntimeError, 'MotionHTMLPipeline::Pipeline::AbsoluteSourceFilter')
48
48
  end
49
49
  end
@@ -48,7 +48,7 @@ describe 'MotionHTMLPipeline::Pipeline::HttpsFilter' do
48
48
  it 'test_validates_http_url' do
49
49
  @options.clear
50
50
 
51
- expect{ filter('') }
51
+ expect { filter('') }
52
52
  .to raise_error(ArgumentError, 'MotionHTMLPipeline::Pipeline::HttpsFilter: :http_url')
53
53
  end
54
54
  end
data/spec/spec_helper.rb CHANGED
@@ -4,10 +4,10 @@
4
4
  #
5
5
  # rake spec filter="name of spec" # To filter by spec name
6
6
  # rake spec files=foo_spec filter="name of spec"
7
- # rake spec filter_context="this doesn't work yet" # To filter by context name (doesn't work until MacBacon implements it)
7
+ # rake spec filter_context="this doesn't work yet" # To filter by context name (doesn't work
8
+ # until MacBacon implements it)
8
9
  # rake spec hide_backtraces=yes # Hide backtraces
9
10
 
10
-
11
11
  # From http://chen.do/blog/2013/06/03/running-individual-specs-with-rubymotion/
12
12
  #------------------------------------------------------------------------------
13
13
  def silence_warnings(&block)
@@ -24,12 +24,12 @@ end
24
24
  silence_warnings do
25
25
  module Bacon
26
26
  if ENV['filter']
27
- $stderr.puts "Filtering specs that match: #{ENV['filter']}"
27
+ warn "Filtering specs that match: #{ENV['filter']}"
28
28
  RestrictName = Regexp.new(ENV['filter'])
29
29
  end
30
30
 
31
31
  if ENV['filter_context']
32
- $stderr.puts "Filtering contexts that match: #{ENV['filter_context']}"
32
+ warn "Filtering contexts that match: #{ENV['filter_context']}"
33
33
  RestrictContext = Regexp.new(ENV['filter_context'])
34
34
  end
35
35
 
@@ -40,11 +40,15 @@ end
40
40
  #------------------------------------------------------------------------------
41
41
  # TODO total hack - without this, the `bacon-expect` gem doesn't get used, and
42
42
  # on iOS I get errors like
43
- # *** Terminating app due to uncaught exception 'NameError', reason: '.../bacon-expect/lib/bacon-expect/matchers/eql.rb:2:in `<main>: uninitialized constant BaconExpect::Matcher::SingleMethod (NameError)
43
+ # *** Terminating app due to uncaught exception 'NameError',
44
+ # reason: '.../bacon-expect/lib/bacon-expect/matchers/eql.rb:2:in `<main>:
45
+ # uninitialized constant BaconExpect::Matcher::SingleMethod (NameError)
44
46
  # and on macOS it only show up as `*nil description*`
47
+ # rubocop: disable Lint/EmptyClass
45
48
  module BaconExpect
46
49
  module Matcher
47
50
  class SingleMethod
48
51
  end
49
52
  end
50
53
  end
54
+ # rubocop: enable Lint/EmptyClass
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-html-pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
8
8
  - Jerry Cheung
9
9
  - Garen J. Torikian
10
10
  - Brett Walker
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-04-11 00:00:00.000000000 Z
14
+ date: 2021-05-05 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: motion-cocoapods
@@ -27,20 +27,6 @@ dependencies:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: rake
32
- requirement: !ruby/object:Gem::Requirement
33
- requirements:
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: '0'
37
- type: :development
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: '0'
44
30
  - !ruby/object:Gem::Dependency
45
31
  name: motion-expect
46
32
  requirement: !ruby/object:Gem::Requirement
@@ -110,7 +96,7 @@ homepage: https://github.com/digitalmoksha/motion-html-pipeline
110
96
  licenses:
111
97
  - MIT
112
98
  metadata: {}
113
- post_install_message:
99
+ post_install_message:
114
100
  rdoc_options: []
115
101
  require_paths:
116
102
  - lib
@@ -125,8 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
111
  - !ruby/object:Gem::Version
126
112
  version: '0'
127
113
  requirements: []
128
- rubygems_version: 3.0.6
129
- signing_key:
114
+ rubygems_version: 3.1.4
115
+ signing_key:
130
116
  specification_version: 4
131
117
  summary: Helpers for processing content through a chain of filters (RubyMotion version,
132
118
  ported from https://github.com/jch/html-pipeline)