lita-trello 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3f8bad963279d61d23aa48e3f6c62525ea6f79c
4
- data.tar.gz: e0a855500187077ac747581774a7636381bda6ba
3
+ metadata.gz: 0d32024858f2d30359789fef493b73a6ae0ca3f4
4
+ data.tar.gz: 31c611c68f82b5642f725767ef981363e52811b4
5
5
  SHA512:
6
- metadata.gz: 58938dcae9f8133382562e1a9c3b26a976979c6613f528ecb19857574bf72f88a3f7ebb9159a5e1e33e19f881acf83b05d9d1b1d9540a7ae0fb2854fc694f033
7
- data.tar.gz: 2468835ed31df28910bf49ae0146944c1aaf54cc8e4c68d0dc06a1ad9d3628e3f43ec2bd7ad644acf82e8806548abccbe86fa9e82e462dd502fb4b81f6bb56c3
6
+ metadata.gz: b5d42862e8507662c722e923de7279472fc035dc34b9e5130a64ea4e9e6b8761e2bedffa90826c426f5fa4feec209b041a7a26b77b544c7e3b26f1a8d413fb89
7
+ data.tar.gz: b7db10dc4818cebe752404729a89749ef1d11455ec6c2ded92ca0b2c3c4834f62a016c546d617f3264773f2287ca05a172bf72d70921c061c9c4a70ab6cf01db
@@ -0,0 +1,19 @@
1
+ Documentation:
2
+ Exclude:
3
+ - lib/lita/handlers/trello.rb
4
+
5
+ FileName:
6
+ Exclude:
7
+ - lib/lita-trello.rb
8
+
9
+ Metrics/AbcSize:
10
+ Max: 23
11
+
12
+ Metrics/ClassLength:
13
+ Max: 115
14
+
15
+ Metrics/LineLength:
16
+ Max: 115
17
+
18
+ Metrics/MethodLength:
19
+ Max: 18
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1
4
+ - 2.2
5
+ services:
6
+ - redis-server
7
+ sudo: false
@@ -0,0 +1,9 @@
1
+ Pull requests are awesome! Pull requests with tests are even more awesome!
2
+
3
+ ## Quick steps
4
+
5
+ 1. Fork the repo.
6
+ 2. Run the tests: `bundle && rake`
7
+ 3. Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, it needs a test!
8
+ 4. Make the test pass.
9
+ 5. Push to your fork and submit a pull request.
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
data/README.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # lita-trello
2
2
 
3
+ [![Build Status](https://img.shields.io/travis/RWJMurphy/lita-trello/master.svg)](https://travis-ci.org/RWJMurphy/lita-trello)
4
+ [![MIT License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://tldrlegal.com/license/mit-license)
5
+ [![RubyGems](http://img.shields.io/gem/v/lita-trello.svg)](https://rubygems.org/gems/lita-trello)
6
+ [![Coveralls Coverage](https://img.shields.io/coveralls/RWJMurphy/lita-trello/master.svg)](https://coveralls.io/r/RWJMurphy/lita-trello)
7
+ [![Code Climate](https://img.shields.io/codeclimate/github/RWJMurphy/lita-trello.svg)](https://codeclimate.com/github/RWJMurphy/lita-trello)
8
+ [![Gemnasium](https://img.shields.io/gemnasium/RWJMurphy/lita-trello.svg)](https://gemnasium.com/RWJMurphy/lita-trello)
9
+
3
10
  Manage your Trello board from Lita.
4
11
 
5
12
  Inspired by [hubot-trello](https://github.com/hubot-scripts/hubot-trello).
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new(:rubocop)
5
7
 
6
- task default: :spec
8
+ task default: [:spec, :rubocop]
@@ -1,12 +1,14 @@
1
- require "lita"
1
+ require 'lita'
2
2
 
3
3
  Lita.load_locales Dir[File.expand_path(
4
- File.join("..", "..", "locales", "*.yml"), __FILE__
4
+ File.join('..', '..', 'locales', '*.yml'), __FILE__
5
5
  )]
6
6
 
7
- require "lita/handlers/trello"
7
+ require 'trello'
8
+
9
+ require 'lita/handlers/trello'
8
10
 
9
11
  Lita::Handlers::Trello.template_root File.expand_path(
10
- File.join("..", "..", "templates"),
11
- __FILE__
12
+ File.join('..', '..', 'templates'),
13
+ __FILE__
12
14
  )
@@ -1,5 +1,3 @@
1
- require 'trello'
2
-
3
1
  module Lita
4
2
  module Handlers
5
3
  class Trello < Handler
@@ -7,90 +5,110 @@ module Lita
7
5
  config :token
8
6
  config :board
9
7
 
10
- route(/^trello\s+new\s+[^\s]+\s+[^\s]+/i, :handle_create_card, command: true, help: {
11
- "trello new LIST Do the thing" => "Create a new card in LIST called 'Do the thing'"
12
- })
13
- def handle_create_card(r)
14
- list_name = r.args[1]
15
- name = r.args[2..-1].join(" ")
8
+ route(
9
+ /^trello\s+new\s+(?<list_name>(\w+|"[^"]+"))\s+(?<name>.*)/i,
10
+ :new,
11
+ command: true,
12
+ help: {
13
+ t('help.new.syntax') => t('help.new.desc')
14
+ }
15
+ )
16
+
17
+ route(
18
+ %r{^trello\s+move\s+https://trello.com/c/(?<card_id>\w+)\s+(?<list_name>(\w+|"[^"]+"))},
19
+ :move,
20
+ command: true,
21
+ help: {
22
+ t('help.move.syntax') => t('help.move.desc')
23
+ }
24
+ )
25
+
26
+ route(
27
+ /^trello\s+list\s+(?<list_name>(\w+|"[^"]+"))/i,
28
+ :list,
29
+ command: true,
30
+ help: {
31
+ t('help.list.syntax') => t('help.list.desc')
32
+ }
33
+ )
34
+
35
+ route(
36
+ /^trello\s+lists$/i,
37
+ :show_lists,
38
+ command: true,
39
+ help: {
40
+ t('help.lists.syntax') => t('help.lists.desc')
41
+ }
42
+ )
43
+
44
+ def new(r)
45
+ list_name = r.match_data['list_name']
46
+ name = r.match_data['name']
16
47
 
17
48
  list_id = lists[list_name.downcase].id
18
49
  if list_id.nil?
19
- r.reply "I couldn't find a list named #{list_name}."
50
+ r.reply t('error.no_list', list_name: list_name)
20
51
  return
21
52
  end
22
53
 
23
- r.reply "Ok #{r.user.name}, I'm creating a new card in #{list_name}."
54
+ r.reply t('card.creating', user_name: r.user.name, list_name: list_name)
24
55
  begin
25
56
  card = new_card(name, list_id)
26
- r.reply "Here you go: #{card.short_url}"
57
+ r.reply t('card.created', url: card.short_url)
27
58
  rescue
28
- r.reply "Something failed."
59
+ r.reply t('error.generic')
29
60
  end
30
61
  end
31
62
 
32
- route(/^trello\s+move\s+[^\s]+\s+[^\s]+/i, :handle_move_card, command: true, help: {
33
- "trello move https://trello.com/c/CARD_ID LIST" => "Move a card to LIST"
34
- })
35
- def handle_move_card(r)
36
- card_id = r.args[1]
37
- list_name = r.args[2]
63
+ def move(r)
64
+ card_id = r.match_data['card_id']
65
+ list_name = r.match_data['list_name']
38
66
 
39
67
  list = lists[list_name.downcase]
40
68
  if list.nil?
41
- r.reply "I couldn't find a list named #{list_name}."
69
+ r.reply t('error.no_list', list_name: list_name)
42
70
  return
43
71
  end
44
72
 
45
- card_id = card_id.gsub(/(^<|>$)/, '')
46
- if %r{^https?://trello.com/c/([^/]+)/?$} =~ card_id
47
- card_id = $1
48
- end
49
-
50
73
  card = trello.find(:card, card_id)
51
74
  if card.nil?
52
- r.reply "I couldn't find that card."
75
+ r.reply t('error.no_card')
53
76
  return
54
77
  end
55
78
 
56
79
  begin
57
80
  card.move_to_list(list)
58
- r.reply "Ok #{r.user.name}, I moved that card to #{list_name}."
81
+ r.reply t('card.moved', user_name: r.user.name, list_name: list_name)
59
82
  rescue
60
- r.reply "Something failed."
83
+ r.reply t('error.generic')
61
84
  end
62
85
  end
63
86
 
64
- route(/^trello\s+list\s+[^\s]+/i, :handle_list_cards, command: true, help: {
65
- "trello list LIST" => "Show all cards in LIST"
66
- })
67
- def handle_list_cards(r)
68
- list_name = r.args[1]
87
+ def list(r)
88
+ list_name = r.match_data['list_name']
69
89
  list = lists[list_name.downcase]
70
90
  if list.nil?
71
- r.reply "I couldn't find a list named #{list_name}."
91
+ r.reply t('error.no_list', list_name: list_name)
72
92
  return
73
93
  end
74
94
 
75
- r.reply("Here are the cards in #{list.name}:\n\n" +
76
- list.cards.map { |card| "* #{card.name} - #{card.short_url}" }.join("\n")
77
- )
95
+ r.reply(t('card.list', list_name: list_name) +
96
+ list.cards.map { |card| "* #{card.name} - #{card.short_url}" }.join("\n")
97
+ )
78
98
  end
79
99
 
80
- route(/^trello\s+lists$/i, :handle_lists, command: true, help: {
81
- "trello lists" => "Show all lists on your board"
82
- })
83
- def handle_lists(r)
84
- r.reply("Here are all the lists on your board:\n\n" +
85
- lists.keys.map { |list_name| "* #{list_name}" }.join("\n")
86
- )
100
+ def show_lists(r)
101
+ r.reply(t('list.list') +
102
+ lists.keys.map { |list_name| "* #{list_name}" }.join("\n")
103
+ )
87
104
  end
88
105
 
89
106
  private
107
+
90
108
  def trello
91
109
  @trello ||= ::Trello::Client.new(
92
110
  developer_public_key: config.public_key,
93
- member_token: config.token,
111
+ member_token: config.token
94
112
  )
95
113
  end
96
114
 
@@ -108,13 +126,12 @@ module Lita
108
126
  @default_list_id ||= redis.get('default_list_id')
109
127
  end
110
128
 
111
- def new_card(name, list_id=nil)
129
+ def new_card(name, list_id = nil)
112
130
  trello.create(:card,
113
- 'name' => name,
114
- 'idList' => list_id || default_list_id,
115
- )
131
+ 'name' => name,
132
+ 'idList' => list_id || default_list_id
133
+ )
116
134
  end
117
-
118
135
  end
119
136
 
120
137
  Lita.register_handler(Trello)
@@ -1,27 +1,30 @@
1
1
  Gem::Specification.new do |spec|
2
- spec.name = "lita-trello"
3
- spec.version = "0.0.5"
4
- spec.authors = ["Reed Kraft-Murphy"]
5
- spec.email = ["reed@reedmurphy.net"]
6
- spec.description = "Manage your Trello board from Lita"
7
- spec.summary = "Manage your Trello board from Lita"
8
- spec.homepage = "https://github.com/RWJMurphy/lita-trello"
9
- spec.license = "MIT"
10
- spec.metadata = { "lita_plugin_type" => "handler" }
2
+ spec.name = 'lita-trello'
3
+ spec.version = '0.0.6'
4
+ spec.authors = ['Reed Kraft-Murphy']
5
+ spec.email = ['reed@reedmurphy.net']
6
+ spec.description = 'Manage your Trello board from Lita'
7
+ spec.summary = 'Manage your Trello board from Lita'
8
+ spec.homepage = 'https://github.com/RWJMurphy/lita-trello'
9
+ spec.license = 'MIT'
10
+ spec.metadata = { 'lita_plugin_type' => 'handler' }
11
11
 
12
- spec.files = `git ls-files`.split($/)
12
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
13
13
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
14
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
- spec.require_paths = ["lib"]
15
+ spec.require_paths = ['lib']
16
16
 
17
- spec.required_ruby_version = ">= 2.1.0"
17
+ spec.required_ruby_version = '>= 2.1.0'
18
18
 
19
- spec.add_runtime_dependency "lita", ">= 4.3"
20
- spec.add_runtime_dependency "ruby-trello", "~> 1.1"
19
+ spec.add_runtime_dependency 'lita', '>= 4.3'
20
+ spec.add_runtime_dependency 'ruby-trello', '~> 1.1'
21
21
 
22
- spec.add_development_dependency "bundler", "~> 1.3"
23
- spec.add_development_dependency "pry-byebug"
24
- spec.add_development_dependency "rake"
25
- spec.add_development_dependency "rack-test"
26
- spec.add_development_dependency "rspec", ">= 3.0.0"
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'coveralls'
24
+ spec.add_development_dependency 'pry-byebug'
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'rack-test'
27
+ spec.add_development_dependency 'rspec', '>= 3.0.0'
28
+ spec.add_development_dependency 'rubocop'
29
+ spec.add_development_dependency 'simplecov'
27
30
  end
@@ -2,3 +2,27 @@ en:
2
2
  lita:
3
3
  handlers:
4
4
  trello:
5
+ error:
6
+ generic: Something failed.
7
+ no_list: "I couldn't find a list named %{list_name}."
8
+ no_card: "I couldn't find that card."
9
+ help:
10
+ new:
11
+ syntax: trello new LIST Do the thing
12
+ desc: Create a new card in LIST called 'Do the thing'
13
+ move:
14
+ syntax: trello move https://trello.com/c/CARD_ID LIST
15
+ desc: Move a card to LIST
16
+ list:
17
+ syntax: trello list LIST
18
+ desc: Show all cards in LIST
19
+ lists:
20
+ syntax: trello lists
21
+ desc: Show all lists on your board
22
+ card:
23
+ creating: "Ok %{user_name}, I'm creating a new card in %{list_name}."
24
+ created: "Here you go: %{url}"
25
+ moved: "Ok %{user_name}, I moved that card to %{list_name}."
26
+ list: "Here are the cards in %{list_name}:\n\n"
27
+ list:
28
+ list: "Here are all the lists on your board:\n\n"
@@ -1,4 +1,85 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Lita::Handlers::Trello, lita_handler: true do
4
+ it { is_expected.to route_command('trello new LIST Do the thing').to(:new) }
5
+ it { is_expected.to route_command('trello new "A LIST" Do the thing').to(:new) }
6
+ it { is_expected.to route_command('trello move https://trello.com/c/CARD_ID LIST').to(:move) }
7
+ it { is_expected.to route_command('trello move https://trello.com/c/CARD_ID "A LIST"').to(:move) }
8
+ it { is_expected.to route_command('trello list LIST').to(:list) }
9
+ it { is_expected.to route_command('trello list "A LIST"').to(:list) }
10
+ it { is_expected.to route_command('trello lists').to(:show_lists) }
11
+
12
+ before do
13
+ registry.config.handlers.trello.public_key = 'foo'
14
+ registry.config.handlers.trello.token = 'bar'
15
+ registry.config.handlers.trello.board = 'baz'
16
+ end
17
+
18
+ let(:card) do
19
+ card = double
20
+ allow(card).to receive(:name) { 'cardname' }
21
+ allow(card).to receive(:short_url) { 'http://example.com/cardshorturl' }
22
+ allow(card).to receive(:move_to_list).with(anything) { true }
23
+ card
24
+ end
25
+
26
+ let(:list) do
27
+ list = double
28
+ allow(list).to receive(:name) { 'listname' }
29
+ allow(list).to receive(:cards) { [card] }
30
+ allow(list).to receive(:id) { 1 }
31
+ list
32
+ end
33
+
34
+ let(:board) do
35
+ board = double
36
+ allow(board).to receive(:lists) { [list] }
37
+ board
38
+ end
39
+
40
+ let(:client) do
41
+ client = double
42
+ allow(client).to receive(:find).with(:board, kind_of(String)) { board }
43
+ allow(client).to receive(:find).with(:card, kind_of(String)) { card }
44
+ allow(client).to receive(:create) { card }
45
+ client
46
+ end
47
+
48
+ describe '#new' do
49
+ it 'creates a card' do
50
+ expect(::Trello::Client).to receive(:new) { client }
51
+ send_command('trello new listname Do the thing')
52
+ expect(replies.last).to eq('Here you go: http://example.com/cardshorturl')
53
+ end
54
+ end
55
+
56
+ describe '#move' do
57
+ it 'moves a card' do
58
+ expect(::Trello::Client).to receive(:new) { client }
59
+ send_command('trello move https://trello.com/c/CARD_ID listname')
60
+ expect(replies.last).to eq('Ok Test User, I moved that card to listname.')
61
+ end
62
+ end
63
+
64
+ describe '#list' do
65
+ it 'shows cards for a list' do
66
+ expect(::Trello::Client).to receive(:new) { client }
67
+ send_command('trello list listname')
68
+ expect(replies.last).to eq("Here are the cards in listname:\n\n* cardname - http://example.com/cardshorturl")
69
+ end
70
+
71
+ it 'shows an error if there is no list' do
72
+ expect(::Trello::Client).to receive(:new) { client }
73
+ send_command('trello list badname')
74
+ expect(replies.last).to eq("I couldn't find a list named badname.")
75
+ end
76
+ end
77
+
78
+ describe '#show_lists' do
79
+ it 'shows lists' do
80
+ expect(::Trello::Client).to receive(:new) { client }
81
+ send_command('trello lists')
82
+ expect(replies.last).to eq("Here are all the lists on your board:\n\n* listname")
83
+ end
84
+ end
4
85
  end
@@ -1,6 +1,31 @@
1
- require "lita-trello"
2
- require "lita/rspec"
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter
6
+ ]
7
+ SimpleCov.start { add_filter '/spec/' }
8
+
9
+ require 'lita-trello'
10
+ require 'lita/rspec'
3
11
 
4
12
  # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
5
13
  # was generated with Lita 4, the compatibility mode should be left disabled.
6
14
  Lita.version_3_compatibility_mode = false
15
+
16
+ RSpec.configure do |config|
17
+ config.expect_with :rspec do |expectations|
18
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
19
+ end
20
+
21
+ config.mock_with :rspec do |mocks|
22
+ mocks.verify_partial_doubles = true
23
+ end
24
+
25
+ config.filter_run :focus
26
+ config.run_all_when_everything_filtered = true
27
+ config.default_formatter = 'doc' if config.files_to_run.one?
28
+ config.order = :random
29
+
30
+ Kernel.srand config.seed
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-trello
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reed Kraft-Murphy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-24 00:00:00.000000000 Z
11
+ date: 2015-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: pry-byebug
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +122,34 @@ dependencies:
108
122
  - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: 3.0.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
111
153
  description: Manage your Trello board from Lita
112
154
  email:
113
155
  - reed@reedmurphy.net
@@ -116,6 +158,9 @@ extensions: []
116
158
  extra_rdoc_files: []
117
159
  files:
118
160
  - ".gitignore"
161
+ - ".rubocop.yml"
162
+ - ".travis.yml"
163
+ - CONTRIBUTING.md
119
164
  - Gemfile
120
165
  - LICENSE.txt
121
166
  - README.md