ews-api 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/VERSION +1 -1
- data/ews-api.gemspec +9 -9
- data/lib/ews/builder.rb +1 -12
- data/lib/ews/error.rb +3 -0
- data/lib/ews/folder.rb +1 -1
- data/lib/ews/model.rb +3 -4
- data/lib/ews/service.rb +4 -0
- data/spec/ews/builder_spec.rb +1 -1
- data/spec/ews/folder_spec.rb +13 -1
- data/spec/ews/service_spec.rb +9 -2
- data/spec/integration.rb +16 -7
- metadata +8 -8
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.1. | 
| 1 | 
            +
            0.1.1
         | 
    
        data/ews-api.gemspec
    CHANGED
    
    | @@ -5,7 +5,7 @@ | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = %q{ews-api}
         | 
| 8 | 
            -
              s.version = "0.1. | 
| 8 | 
            +
              s.version = "0.1.1"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["jrun"]
         | 
| @@ -65,17 +65,17 @@ Gem::Specification.new do |s| | |
| 65 65 | 
             
              s.rubygems_version = %q{1.3.5}
         | 
| 66 66 | 
             
              s.summary = %q{Exchange Web Services API}
         | 
| 67 67 | 
             
              s.test_files = [
         | 
| 68 | 
            -
                "spec/ | 
| 69 | 
            -
                 "spec/integration.rb",
         | 
| 70 | 
            -
                 "spec/ews/parser_spec.rb",
         | 
| 71 | 
            -
                 "spec/ews/message_spec.rb",
         | 
| 68 | 
            +
                "spec/ews/attachment_spec.rb",
         | 
| 72 69 | 
             
                 "spec/ews/builder_spec.rb",
         | 
| 73 | 
            -
                 "spec/ews/attachment_spec.rb",
         | 
| 74 | 
            -
                 "spec/ews/folder_spec.rb",
         | 
| 75 | 
            -
                 "spec/ews/service_spec.rb",
         | 
| 76 70 | 
             
                 "spec/ews/builders/resolve_names_builder_spec.rb",
         | 
| 77 71 | 
             
                 "spec/ews/builders/shape_builder_spec.rb",
         | 
| 78 | 
            -
                 "spec/ews/ | 
| 72 | 
            +
                 "spec/ews/folder_spec.rb",
         | 
| 73 | 
            +
                 "spec/ews/message_spec.rb",
         | 
| 74 | 
            +
                 "spec/ews/model_spec.rb",
         | 
| 75 | 
            +
                 "spec/ews/parser_spec.rb",
         | 
| 76 | 
            +
                 "spec/ews/service_spec.rb",
         | 
| 77 | 
            +
                 "spec/integration.rb",
         | 
| 78 | 
            +
                 "spec/spec_helper.rb"
         | 
| 79 79 | 
             
              ]
         | 
| 80 80 |  | 
| 81 81 | 
             
              if s.respond_to? :specification_version then
         | 
    
        data/lib/ews/builder.rb
    CHANGED
    
    | @@ -48,7 +48,7 @@ module EWS | |
| 48 48 |  | 
| 49 49 | 
             
                def id_container!(container_node_name, ids)
         | 
| 50 50 | 
             
                  @action_node.add(container_node_name) do |container_node|
         | 
| 51 | 
            -
                     | 
| 51 | 
            +
                    Array(ids).each {|id| yield container_node, id }
         | 
| 52 52 | 
             
                  end
         | 
| 53 53 | 
             
                end
         | 
| 54 54 |  | 
| @@ -91,17 +91,6 @@ module EWS | |
| 91 91 | 
             
                    id_node.set_attr 'ChangeKey', opts[:change_key] if opts[:change_key]
         | 
| 92 92 | 
             
                  end 
         | 
| 93 93 | 
             
                end
         | 
| 94 | 
            -
             | 
| 95 | 
            -
                # TODO: core_ext?
         | 
| 96 | 
            -
                def to_a(ids)
         | 
| 97 | 
            -
                  case ids
         | 
| 98 | 
            -
                  when Enumerable
         | 
| 99 | 
            -
                    ids
         | 
| 100 | 
            -
                  else
         | 
| 101 | 
            -
                    [ids]
         | 
| 102 | 
            -
                  end
         | 
| 103 | 
            -
                end
         | 
| 104 | 
            -
             | 
| 105 94 | 
             
              end
         | 
| 106 95 |  | 
| 107 96 | 
             
            end
         | 
    
        data/lib/ews/error.rb
    CHANGED
    
    
    
        data/lib/ews/folder.rb
    CHANGED
    
    | @@ -33,7 +33,7 @@ module EWS | |
| 33 33 | 
             
                  # NOTE: This assumes Service#find_item only returns
         | 
| 34 34 | 
             
                  # Messages. That is true now but will change as more
         | 
| 35 35 | 
             
                  # of the parser is implemented.
         | 
| 36 | 
            -
                  service.find_item(self. | 
| 36 | 
            +
                  service.find_item(self.id, :base_shape => :AllProperties)
         | 
| 37 37 | 
             
                end
         | 
| 38 38 |  | 
| 39 39 | 
             
                def find_folders
         | 
    
        data/lib/ews/model.rb
    CHANGED
    
    | @@ -1,8 +1,11 @@ | |
| 1 1 | 
             
            module EWS
         | 
| 2 2 |  | 
| 3 3 | 
             
              class Model
         | 
| 4 | 
            +
                attr_accessor :service
         | 
| 5 | 
            +
                
         | 
| 4 6 | 
             
                def initialize(attrs = {})
         | 
| 5 7 | 
             
                  @attrs = attrs.dup
         | 
| 8 | 
            +
                  @service = EWS::Service
         | 
| 6 9 | 
             
                end
         | 
| 7 10 |  | 
| 8 11 | 
             
                def shallow?
         | 
| @@ -12,10 +15,6 @@ module EWS | |
| 12 15 | 
             
                protected
         | 
| 13 16 | 
             
                attr_reader :attrs
         | 
| 14 17 |  | 
| 15 | 
            -
                def service
         | 
| 16 | 
            -
                  EWS::Service
         | 
| 17 | 
            -
                end
         | 
| 18 | 
            -
             | 
| 19 18 | 
             
                public
         | 
| 20 19 | 
             
                def method_missing(meth, *args)
         | 
| 21 20 | 
             
                  method_name = meth.to_s
         | 
    
        data/lib/ews/service.rb
    CHANGED
    
    | @@ -275,6 +275,8 @@ module EWS | |
| 275 275 | 
             
                # @see http://msdn.microsoft.com/en-us/library/aa563525.aspx
         | 
| 276 276 | 
             
                # ItmeIds
         | 
| 277 277 | 
             
                def get_item(item_id, opts = {})
         | 
| 278 | 
            +
                  raise PreconditionFailed, "Id must be non-empty" if item_id.nil?
         | 
| 279 | 
            +
                  
         | 
| 278 280 | 
             
                  soap_action = 'http://schemas.microsoft.com/exchange/services/2006/messages/GetItem'
         | 
| 279 281 | 
             
                  response = invoke('tns:GetItem', soap_action) do |get_item|
         | 
| 280 282 | 
             
                    builder(get_item, opts) do
         | 
| @@ -379,6 +381,8 @@ module EWS | |
| 379 381 | 
             
                # @see http://msdn.microsoft.com/en-us/library/aa494316.aspx
         | 
| 380 382 | 
             
                # GetAttachment
         | 
| 381 383 | 
             
                def get_attachment(attachment_id, opts = {})
         | 
| 384 | 
            +
                  raise PreconditionFailed, "Id must be non-empty" if attachment_id.nil?
         | 
| 385 | 
            +
                  
         | 
| 382 386 | 
             
                  soap_action = 'http://schemas.microsoft.com/exchange/services/2006/messages/GetAttachment'
         | 
| 383 387 | 
             
                  response = invoke('tns:GetAttachment', soap_action) do |get_attachment|
         | 
| 384 388 | 
             
                    builder(get_attachment, opts) do
         | 
    
        data/spec/ews/builder_spec.rb
    CHANGED
    
    
    
        data/spec/ews/folder_spec.rb
    CHANGED
    
    | @@ -6,6 +6,18 @@ module EWS | |
| 6 6 | 
             
                  @parser = Parser.new
         | 
| 7 7 | 
             
                end
         | 
| 8 8 |  | 
| 9 | 
            +
                context "#iems" do
         | 
| 10 | 
            +
                  it "should call service#find_item with the folder id" do
         | 
| 11 | 
            +
                    service = mock(:service)
         | 
| 12 | 
            +
                    service.should_receive(:find_item).with('maid of tarth', anything())
         | 
| 13 | 
            +
                    
         | 
| 14 | 
            +
                    folder = Folder.new(:folder_id => {:id => 'maid of tarth'})
         | 
| 15 | 
            +
                    folder.service = service
         | 
| 16 | 
            +
                    
         | 
| 17 | 
            +
                    folder.items
         | 
| 18 | 
            +
                  end      
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
                
         | 
| 9 21 | 
             
                context '#folders' do
         | 
| 10 22 | 
             
                  it "should be indexed by display name" do
         | 
| 11 23 | 
             
                    mock_response response(:find_folder)
         | 
| @@ -21,7 +33,7 @@ module EWS | |
| 21 33 |  | 
| 22 34 | 
             
                    message_count = 0
         | 
| 23 35 | 
             
                    subjects = ['test', 'Regarding Brandon Stark', 'Re: Regarding Brandon Stark']
         | 
| 24 | 
            -
                    folder = Folder.new(:display_name => 'Inbox')
         | 
| 36 | 
            +
                    folder = Folder.new(:display_name => 'Inbox', :folder_id => {:id => 'maid of tarth'})
         | 
| 25 37 |  | 
| 26 38 | 
             
                    folder.each_message do |message|
         | 
| 27 39 | 
             
                      message_count += 1
         | 
    
        data/spec/ews/service_spec.rb
    CHANGED
    
    | @@ -5,10 +5,17 @@ EWS::Service.endpoint 'http://localhost/ews/exchange.aspx' | |
| 5 5 | 
             
            describe EWS::Service do
         | 
| 6 6 | 
             
              context '#get_item' do    
         | 
| 7 7 | 
             
                it "should raise an error when the id is not found" do
         | 
| 8 | 
            -
                  mock_response response(:get_item_with_error)
         | 
| 9 8 | 
             
                  lambda do
         | 
| 10 9 | 
             
                    EWS::Service.get_item nil
         | 
| 11 | 
            -
                  end.should raise_error(EWS:: | 
| 10 | 
            +
                  end.should raise_error(EWS::PreconditionFailed, /Id must be non-empty/)
         | 
| 12 11 | 
             
                end
         | 
| 13 12 | 
             
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              context "#get_attachment" do
         | 
| 15 | 
            +
                it "should raise an error when the id is not found" do
         | 
| 16 | 
            +
                  lambda do
         | 
| 17 | 
            +
                    EWS::Service.get_attachment nil
         | 
| 18 | 
            +
                  end.should raise_error(EWS::PreconditionFailed, /Id must be non-empty/)
         | 
| 19 | 
            +
                end    
         | 
| 20 | 
            +
              end
         | 
| 14 21 | 
             
            end
         | 
    
        data/spec/integration.rb
    CHANGED
    
    | @@ -111,11 +111,11 @@ describe 'Integration Tests' do | |
| 111 111 | 
             
                  item = EWS::Service.get_item EWS_CONFIG['item_id'], :base_shape => :AllProperties
         | 
| 112 112 | 
             
                  item.should be_instance_of(EWS::Message)
         | 
| 113 113 | 
             
                end
         | 
| 114 | 
            -
             | 
| 115 | 
            -
                it "should raise  | 
| 114 | 
            +
                
         | 
| 115 | 
            +
                it "should raise an error when the requested id is nil" do
         | 
| 116 116 | 
             
                  lambda do
         | 
| 117 117 | 
             
                    EWS::Service.get_item(nil)
         | 
| 118 | 
            -
                  end.should raise_error(EWS:: | 
| 118 | 
            +
                  end.should raise_error(EWS::PreconditionFailed, /Id must be non-empty/)
         | 
| 119 119 | 
             
                end
         | 
| 120 120 | 
             
              end
         | 
| 121 121 |  | 
| @@ -125,11 +125,11 @@ describe 'Integration Tests' do | |
| 125 125 | 
             
                    rtn = EWS::Service.get_attachment EWS_CONFIG['attachment_id'] # lame
         | 
| 126 126 | 
             
                  end.should_not raise_error
         | 
| 127 127 | 
             
                end
         | 
| 128 | 
            -
             | 
| 129 | 
            -
                it "should raise  | 
| 128 | 
            +
                
         | 
| 129 | 
            +
                it "should raise an error when the requested id is nil" do
         | 
| 130 130 | 
             
                  lambda do
         | 
| 131 131 | 
             
                    EWS::Service.get_attachment(nil)
         | 
| 132 | 
            -
                  end.should raise_error(EWS:: | 
| 132 | 
            +
                  end.should raise_error(EWS::PreconditionFailed, /Id must be non-empty/)
         | 
| 133 133 | 
             
                end
         | 
| 134 134 | 
             
              end
         | 
| 135 135 |  | 
| @@ -153,5 +153,14 @@ describe 'Integration Tests' do | |
| 153 153 | 
             
                  end.should raise_error(EWS::ResponseError, /Id is malformed/)      
         | 
| 154 154 | 
             
                end
         | 
| 155 155 | 
             
              end
         | 
| 156 | 
            -
             | 
| 156 | 
            +
             | 
| 157 | 
            +
              context "EWS.inbox" do
         | 
| 158 | 
            +
                it "#each_message should iterate through the inbox without errors" do
         | 
| 159 | 
            +
                  # lame test but will help protect against a regression until a
         | 
| 160 | 
            +
                  # proper inbox setup is complete
         | 
| 161 | 
            +
                  count = 0
         | 
| 162 | 
            +
                  EWS.inbox.each_message {|m| count += 1}
         | 
| 163 | 
            +
                  count.should > 0
         | 
| 164 | 
            +
                end
         | 
| 165 | 
            +
              end
         | 
| 157 166 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: ews-api
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - jrun
         | 
| @@ -142,14 +142,14 @@ signing_key: | |
| 142 142 | 
             
            specification_version: 3
         | 
| 143 143 | 
             
            summary: Exchange Web Services API
         | 
| 144 144 | 
             
            test_files: 
         | 
| 145 | 
            -
            - spec/spec_helper.rb
         | 
| 146 | 
            -
            - spec/integration.rb
         | 
| 147 | 
            -
            - spec/ews/parser_spec.rb
         | 
| 148 | 
            -
            - spec/ews/message_spec.rb
         | 
| 149 | 
            -
            - spec/ews/builder_spec.rb
         | 
| 150 145 | 
             
            - spec/ews/attachment_spec.rb
         | 
| 151 | 
            -
            - spec/ews/ | 
| 152 | 
            -
            - spec/ews/service_spec.rb
         | 
| 146 | 
            +
            - spec/ews/builder_spec.rb
         | 
| 153 147 | 
             
            - spec/ews/builders/resolve_names_builder_spec.rb
         | 
| 154 148 | 
             
            - spec/ews/builders/shape_builder_spec.rb
         | 
| 149 | 
            +
            - spec/ews/folder_spec.rb
         | 
| 150 | 
            +
            - spec/ews/message_spec.rb
         | 
| 155 151 | 
             
            - spec/ews/model_spec.rb
         | 
| 152 | 
            +
            - spec/ews/parser_spec.rb
         | 
| 153 | 
            +
            - spec/ews/service_spec.rb
         | 
| 154 | 
            +
            - spec/integration.rb
         | 
| 155 | 
            +
            - spec/spec_helper.rb
         |