ruboty-irkit 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c89a10d8ca5cdc039a8f498393366fcd26502a38
4
+ data.tar.gz: 4e8a88dfe5a731ad5cbaf7d0142f4a660a5b0073
5
+ SHA512:
6
+ metadata.gz: ee0c0a9111155763932bbde5d530c5e5702f8f6a093a5adeeaf4b01f0fdcdffb6c20071db84e417dc0430d7768240baead94b51585365b152321e361a67f9898
7
+ data.tar.gz: 5b080444cf9cd77042f719823f38a05a4866e416f51babc6e09c92e3fd7ce242ce6a2b5adb2ba6604b8357fd276d2dde1c15549356cd672682312f66fb211f2c
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruboty-irkit.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # Ruboty::IRKit
2
+
3
+ A ruboty handler to control IRKit.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ruboty-irkit'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ruboty-irkit
20
+
21
+ ## Usage
22
+
23
+ ```
24
+ ruboty irkit get <name> - Get IR Data (alias: read)
25
+ ruboty irkit post <name> - Post IR Data (alias: write)
26
+ ruboty irkit delete <name> - Delete IR Data
27
+ ruboty irkit import <name> <json> - Import IR Data
28
+ ruboty irkit list - Show list of IR Data
29
+ ruboty irkit rename <old_name> <new_name> - rename IR Data to new name
30
+ ruboty irkit show <name> - Show IR Data
31
+ ```
32
+
33
+ ## ENV
34
+
35
+ ```
36
+ IRKIT_CLIENTKEY - clientkey for IRKit
37
+ IRKIT_DEVICEID - deviceid for IRKit
38
+ ```
39
+
40
+ ## Development
41
+
42
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
43
+
44
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it ( https://github.com/kei-s/ruboty-irkit/fork )
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ruboty/irkit"
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 ADDED
@@ -0,0 +1,7 @@
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
@@ -0,0 +1,98 @@
1
+ require "irkit"
2
+
3
+ module Ruboty
4
+ module Handlers
5
+ class IRKit < Base
6
+ NAMESPACE = "irkit"
7
+
8
+ env :IRKIT_CLIENTKEY, "clientkey for IRKit"
9
+ env :IRKIT_DEVICEID, "deviceid for IRKit"
10
+
11
+ on(/irkit (get|read) (?<name>.+)/, name: "get", description: "Get IR Data")
12
+ on(/irkit (post|write) (?<name>.+)/, name: "post", description: "Post IR Data")
13
+ on(/irkit show (?<name>.+)/, name: "show", description: "Show IR Data")
14
+ on(/irkit import (?<name>.+) (?<json>.+)/, name: "import", description: "Import IR Data")
15
+ on(/irkit delete (?<name>.+)/, name: "delete", description: "Delete IR Data")
16
+ on(/irkit rename (?<old_name>.+) (?<new_name>.+)/, name: "rename", description: "Rename IR Data to new name")
17
+ on(/irkit list/, name: "list", description: "Show list of IR Data")
18
+
19
+ def get(message)
20
+ name = message[:name]
21
+ message.reply "Please send IR message \"#{name}\" to IRKit."
22
+ ir_data = client.get_messages(clear: 1)
23
+ if ir_data
24
+ data[name] = ir_data.message.to_json
25
+ message.reply "Received IR message \"#{name}\"."
26
+ else
27
+ message.reply "Can't find IR message \"#{name}\"."
28
+ end
29
+ end
30
+
31
+ def post(message)
32
+ name = message[:name]
33
+ if data[name]
34
+ response = client.post_messages JSON.parse(data[name])
35
+ if response.code == 200
36
+ message.reply "IR message \"#{name}\" is succeeded."
37
+ else
38
+ message.reply "IR message \"#{name}\" is failed."
39
+ end
40
+ else
41
+ message.reply "IR message \"#{name}\" is not registered."
42
+ end
43
+ end
44
+
45
+ def show(message)
46
+ name = message[:name]
47
+ if data[name]
48
+ message.reply data[name]
49
+ else
50
+ message.reply "IR message \"#{name}\" is not registered."
51
+ end
52
+ end
53
+
54
+ def import(message)
55
+ name = message[:name]
56
+ json = message[:json]
57
+ data[name] = json
58
+ message.reply "Imported IR message \"#{name}\"."
59
+ end
60
+
61
+ def delete(message)
62
+ name = message[:name]
63
+ if data[name]
64
+ data.delete name
65
+ message.reply "IR message \"#{name}\" is deleted."
66
+ else
67
+ message.reply "IR message \"#{name}\" is not registered."
68
+ end
69
+ end
70
+
71
+ def rename(message)
72
+ old_name = message[:old_name]
73
+ new_name = message[:new_name]
74
+ if data[old_name]
75
+ data[new_name] = data[old_name]
76
+ data.delete old_name
77
+ message.reply "IR message \"#{old_name}\" is changed to \"#{new_name}\"."
78
+ else
79
+ message.reply "IR message \"#{old_name}\" is not registered."
80
+ end
81
+ end
82
+
83
+ def list(message)
84
+ message.reply data.keys.join("\n")
85
+ end
86
+
87
+ private
88
+
89
+ def client
90
+ @client ||= ::IRKit::InternetAPI.new(clientkey: ENV['IRKIT_CLIENTKEY'], deviceid: ENV['IRKIT_DEVICEID'])
91
+ end
92
+
93
+ def data
94
+ robot.brain.data[NAMESPACE] ||= {}
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,5 @@
1
+ module Ruboty
2
+ module IRKit
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ require "ruboty"
2
+ require "ruboty/irkit/version"
3
+ require "ruboty/handlers/irkit"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruboty/irkit/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruboty-irkit"
8
+ spec.version = Ruboty::IRKit::VERSION
9
+ spec.authors = ["kei-s"]
10
+ spec.email = ["kei.shiratsuchi@gmail.com"]
11
+
12
+ spec.summary = %q{A ruboty handler to controll IRKit}
13
+ spec.homepage = "https://github.com/kei-s/ruboty-irkit"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "ruboty"
21
+ spec.add_dependency "irkit"
22
+ spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruboty-irkit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kei-s
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-04-27 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: irkit
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.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.9'
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
+ description:
70
+ email:
71
+ - kei.shiratsuchi@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - README.md
79
+ - Rakefile
80
+ - bin/console
81
+ - bin/setup
82
+ - lib/ruboty/handlers/irkit.rb
83
+ - lib/ruboty/irkit.rb
84
+ - lib/ruboty/irkit/version.rb
85
+ - ruboty-irkit.gemspec
86
+ homepage: https://github.com/kei-s/ruboty-irkit
87
+ licenses: []
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.4.5
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: A ruboty handler to controll IRKit
109
+ test_files: []