twin 0.1.0 → 0.1.1
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/twin.rb +13 -3
- data/lib/twin/resources.rb +5 -5
- data/test/app.rb +1 -1
- metadata +3 -3
    
        data/lib/twin.rb
    CHANGED
    
    | @@ -3,7 +3,9 @@ require 'active_support/core_ext/hash/conversions' | |
| 3 3 | 
             
            require 'active_support/core_ext/hash/keys'
         | 
| 4 4 | 
             
            require 'active_support/core_ext/hash/indifferent_access'
         | 
| 5 5 | 
             
            require 'active_support/json'
         | 
| 6 | 
            -
             | 
| 6 | 
            +
            # Active Support 2 doesn't have the following file, but it's OK
         | 
| 7 | 
            +
            # since we already got the method from "hash/conversions"
         | 
| 8 | 
            +
            require 'active_support/core_ext/object/to_query' unless {}.respond_to? :to_query
         | 
| 7 9 | 
             
            require 'digest/md5'
         | 
| 8 10 |  | 
| 9 11 | 
             
            class Twin
         | 
| @@ -39,9 +41,9 @@ class Twin | |
| 39 41 | 
             
                if path != '/' and found = recognize_resource(path)
         | 
| 40 42 | 
             
                  block, matches = found
         | 
| 41 43 |  | 
| 42 | 
            -
                  # TODO: bail out early if authentication failed
         | 
| 43 44 | 
             
                  twin_token = env[AUTHORIZATION] =~ / oauth_token="(.+?)"/ && $1
         | 
| 44 45 | 
             
                  authenticated_user = twin_token && model.find_by_twin_token(twin_token)
         | 
| 46 | 
            +
                  return not_authenticated if twin_token and not authenticated_user
         | 
| 45 47 |  | 
| 46 48 | 
             
                  clone = self.dup
         | 
| 47 49 | 
             
                  clone.request = Rack::Request.new env
         | 
| @@ -83,7 +85,7 @@ class Twin | |
| 83 85 | 
             
                  }
         | 
| 84 86 | 
             
                  # later sent back as: oauth_token="..."
         | 
| 85 87 | 
             
                else
         | 
| 86 | 
            -
                   | 
| 88 | 
            +
                  not_authenticated
         | 
| 87 89 | 
             
                end
         | 
| 88 90 | 
             
              end
         | 
| 89 91 |  | 
| @@ -120,6 +122,14 @@ class Twin | |
| 120 122 | 
             
                [404, {'Content-Type' => 'text/plain'}, ['Not found']]
         | 
| 121 123 | 
             
              end
         | 
| 122 124 |  | 
| 125 | 
            +
              def not_implemented
         | 
| 126 | 
            +
                [501, {'Content-Type' => 'text/plain'}, ['Not implemented']]
         | 
| 127 | 
            +
              end
         | 
| 128 | 
            +
              
         | 
| 129 | 
            +
              def not_authenticated
         | 
| 130 | 
            +
                [400, {'Content-Type' => 'text/plain'}, ['Not authenticated']]
         | 
| 131 | 
            +
              end
         | 
| 132 | 
            +
              
         | 
| 123 133 | 
             
              def normalize_statuses(statuses)
         | 
| 124 134 | 
             
                statuses.map do |status|
         | 
| 125 135 | 
             
                  hash = convert_twin_hash(status)
         | 
    
        data/lib/twin/resources.rb
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            class Twin
         | 
| 2 2 | 
             
              resource 'statuses/home_timeline' do
         | 
| 3 | 
            -
                statuses = self.model.statuses(params.with_indifferent_access)
         | 
| 3 | 
            +
                statuses = self.model.statuses(params.with_indifferent_access, current_user)
         | 
| 4 4 | 
             
                respond_with('statuses', normalize_statuses(statuses))
         | 
| 5 5 | 
             
              end
         | 
| 6 6 |  | 
| @@ -73,6 +73,10 @@ class Twin | |
| 73 73 | 
             
                respond_with('saved_searches', [])
         | 
| 74 74 | 
             
              end
         | 
| 75 75 |  | 
| 76 | 
            +
              resource 'account/(settings|apple_push_destinations(/(destroy|device))?)' do
         | 
| 77 | 
            +
                not_implemented
         | 
| 78 | 
            +
              end
         | 
| 79 | 
            +
              
         | 
| 76 80 | 
             
              DEFAULT_STATUS_PARAMS = {
         | 
| 77 81 | 
             
                :id => nil,
         | 
| 78 82 | 
             
                :text => "",
         | 
| @@ -135,7 +139,3 @@ class Twin | |
| 135 139 | 
             
              #   :sender
         | 
| 136 140 | 
             
              #   :recipient
         | 
| 137 141 | 
             
            end
         | 
| 138 | 
            -
             | 
| 139 | 
            -
            # POST /1/account/apple_push_destinations.xml
         | 
| 140 | 
            -
            # POST /1/account/apple_push_destinations/destroy.xml
         | 
| 141 | 
            -
            # GET /1/account/settings.xml
         | 
    
        data/test/app.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: twin
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 25
         | 
| 5 5 | 
             
              prerelease: false
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 8 | 
             
              - 1
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 0.1. | 
| 9 | 
            +
              - 1
         | 
| 10 | 
            +
              version: 0.1.1
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - "Mislav Marohni\xC4\x87"
         |