flowdock 0.2.3 → 0.3.0
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/README.md +10 -0
- data/VERSION +1 -1
- data/flowdock.gemspec +3 -3
- data/lib/flowdock.rb +5 -1
- data/spec/flowdock_spec.rb +38 -2
- metadata +4 -4
    
        data/README.md
    CHANGED
    
    | @@ -45,6 +45,16 @@ To post content to Chat or Team Inbox, you need to use the target flow's API tok | |
| 45 45 | 
             
                  :content => "<h2>It works!</h2><p>Now you can start developing your awesome application for Flowdock.</p>",
         | 
| 46 46 | 
             
                  :tags => ["cool", "stuff"], :link => "http://www.flowdock.com/")
         | 
| 47 47 |  | 
| 48 | 
            +
            ### Posting to multiple flows
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                require 'rubygems'
         | 
| 51 | 
            +
                require 'flowdock'
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                # create a new Flow object with the api tokens of the target flows
         | 
| 54 | 
            +
                flow = Flowdock::Flow.new(:api_token => ["__FLOW_TOKEN__", "__ANOTHER_FLOW_TOKEN__"], ... )
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                # see above examples of posting to Chat or Team Inbox
         | 
| 57 | 
            +
             | 
| 48 58 | 
             
            ## API methods
         | 
| 49 59 |  | 
| 50 60 | 
             
            * Flow methods
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0. | 
| 1 | 
            +
            0.3.0
         | 
    
        data/flowdock.gemspec
    CHANGED
    
    | @@ -5,11 +5,11 @@ | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = "flowdock"
         | 
| 8 | 
            -
              s.version = "0. | 
| 8 | 
            +
              s.version = "0.3.0"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["Antti Pitk\u{e4}nen"]
         | 
| 12 | 
            -
              s.date = "2013- | 
| 12 | 
            +
              s.date = "2013-03-18"
         | 
| 13 13 | 
             
              s.email = "team@flowdock.com"
         | 
| 14 14 | 
             
              s.extra_rdoc_files = [
         | 
| 15 15 | 
             
                "LICENSE",
         | 
| @@ -33,7 +33,7 @@ Gem::Specification.new do |s| | |
| 33 33 | 
             
              s.homepage = "http://github.com/flowdock/flowdock-api"
         | 
| 34 34 | 
             
              s.licenses = ["MIT"]
         | 
| 35 35 | 
             
              s.require_paths = ["lib"]
         | 
| 36 | 
            -
              s.rubygems_version = "1.8. | 
| 36 | 
            +
              s.rubygems_version = "1.8.25"
         | 
| 37 37 | 
             
              s.summary = "Ruby Gem for using Flowdock's API"
         | 
| 38 38 |  | 
| 39 39 | 
             
              if s.respond_to? :specification_version then
         | 
    
        data/lib/flowdock.rb
    CHANGED
    
    | @@ -15,7 +15,11 @@ module Flowdock | |
| 15 15 | 
             
                # Required options keys: :api_token
         | 
| 16 16 | 
             
                # Optional keys: :external_user_name, :source, :project, :from => { :name, :address }, :reply_to
         | 
| 17 17 | 
             
                def initialize(options = {})
         | 
| 18 | 
            -
                  @api_token = options[:api_token]
         | 
| 18 | 
            +
                  @api_token = if options[:api_token].kind_of?(Array)
         | 
| 19 | 
            +
                    options[:api_token].join(",")
         | 
| 20 | 
            +
                  else
         | 
| 21 | 
            +
                    options[:api_token].to_s
         | 
| 22 | 
            +
                  end
         | 
| 19 23 | 
             
                  raise InvalidParameterError, "Flow must have :api_token attribute" if blank?(@api_token)
         | 
| 20 24 |  | 
| 21 25 | 
             
                  @source = options[:source] || nil
         | 
    
        data/spec/flowdock_spec.rb
    CHANGED
    
    | @@ -13,6 +13,12 @@ describe Flowdock do | |
| 13 13 | 
             
                    @flow = Flowdock::Flow.new(:api_token => "")
         | 
| 14 14 | 
             
                  }.should raise_error(Flowdock::Flow::InvalidParameterError)
         | 
| 15 15 | 
             
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                it "should succeed with array of tokens" do
         | 
| 18 | 
            +
                  lambda {
         | 
| 19 | 
            +
                    @flow = Flowdock::Flow.new(:api_token => ["test", "foobar"])
         | 
| 20 | 
            +
                  }.should_not raise_error
         | 
| 21 | 
            +
                end
         | 
| 16 22 | 
             
              end
         | 
| 17 23 |  | 
| 18 24 | 
             
              describe "with sending Team Inbox messages" do
         | 
| @@ -93,6 +99,28 @@ describe Flowdock do | |
| 93 99 | 
             
                  }.should_not raise_error
         | 
| 94 100 | 
             
                end
         | 
| 95 101 |  | 
| 102 | 
            +
                it "should succeed with correct params and multiple tokens" do
         | 
| 103 | 
            +
                  lambda {
         | 
| 104 | 
            +
                    tokens = ["test", "foobar"]
         | 
| 105 | 
            +
                    stub_request(:post, push_to_team_inbox_url(tokens)).
         | 
| 106 | 
            +
                      with(:body => {
         | 
| 107 | 
            +
                        :source => "myapp",
         | 
| 108 | 
            +
                        :format => "html",
         | 
| 109 | 
            +
                        :from_name => "Eric Example",
         | 
| 110 | 
            +
                        :from_address => "eric@example.com",
         | 
| 111 | 
            +
                        :reply_to => "john@example.com",
         | 
| 112 | 
            +
                        :subject => "Hello World",
         | 
| 113 | 
            +
                        :content => @example_content,
         | 
| 114 | 
            +
                        :tags => "cool,stuff",
         | 
| 115 | 
            +
                        :link => "http://www.flowdock.com/"
         | 
| 116 | 
            +
                      }).
         | 
| 117 | 
            +
                      to_return(:body => "", :status => 200)
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                    @flow = Flowdock::Flow.new(@flow_attributes.merge(:project => "", :api_token => tokens))
         | 
| 120 | 
            +
                    @flow.push_to_team_inbox(@valid_attributes)
         | 
| 121 | 
            +
                  }.should_not raise_error
         | 
| 122 | 
            +
                end
         | 
| 123 | 
            +
             | 
| 96 124 | 
             
                it "should succeed without the optional from-name parameter" do
         | 
| 97 125 | 
             
                  lambda {
         | 
| 98 126 | 
             
                    stub_request(:post, push_to_team_inbox_url(@token)).
         | 
| @@ -267,10 +295,18 @@ describe Flowdock do | |
| 267 295 | 
             
              end
         | 
| 268 296 |  | 
| 269 297 | 
             
              def push_to_chat_url(token)
         | 
| 270 | 
            -
                "#{Flowdock::FLOWDOCK_API_URL}/messages/chat/#{token}"
         | 
| 298 | 
            +
                "#{Flowdock::FLOWDOCK_API_URL}/messages/chat/#{join_tokens(token)}"
         | 
| 271 299 | 
             
              end
         | 
| 272 300 |  | 
| 273 301 | 
             
              def push_to_team_inbox_url(token)
         | 
| 274 | 
            -
                "#{Flowdock::FLOWDOCK_API_URL}/messages/team_inbox/#{token}"
         | 
| 302 | 
            +
                "#{Flowdock::FLOWDOCK_API_URL}/messages/team_inbox/#{join_tokens(token)}"
         | 
| 303 | 
            +
              end
         | 
| 304 | 
            +
             | 
| 305 | 
            +
              def join_tokens(tokens)
         | 
| 306 | 
            +
                if tokens.kind_of?(Array)
         | 
| 307 | 
            +
                  tokens.join(",")
         | 
| 308 | 
            +
                else
         | 
| 309 | 
            +
                  tokens.to_s
         | 
| 310 | 
            +
                end
         | 
| 275 311 | 
             
              end
         | 
| 276 312 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: flowdock
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.3.0
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2013- | 
| 12 | 
            +
            date: 2013-03-18 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: httparty
         | 
| @@ -175,7 +175,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 175 175 | 
             
                  version: '0'
         | 
| 176 176 | 
             
                  segments:
         | 
| 177 177 | 
             
                  - 0
         | 
| 178 | 
            -
                  hash:  | 
| 178 | 
            +
                  hash: -1709171336806452392
         | 
| 179 179 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 180 180 | 
             
              none: false
         | 
| 181 181 | 
             
              requirements:
         | 
| @@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 184 184 | 
             
                  version: '0'
         | 
| 185 185 | 
             
            requirements: []
         | 
| 186 186 | 
             
            rubyforge_project: 
         | 
| 187 | 
            -
            rubygems_version: 1.8. | 
| 187 | 
            +
            rubygems_version: 1.8.25
         | 
| 188 188 | 
             
            signing_key: 
         | 
| 189 189 | 
             
            specification_version: 3
         | 
| 190 190 | 
             
            summary: Ruby Gem for using Flowdock's API
         |