ruboty-authorization 0.1.0 → 0.1.1

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: 94ac518c1f3febca4d9a1326852ca1b3759bf9b5
4
- data.tar.gz: fafb776ba1a2729ef8dce9609cbc1619d853856f
3
+ metadata.gz: 6d80b0bcd894dd9262aefabebdf5db3e90d7e77a
4
+ data.tar.gz: 928e0f37108f9619ba9a869f088128aea4f9ad72
5
5
  SHA512:
6
- metadata.gz: 48b7556e1b1cf180ae167f749a2971b977f5dbfbf8b88cd5d52e95574e6e33f0fcc88941cd31ec6b1f26958d69c85aedef40e0ea831e2b8e4eebdfc51518d1d0
7
- data.tar.gz: 979e2aa5d67fc71aee197307799c80dfb325efe79459309ace0439ba022d738906d47c213208e486ed4eb694580f5525b7a94411c1cd5a8f874915fe948bd5fd
6
+ metadata.gz: 6c26c3500e0cd2c901bb44f5f2541e0eeef57356c68b68591ebfe1a18ec78ba5cc1178a9fba49ea29e8fd244d64e9c6320c0f516726c444803b66b98ba827245
7
+ data.tar.gz: 7a58161d8634bd54bebf86b828f535454c19bf4d67112479f6667757eeaed3587bf700a0eec55845fec38e73e0e2e7eeff36d9840dc892a75bd5a1dd4d3f0eee
data/README.md CHANGED
@@ -31,6 +31,12 @@ authorize user
31
31
  @bot_name authorize user_name
32
32
  ```
33
33
 
34
+ return authorized users
35
+
36
+ ```
37
+ @bot_name users
38
+ ```
39
+
34
40
  ## Env
35
41
 
36
42
  ```
@@ -9,12 +9,13 @@ module Ruboty
9
9
  class AuthenticationError < StandardError; end
10
10
 
11
11
  def call(handler, message, options = {})
12
- if !!options[:missing] == missing? && message.match(pattern_with(handler.robot.name))
13
- authorized!(message)
14
- !!handler.send(name, message)
15
- else
16
- false
17
- end
12
+ return false unless !!options[:missing] == missing?
13
+ return false unless message.match(pattern_with(handler.robot.name))
14
+
15
+ authorized!(message)
16
+ !!handler.send(name, message)
17
+ rescue => e
18
+ message.reply(e.message)
18
19
  end
19
20
 
20
21
  def authorized!(message)
@@ -23,7 +24,7 @@ module Ruboty
23
24
  return if [ self.name , owner_name ].include? message.from_name
24
25
  return if @user_list.find_by_name(message.from_name)
25
26
 
26
- raise AuthenticationError.new("#{message.from_name} は許可されていないユーザーです")
27
+ raise AuthenticationError.new("#{message.from_name} is not authorized user")
27
28
  end
28
29
 
29
30
  def owner_name
@@ -1,4 +1,4 @@
1
- module Ruboty::Authorization
1
+ module Ruboty::Authorization::Action
2
2
  class Authorize < Ruboty::Actions::Base
3
3
  attr_reader :user_list
4
4
 
@@ -0,0 +1,11 @@
1
+ module Ruboty::Authorization::Action
2
+ class ReturnUser < Ruboty::Actions::Base
3
+ attr_reader :user_list
4
+
5
+ def call
6
+ @user_list = ::Ruboty::Authorization::UserList.new(message.robot.brain)
7
+ names = @user_list.users.map(&:name).join("\n")
8
+ message.reply(names)
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module Authorization
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -1,12 +1,18 @@
1
1
  require "ruboty/authorization/actions/authorize"
2
+ require "ruboty/authorization/actions/return_user"
2
3
 
3
4
  module Ruboty
4
5
  module Handlers
5
6
  class Authorization < Base
6
- on(/authorize +(.*)/m, name: 'authorize', description: '特定のユーザーのみ実行できるようにする')
7
+ on(/authorize\s+(.*)/m, name: 'authorize', description: 'authorize specific user')
8
+ on(/users\z/, name: 'return_users', description: 'return authorized users name')
7
9
 
8
10
  def authorize(message)
9
- Ruboty::Authorization::Authorize.new(message).call
11
+ Ruboty::Authorization::Action::Authorize.new(message).call
12
+ end
13
+
14
+ def return_users(message)
15
+ Ruboty::Authorization::Action::ReturnUser.new(message).call
10
16
  end
11
17
  end
12
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morioka Shuhei
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-13 00:00:00.000000000 Z
11
+ date: 2016-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -71,6 +71,7 @@ files:
71
71
  - bin/setup
72
72
  - lib/ruboty/authorization.rb
73
73
  - lib/ruboty/authorization/actions/authorize.rb
74
+ - lib/ruboty/authorization/actions/return_user.rb
74
75
  - lib/ruboty/authorization/user.rb
75
76
  - lib/ruboty/authorization/user_list.rb
76
77
  - lib/ruboty/authorization/version.rb