buddy 1.0.2 → 1.0.3
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.
- data/lib/buddy/service.rb +19 -11
 - data/lib/buddy/version.rb +1 -1
 - metadata +4 -4
 
    
        data/lib/buddy/service.rb
    CHANGED
    
    | 
         @@ -10,13 +10,21 @@ module Buddy 
     | 
|
| 
       10 
10 
     | 
    
         
             
                  end
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
                  def get(resource, params = {})
         
     | 
| 
       13 
     | 
    
         
            -
                     
     | 
| 
       14 
     | 
    
         
            -
                    raise OAuthException.new(result["error"]["message"]) if result["error"]
         
     | 
| 
       15 
     | 
    
         
            -
                    result
         
     | 
| 
      
 13 
     | 
    
         
            +
                    call_graph(:get, resource, params)
         
     | 
| 
       16 
14 
     | 
    
         
             
                  end
         
     | 
| 
       17 
15 
     | 
    
         | 
| 
       18 
16 
     | 
    
         
             
                  def post(resource, params = {})
         
     | 
| 
       19 
     | 
    
         
            -
                     
     | 
| 
      
 17 
     | 
    
         
            +
                    call_graph(:post, resource, params)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  private
         
     | 
| 
      
 21 
     | 
    
         
            +
                  def call_graph(method, resource, params)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    result = nil
         
     | 
| 
      
 23 
     | 
    
         
            +
                    time = Benchmark.realtime do
         
     | 
| 
      
 24 
     | 
    
         
            +
                      result = GraphApiClient.send(method, resource, :query => params).parsed_response
         
     | 
| 
      
 25 
     | 
    
         
            +
                    end
         
     | 
| 
      
 26 
     | 
    
         
            +
                    Buddy.logger.info("GraphAPI: #{method} #{resource} - #{time}")
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
       20 
28 
     | 
    
         
             
                    raise OAuthException.new(result["error"]["message"]) if result["error"]
         
     | 
| 
       21 
29 
     | 
    
         
             
                    result
         
     | 
| 
       22 
30 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -39,15 +47,15 @@ module Buddy 
     | 
|
| 
       39 
47 
     | 
    
         
             
                    changed
         
     | 
| 
       40 
48 
     | 
    
         
             
                    notify_observers(api_method, params, options)
         
     | 
| 
       41 
49 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
      
 50 
     | 
    
         
            +
                    fun = case api_method
         
     | 
| 
      
 51 
     | 
    
         
            +
                      when 'fql.query'
         
     | 
| 
       44 
52 
     | 
    
         
             
                        lambda { MiniFB.fql(params[:access_token], params[:query], options) }
         
     | 
| 
       45 
53 
     | 
    
         
             
                      when 'fql.multiquery'
         
     | 
| 
       46 
54 
     | 
    
         
             
                        lambda { MiniFB.multifql(params[:access_token], params[:queries], options) }
         
     | 
| 
       47 
55 
     | 
    
         
             
                      else
         
     | 
| 
       48 
56 
     | 
    
         
             
                        lambda do
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
      
 57 
     | 
    
         
            +
                          if params[:access_token]
         
     | 
| 
      
 58 
     | 
    
         
            +
                            options[:params] = params
         
     | 
| 
       51 
59 
     | 
    
         
             
                            MiniFB.rest(params[:access_token], api_method, options)
         
     | 
| 
       52 
60 
     | 
    
         
             
                          else
         
     | 
| 
       53 
61 
     | 
    
         
             
                            MiniFB.call(Buddy.buddy_config[application]["api_key"],
         
     | 
| 
         @@ -55,14 +63,14 @@ module Buddy 
     | 
|
| 
       55 
63 
     | 
    
         
             
                              api_method,
         
     | 
| 
       56 
64 
     | 
    
         
             
                              params.stringify_keys)
         
     | 
| 
       57 
65 
     | 
    
         
             
                          end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
      
 66 
     | 
    
         
            +
                        end
         
     | 
| 
      
 67 
     | 
    
         
            +
                    end
         
     | 
| 
       60 
68 
     | 
    
         | 
| 
       61 
69 
     | 
    
         
             
                    result = nil
         
     | 
| 
       62 
70 
     | 
    
         
             
                    time = Benchmark.realtime do
         
     | 
| 
       63 
71 
     | 
    
         
             
                      result = fun.call
         
     | 
| 
       64 
72 
     | 
    
         
             
                    end
         
     | 
| 
       65 
     | 
    
         
            -
                    Buddy.logger.info(" 
     | 
| 
      
 73 
     | 
    
         
            +
                    Buddy.logger.info("RestAPI: #{api_method} (#{params.inspect}) - #{time}")
         
     | 
| 
       66 
74 
     | 
    
         
             
                    result
         
     | 
| 
       67 
75 
     | 
    
         
             
                  end
         
     | 
| 
       68 
76 
     | 
    
         
             
                end
         
     | 
    
        data/lib/buddy/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: buddy
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              hash:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 17
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 1
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 0
         
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 1.0. 
     | 
| 
      
 9 
     | 
    
         
            +
              - 3
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 1.0.3
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - Ole Riesenberg
         
     | 
| 
         @@ -15,7 +15,7 @@ autorequire: 
     | 
|
| 
       15 
15 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
16 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            date: 2011-02- 
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2011-02-24 00:00:00 +01:00
         
     | 
| 
       19 
19 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       20 
20 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       21 
21 
     | 
    
         |