[DRE-commits] [atig] 01/03: Imported Upstream version 0.4.3

Youhei SASAKI uwabami-guest at alioth.debian.org
Wed Oct 30 15:25:57 UTC 2013


This is an automated email from the git hooks/post-receive script.

uwabami-guest pushed a commit to branch master
in repository atig.

commit 20a836d70f2140c2d33980a2c29e50dc785cb206
Author: Youhei SASAKI <uwabami at gfd-dennou.org>
Date:   Fri Oct 25 02:39:42 2013 +0900

    Imported Upstream version 0.4.3
---
 Gemfile.lock                     |   24 ++++++++-------
 checksums.yaml.gz                |  Bin 268 -> 267 bytes
 docs/options.rst                 |    5 +++
 lib/atig/agent/timeline.rb       |   11 +++++--
 lib/atig/ifilter/expand_url.rb   |   63 +++++++++++++++++++++++++-------------
 lib/atig/version.rb              |    2 +-
 metadata.yml                     |   48 ++++++++++++++---------------
 spec/command/destroy_spec.rb     |    6 ++--
 spec/command/favorite_spec.rb    |    2 +-
 spec/command/limit_spec.rb       |    6 ++--
 spec/command/option_spec.rb      |   32 +++++++++----------
 spec/command/reply_spec.rb       |    2 +-
 spec/command/retweet_spec.rb     |    8 ++---
 spec/command/thread_spec.rb      |    6 ++--
 spec/command/time_spec.rb        |    6 ++--
 spec/command/user_info_spec.rb   |    8 ++---
 spec/command/version_spec.rb     |   14 ++++-----
 spec/command/whois_spec.rb       |   28 ++++++++---------
 spec/command_helper.rb           |    8 ++---
 spec/db/sized_uniq_array_spec.rb |    4 +--
 spec/ifilter/expand_url_spec.rb  |   56 +++++++++++++++++++++++++++++++--
 spec/ifilter/sid_spec.rb         |    4 +--
 spec/ifilter/tid_spec.rb         |    4 +--
 spec/ofilter/escape_url_spec.rb  |    4 +--
 spec/ofilter/short_url_spec.rb   |   38 +++++++++++------------
 spec/spec_helper.rb              |   14 ++++-----
 spec/update_checker_spec.rb      |   20 ++++++------
 27 files changed, 254 insertions(+), 169 deletions(-)

diff --git a/Gemfile.lock b/Gemfile.lock
index fdeb08f..66684a7 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,7 +1,7 @@
 PATH
   remote: .
   specs:
-    atig (0.4.1)
+    atig (0.4.3)
       json
       net-irc
       oauth
@@ -11,17 +11,16 @@ PATH
 GEM
   remote: https://rubygems.org/
   specs:
-    colorize (0.5.8)
-    coveralls (0.6.7)
-      colorize
+    coveralls (0.7.0)
       multi_json (~> 1.3)
       rest-client
       simplecov (>= 0.7)
+      term-ansicolor
       thor
     diff-lcs (1.2.4)
-    json (1.8.0)
-    mime-types (1.23)
-    multi_json (1.7.7)
+    json (1.8.1)
+    mime-types (1.25)
+    multi_json (1.8.2)
     net-irc (0.0.9)
     oauth (0.4.7)
     rake (10.1.0)
@@ -31,16 +30,19 @@ GEM
       rspec-core (~> 2.14.0)
       rspec-expectations (~> 2.14.0)
       rspec-mocks (~> 2.14.0)
-    rspec-core (2.14.4)
-    rspec-expectations (2.14.0)
+    rspec-core (2.14.6)
+    rspec-expectations (2.14.3)
       diff-lcs (>= 1.1.3, < 2.0)
-    rspec-mocks (2.14.2)
+    rspec-mocks (2.14.4)
     simplecov (0.7.1)
       multi_json (~> 1.0)
       simplecov-html (~> 0.7.1)
     simplecov-html (0.7.1)
-    sqlite3 (1.3.7)
+    sqlite3 (1.3.8)
+    term-ansicolor (1.2.2)
+      tins (~> 0.8)
     thor (0.18.1)
+    tins (0.12.0)
 
 PLATFORMS
   ruby
diff --git a/checksums.yaml.gz b/checksums.yaml.gz
index 54ab88e..5d9eb90 100644
Binary files a/checksums.yaml.gz and b/checksums.yaml.gz differ
diff --git a/docs/options.rst b/docs/options.rst
index 022ce83..3b811a8 100644
--- a/docs/options.rst
+++ b/docs/options.rst
@@ -36,12 +36,17 @@ only
 
 発言関連
 ------------------------------
+stream
+  `UserStream`_ を有効にします。
+  実行中の変更には対応していません。
 footer=\ ``footer``
   発言の末尾に、 ``footer`` を追加します。
   ただし ``footer`` がfalseの場合は、追加しません。
 old_style_reply
   @nickで始まる発言が、@nick の最新の発言へのreplyとなるモードに切り替えます。
 
+.. _UserStream: https://dev.twitter.com/docs/streaming-apis/streams/user
+
 URL短縮関係
 ------------------------------
 
diff --git a/lib/atig/agent/timeline.rb b/lib/atig/agent/timeline.rb
index 4f4ce88..389ad8e 100644
--- a/lib/atig/agent/timeline.rb
+++ b/lib/atig/agent/timeline.rb
@@ -4,11 +4,18 @@ require 'atig/agent/agent'
 module Atig
   module Agent
     class Timeline < Atig::Agent::Agent
+      DEFAULT_INTERVAL = 60
+
       def initialize(context, api, db)
-        return if context.opts.stream
+        @opts = context.opts
+        return if @opts.stream
         super
       end
-      def interval; 30 end
+
+      def interval
+        @interval ||= @opts.interval.nil? ? DEFAULT_INTERVAL : @opts.interval.to_i
+      end
+
       def path; '/statuses/home_timeline' end
       def source; :timeline end
     end
diff --git a/lib/atig/ifilter/expand_url.rb b/lib/atig/ifilter/expand_url.rb
index 882e302..7b93a3b 100644
--- a/lib/atig/ifilter/expand_url.rb
+++ b/lib/atig/ifilter/expand_url.rb
@@ -16,33 +16,52 @@ module Atig
       end
 
       def call(status)
-        target = if @opts.untiny_whole_urls then
-                   URI.regexp(%w[http https])
-                 else
-                   %r{
-			http:// (?:
-				(?: bit\.ly | (?: tin | rub) yurl\.com | j\.mp | t\.co
-                                  | htn.to
-				  | is\.gd | cli\.gs | tr\.im | u\.nu | airme\.us
-				  | ff\.im | twurl.nl | bkite\.com | tumblr\.com
-				  | pic\.gd | sn\.im | digg\.com | goo\.gl)
-				/ [0-9a-z=-]+ |
-				blip\.fm/~ (?> [0-9a-z]+) (?! /) |
-				flic\.kr/[a-z0-9/]+
-			)
-		   }ix
-                 end
-
+        target = short_url_regexp
+        entities = (entities = status.entities).nil? ? [] : entities.urls
         status.merge :text => status.text.gsub(target) {|url|
-          x = @cache[url]
-          if x then
-            x
-          else
-            @cache[url] = resolve_http_redirect(URI(url)).to_s || url
+          unless entities.nil? or entities.empty?
+            @cache[url] ||= search_url_from_entities(url, entities)
+            url = @cache[url] if @cache[url] =~ target
           end
+          @cache[url] ||= resolve_http_redirect(URI(url)).to_s || url
         }
       end
 
+      private
+
+      def short_url_regexp
+        return URI.regexp(%w[http https]) if @opts.untiny_whole_urls
+        %r{
+          https?:// (?:
+                    (?: t (?: mblr )? \.co
+                      | (?: bitly | bkite | digg | tumblr | (?: tin | rub ) yurl ) \.com
+                      | (?: is | pic ) \.gd
+                      | goo\.gl
+                      | cli\.gs
+                      | (?: ff | sn | tr ) \.im
+                      | bit\.ly
+                      | j\.mp
+                      | nico\.ms
+                      | airme\.us
+                      | twurl\.nl
+                      | u\.nu
+                      | htn\.to)
+                    / [0-9a-z=-]+ |
+                    blip\.fm/~ (?> [0-9a-z]+) (?! /) |
+                    flic\.kr/[a-z0-9/]+
+          )
+        }ix
+      end
+
+      def search_url_from_entities(url, entities)
+        expanded_url = nil
+        entities.reject! do |entity|
+          entity.url == url &&
+            (expanded_url = entity.expanded_url)
+        end
+        expanded_url
+      end
+
       def resolve_http_redirect(uri, limit = 3)
         return uri if limit.zero? or uri.nil?
         log :debug, uri.inspect
diff --git a/lib/atig/version.rb b/lib/atig/version.rb
index ac189a9..69f9502 100644
--- a/lib/atig/version.rb
+++ b/lib/atig/version.rb
@@ -1,3 +1,3 @@
 module Atig
-  VERSION = "0.4.1"
+  VERSION = "0.4.3"
 end
diff --git a/metadata.yml b/metadata.yml
index 196d4ef..e6eed77 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -1,125 +1,125 @@
 --- !ruby/object:Gem::Specification
 name: atig
 version: !ruby/object:Gem::Version
-  version: 0.4.1
+  version: 0.4.3
 platform: ruby
 authors:
 - SHIBATA Hiroshi
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2013-08-02 00:00:00.000000000 Z
+date: 2013-10-18 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: sqlite3
   requirement: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: 1.3.2
   type: :runtime
   prerelease: false
   version_requirements: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: 1.3.2
 - !ruby/object:Gem::Dependency
   name: net-irc
   requirement: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: '0'
   type: :runtime
   prerelease: false
   version_requirements: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: '0'
 - !ruby/object:Gem::Dependency
   name: oauth
   requirement: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: '0'
   type: :runtime
   prerelease: false
   version_requirements: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: '0'
 - !ruby/object:Gem::Dependency
   name: rake
   requirement: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: '0'
   type: :runtime
   prerelease: false
   version_requirements: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: '0'
 - !ruby/object:Gem::Dependency
   name: json
   requirement: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: '0'
   type: :runtime
   prerelease: false
   version_requirements: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: '0'
 - !ruby/object:Gem::Dependency
   name: bundler
   requirement: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: '0'
   type: :development
   prerelease: false
   version_requirements: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: '0'
 - !ruby/object:Gem::Dependency
   name: rspec
   requirement: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: '0'
   type: :development
   prerelease: false
   version_requirements: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: '0'
 - !ruby/object:Gem::Dependency
   name: coveralls
   requirement: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: '0'
   type: :development
   prerelease: false
   version_requirements: !ruby/object:Gem::Requirement
     requirements:
-    - - '>='
+    - - ">="
       - !ruby/object:Gem::Version
         version: '0'
 description: Atig.rb is Twitter Irc Gateway.
@@ -130,9 +130,9 @@ executables:
 extensions: []
 extra_rdoc_files: []
 files:
-- .gitignore
-- .rspec
-- .travis.yml
+- ".gitignore"
+- ".rspec"
+- ".travis.yml"
 - Gemfile
 - Gemfile.lock
 - README.mkdn
@@ -308,17 +308,17 @@ require_paths:
 - lib
 required_ruby_version: !ruby/object:Gem::Requirement
   requirements:
-  - - '>='
+  - - ">="
     - !ruby/object:Gem::Version
       version: '0'
 required_rubygems_version: !ruby/object:Gem::Requirement
   requirements:
-  - - '>='
+  - - ">="
     - !ruby/object:Gem::Version
       version: '0'
 requirements: []
 rubyforge_project: 
-rubygems_version: 2.0.6
+rubygems_version: 2.1.9
 signing_key: 
 specification_version: 4
 summary: Atig.rb is forked from cho45's tig.rb. We improve some features of tig.rb.
diff --git a/spec/command/destroy_spec.rb b/spec/command/destroy_spec.rb
index bf58eca..169819a 100644
--- a/spec/command/destroy_spec.rb
+++ b/spec/command/destroy_spec.rb
@@ -12,7 +12,7 @@ describe Atig::Command::Destroy,"when status is not removed" do
 
   it "should specified other's status" do
     entry  = entry user(2,'other'), status('blah blah', 'id'=>'1')
-    @statuses.stub!(:find_by_tid).with('b').and_return(entry)
+    @statuses.stub(:find_by_tid).with('b').and_return(entry)
 
     @channel.should_receive(:notify).with("The status you specified by the ID tid is not yours.")
     call "#twitter","destory",%w(b)
@@ -27,7 +27,7 @@ describe Atig::Command::Destroy,"when remove recently tweet" do
 
     target = status 'blah blah', 'id'=>'1'
     entry  = entry @me, target,'entry',1
-    @res   = mock 'res'
+    @res   = double 'res'
 
     stub_status(:find_by_tid,'a' => entry)
     stub_status(:find_by_sid,'mzp:a' => entry)
@@ -71,7 +71,7 @@ describe Atig::Command::Destroy,"when remove old tweet" do
 
     target = status 'blah blah', 'id'=>'1'
     entry  = entry @me, target,'entry',1
-    @res   = mock 'res'
+    @res   = double 'res'
 
     stub_status(:find_by_tid,'a' => entry)
     stub_status(:find_by_sid,'mzp:a' => entry)
diff --git a/spec/command/favorite_spec.rb b/spec/command/favorite_spec.rb
index b1ae024..a01ceed 100644
--- a/spec/command/favorite_spec.rb
+++ b/spec/command/favorite_spec.rb
@@ -10,7 +10,7 @@ describe Atig::Command::Favorite do
 
     target = status 'blah blah', 'id'=>'1'
     entry  = entry user(1,'mzp'), target
-    @res   = mock 'res'
+    @res   = double 'res'
 
     stub_status(:find_by_tid,'a' => entry)
     stub_status(:find_by_sid,'mzp:a' => entry)
diff --git a/spec/command/limit_spec.rb b/spec/command/limit_spec.rb
index ba7b180..5de9de8 100644
--- a/spec/command/limit_spec.rb
+++ b/spec/command/limit_spec.rb
@@ -9,9 +9,9 @@ describe Atig::Command::Limit do
   before do
     @reset = ::Time.utc(2010,9,25,8,24,12)
     @command = init Atig::Command::Limit
-    @api.stub!(:limit).and_return(150)
-    @api.stub!(:remain).and_return(148)
-    @api.stub!(:reset).and_return(@reset)
+    @api.stub(:limit).and_return(150)
+    @api.stub(:remain).and_return(148)
+    @api.stub(:reset).and_return(@reset)
   end
 
   it "should provide limit command" do
diff --git a/spec/command/option_spec.rb b/spec/command/option_spec.rb
index b998ec6..8a9c9d7 100644
--- a/spec/command/option_spec.rb
+++ b/spec/command/option_spec.rb
@@ -24,14 +24,14 @@ describe Atig::Command::Option, 'when have many property' do
     @opts.foo2 = 42
     @opts.foo3 = 42.1
 
-    @opts.stub!(:foo1=)
-    @opts.stub!(:foo2=)
-    @opts.stub!(:foo3=)
+    @opts.stub(:foo1=)
+    @opts.stub(:foo2=)
+    @opts.stub(:foo3=)
   end
 
   it "should list up values" do
     xs = []
-    @channel.stub!(:notify){|x| xs << x}
+    @channel.stub(:notify){|x| xs << x}
     call '#twitter', 'opt', %w()
     xs.should == [
                   "foo1 => true",
@@ -47,9 +47,9 @@ describe Atig::Command::Option, 'when have bool property' do
 
   before do
     @command = init Atig::Command::Option
-    @opts.stub!(:foo).and_return true
-    @opts.stub!(:foo=){|v| @value = v }
-    @channel.stub!(:notify)
+    @opts.stub(:foo).and_return true
+    @opts.stub(:foo=){|v| @value = v }
+    @channel.stub(:notify)
   end
 
   it "should show the value" do
@@ -68,9 +68,9 @@ describe Atig::Command::Option, 'when have int property' do
 
   before do
     @command = init Atig::Command::Option
-    @opts.stub!(:foo).and_return 42
-    @opts.stub!(:foo=){|v| @value = v }
-    @channel.stub!(:notify)
+    @opts.stub(:foo).and_return 42
+    @opts.stub(:foo=){|v| @value = v }
+    @channel.stub(:notify)
   end
 
   it "should show the value" do
@@ -89,9 +89,9 @@ describe Atig::Command::Option, 'when have float property' do
 
   before do
     @command = init Atig::Command::Option
-    @opts.stub!(:foo).and_return 1.23
-    @opts.stub!(:foo=){|v| @value = v }
-    @channel.stub!(:notify)
+    @opts.stub(:foo).and_return 1.23
+    @opts.stub(:foo=){|v| @value = v }
+    @channel.stub(:notify)
   end
 
   it "should show the value" do
@@ -110,9 +110,9 @@ describe Atig::Command::Option, 'when have string property' do
 
   before do
     @command = init Atig::Command::Option
-    @opts.stub!(:foo).and_return "bar"
-    @opts.stub!(:foo=){|v| @value = v }
-    @channel.stub!(:notify)
+    @opts.stub(:foo).and_return "bar"
+    @opts.stub(:foo=){|v| @value = v }
+    @channel.stub(:notify)
   end
 
   it "should show the value" do
diff --git a/spec/command/reply_spec.rb b/spec/command/reply_spec.rb
index 18038a0..f893403 100644
--- a/spec/command/reply_spec.rb
+++ b/spec/command/reply_spec.rb
@@ -10,7 +10,7 @@ describe Atig::Command::Reply do
 
     target = status 'blah blah', 'id'=>'1'
     entry  = entry user(1,'mzp'), target
-    @res   = mock 'res'
+    @res   = double 'res'
 
     stub_status(:find_by_tid,'a' => entry)
     stub_status(:find_by_sid,'mzp:a' => entry)
diff --git a/spec/command/retweet_spec.rb b/spec/command/retweet_spec.rb
index a7ed44e..d3f31bf 100644
--- a/spec/command/retweet_spec.rb
+++ b/spec/command/retweet_spec.rb
@@ -6,17 +6,17 @@ require 'atig/command/retweet'
 describe Atig::Command::Retweet do
   include CommandHelper
   before do
-    bitly =  mock("Bitly")
-    bitly.stub!(:shorten).and_return{|s|
+    bitly =  double("Bitly")
+    bitly.stub(:shorten).and_return{|s|
       "[#{s}]"
     }
-    Atig::Bitly.stub!(:no_login).and_return(bitly)
+    Atig::Bitly.stub(:no_login).and_return(bitly)
 
     @command = init Atig::Command::Retweet
 
     target = status 'blah blah blah blah blah blah blah blah', 'id'=>'1'
     entry  = entry user(1,'mzp'), target
-    @res   = mock 'res'
+    @res   = double 'res'
 
     stub_status(:find_by_tid,'a' => entry)
     stub_status(:find_by_sid,'mzp:a' => entry)
diff --git a/spec/command/thread_spec.rb b/spec/command/thread_spec.rb
index 2e31f22..adde583 100644
--- a/spec/command/thread_spec.rb
+++ b/spec/command/thread_spec.rb
@@ -6,7 +6,7 @@ require 'atig/command/thread'
 describe Atig::Command::Thread do
   include CommandHelper
   before do
-    u = mock 'user'
+    u = double 'user'
     @entries = [
                 entry(u, status(''),'entry-0'),
                 entry(u, status('','in_reply_to_status_id'=>2),'entry-1'),
@@ -16,10 +16,10 @@ describe Atig::Command::Thread do
                ]
     @command = init Atig::Command::Thread
     @messages = []
-    @channel.stub!(:message).and_return{|entry,_|
+    @channel.stub(:message).and_return{|entry,_|
       @messages.unshift entry
     }
-    @statuses.stub!(:find_by_status_id).with(anything).and_return{|id|
+    @statuses.stub(:find_by_status_id).with(anything).and_return{|id|
       @entries[id.to_i]
     }
   end
diff --git a/spec/command/time_spec.rb b/spec/command/time_spec.rb
index 5d1f93c..5c46b32 100644
--- a/spec/command/time_spec.rb
+++ b/spec/command/time_spec.rb
@@ -7,9 +7,9 @@ describe Atig::Command::Time do
   include CommandHelper
 
   def user(offset, tz)
-    u = mock "user-#{offset}"
-    u.stub!(:utc_offset).and_return(offset)
-    u.stub!(:time_zone).and_return(tz)
+    u = double "user-#{offset}"
+    u.stub(:utc_offset).and_return(offset)
+    u.stub(:time_zone).and_return(tz)
     u
   end
 
diff --git a/spec/command/user_info_spec.rb b/spec/command/user_info_spec.rb
index d6da95e..37acc76 100644
--- a/spec/command/user_info_spec.rb
+++ b/spec/command/user_info_spec.rb
@@ -8,10 +8,10 @@ describe Atig::Command::UserInfo do
 
   before do
     @command = init Atig::Command::UserInfo
-    @status  = stub "status"
-    @user    = stub "user"
-    @user.stub!(:description).and_return('hogehoge')
-    @user.stub!(:status).and_return(@status)
+    @status  = double "status"
+    @user    = double "user"
+    @user.stub(:description).and_return('hogehoge')
+    @user.stub(:status).and_return(@status)
   end
 
   it "should show the source via DB" do
diff --git a/spec/command/version_spec.rb b/spec/command/version_spec.rb
index 2425e72..908a19f 100644
--- a/spec/command/version_spec.rb
+++ b/spec/command/version_spec.rb
@@ -8,10 +8,10 @@ describe Atig::Command::Version do
 
   before do
     @command = init Atig::Command::Version
-    @status  = stub "status"
-    @status.stub!(:source).and_return('<a href="http://echofon.com/" rel="nofollow">Echofon</a>')
-    @user    = stub "user"
-    @user.stub!(:status).and_return(@status)
+    @status  = double "status"
+    @status.stub(:source).and_return('<a href="http://echofon.com/" rel="nofollow">Echofon</a>')
+    @user    = double "user"
+    @user.stub(:status).and_return(@status)
   end
 
   it "should provide version command" do
@@ -33,8 +33,8 @@ describe Atig::Command::Version do
   end
 
   it "should show the source of web" do
-    status  = stub "status"
-    status.stub!(:source).and_return('web')
+    status  = double "status"
+    status.stub(:source).and_return('web')
     @statuses.
       should_receive(:find_by_screen_name).
       with('mzp',:limit => 1).
@@ -49,7 +49,7 @@ describe Atig::Command::Version do
   end
 
   it "should show the source via API" do
-    @statuses.stub!(:find_by_screen_name).and_return(@status)
+    @statuses.stub(:find_by_screen_name).and_return(@status)
     @statuses.should_receive(:find_by_screen_name).with('mzp',:limit => 1).and_return(nil)
     @statuses.should_receive(:add).with(:status => @status, :user => @user, :source=>:version)
     @api.should_receive(:get).with('users/show',:screen_name=>'mzp').and_return(@user)
diff --git a/spec/command/whois_spec.rb b/spec/command/whois_spec.rb
index dc0b5da..14e25bd 100644
--- a/spec/command/whois_spec.rb
+++ b/spec/command/whois_spec.rb
@@ -16,20 +16,20 @@ describe Atig::Command::Whois do
 
   before do
     @command = init Atig::Command::Whois
-    @status  = stub 'status'
-    @status.stub!(:created_at).and_return(time(::Time.at(42)))
-    @user    = stub "user"
-    @user.stub!(:name)       .and_return('name')
-    @user.stub!(:id)         .and_return('10')
-    @user.stub!(:screen_name).and_return('screen_name')
-    @user.stub!(:description).and_return('blah blah')
-    @user.stub!(:protected)  .and_return(false)
-    @user.stub!(:location)   .and_return('Tokyo, Japan')
-    @user.stub!(:created_at) .and_return(time(::Time.at(0)))
-    @user.stub!(:status)     .and_return(@status)
+    @status  = double 'status'
+    @status.stub(:created_at).and_return(time(::Time.at(42)))
+    @user    = double "user"
+    @user.stub(:name)       .and_return('name')
+    @user.stub(:id)         .and_return('10')
+    @user.stub(:screen_name).and_return('screen_name')
+    @user.stub(:description).and_return('blah blah')
+    @user.stub(:protected)  .and_return(false)
+    @user.stub(:location)   .and_return('Tokyo, Japan')
+    @user.stub(:created_at) .and_return(time(::Time.at(0)))
+    @user.stub(:status)     .and_return(@status)
 
-    ::Time.stub!(:now).and_return(::Time.at(50))
-    @followings.stub!(:find_by_screen_name).with('mzp').and_return(@user)
+    ::Time.stub(:now).and_return(::Time.at(50))
+    @followings.stub(:find_by_screen_name).with('mzp').and_return(@user)
   end
 
   it "should proide whois command" do
@@ -56,7 +56,7 @@ describe Atig::Command::Whois do
   end
 
   it "should append /protect if the user is protected" do
-    @user.stub!(:protected).and_return(true)
+    @user.stub(:protected).and_return(true)
     commands = []
     @gateway.should_receive(:post){|_,command,_,_,*params|
       commands << command
diff --git a/spec/command_helper.rb b/spec/command_helper.rb
index 6daa888..a73c831 100644
--- a/spec/command_helper.rb
+++ b/spec/command_helper.rb
@@ -64,13 +64,13 @@ end
 
 module CommandHelper
   def init(klass)
-    @log    = mock 'log'
+    @log    = double 'log'
     @opts   = Atig::Option.new({})
     context = OpenStruct.new :log=>@log, :opts=>@opts
 
-    @channel    = mock 'channel'
+    @channel    = double 'channel'
     @gateway    = FakeGateway.new @channel
-    @api        = mock 'api'
+    @api        = double 'api'
     @statuses   = FakeDbEntry.new 'status DB'
     @followings = FakeDbEntry.new 'followings DB'
     @lists      = {
@@ -88,7 +88,7 @@ module CommandHelper
   end
 
   def stub_status(key, hash)
-    @statuses.stub!(key).and_return{|arg,*_|
+    @statuses.stub(key).and_return{|arg,*_|
       hash.fetch(arg, hash[:default])
     }
   end
diff --git a/spec/db/sized_uniq_array_spec.rb b/spec/db/sized_uniq_array_spec.rb
index e2c9f2e..8dc1b84 100644
--- a/spec/db/sized_uniq_array_spec.rb
+++ b/spec/db/sized_uniq_array_spec.rb
@@ -6,8 +6,8 @@ require 'ostruct'
 
 describe Atig::Db::SizedUniqArray do
   def item(id)
-    item = stub "Item-#{id}"
-    item.stub!(:id).and_return id
+    item = double "Item-#{id}"
+    item.stub(:id).and_return id
     item
   end
 
diff --git a/spec/ifilter/expand_url_spec.rb b/spec/ifilter/expand_url_spec.rb
index 8f40f45..62f3d88 100644
--- a/spec/ifilter/expand_url_spec.rb
+++ b/spec/ifilter/expand_url_spec.rb
@@ -10,12 +10,26 @@ end
 
 describe Atig::IFilter::ExpandUrl, "when disable whole url" do
   def filtered(text)
-    ifilter = Atig::IFilter::ExpandUrl.new OpenStruct.new(:log=>mock('log'),:opts=>OpenStruct.new)
+    ifilter = Atig::IFilter::ExpandUrl.new OpenStruct.new(:log=>double('log'),:opts=>OpenStruct.new)
     ifilter.call status(text)
   end
 
   it "should expand bit.ly" do
     filtered("This is http://bit.ly/hoge").should be_text("This is [http://bit.ly/hoge]")
+    filtered("This is http://bitly.com/hoge").should be_text("This is [http://bitly.com/hoge]")
+  end
+
+  it "should expand htn.to" do
+    filtered("This is http://htn.to/TZdkXg").should be_text("This is [http://htn.to/TZdkXg]")
+    filtered("This is http://htnnto/TZdkXg").should be_text("This is http://htnnto/TZdkXg")
+  end
+
+  it "should expand tmblr.co" do
+    filtered("This is http://tmblr.co/Z0rNbyxhxUK5").should be_text("This is [http://tmblr.co/Z0rNbyxhxUK5]")
+  end
+
+  it "should expand nico.ms" do
+    filtered("This is http://nico.ms/sm11870888").should be_text("This is [http://nico.ms/sm11870888]")
   end
 
   it "should through other url" do
@@ -26,7 +40,7 @@ end
 describe Atig::IFilter::ExpandUrl, "when enable whole url" do
   def filtered(text)
     context = OpenStruct.new(
-                             :log  => mock('log'),
+                             :log  => double('log'),
                              :opts => OpenStruct.new(:untiny_whole_urls=>true))
     ifilter = Atig::IFilter::ExpandUrl.new(context)
     ifilter.call status(text)
@@ -42,3 +56,41 @@ describe Atig::IFilter::ExpandUrl, "when enable whole url" do
   end
 end
 
+describe Atig::IFilter::ExpandUrl, "when has urls entities" do
+  def filtered(text, opts)
+    context = OpenStruct.new(
+                             :log => double('log'),
+                             :opts => OpenStruct.new)
+    ifilter = Atig::IFilter::ExpandUrl.new(context)
+    ifilter.call status(text, opts)
+  end
+
+  it "should expand t.co" do
+    opts = {
+      "entities" => {
+        "urls" => [{
+          "url" => "http://t.co/1Vyoux4kB8",
+          "expanded_url" => "http://example.com/"
+        }, {
+          "url" => "http://t.co/V1441ye6g2",
+          "expanded_url" => "http://example.org/"
+        }]
+      }
+    }
+    filtered("http://t.co/1Vyoux4kB8", opts).should be_text("http://example.com/")
+    filtered("http://t.co/1Vyoux4kB8 http://t.co/V1441ye6g2", opts).should
+      be_text("http://example.com/ http://expmaple.org/")
+  end
+
+  it "should expand recursive shorten URL" do
+    opts = {
+      "entities" => {
+        "urls" => [{
+          "url" => "http://t.co/h8sqL5ZMuz",
+          "expanded_url" => "http://bit.ly/1LM4fW"
+        }]
+      }
+    }
+    filtered("http://t.co/h8sqL5ZMuz", opts).should be_text("[http://bit.ly/1LM4fW]")
+  end
+end
diff --git a/spec/ifilter/sid_spec.rb b/spec/ifilter/sid_spec.rb
index 3041065..18c1e41 100644
--- a/spec/ifilter/sid_spec.rb
+++ b/spec/ifilter/sid_spec.rb
@@ -6,7 +6,7 @@ require 'atig/twitter_struct'
 
 describe Atig::IFilter::Sid, "when disable tid" do
   def filtered(text)
-    ifilter = Atig::IFilter::Sid.new(OpenStruct.new(:log=>mock('log'),
+    ifilter = Atig::IFilter::Sid.new(OpenStruct.new(:log=>double('log'),
                                                     :opts=>OpenStruct.new))
     ifilter.call status(text,'sid'=>1)
   end
@@ -18,7 +18,7 @@ end
 
 describe Atig::IFilter::Sid, "when enable tid" do
   def filtered(text)
-    ifilter = Atig::IFilter::Sid.new(OpenStruct.new(:log=>mock('log'),
+    ifilter = Atig::IFilter::Sid.new(OpenStruct.new(:log=>double('log'),
                                                     :opts=>OpenStruct.new(:sid=>true)))
     ifilter.call status(text,'sid'=>1)
   end
diff --git a/spec/ifilter/tid_spec.rb b/spec/ifilter/tid_spec.rb
index 5ac48e8..8bb8ca6 100644
--- a/spec/ifilter/tid_spec.rb
+++ b/spec/ifilter/tid_spec.rb
@@ -6,7 +6,7 @@ require 'atig/twitter_struct'
 
 describe Atig::IFilter::Tid, "when disable tid" do
   def filtered(text)
-    ifilter = Atig::IFilter::Tid.new(OpenStruct.new(:log=>mock('log'),
+    ifilter = Atig::IFilter::Tid.new(OpenStruct.new(:log=>double('log'),
                                                     :opts=>OpenStruct.new))
     ifilter.call status(text,'tid'=>1)
   end
@@ -18,7 +18,7 @@ end
 
 describe Atig::IFilter::Tid, "when enable tid" do
   def filtered(text)
-    ifilter = Atig::IFilter::Tid.new(OpenStruct.new(:log=>mock('log'),
+    ifilter = Atig::IFilter::Tid.new(OpenStruct.new(:log=>double('log'),
                                                     :opts=>OpenStruct.new(:tid=>true)))
     ifilter.call status(text,'tid'=>1)
   end
diff --git a/spec/ofilter/escape_url_spec.rb b/spec/ofilter/escape_url_spec.rb
index 4ce94cb..3410898 100644
--- a/spec/ofilter/escape_url_spec.rb
+++ b/spec/ofilter/escape_url_spec.rb
@@ -9,7 +9,7 @@ end
 
 describe Atig::OFilter::EscapeUrl do
   before do
-    @logger = mock('Logger')
+    @logger = double('Logger')
     @logger.should_receive(:info).at_most(:once)
     @logger.should_receive(:error).at_most(:once)
     @logger.should_receive(:debug).at_most(:once)
@@ -32,7 +32,7 @@ end
 if defined? ::Punycode then
   describe Atig::OFilter::EscapeUrl,"when punycode is enabled" do
     before do
-      @logger = mock('Logger')
+      @logger = double('Logger')
       @logger.should_receive(:info).at_most(:once)
       @logger.should_receive(:error).at_most(:once)
       @logger.should_receive(:debug).at_most(:once)
diff --git a/spec/ofilter/short_url_spec.rb b/spec/ofilter/short_url_spec.rb
index 6967a73..a305cbd 100644
--- a/spec/ofilter/short_url_spec.rb
+++ b/spec/ofilter/short_url_spec.rb
@@ -6,9 +6,9 @@ require 'ostruct'
 
 describe Atig::OFilter::ShortUrl,"when no-login bitly" do
   before do
-    logger = mock('Logger')
-    bitly =  mock("Bitly")
-    bitly.stub!(:shorten).and_return{|s|
+    logger = double('Logger')
+    bitly =  double("Bitly")
+    bitly.stub(:shorten).and_return{|s|
       "[#{s}]"
     }
     Atig::Bitly.should_receive(:no_login).with(logger).and_return(bitly)
@@ -24,9 +24,9 @@ end
 
 describe Atig::OFilter::ShortUrl,"when no-login bitly with size" do
   before do
-    logger = mock('Logger')
-    bitly =  mock("Bitly")
-    bitly.stub!(:shorten).and_return{|s|
+    logger = double('Logger')
+    bitly =  double("Bitly")
+    bitly.stub(:shorten).and_return{|s|
       "[#{s}]"
     }
     Atig::Bitly.should_receive(:no_login).with(logger).and_return(bitly)
@@ -42,9 +42,9 @@ end
 
 describe Atig::OFilter::ShortUrl,"when login bitly" do
   before do
-    logger = mock('Logger')
-    bitly =  mock("Bitly")
-    bitly.stub!(:shorten).and_return{|s|
+    logger = double('Logger')
+    bitly =  double("Bitly")
+    bitly.stub(:shorten).and_return{|s|
       "[#{s}]"
     }
     Atig::Bitly.should_receive(:login).with(logger,"username","api_key").and_return(bitly)
@@ -60,9 +60,9 @@ end
 
 describe Atig::OFilter::ShortUrl,"when login bitly with size" do
   before do
-    logger = mock('Logger')
-    bitly =  mock("Bitly")
-    bitly.stub!(:shorten).and_return{|s|
+    logger = double('Logger')
+    bitly =  double("Bitly")
+    bitly.stub(:shorten).and_return{|s|
       "[#{s}]"
     }
     Atig::Bitly.should_receive(:login).with(logger,"username","api_key").and_return(bitly)
@@ -78,9 +78,9 @@ end
 
 describe Atig::OFilter::ShortUrl,"when unu bitly" do
   before do
-    logger = mock('Logger')
-    unu =  mock("Unu")
-    unu.stub!(:shorten).and_return{|s|
+    logger = double('Logger')
+    unu =  double("Unu")
+    unu.stub(:shorten).and_return{|s|
       "[#{s}]"
     }
     Atig::Unu.should_receive(:new).with(logger).and_return(unu)
@@ -96,9 +96,9 @@ end
 
 describe Atig::OFilter::ShortUrl,"when no-login unu with size" do
   before do
-    logger = mock('Logger')
-    unu =  mock("Unu")
-    unu.stub!(:shorten).and_return{|s|
+    logger = double('Logger')
+    unu =  double("Unu")
+    unu.stub(:shorten).and_return{|s|
       "[#{s}]"
     }
     Atig::Unu.should_receive(:new).with(logger).and_return(unu)
@@ -114,7 +114,7 @@ end
 
 describe Atig::OFilter::ShortUrl,"when nop" do
   before do
-    logger = mock('Logger')
+    logger = double('Logger')
 
     @ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(:log=>logger, :opts=>OpenStruct.new()))
   end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index baf8908..c85417a 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -19,17 +19,17 @@ def status(text, opt = {})
 end
 
 def user(id, name)
-  user = stub("User-#{name}")
-  user.stub!(:id).and_return(id)
-  user.stub!(:screen_name).and_return(name)
+  user = double("User-#{name}")
+  user.stub(:id).and_return(id)
+  user.stub(:screen_name).and_return(name)
   user
 end
 
 def entry(user, status, name = 'entry', id = 0)
-  entry = stub name
-  entry.stub!('id').and_return(id)
-  entry.stub!('user').and_return(user)
-  entry.stub!('status').and_return(status)
+  entry = double name
+  entry.stub('id').and_return(id)
+  entry.stub('user').and_return(user)
+  entry.stub('status').and_return(status)
   entry
 end
 
diff --git a/spec/update_checker_spec.rb b/spec/update_checker_spec.rb
index 7d35183..1ad54c9 100644
--- a/spec/update_checker_spec.rb
+++ b/spec/update_checker_spec.rb
@@ -13,8 +13,8 @@ describe Atig::UpdateChecker,'when use git version' do
   end
 
   before do
-    Atig::UpdateChecker.stub!(:git?).and_return(true)
-    Atig::UpdateChecker.stub!(:commits).
+    Atig::UpdateChecker.stub(:git?).and_return(true)
+    Atig::UpdateChecker.stub(:commits).
       and_return [
                   commit('a', 'foo'),
                   commit('b', 'bar'),
@@ -25,29 +25,29 @@ describe Atig::UpdateChecker,'when use git version' do
   end
 
   it "should not do anything when use HEAD version" do
-    Atig::UpdateChecker.stub!(:local_repos?).and_return true
-    Atig::UpdateChecker.stub!(:server_version).and_return rev('a')
+    Atig::UpdateChecker.stub(:local_repos?).and_return true
+    Atig::UpdateChecker.stub(:server_version).and_return rev('a')
 
     Atig::UpdateChecker.latest.should == []
   end
 
   it "should notify when not use HEAD version" do
-    Atig::UpdateChecker.stub!(:local_repos?).and_return false
-    Atig::UpdateChecker.stub!(:server_version).and_return rev('b')
+    Atig::UpdateChecker.stub(:local_repos?).and_return false
+    Atig::UpdateChecker.stub(:server_version).and_return rev('b')
 
     Atig::UpdateChecker.latest.should == [ 'foo' ]
   end
 
   it "should notify many changes" do
-    Atig::UpdateChecker.stub!(:local_repos?).and_return false
-    Atig::UpdateChecker.stub!(:server_version).and_return rev('d')
+    Atig::UpdateChecker.stub(:local_repos?).and_return false
+    Atig::UpdateChecker.stub(:server_version).and_return rev('d')
 
     Atig::UpdateChecker.latest.should == [ 'foo', 'bar', 'baz' ]
   end
 
   it "should notify all changes" do
-    Atig::UpdateChecker.stub!(:local_repos?).and_return false
-    Atig::UpdateChecker.stub!(:server_version).and_return rev('z')
+    Atig::UpdateChecker.stub(:local_repos?).and_return false
+    Atig::UpdateChecker.stub(:server_version).and_return rev('z')
 
     Atig::UpdateChecker.latest.should == [ 'foo', 'bar', 'baz', 'xyzzy', 'fuga' ]
   end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/atig.git



More information about the Pkg-ruby-extras-commits mailing list