diff --git a/.gitignore b/.gitignore index d87d4be..d279d99 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ spec/reports test/tmp test/version_tmp tmp +tags diff --git a/README.md b/README.md index 79f313c..c9b0041 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # lita-gitlab-ci-hipchat -[![Build Status](https://travis-ci.org/Flink/lita-gitlab-ci-hipchat.svg?branch=develop)](https://travis-ci.org/Flink/lita-gitlab-ci-hipchat) [![Coverage Status](https://coveralls.io/repos/Flink/lita-gitlab-ci-hipchat/badge.png?branch=develop)](https://coveralls.io/r/Flink/lita-gitlab-ci-hipchat?branch=develop) +[![Gem Version](https://badge.fury.io/rb/lita-gitlab-ci-hipchat.svg)](http://badge.fury.io/rb/lita-gitlab-ci-hipchat) [![Build Status](https://travis-ci.org/Flink/lita-gitlab-ci-hipchat.svg?branch=develop)](https://travis-ci.org/Flink/lita-gitlab-ci-hipchat) [![Coverage Status](https://coveralls.io/repos/Flink/lita-gitlab-ci-hipchat/badge.png?branch=develop)](https://coveralls.io/r/Flink/lita-gitlab-ci-hipchat?branch=develop) [![Code Climate](https://codeclimate.com/github/Flink/lita-gitlab-ci-hipchat/badges/gpa.svg)](https://codeclimate.com/github/Flink/lita-gitlab-ci-hipchat) [![Dependency Status](https://gemnasium.com/Flink/lita-gitlab-ci-hipchat.svg)](https://gemnasium.com/Flink/lita-gitlab-ci-hipchat) Receive and display nicely web hooks from GitLab CI in HipChat. @@ -9,10 +9,12 @@ Receive and display nicely web hooks from GitLab CI in HipChat. Add lita-gitlab-ci-hipchat to your Lita instance's Gemfile: ``` ruby -gem 'lita-gitlab-ci-hipchat' +gem 'lita-gitlab-ci-hipchat', '~> 1.1' ``` +For Lita 3.x, use the 1.0 version of this gem. + ## Configuration ```ruby @@ -20,14 +22,14 @@ Lita.configure do |config| # The API token for your bot’s user config.handlers.gitlab_ci_hipchat.api_token = 'token' # The room to be notified (HipChat name, not JID) - config.handlers.gitlab_ci_hipchat.room = 'my_room' + config.handlers.gitlab_ci_hipchat.room = 'my_room' end ``` ## Usage This handler add a HTTP route at `/gitlab-ci`. So you have to add a web -hook pointing to that URL (http://lita-bot.tld/gitlab-ci). +hook pointing to that URL in GitLab CI (http://lita-bot.tld/gitlab-ci). ## License diff --git a/lib/lita/handlers/gitlab_ci_hipchat.rb b/lib/lita/handlers/gitlab_ci_hipchat.rb index 8f4027e..0db1482 100644 --- a/lib/lita/handlers/gitlab_ci_hipchat.rb +++ b/lib/lita/handlers/gitlab_ci_hipchat.rb @@ -1,10 +1,12 @@ module Lita module Handlers - class GitlabCiHipchat < Handler - http.post '/gitlab-ci', :receive + class GitlabCiHipchat + extend Lita::Handler::HTTPRouter - def self.default_config(config) - end + config :api_token, type: String, required: true + config :room, type: String, required: true + + http.post '/gitlab-ci', :receive def receive(request, response) json_data = JSON.parse(request.body.read) diff --git a/lita-gitlab-ci-hipchat.gemspec b/lita-gitlab-ci-hipchat.gemspec index 44cd04d..2a84541 100644 --- a/lita-gitlab-ci-hipchat.gemspec +++ b/lita-gitlab-ci-hipchat.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = "lita-gitlab-ci-hipchat" - spec.version = "1.0.0" + spec.version = "1.1.0" spec.authors = ["Loïc Guitaut"] spec.email = ["flink@belfalas.eu"] spec.description = %q{Receive and display nicely web hooks from GitLab CI in HipChat.} @@ -14,7 +14,7 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - spec.add_runtime_dependency "lita", ">= 3.3" + spec.add_runtime_dependency "lita", "~> 4.0" spec.add_runtime_dependency "hipchat", "~> 1.3.0" spec.add_development_dependency "bundler", "~> 1.3" diff --git a/spec/lita/handlers/gitlab_ci_hipchat_spec.rb b/spec/lita/handlers/gitlab_ci_hipchat_spec.rb index 0636bc3..e39b586 100644 --- a/spec/lita/handlers/gitlab_ci_hipchat_spec.rb +++ b/spec/lita/handlers/gitlab_ci_hipchat_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" describe Lita::Handlers::GitlabCiHipchat, lita_handler: true do - it { routes_http(:post, '/gitlab-ci').to(:receive) } + it { is_expected.to route_http(:post, '/gitlab-ci').to(:receive) } describe '#receive(request, response)' do let(:request) { double(Rack::Request) } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a237788..d4587ee 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,3 +9,5 @@ require 'fabrication' require "lita-gitlab-ci-hipchat" require "lita/rspec" +Lita.version_3_compatibility_mode = false +