ruboty-icon_roulette 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ad66b7af9e117dce65a73f833afc53332b16cac1
4
+ data.tar.gz: 15bf9227c53123cbefbd3d97037a1baf01d18ca1
5
+ SHA512:
6
+ metadata.gz: e3dc75c56c843fdaa46c4a0add435b4e78838ec38b71e0c23bf7816be4d3612acae050c5e6d39b320850363acbde8573134897f83971a8cfe754730214ea5268
7
+ data.tar.gz: 59fc69f5c94622db719c3d2d9192211f9923d02d3dd8e5fb53b323ef969919f3fff9fb9c07b698f3164b62e918e73f92d2a28b9502d6f84822682c0c185ed34c
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruboty-icon_roulette.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Seiei Higa
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Ruboty::IconRoulette
2
+
3
+ ruboty handler for change bot's icon at random.
4
+
5
+ _Currently it works only with `ruboty-idobata` adapter_
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'ruboty-icon_roulette'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ruboty-icon_roulette
20
+
21
+ ## Usage
22
+
23
+ Set icon directory via ICON_PATHS environment variable.
24
+
25
+ ```
26
+ % tree icons
27
+ icons
28
+ ├── kao.jpeg
29
+ └── mihashi.jpg
30
+ % export ICON_PATH='icons/*'
31
+ % echo $ICON_PATH
32
+ icons/*
33
+ ```
34
+
35
+ then change bot's icon by below:
36
+
37
+ ```
38
+ > ruboty icon roulette!
39
+ ```
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it ( http://github.com/<my-github-username>/ruboty-icon_roulette/fork )
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,48 @@
1
+ module Ruboty
2
+ module Actions
3
+ class IconRoulette < Base
4
+ include Env::Validatable
5
+
6
+ env :ICON_PATHS, "Icon image file path to be used in icon roulette (e.g. icons/*)"
7
+
8
+ class << self
9
+ attr_accessor :bots
10
+ end
11
+
12
+ def initialize(message)
13
+ super
14
+ validate
15
+ end
16
+
17
+ def call
18
+ case message.robot.adapter.class.name
19
+ when 'Ruboty::Adapters::Idobata'
20
+ client.update_bot_icon(id: bot['id'], file_path: icon_paths.sample)
21
+ message.reply('lol')
22
+ else
23
+ message.reply("aahhhhhh, can't change icon!!!")
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def icon_paths
30
+ Dir[ENV['ICON_PATHS']].select do |path|
31
+ File.file?(path)
32
+ end
33
+ end
34
+
35
+ def idobata_api_token
36
+ message.robot.adapter.idobata_api_token
37
+ end
38
+
39
+ def client
40
+ @client ||= Atabodi::Client.new(api_token: idobata_api_token)
41
+ end
42
+
43
+ def bot
44
+ client.list_bots.body.bots.detect {|b| b['api_token'] == idobata_api_token }
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,11 @@
1
+ module Ruboty
2
+ module Handlers
3
+ class IconRoulette < Base
4
+ on /icon roulette!/, name: 'icon_roulette!', description: 'Change my icon at random'
5
+
6
+ def icon_roulette!(message)
7
+ Ruboty::Actions::IconRoulette.new(message).call
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ require "ruboty/icon_roulette/version"
2
+ require "ruboty/actions/icon_roulette"
3
+ require "ruboty/handlers/icon_roulette"
4
+
5
+ module Ruboty
6
+ module IconRoulette
7
+ # Your code goes here...
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Ruboty
2
+ module IconRoulette
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruboty/icon_roulette/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruboty-icon_roulette"
8
+ spec.version = Ruboty::IconRoulette::VERSION
9
+ spec.authors = ["Seiei Higa"]
10
+ spec.email = ["hanachin@gmail.com"]
11
+ spec.summary = %q{ruboty handler for change bot's icon at random.}
12
+ spec.homepage = "https://github.com/hanachin/ruboty-icon_roulette"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency "atabodi"
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruboty-icon_roulette
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Seiei Higa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: atabodi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - hanachin@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/ruboty/actions/icon_roulette.rb
68
+ - lib/ruboty/handlers/icon_roulette.rb
69
+ - lib/ruboty/icon_roulette.rb
70
+ - lib/ruboty/icon_roulette/version.rb
71
+ - ruboty-icon_roulette.gemspec
72
+ homepage: https://github.com/hanachin/ruboty-icon_roulette
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.2.2
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: ruboty handler for change bot's icon at random.
96
+ test_files: []
97
+ has_rdoc: