lita-gerrit 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/lib/lita/handlers/gerrit.rb +10 -12
- data/lita-gerrit.gemspec +2 -2
- data/spec/lita/handlers/gerrit_spec.rb +5 -5
- data/spec/spec_helper.rb +1 -0
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b63fa796726ff840033b17ea3e49fb54490b9875
         | 
| 4 | 
            +
              data.tar.gz: 2b2bf62d813d6e8796fa27b85b53979085e18947
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: f56f3209bfb27973e5587ba4078e0d697873eeff474010a436b921c0609fd52a48c09e4f484f317d8057084f3693db3bac0d3747cdbe8a6a62340c980b326646
         | 
| 7 | 
            +
              data.tar.gz: f65661a6c7144645d172cda2a6534eef9238a54462a1db557670cec700825af1bf57fe9c8b11dc36a320ef5576c71efff3fa3d2c77f912885fa2dc70eb050356
         | 
    
        data/lib/lita/handlers/gerrit.rb
    CHANGED
    
    | @@ -2,12 +2,10 @@ module Lita | |
| 2 2 | 
             
              module Handlers
         | 
| 3 3 | 
             
                class Gerrit < Handler
         | 
| 4 4 |  | 
| 5 | 
            -
                   | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
                    config.default_room = nil
         | 
| 10 | 
            -
                  end
         | 
| 5 | 
            +
                  config :url, default: "https://gerrit.example.com"
         | 
| 6 | 
            +
                  config :username, default: "foo"
         | 
| 7 | 
            +
                  config :password, default: "bar"
         | 
| 8 | 
            +
                  config :default_room
         | 
| 11 9 |  | 
| 12 10 | 
             
                  #
         | 
| 13 11 | 
             
                  # Fetch details of a given patchset
         | 
| @@ -17,12 +15,12 @@ module Lita | |
| 17 15 |  | 
| 18 16 | 
             
                  def change_details(response)
         | 
| 19 17 | 
             
                    change_id = response.matches.flatten.first
         | 
| 20 | 
            -
                    change_uri = "#{ | 
| 21 | 
            -
                    change_link = "#{ | 
| 18 | 
            +
                    change_uri = "#{config.url.chomp("/")}/a/changes/#{change_id}"
         | 
| 19 | 
            +
                    change_link = "#{config.url.chomp("/")}/#{change_id}"
         | 
| 22 20 |  | 
| 23 21 | 
             
                    http_resp = HTTParty.get(change_uri, :digest_auth => {
         | 
| 24 | 
            -
                      username:  | 
| 25 | 
            -
                      password:  | 
| 22 | 
            +
                      username: config.username,
         | 
| 23 | 
            +
                      password: config.password
         | 
| 26 24 | 
             
                    })
         | 
| 27 25 |  | 
| 28 26 | 
             
                    case http_resp.code
         | 
| @@ -59,8 +57,8 @@ module Lita | |
| 59 57 |  | 
| 60 58 | 
             
                    if request.params.has_key?("room")
         | 
| 61 59 | 
             
                      room = request.params["room"]
         | 
| 62 | 
            -
                    elsif  | 
| 63 | 
            -
                      room =  | 
| 60 | 
            +
                    elsif config.default_room
         | 
| 61 | 
            +
                      room = config.default_room
         | 
| 64 62 | 
             
                    else
         | 
| 65 63 | 
             
                      raise "Room must be defined. Either fix your hook or specify a default room ('config.handlers.gerrit.default_room')"
         | 
| 66 64 | 
             
                    end
         | 
    
        data/lita-gerrit.gemspec
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            Gem::Specification.new do |spec|
         | 
| 2 2 | 
             
              spec.name          = "lita-gerrit"
         | 
| 3 | 
            -
              spec.version       = "0.1. | 
| 3 | 
            +
              spec.version       = "0.1.2"
         | 
| 4 4 | 
             
              spec.authors       = ["Jonathan Amiez"]
         | 
| 5 5 | 
             
              spec.email         = ["jonathan.amiez@gmail.com"]
         | 
| 6 6 | 
             
              spec.description   = "Gerrit API client and hook events handler"
         | 
| @@ -14,7 +14,7 @@ Gem::Specification.new do |spec| | |
| 14 14 | 
             
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 15 15 | 
             
              spec.require_paths = ["lib"]
         | 
| 16 16 |  | 
| 17 | 
            -
              spec.add_runtime_dependency "lita", "~>  | 
| 17 | 
            +
              spec.add_runtime_dependency "lita", "~> 4.0"
         | 
| 18 18 | 
             
              spec.add_runtime_dependency "httparty", "~> 0.13.0"
         | 
| 19 19 |  | 
| 20 20 | 
             
              spec.add_development_dependency "bundler", "~> 1.3"
         | 
| @@ -11,8 +11,8 @@ describe Lita::Handlers::Gerrit, lita_handler: true do | |
| 11 11 | 
             
                end
         | 
| 12 12 | 
             
              end
         | 
| 13 13 |  | 
| 14 | 
            -
              it {  | 
| 15 | 
            -
              it {  | 
| 14 | 
            +
              it { is_expected.to route("get me gerrit 123, please").to(:change_details) }
         | 
| 15 | 
            +
              it { is_expected.not_to route("gerrit foo").to(:change_details) }
         | 
| 16 16 |  | 
| 17 17 | 
             
              describe "#change_details" do
         | 
| 18 18 | 
             
                let(:response) { double("HTTParty::Response") }
         | 
| @@ -47,7 +47,7 @@ describe Lita::Handlers::Gerrit, lita_handler: true do | |
| 47 47 | 
             
                end
         | 
| 48 48 | 
             
              end
         | 
| 49 49 |  | 
| 50 | 
            -
              it {  | 
| 50 | 
            +
              it { is_expected.to route_http(:post, "/gerrit/hooks").to(:hook) }
         | 
| 51 51 |  | 
| 52 52 | 
             
              describe "#hook" do
         | 
| 53 53 | 
             
                let(:request) do
         | 
| @@ -61,8 +61,8 @@ describe Lita::Handlers::Gerrit, lita_handler: true do | |
| 61 61 | 
             
                let(:params) { double("Hash") }
         | 
| 62 62 | 
             
              end
         | 
| 63 63 |  | 
| 64 | 
            -
              it {  | 
| 65 | 
            -
              it {  | 
| 64 | 
            +
              it { is_expected.to route_http(:post, "/gerrit/build/myroom").to(:build_notification) }
         | 
| 65 | 
            +
              it { is_expected.not_to route_http(:post, "/gerrit/build/").to(:build_notification) }
         | 
| 66 66 |  | 
| 67 67 | 
             
              describe "#build_notification" do
         | 
| 68 68 | 
             
                let(:request) { double("Rack::Request") }
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: lita-gerrit
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Jonathan Amiez
         | 
| @@ -16,14 +16,14 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - "~>"
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: ' | 
| 19 | 
            +
                    version: '4.0'
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 24 | 
             
                - - "~>"
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version: ' | 
| 26 | 
            +
                    version: '4.0'
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: httparty
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         |