atig 0.4.2 → 0.4.3

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: f52437a64db888b7a72bfcb418fdfe62222e0380
4
- data.tar.gz: 064c715ba416098c2602455f2d637f662a63b06d
3
+ metadata.gz: 4fa3205294dc32a30048fe0bb019a00ee64b993b
4
+ data.tar.gz: af811c86345b7f465ea7d461332a24f929054c3a
5
5
  SHA512:
6
- metadata.gz: 2d7094055345ec00bebe4b8a2ea7a8f36c26500dfc8530c9fc25c5d8d353c584209dd11c25b66b921c1d76b5e3e6f14bdc85c0a3176e1458806a7813963754ec
7
- data.tar.gz: 28ecc6f10e97b88ffd6215d9c6e1688a9a4572edbeda0479a526fde67c33f97d4d81aec4d958e53f8f191d6909a4803fade7e0b3d876fb5041c71c62ad872413
6
+ metadata.gz: b527ca8c8e5526320297014377b0ff46979622c846bb459b064e32e8dd1c5f6a394645a6521240693677d57d20fd614ae26e5d0fa88ce7c259862167b79b56cb
7
+ data.tar.gz: 30616c567a4fe5359fe331de8ecd3f12acfa088d262a4d97baa5457bc1a5903312fb61234490be3018a85811efb7638bb524dccdfaec471b5f2049a42cae2520
@@ -17,10 +17,11 @@ module Atig
17
17
 
18
18
  def call(status)
19
19
  target = short_url_regexp
20
- entities = status.entities
20
+ entities = (entities = status.entities).nil? ? [] : entities.urls
21
21
  status.merge :text => status.text.gsub(target) {|url|
22
- unless entities.nil? or (entities = entities.urls).empty?
22
+ unless entities.nil? or entities.empty?
23
23
  @cache[url] ||= search_url_from_entities(url, entities)
24
+ url = @cache[url] if @cache[url] =~ target
24
25
  end
25
26
  @cache[url] ||= resolve_http_redirect(URI(url)).to_s || url
26
27
  }
@@ -32,11 +33,19 @@ module Atig
32
33
  return URI.regexp(%w[http https]) if @opts.untiny_whole_urls
33
34
  %r{
34
35
  https?:// (?:
35
- (?: bit\.ly | (?: tin | rub) yurl\.com | j\.mp | t\.co
36
- | htn.to
37
- | is\.gd | cli\.gs | tr\.im | u\.nu | airme\.us
38
- | ff\.im | twurl.nl | bkite\.com | tumblr\.com
39
- | pic\.gd | sn\.im | digg\.com | goo\.gl)
36
+ (?: t (?: mblr )? \.co
37
+ | (?: bitly | bkite | digg | tumblr | (?: tin | rub ) yurl ) \.com
38
+ | (?: is | pic ) \.gd
39
+ | goo\.gl
40
+ | cli\.gs
41
+ | (?: ff | sn | tr ) \.im
42
+ | bit\.ly
43
+ | j\.mp
44
+ | nico\.ms
45
+ | airme\.us
46
+ | twurl\.nl
47
+ | u\.nu
48
+ | htn\.to)
40
49
  / [0-9a-z=-]+ |
41
50
  blip\.fm/~ (?> [0-9a-z]+) (?! /) |
42
51
  flic\.kr/[a-z0-9/]+
@@ -1,3 +1,3 @@
1
1
  module Atig
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
@@ -16,6 +16,20 @@ describe Atig::IFilter::ExpandUrl, "when disable whole url" do
16
16
 
17
17
  it "should expand bit.ly" do
18
18
  filtered("This is http://bit.ly/hoge").should be_text("This is [http://bit.ly/hoge]")
19
+ filtered("This is http://bitly.com/hoge").should be_text("This is [http://bitly.com/hoge]")
20
+ end
21
+
22
+ it "should expand htn.to" do
23
+ filtered("This is http://htn.to/TZdkXg").should be_text("This is [http://htn.to/TZdkXg]")
24
+ filtered("This is http://htnnto/TZdkXg").should be_text("This is http://htnnto/TZdkXg")
25
+ end
26
+
27
+ it "should expand tmblr.co" do
28
+ filtered("This is http://tmblr.co/Z0rNbyxhxUK5").should be_text("This is [http://tmblr.co/Z0rNbyxhxUK5]")
29
+ end
30
+
31
+ it "should expand nico.ms" do
32
+ filtered("This is http://nico.ms/sm11870888").should be_text("This is [http://nico.ms/sm11870888]")
19
33
  end
20
34
 
21
35
  it "should through other url" do
@@ -57,9 +71,26 @@ describe Atig::IFilter::ExpandUrl, "when has urls entities" do
57
71
  "urls" => [{
58
72
  "url" => "http://t.co/1Vyoux4kB8",
59
73
  "expanded_url" => "http://example.com/"
74
+ }, {
75
+ "url" => "http://t.co/V1441ye6g2",
76
+ "expanded_url" => "http://example.org/"
60
77
  }]
61
78
  }
62
79
  }
63
80
  filtered("http://t.co/1Vyoux4kB8", opts).should be_text("http://example.com/")
81
+ filtered("http://t.co/1Vyoux4kB8 http://t.co/V1441ye6g2", opts).should
82
+ be_text("http://example.com/ http://expmaple.org/")
83
+ end
84
+
85
+ it "should expand recursive shorten URL" do
86
+ opts = {
87
+ "entities" => {
88
+ "urls" => [{
89
+ "url" => "http://t.co/h8sqL5ZMuz",
90
+ "expanded_url" => "http://bit.ly/1LM4fW"
91
+ }]
92
+ }
93
+ }
94
+ filtered("http://t.co/h8sqL5ZMuz", opts).should be_text("[http://bit.ly/1LM4fW]")
64
95
  end
65
96
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - SHIBATA Hiroshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-13 00:00:00.000000000 Z
11
+ date: 2013-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -318,7 +318,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
318
318
  version: '0'
319
319
  requirements: []
320
320
  rubyforge_project:
321
- rubygems_version: 2.1.8
321
+ rubygems_version: 2.1.9
322
322
  signing_key:
323
323
  specification_version: 4
324
324
  summary: Atig.rb is forked from cho45's tig.rb. We improve some features of tig.rb.
@@ -366,4 +366,3 @@ test_files:
366
366
  - spec/sized_hash_spec.rb
367
367
  - spec/spec_helper.rb
368
368
  - spec/update_checker_spec.rb
369
- has_rdoc: