ruboty-trello 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f5dc2041be99da7233feb6fff7a8da132312fbae
4
- data.tar.gz: ae437de2c9534e8a9a3386106d0d632ed6da8a51
2
+ SHA256:
3
+ metadata.gz: d5de100aa0c41aadb14b6a50f78fbe529327120f15553df55a4d656729381392
4
+ data.tar.gz: 3ddadb88822d1ccde139374a725933b1f69461d9b5832761f068cccb0b9fa214
5
5
  SHA512:
6
- metadata.gz: 21c8ca3d2d14c3051874c65f0e2d4fe8e6a769c96612de3491a4df3fa30fc3f0a751f269e50d9ab1028fc58db377f1c63c3cd8766e41692a901e0388d8f4a881
7
- data.tar.gz: a56c36a8dc7d7c61a7e6ba88781c63d1e8893316b4ad792c104d51569605141172ff12ba210b93f86e119ed922fc9f0dc7f9c73c6de9fb1f4fe345ad6680f92c
6
+ metadata.gz: a55234c16243c7af01196b0867b4e149fa5c101cb8a1e62d6838631edaffaa2432b31a53ca999b8911970cffcc1bda950eb5b070a02cc3080f25e6e07b5690ef
7
+ data.tar.gz: 9a29be0f2b574e5057ed2b58350db37027c1b92460d26c2784e8aa3b2939b38dcaf50494a1e86287d56a1bfc95651da9778802ee363665e5ad68f9703c7a6e4d
data/README.md CHANGED
@@ -21,18 +21,46 @@ Or install it yourself as:
21
21
  ## Usage
22
22
 
23
23
  ```
24
- @ruboty trello b <board_name> l <list_name> name
24
+ @ruboty trello b <board_name> l <list_name> (lb <label_name>) (dd <due_date>) c <card_name>
25
25
  ```
26
26
 
27
+ e.g.
28
+
29
+
30
+ ```
31
+ @ruboty trello b development l icebox c something
32
+ @ruboty trello b development l icebox dd 2016-01-01 c something
33
+ @ruboty trello b development l icebox dd 2016-01-01 01:02 c something
34
+ @ruboty trello b development l icebox lb feature dd 2016-01-01 01:02 c something
35
+ ```
36
+
37
+
27
38
  ## ENV
28
39
 
40
+ ### required
41
+
29
42
  ```
30
43
  TRELLO_DEVELOPER_PUBLIC_KEY - Developer API Key
31
- TRELLO_MEMBER_TOKEN - Member Token
44
+ TRELLO_MEMBER_TOKEN - Member Token (require read&write scope)
32
45
  ```
33
46
 
34
47
  see https://github.com/jeremytregunna/ruby-trello#configuration to get these keys
35
48
 
49
+ ### optional
50
+
51
+ ```
52
+ TRELLO_AUTO_ASSIGN - If set to '1', assigns sender with created card
53
+ TRELLO_RESPONSE_PREFIX - Specify response message (default is 'Created')
54
+ TRELLO_MEMBER_FROM_SENDER - JSON for sender to Trello member mapping (ex: {"ihara":"masahiroihara", "taro":"taroyamada"})
55
+ ```
56
+
57
+ ## How to develop
58
+
59
+ You have to set TRELO_DEVELOPER_PUBLIC_KEY and TRELLO_MEMBER_TOKEN, set other environment variables if you need.
60
+ ```
61
+ > TRELLO_DEVELOPER_PUBLIC_KEY=xxx TRELLO_MEMBER_TOKEN=xxx bundle exec ruboty -l lib/rutoby/trello.rb
62
+ ```
63
+
36
64
  ## Contributing
37
65
 
38
66
  1. Fork it ( https://github.com/bitjourney/ruboty-trello/fork )
data/Rakefile CHANGED
@@ -1,6 +1 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
1
+ require 'bundler/gem_tasks'
@@ -8,7 +8,7 @@ end
8
8
  module Ruboty
9
9
  module Handlers
10
10
  class Trello < Base
11
- on /trello b (?<board_name>.*) l (?<list_name>.*) (?<name>.*)\z/i, name: 'trello', description: 'Add card to Trello'
11
+ on /trello\s+b\s+(?<board_name>.*?)\s+l\s+(?<list_name>.*?)\s+(lb\s+(?<label_name>.*?)\s+)?(dd\s+(?<due_date>.*?)\s+)?c\s+(?<name>.*)\z/, name: 'trello', description: 'Add card to Trello'
12
12
 
13
13
  def trello(message)
14
14
  me = ::Trello::Member.find('me')
@@ -25,7 +25,37 @@ module Ruboty
25
25
  return
26
26
  end
27
27
 
28
- ::Trello::Card.create(name: message[:name], list_id: list.id)
28
+ label = board.labels.find { |label| label.name == message[:label_name] }
29
+ label_id = label&.id
30
+
31
+ member_id = nil
32
+ if ENV['TRELLO_AUTO_ASSIGN'] && message.from_name
33
+ sender = message.from_name.downcase
34
+ member = find_member(board.members, sender)
35
+ member_id = member&.id
36
+ end
37
+
38
+ iso8601_time = Time.parse(message[:due_date]).iso8601 rescue nil
39
+
40
+ new_card = ::Trello::Card.create(name: message[:name], list_id: list.id, card_labels: label_id, member_ids: member_id, due: iso8601_time)
41
+ if new_card.short_url
42
+ prefix = ENV['TRELLO_RESPONSE_PREFIX'] || 'Created'
43
+ message.reply "#{prefix} #{new_card.short_url}"
44
+ end
45
+ end
46
+
47
+ def find_member(members, sender)
48
+ # SlackのDisplay NameとTrelloのUsernameのマッピング
49
+ senders_to_members = {}
50
+ if ENV['TRELLO_MEMBER_FROM_SENDER']
51
+ senders_to_members = JSON.parse(ENV['TRELLO_MEMBER_FROM_SENDER'])
52
+ end
53
+ members.find do |member|
54
+ # sender: SlackのDisplay Name
55
+ # member.username: TrelloのUsername
56
+ # member.full_name: AtlassianのPublic Name
57
+ member.username.downcase == senders_to_members[sender] || member.username.downcase == sender || member.full_name.downcase == sender
58
+ end
29
59
  end
30
60
  end
31
61
  end
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module Trello
3
- VERSION = '0.1.2'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -5,12 +5,12 @@ require 'ruboty/trello/version'
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'ruboty-trello'
7
7
  spec.version = Ruboty::Trello::VERSION
8
- spec.authors = ['Masahiro Ihara']
9
- spec.email = ['ihara@bitjourney.com']
8
+ spec.authors = ['Masahiro Ihara', 'Takaya Deguchi']
9
+ spec.email = ['ihara@bitjourney.com', 'dex1t@degoo.org']
10
10
 
11
11
  spec.summary = %q{Ruboty plugin for adding a new card to Trello}
12
12
  spec.description = %q{Ruboty plugin for adding a new card to Trello}
13
- spec.homepage = 'http://github.com/bitjourney/ruboty-trello'
13
+ spec.homepage = 'https://github.com/bitjourney/ruboty-trello'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency 'ruboty'
22
22
  spec.add_dependency 'ruby-trello'
23
- spec.add_development_dependency 'bundler', '~> 1.10'
24
- spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'bundler'
24
+ spec.add_development_dependency 'rake'
25
25
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-trello
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Ihara
8
+ - Takaya Deguchi
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2015-06-05 00:00:00.000000000 Z
12
+ date: 2020-09-17 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: ruboty
@@ -42,49 +43,47 @@ dependencies:
42
43
  name: bundler
43
44
  requirement: !ruby/object:Gem::Requirement
44
45
  requirements:
45
- - - "~>"
46
+ - - ">="
46
47
  - !ruby/object:Gem::Version
47
- version: '1.10'
48
+ version: '0'
48
49
  type: :development
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
- - - "~>"
53
+ - - ">="
53
54
  - !ruby/object:Gem::Version
54
- version: '1.10'
55
+ version: '0'
55
56
  - !ruby/object:Gem::Dependency
56
57
  name: rake
57
58
  requirement: !ruby/object:Gem::Requirement
58
59
  requirements:
59
- - - "~>"
60
+ - - ">="
60
61
  - !ruby/object:Gem::Version
61
- version: '10.0'
62
+ version: '0'
62
63
  type: :development
63
64
  prerelease: false
64
65
  version_requirements: !ruby/object:Gem::Requirement
65
66
  requirements:
66
- - - "~>"
67
+ - - ">="
67
68
  - !ruby/object:Gem::Version
68
- version: '10.0'
69
+ version: '0'
69
70
  description: Ruboty plugin for adding a new card to Trello
70
71
  email:
71
72
  - ihara@bitjourney.com
73
+ - dex1t@degoo.org
72
74
  executables: []
73
75
  extensions: []
74
76
  extra_rdoc_files: []
75
77
  files:
76
78
  - ".gitignore"
77
79
  - ".rspec"
78
- - ".travis.yml"
79
80
  - Gemfile
80
81
  - README.md
81
82
  - Rakefile
82
- - bin/console
83
- - bin/setup
84
83
  - lib/ruboty/trello.rb
85
84
  - lib/ruboty/trello/version.rb
86
85
  - ruboty-trello.gemspec
87
- homepage: http://github.com/bitjourney/ruboty-trello
86
+ homepage: https://github.com/bitjourney/ruboty-trello
88
87
  licenses:
89
88
  - MIT
90
89
  metadata: {}
@@ -103,8 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
102
  - !ruby/object:Gem::Version
104
103
  version: '0'
105
104
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.4.5
105
+ rubygems_version: 3.1.2
108
106
  signing_key:
109
107
  specification_version: 4
110
108
  summary: Ruboty plugin for adding a new card to Trello
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.2
4
- before_install: gem install bundler -v 1.10.2
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "ruboty/trello"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here