ruboty-qiita_scouter 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a60c584336539051f629becfd150e569d99e6462
4
+ data.tar.gz: 7b07c03afe0a83537fae9f64a5a14c5fda6d2c19
5
+ SHA512:
6
+ metadata.gz: ff21332e275e2f3ac1485db3cce0b20af854b4795e16cf26e6dde09045a5304f7c3249bda735ff6785ab10bd3f4983372ce03c8dbfa89868252c60040f27d760
7
+ data.tar.gz: 5f7d3c8c71158d97bdba4fd49eea9753a9bc6e45058961c37b19ef5e74e7d94cd42101cfb35d6834fbc8101ca401afa95dae67a73b36dacd9276430c724a3e03
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
File without changes
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem update --system 2.1.11
4
+ - gem --version
5
+ rvm:
6
+ - 1.9.3
7
+ - 2.0.0
8
+ - 2.1.0
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+ gem 'simplecov', '~> 0.8.2'
5
+ group :test do
6
+ gem 'coveralls', require: false
7
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 tbpgr
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.
@@ -0,0 +1,62 @@
1
+ # Ruboty::QiitaScouter
2
+
3
+ An Ruboty Handler + Actions plugin to analyze your Qiita power.
4
+
5
+ [![Build Status](https://travis-ci.org/tbpgr/ruboty-qiita_scouter.png?branch=master)](https://travis-ci.org/tbpgr/ruboty-qiita_scouter)
6
+ [![Coverage Status](https://coveralls.io/repos/tbpgr/ruboty-qiita_scouter/badge.png)](https://coveralls.io/r/tbpgr/ruboty-qiita_scouter)
7
+
8
+ [Ruboty](https://github.com/r7kamura/ruboty) is Chat bot framework. Ruby + Bot = Ruboty
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'ruboty-qiita_scouter'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install ruboty-qiita_scouter
25
+
26
+ ## Usage
27
+ ### Analyze your qiita power
28
+
29
+ ~~~
30
+ > ruboty help
31
+ ruboty /qiita scouter (?<id>.+?)\z/ - analyze qiita power
32
+
33
+ # exist user
34
+ > ruboty qiita scouter tbpgr
35
+ ユーザー名: tbpgr 戦闘力: 218544 攻撃力: 27840 知力: 183860 すばやさ: 6844
36
+
37
+ # not exist user
38
+ > ruboty qiita scouter invalid_user
39
+ Failed by OpenURI::HTTPError
40
+ ~~~
41
+
42
+ ## ENV
43
+ nothing
44
+
45
+ ## Screenshot
46
+ nothing
47
+
48
+ ## Dependency
49
+ * [QiitaScouter gem](https://github.com/tbpgr/qiita_scouter)
50
+ * QiitaScouter gem depend on [Qiita Developer API v1](https://qiita.com/docs)
51
+
52
+ ## Reference
53
+ * This plugin's product code template is generated by [ruboty-gen GitHub](https://github.com/blockgiven/ruboty-gen)
54
+ * This plugin's test code template is generated by [rspec_piccolo GitHub](https://github.com/tbpgr/rspec_piccolo)
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it ( https://github.com/tbpgr/ruboty-qiita_scouter/fork )
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create a new Pull Request
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core'
3
+ require 'rspec/core/rake_task'
4
+ task default: [:spec]
5
+
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = 'spec/**/*_spec.rb'
8
+ end
@@ -0,0 +1,19 @@
1
+ require 'ruboty/qiita_scouter/actions/analyze'
2
+
3
+ module Ruboty
4
+ # Handlers
5
+ module Handlers
6
+ # QiitaScouter
7
+ class QiitaScouter < Base
8
+ on(
9
+ /qiita scouter (?<id>.+?)\z/,
10
+ name: 'analyze',
11
+ description: 'analyze qiita power'
12
+ )
13
+
14
+ def analyze(message)
15
+ Ruboty::QiitaScouter::Actions::Analyze.new(message).call
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ require 'qiita_scouter_core'
2
+
3
+ require 'ruboty'
4
+ require 'ruboty/qiita_scouter/version'
5
+ require 'ruboty/handlers/qiita_scouter'
6
+
7
+ module Ruboty
8
+ # QiitaScouter
9
+ module QiitaScouter
10
+ # Your code goes here...
11
+ end
12
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+ # rubocop:disable LineLength
3
+ module Ruboty
4
+ module QiitaScouter
5
+ # Actions
6
+ module Actions
7
+ # Analyze Qiita power
8
+ class Analyze < Ruboty::Actions::Base
9
+ def call
10
+ message.reply(analyze)
11
+ end
12
+
13
+ private
14
+
15
+ def analyze
16
+ power_levels = ::QiitaScouter::Core.new.analyze(id)
17
+ format("ユーザー名: %s 戦闘力: %s 攻撃力: %s 知力: %s すばやさ: %s", id, *power_levels)
18
+ rescue => e
19
+ format("Failed by %s", e.class.name)
20
+ end
21
+
22
+ def id
23
+ message[:id]
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ # rubocop:enable LineLength
@@ -0,0 +1,6 @@
1
+ module Ruboty
2
+ # QiitaScouter
3
+ module QiitaScouter
4
+ VERSION = '1.0.0'
5
+ end
6
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruboty/qiita_scouter/version'
5
+
6
+ # rubocop:disable LineLength
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'ruboty-qiita_scouter'
9
+ spec.version = Ruboty::QiitaScouter::VERSION
10
+ spec.authors = ['tbpgr']
11
+ spec.email = ['tbpgr@tbpgr.jp']
12
+ spec.summary = 'An Ruboty Handler + Actions to analyze your Qiita power.'
13
+ spec.description = 'An Ruboty Handler + Actions to analyze your Qiita power.'
14
+ spec.homepage = 'https://github.com/tbpgr/ruboty-qiita_scouter'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'ruboty'
23
+ spec.add_dependency 'qiita_scouter'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.6'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rspec'
28
+ spec.add_development_dependency 'simplecov'
29
+ end
30
+ # rubocop:enable LineLength
@@ -0,0 +1,66 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'ruboty/handlers/qiita_scouter'
4
+ require 'ruboty/qiita_scouter/actions/analyze'
5
+
6
+ # rubocop:disable LineLength, UnusedMethodArgument
7
+ describe Ruboty::Handlers::QiitaScouter do
8
+ context :analyze do
9
+ let(:robot) do
10
+ Ruboty::Robot.new
11
+ end
12
+
13
+ let(:analyze) do
14
+ Ruboty::QiitaScouter::Actions::Analyze
15
+ end
16
+
17
+ cases = [
18
+ {
19
+ case_no: 1,
20
+ case_title: 'exist id case',
21
+ body: 'ruboty qiita scouter tbpgr',
22
+ expected: 'expected message',
23
+ hit: true
24
+ },
25
+ {
26
+ case_no: 2,
27
+ case_title: 'not hit message case',
28
+ body: 'ruboty not_exist message',
29
+ expected: 'expected message',
30
+ hit: false
31
+ }
32
+ ]
33
+
34
+ cases.each do |c|
35
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
36
+ begin
37
+ case_before c
38
+
39
+ # -- given --
40
+ allow_any_instance_of(analyze).to receive(:analyze).and_return(c[:expected])
41
+
42
+ # -- then --
43
+ if c[:hit]
44
+ Ruboty.logger.should_receive(:info).with(c[:expected])
45
+ else
46
+ Ruboty.logger.should_not_receive(:info)
47
+ end
48
+
49
+ # -- when --
50
+ robot.receive(body: c[:body], from: 'sender', to: 'channel')
51
+ ensure
52
+ case_after c
53
+ end
54
+ end
55
+
56
+ def case_before(_c)
57
+ # implement each case before
58
+ end
59
+
60
+ def case_after(_c)
61
+ # implement each case after
62
+ end
63
+ end
64
+ end
65
+ end
66
+ # rubocop:enable LineLength, UnusedMethodArgument
@@ -0,0 +1,74 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'qiita_scouter_core'
4
+ require 'ruboty/qiita_scouter/actions/analyze'
5
+
6
+ # rubocop:disable LineLength, UnusedMethodArgument
7
+ describe Ruboty::QiitaScouter::Actions::Analyze do
8
+ context :analyze do
9
+ let(:message) do
10
+ # Dummy Message
11
+ class Message < Hash
12
+ def reply(message)
13
+ message
14
+ end
15
+ end
16
+ Message.new
17
+ end
18
+
19
+ let(:qiita_scouter) do
20
+ ::QiitaScouter::Core
21
+ end
22
+
23
+ cases = [
24
+ {
25
+ case_no: 1,
26
+ case_title: 'exist user case',
27
+ id: 'tbpgr',
28
+ power_levels: [600, 200, 300, 100],
29
+ expected: "ユーザー名: tbpgr 戦闘力: 600 攻撃力: 200 知力: 300 すばやさ: 100"
30
+ },
31
+ {
32
+ case_no: 2,
33
+ case_title: 'not exist user case',
34
+ id: 'tbpgr',
35
+ expected: 'Failed by NoMethodError',
36
+ expect_error: true
37
+ }
38
+ ]
39
+
40
+ cases.each do |c|
41
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
42
+ begin
43
+ case_before c
44
+
45
+ # -- given --
46
+ message[:id] = c[:id]
47
+ if c[:expect_error]
48
+ allow_any_instance_of(qiita_scouter).to receive(:analyze).with(c[:id]).and_raise(NoMethodError)
49
+ else
50
+ allow_any_instance_of(qiita_scouter).to receive(:analyze).with(c[:id]).and_return(c[:power_levels])
51
+ end
52
+ action = Ruboty::QiitaScouter::Actions::Analyze.new(message)
53
+
54
+ # -- when --
55
+ actual = action.send(:analyze)
56
+
57
+ # -- then --
58
+ expect(actual).to eq(c[:expected])
59
+ ensure
60
+ case_after c
61
+ end
62
+ end
63
+
64
+ def case_before(_c)
65
+ # implement each case before
66
+ end
67
+
68
+ def case_after(_c)
69
+ # implement each case after
70
+ end
71
+ end
72
+ end
73
+ end
74
+ # rubocop:enable LineLength, UnusedMethodArgument
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+ require 'simplecov'
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
+ SimpleCov::Formatter::HTMLFormatter,
7
+ Coveralls::SimpleCov::Formatter
8
+ ]
9
+ SimpleCov.start do
10
+ add_filter '/spec/'
11
+ end
12
+ require 'ruboty/qiita_scouter'
13
+ RSpec.configure do |config|
14
+ config.treat_symbols_as_metadata_keys_with_true_values = true
15
+ config.run_all_when_everything_filtered = true
16
+ config.filter_run :focus
17
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruboty-qiita_scouter
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - tbpgr
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruboty
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: qiita_scouter
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: An Ruboty Handler + Actions to analyze your Qiita power.
98
+ email:
99
+ - tbpgr@tbpgr.jp
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .coveralls.yml
105
+ - .gitignore
106
+ - .rspec
107
+ - .rubocop.yml
108
+ - .travis.yml
109
+ - Gemfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - lib/ruboty/handlers/qiita_scouter.rb
114
+ - lib/ruboty/qiita_scouter.rb
115
+ - lib/ruboty/qiita_scouter/actions/analyze.rb
116
+ - lib/ruboty/qiita_scouter/version.rb
117
+ - ruboty-qiita_scouter.gemspec
118
+ - spec/ruboty/handlers/qiita_scouter_spec.rb
119
+ - spec/ruboty/qiita_scouter/actions/analyze_spec.rb
120
+ - spec/spec_helper.rb
121
+ homepage: https://github.com/tbpgr/ruboty-qiita_scouter
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.3.0
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: An Ruboty Handler + Actions to analyze your Qiita power.
145
+ test_files:
146
+ - spec/ruboty/handlers/qiita_scouter_spec.rb
147
+ - spec/ruboty/qiita_scouter/actions/analyze_spec.rb
148
+ - spec/spec_helper.rb