embedrb 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb13bb8367d8bc1b9e74342cc6ef9f115e60b0b7
4
- data.tar.gz: 6e1e6f4c6abf459605d3a61f3186375b5f422f40
3
+ metadata.gz: 29a1c1027ae50d6fb90093dc118e01fb4c6a8930
4
+ data.tar.gz: d59b3a1453772ac11d5e4dc4efe6e647b03b2ef9
5
5
  SHA512:
6
- metadata.gz: adffaeebd9425607c766fddac9ad8410f3a36ed282b1eb9840973668d5adcef9a606fae5325d41763b89e3a64df4dba6d787a57e326305dd8c991075822d7fa7
7
- data.tar.gz: bff09245e87ff5290e06dd93638b73fb1bae082759cf5e750957f7d84999b3039f5a698b04e8c99bae3ae8cd624bd685846cd959362045052a2844599bc9ff9e
6
+ metadata.gz: 323db49baac4ffd1bb6dd04f537d5342ec35880014095b7cadfafe1e84596e15990fe5459b14c59051e0bbfefb148d646552c01b575e30cabeccde870f540ae1
7
+ data.tar.gz: 2cbe816d5f8777ff7e10fd8ea7bf020fac78999a5b11903dec77c43669d0a5153ca58174fc0b1cd8c682d266552bcc51d70a50db528747d0056212ab3f5388cd
data/embedrb.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: embedrb 0.2.1 ruby lib
5
+ # stub: embedrb 0.2.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "embedrb"
9
- s.version = "0.2.1"
9
+ s.version = "0.2.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["liris"]
14
- s.date = "2016-02-17"
14
+ s.date = "2016-02-22"
15
15
  s.description = "a ruby port of Embed.js"
16
16
  s.email = "liris.pp@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -11,6 +11,7 @@ module EmbedRb
11
11
  @embeds = embeds
12
12
  @options = options
13
13
  @regex = /((?:https?):\/\/\S*\.(?:wav|mp3|ogg))/mi
14
+ @service = :audio
14
15
  end
15
16
 
16
17
  private
data/lib/embedrb/base.rb CHANGED
@@ -9,7 +9,7 @@ module EmbedRb
9
9
  def embed()
10
10
  @input.scan(@regex) {|match|
11
11
  url = match[0]
12
- if !@options[:served].include? url
12
+ if !@options[:served].include? url && EmbedRb.process_more?(@options, @service, @embeds)
13
13
  text = url_to_text match
14
14
  if text
15
15
  @options[:served] << url
data/lib/embedrb/embed.rb CHANGED
@@ -26,6 +26,8 @@ PROCESSORS = {
26
26
  }
27
27
 
28
28
  DEFAULT_OPTIONS = {
29
+ :maxEmbed => 0,
30
+ :maxEmbedExcludes => [],
29
31
  :link => true,
30
32
  :linkOptions => {
31
33
  :target => 'self',
@@ -76,8 +78,8 @@ module EmbedRb
76
78
  output = ''
77
79
 
78
80
  PROCESSORS.each {|key, klass|
79
- if @options[key]
80
- output = klass.new(input, output, @options, embeds).process()
81
+ if @options[key] && EmbedRb.process_more?(@options, key, embeds)
82
+ output = klass.new(input, output, @options, embeds).process
81
83
  end
82
84
  }
83
85
 
@@ -25,7 +25,7 @@ module EmbedRb
25
25
  @input.scan(@url_regex) {|match|
26
26
  url = match[2]
27
27
  short_url = shorten(url)
28
- if !exclude?(url) && !@options[:served].include?(short_url)
28
+ if !exclude?(url) && !@options[:served].include?(short_url) && EmbedRb.process_more?(@options, :openGraphEndpoint, @embeds)
29
29
  p short_url
30
30
  data = fetch(url)
31
31
  if data
@@ -11,6 +11,7 @@ module EmbedRb
11
11
  @embeds = embeds
12
12
  @options = options
13
13
  @regex = /(flickr.com\/[a-z]+\/[a-zA-Z0-9@_\-]+\/[\d]+)/mi
14
+ @service = :flickr
14
15
  end
15
16
 
16
17
  private
@@ -11,6 +11,7 @@ module EmbedRb
11
11
  @embeds = embeds
12
12
  @options = options
13
13
  @regex = /((?:https?):\/\/\S*\.(?:gif|jpg|jpeg|tiff|png|svg|webp))/mi
14
+ @service = :image
14
15
  end
15
16
 
16
17
  private
@@ -11,6 +11,7 @@ module EmbedRb
11
11
  @embeds = embeds
12
12
  @options = options
13
13
  @regex = /(instagram.com\/p\/[a-zA-Z0-9_\/\?\-\=]+)/mi
14
+ @service = :instagram
14
15
  end
15
16
 
16
17
  private
data/lib/embedrb/utils.rb CHANGED
@@ -28,6 +28,14 @@ module EmbedRb
28
28
  options[key] ? options[key] : {}
29
29
  end
30
30
 
31
+ def process_more?(options, key, embeds)
32
+ max_num = options[:maxEmbed]
33
+ if max_num == 0
34
+ return true
35
+ end
36
+ embeds.length < max_num || options[:maxEmbedExcludes].include?(key)
37
+ end
38
+
31
39
  def create_text(str, embeds)
32
40
  # TODO: sort embeds
33
41
  embeds_str = embeds.map {|embed|
@@ -1,4 +1,4 @@
1
1
 
2
2
  module EmbedRb
3
- VERSION="0.2.1"
3
+ VERSION="0.2.2"
4
4
  end
@@ -11,6 +11,7 @@ module EmbedRb
11
11
  @embeds = embeds
12
12
  @options = options
13
13
  @regex = /(ted.com\/talks\/([a-zA-Z0-9_]+))/mi
14
+ @service = :ted
14
15
  end
15
16
 
16
17
  private
@@ -11,6 +11,7 @@ module EmbedRb
11
11
  @embeds = embeds
12
12
  @options = options
13
13
  @regex = /(ustream.tv\/([a-z\/0-9%]*))/mi
14
+ @service = :ustream
14
15
  end
15
16
 
16
17
  private
@@ -11,6 +11,7 @@ module EmbedRb
11
11
  @embeds = embeds
12
12
  @options = options
13
13
  @regex = /((?:https?):\/\/\S*\.(?:ogv|webm|mp4))/mi
14
+ @service = :video
14
15
  end
15
16
 
16
17
  private
@@ -11,6 +11,7 @@ module EmbedRb
11
11
  @embeds = embeds
12
12
  @options = options
13
13
  @regex = /(https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[?=&+%\w-]*)/mi
14
+ @service = :youtube
14
15
  end
15
16
 
16
17
  private
@@ -22,8 +23,8 @@ module EmbedRb
22
23
  def render(url)
23
24
  dims = EmbedRb.get_dimensions(@options)
24
25
  return <<EOF
25
- <div class="ejs-video-player ejs-embed">
26
- <iframe src="#{url}" frameBorder="0" width="#{dims[:width]}" height="#{dims[:height]}" ></iframe>
26
+ <div class="ejs-video-player ejs-embed" style="width: #{dims[:width]}px; height: #{dims[:height]}px;">
27
+ <iframe src="#{url}" frameBorder="0" width="#{dims[:width]}px" height="#{dims[:height]}px" ></iframe>
27
28
  </div>
28
29
  EOF
29
30
  end
data/lib/embedrb.rb CHANGED
@@ -7,6 +7,7 @@ if $0 == __FILE__
7
7
  http://www.google.com/
8
8
  the following is geocode
9
9
  @(東京駅)
10
+ @(東京駅)
10
11
  http://hoge.fuga.com/xxx/yyy.png
11
12
  https://www.flickr.com/photos/parismadrid/5573484679/in/photolist-9uvyPr-7TD5uZ-jYwbo8-qeZLRe-odzeYC-n8x6Xn-dzq2Ws-oRNMGp-68DxGi-c4DxV7-bnmwjN-nqZDVD-kF39se-rXJWT4-nTTR4S-7YLgdX-apPuvi-q1DhYc-kFWFjG-a2c9kr-aPGmhK-oqB5cQ-ziBGRr-oBkGxp-pEFgd8-jY9diK-mDTbpD-jzSaXQ-cuCWwN-pzK88U-9HvHVt-dBPTZV-nKdYRM-oEDGkL-bTygzn-o3CxjL-rhtanH-oXpW1i-s4Jdat-p8N1RJ-fhpghZ-dX2tPC-v8R2LX-x7M7j1-xFACNe-cAWLSf-A6FvqE-adcNyU-t2N6Hh-j1TaxV
12
13
 
@@ -23,6 +24,8 @@ if $0 == __FILE__
23
24
  EOF
24
25
 
25
26
  opts = {
27
+ :maxEmbed => 0,
28
+ :maxEmbedExcludes => [ :youtube ],
26
29
  :openGraphEndpoint => 'http://opengraph.io/api/1.0/site/',
27
30
  :gmap => true,
28
31
  :gmapOptions => {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embedrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - liris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-17 00:00:00.000000000 Z
11
+ date: 2016-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda