Skip to content
This repository
  • 5 commits
  • 11 files changed
  • 0 comments
  • 1 contributor
May 31, 2012
Erik Michaels-Ober Remove dependency on activesupport for except
Progress toward #264.
9019137
Erik Michaels-Ober Remove dependency on activesupport for each_with_object compatibility…
… in Ruby 1.8

Use Enumerable#inject instead. This change can be reverted when the
required Ruby version >= 1.9.

Progress toward #264.
6052252
Erik Michaels-Ober Remove dependency on activesupport for camelize
Progress toward #264.
538cd2f
Erik Michaels-Ober Remove dependency on activesupport for singleton_class
This change can be reverted when the required Ruby version >= 1.9.

Closes #264.
2ed9db2
Erik Michaels-Ober Bump version to 2.5.0 13a0b80
5  lib/twitter/action_factory.rb
... ...
@@ -1,6 +1,6 @@
1  
-require 'active_support/core_ext/string/inflections'
2 1
 require 'twitter/favorite'
3 2
 require 'twitter/follow'
  3
+require 'twitter/inflector'
4 4
 require 'twitter/list_member_added'
5 5
 require 'twitter/mention'
6 6
 require 'twitter/reply'
@@ -8,6 +8,7 @@
8 8
 
9 9
 module Twitter
10 10
   class ActionFactory
  11
+    extend Twitter::Inflector
11 12
 
12 13
     # Instantiates a new action object
13 14
     #
@@ -17,7 +18,7 @@ class ActionFactory
17 18
     def self.new(action={})
18 19
       type = action.delete('action')
19 20
       if type
20  
-        Twitter.const_get(type.camelize.to_sym).new(action)
  21
+        Twitter.const_get(camelize(type).to_sym).new(action)
21 22
       else
22 23
         raise ArgumentError, "argument must have an 'action' key"
23 24
       end
4  lib/twitter/configuration.rb
... ...
@@ -1,4 +1,3 @@
1  
-require 'active_support/core_ext/enumerable'
2 1
 require 'twitter/base'
3 2
 require 'twitter/size'
4 3
 
@@ -11,8 +10,9 @@ class Configuration < Twitter::Base
11 10
     #
12 11
     # @return [Array<Twitter::Size>]
13 12
     def photo_sizes
14  
-      @photo_sizes ||= Array(@attrs['photo_sizes']).each_with_object({}) do |(key, value), object|
  13
+      @photo_sizes ||= Array(@attrs['photo_sizes']).inject({}) do |object, (key, value)|
15 14
         object[key] = Twitter::Size.new(value)
  15
+        object
16 16
       end
17 17
     end
18 18
 
17  lib/twitter/core_ext/hash.rb
... ...
@@ -1,5 +1,22 @@
1 1
 class Hash
2 2
 
  3
+  # Return a hash that includes everything but the given keys.
  4
+  #
  5
+  # @param keys [Array, Set]
  6
+  # @return [Hash]
  7
+  def except(*keys)
  8
+    dup.except!(*keys)
  9
+  end
  10
+
  11
+  # Replaces the hash without the given keys.
  12
+  #
  13
+  # @param keys [Array, Set]
  14
+  # @return [Hash]
  15
+  def except!(*keys)
  16
+    keys.each{|key| delete(key)}
  17
+    self
  18
+  end
  19
+
3 20
   # Merges self with another hash, recursively
4 21
   #
5 22
   # @param hash [Hash] The hash to merge
15  lib/twitter/core_ext/kernel.rb
... ...
@@ -0,0 +1,15 @@
  1
+module Kernel
  2
+
  3
+  # Returns the object's singleton class.
  4
+  def singleton_class
  5
+    class << self
  6
+      self
  7
+    end
  8
+  end unless respond_to?(:singleton_class) # exists in 1.9.2
  9
+
  10
+  # class_eval on an object acts like singleton_class.class_eval.
  11
+  def class_eval(*args, &block)
  12
+    singleton_class.class_eval(*args, &block)
  13
+  end
  14
+
  15
+end
4  lib/twitter/cursor.rb
... ...
@@ -1,5 +1,5 @@
1  
-require 'active_support/core_ext/kernel/singleton_class'
2 1
 require 'twitter/base'
  2
+require 'twitter/core_ext/kernel'
3 3
 
4 4
 module Twitter
5 5
   class Cursor < Twitter::Base
@@ -23,7 +23,7 @@ def initialize(attrs, method, klass=nil)
23 23
           item
24 24
         end
25 25
       end
26  
-      singleton_class.class_eval do
  26
+      class_eval do
27 27
         alias_method method.to_sym, :collection
28 28
       end
29 29
     end
13  lib/twitter/inflector.rb
... ...
@@ -0,0 +1,13 @@
  1
+module Twitter
  2
+  module Inflector
  3
+
  4
+    # Converts a snake_case string to CamelCase
  5
+    #
  6
+    # @params string [String]
  7
+    # @return [String]
  8
+    def camelize(string)
  9
+      string.split('_').map(&:capitalize).join
  10
+    end
  11
+
  12
+  end
  13
+end
4  lib/twitter/photo.rb
... ...
@@ -1,4 +1,3 @@
1  
-require 'active_support/core_ext/enumerable'
2 1
 require 'twitter/base'
3 2
 require 'twitter/size'
4 3
 
@@ -15,8 +14,9 @@ def ==(other)
15 14
 
16 15
     # @return [Array<Twitter::Size>]
17 16
     def sizes
18  
-      @sizes ||= Array(@attrs['sizes']).each_with_object({}) do |(key, value), object|
  17
+      @sizes ||= Array(@attrs['sizes']).inject({}) do |object, (key, value)|
19 18
         object[key] = Twitter::Size.new(value)
  19
+        object
20 20
       end
21 21
     end
22 22
 
2  lib/twitter/status.rb
... ...
@@ -1,6 +1,6 @@
1  
-require 'active_support/core_ext/hash/except'
2 1
 require 'twitter/base'
3 2
 require 'twitter/client'
  3
+require 'twitter/core_ext/hash'
4 4
 require 'twitter/creatable'
5 5
 require 'twitter/entity/hashtag'
6 6
 require 'twitter/entity/url'
2  lib/twitter/user.rb
... ...
@@ -1,6 +1,6 @@
1  
-require 'active_support/core_ext/hash/except'
2 1
 require 'twitter/authenticatable'
3 2
 require 'twitter/base'
  3
+require 'twitter/core_ext/hash'
4 4
 require 'twitter/creatable'
5 5
 require 'twitter/status'
6 6
 
2  lib/twitter/version.rb
@@ -8,7 +8,7 @@ def self.major
8 8
 
9 9
     # @return [Integer]
10 10
     def self.minor
11  
-      4
  11
+      5
12 12
     end
13 13
 
14 14
     # @return [Integer]
1  twitter.gemspec
@@ -2,7 +2,6 @@
2 2
 require File.expand_path('../lib/twitter/version', __FILE__)
3 3
 
4 4
 Gem::Specification.new do |gem|
5  
-  gem.add_dependency 'activesupport', ['>= 2.3.9', '< 4']
6 5
   gem.add_dependency 'faraday', '~> 0.8'
7 6
   gem.add_dependency 'multi_json', '~> 1.3'
8 7
   gem.add_dependency 'simple_oauth', '~> 0.1.6'

No commit comments for this range

Something went wrong with that request. Please try again.