goraku 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 059bc4afbf8b0b56f3bbe73a8402dd7ccbb6f1ff
4
+ data.tar.gz: 9f8eec45a4021580c9f7c8d28f1b8ddd7077ec08
5
+ SHA512:
6
+ metadata.gz: 851b17fada04241c28e6aac1e40c35cad7192e72707a8265d1df848dce96d9c00292bf36e89c68660060c247518eec3c10c3f95cc55a79f2a0ebc43f251f9e37
7
+ data.tar.gz: 83225d597024613f935dcb2e1a6aa91be71c5b92c3f1e2c72882f3033664facb936dfed3877ac9fd11e6e23dd7abec137354a94f5f2ecd1504c41bf815b81b82
@@ -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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in goraku.gemspec
4
+ gemspec
@@ -0,0 +1,14 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2004 Yasuhiro Kinoshita <WhoIsDissolvedGirl+github@gmail.com>
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
14
+
@@ -0,0 +1,47 @@
1
+ # Goraku
2
+
3
+ Goraku is API client for Chinachu(https://chinachu.moe/)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'goraku'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install goraku
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'goraku'
25
+
26
+ client = Goraku::Client.new(api_endpoint: "http://your.chinachu.host", login: "basic_user", passwprd: "basic_pass")
27
+ client.reserves # get reservation list json
28
+ ```
29
+
30
+ See more infomations about Chinachu API here(https://github.com/kanreisa/Chinachu/wiki/REST-API)
31
+
32
+ ## TODO
33
+
34
+ - spec, spec, spec!!!
35
+ - some api is not implemented
36
+ - /recording/:programId/watch
37
+ - /recorded/:programId/watch
38
+ - documentation
39
+
40
+ ## LICENSE
41
+
42
+ WTFPL
43
+
44
+ ## Contributing
45
+
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/YasuhiroKinoshita/goraku. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
47
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'goraku/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "goraku"
8
+ spec.version = Goraku::VERSION
9
+ spec.authors = ["Kinoshita.Yasuhiro"]
10
+ spec.email = ["WhoIsDissolvedGirl+github@gmail.com"]
11
+
12
+ spec.summary = %q{Goraku is API client for Chinachu}
13
+ spec.description = %q{Goraku is API client for Chinachu}
14
+ spec.homepage = "https://github.com/YasuhiroKinoshita/goraku"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.license = "WTFPL"
21
+
22
+ spec.add_runtime_dependency "sawyer", "~> 0.6"
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "wtfpl_init"
28
+ end
@@ -0,0 +1,6 @@
1
+ require "goraku/version"
2
+ require "goraku/client"
3
+
4
+ module Goraku
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,8 @@
1
+ module Goraku
2
+ module Authentication
3
+
4
+ def basic_authenticated?
5
+ !!(@login && @password)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,85 @@
1
+ require 'sawyer'
2
+
3
+ require 'goraku/configurable'
4
+ require 'goraku/authentication'
5
+
6
+ require 'goraku/client/program'
7
+ require 'goraku/client/recorded'
8
+ require 'goraku/client/recording'
9
+ require 'goraku/client/reserves'
10
+ require 'goraku/client/rules'
11
+ require 'goraku/client/schedule'
12
+ require 'goraku/client/scheduler'
13
+
14
+ module Goraku
15
+ class Client
16
+
17
+ include Goraku::Configurable
18
+ include Goraku::Authentication
19
+
20
+ include Goraku::Client::Program
21
+ include Goraku::Client::Recorded
22
+ include Goraku::Client::Recording
23
+ include Goraku::Client::Reserves
24
+ include Goraku::Client::Rules
25
+ include Goraku::Client::Schedule
26
+ include Goraku::Client::Scheduler
27
+
28
+ def initialize(options = {})
29
+ Configurable.keys.each do |key|
30
+ instance_variable_set(:"@#{key}", options[key] || Goraku.instance_variable_get(:"@#{key}"))
31
+ end
32
+ end
33
+
34
+ def get(path, options = {})
35
+ request :get, path, options
36
+ end
37
+
38
+ def put(path, options = {})
39
+ request :put, path, options
40
+ end
41
+
42
+ def delete(path, options = {})
43
+ request :delete, path, options
44
+ end
45
+
46
+ def root
47
+ get '/'
48
+ end
49
+
50
+ def inspect
51
+ inspected = super
52
+ inspected.gsub! @password, "*****" if @password
53
+ end
54
+
55
+ private
56
+
57
+ # HTTP client
58
+ #
59
+ # @return [Sawyer::Agent]
60
+ def agent
61
+ @agent ||= Sawyer::Agent.new(api_endpoint, sawyer_options) do |http|
62
+ http.headers['content-type'] = 'application/json'
63
+ if basic_authenticated?
64
+ http.basic_auth(@login, @password)
65
+ end
66
+ end
67
+ end
68
+
69
+ def request(method, path, data, options = {})
70
+ agent.call(method, URI::Parser.new.escape("/api#{path.to_s}"), data, options).data
71
+ end
72
+
73
+ def sawyer_options
74
+ opts = {
75
+ :links_parser => Sawyer::LinkParsers::Simple.new
76
+ }
77
+ conn_ops = @connection_options
78
+ conn_ops[:builder] = @middleware if @middleware
79
+ conn_ops[:proxy] = @proxy if @proxy
80
+ opts[:faraday] = Faraday.new(conn_ops)
81
+
82
+ opts
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,14 @@
1
+ module Goraku
2
+ class Client
3
+ module Program
4
+
5
+ def program(id)
6
+ get "/program/#{id}.json"
7
+ end
8
+
9
+ def reserve_program(id)
10
+ put "/program/#{id}.json"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,35 @@
1
+ module Goraku
2
+ class Client
3
+ module Recorded
4
+
5
+ def recorded
6
+ get '/recorded.json'
7
+ end
8
+
9
+ def recorded_program(program_id)
10
+ get "/recorded/#{program_id}.json"
11
+ end
12
+
13
+ def delete_recorded_program(program_id)
14
+ delete "/recorded/#{program_id}.json"
15
+ end
16
+
17
+ def recorded_program_file(program_id)
18
+ get "/recorded/#{program_id}/file.json"
19
+ end
20
+
21
+ def recorded_program_preview(program_id, format = 'png', options = {})
22
+ raise StandardError.new unless ['png', 'jpg', 'txt'].include?(format)
23
+ default_options = {pos: 7, width: 320, height: 180}
24
+ options = options.merge(default_options)
25
+
26
+ get "/recorded/#{program_id}/preview.#{format}", options
27
+ end
28
+
29
+ # Not implemented
30
+ def watch_recorded_program(program_id)
31
+ raise NotImplementedError.new
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,28 @@
1
+ module Goraku
2
+ class Client
3
+ module Recording
4
+
5
+ def recording
6
+ get '/recording.json'
7
+ end
8
+
9
+ def recording_program(program_id)
10
+ get "/recording/#{program_id}.json"
11
+ end
12
+
13
+ def stop_recording_program(program_id)
14
+ delete "/recording/#{program_id}.json"
15
+ end
16
+
17
+ def recording_program_preview(program_id, format = 'png')
18
+ raise StandardError.new unless ['png', 'jpg', 'txt'].include?(format)
19
+ get "recording/#{program_id}/preview.#{format}"
20
+ end
21
+
22
+ # Not implemented
23
+ def watch_recording_program(program_id)
24
+ raise NotImplementedError.new
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,18 @@
1
+ module Goraku
2
+ class Client
3
+ module Reserves
4
+
5
+ def reserves
6
+ get '/reserves.json'
7
+ end
8
+
9
+ def reserves_program(program_id)
10
+ get "/reserves/#{program_id}.json"
11
+ end
12
+
13
+ def delete_reserved_program(program_id)
14
+ delete "/reserves/#{program_id}.json"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,34 @@
1
+ module Goraku
2
+ class Client
3
+ module Rules
4
+
5
+ def rules
6
+ get '/rules.json'
7
+ end
8
+
9
+ def rule(rule_num)
10
+ get "/rules/#{rule_num}.json"
11
+ end
12
+
13
+ def update_rule(rule_num, rule)
14
+ put "/rules/#{rule_num}.json", rule
15
+ end
16
+
17
+ def delete_rule(rule_num)
18
+ delete "/rules/#{rule_num}.json"
19
+ end
20
+
21
+ def rule_enable(rule_num)
22
+ put "/rules/#{rule_num}/enable.json"
23
+ end
24
+
25
+ def rule_disable(rule_num)
26
+ put "/rules/#{rule_num}/disable.json"
27
+ end
28
+
29
+ def add_rule(rule)
30
+ post '/rules.json', rule
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,30 @@
1
+ module Goraku
2
+ class Client
3
+ module Schedule
4
+
5
+ def schedule
6
+ get '/schedule.json'
7
+ end
8
+
9
+ def schedule_programs
10
+ get '/schedule/programs.json'
11
+ end
12
+
13
+ def schedule_broadcasting
14
+ get '/schedule/broadcasting.json'
15
+ end
16
+
17
+ def schedule_channel(channel_id)
18
+ get "/schedule/#{channel_id}.json"
19
+ end
20
+
21
+ def schedule_channel_programs(channel_id)
22
+ get "/schedule/#{channel_id}.json"
23
+ end
24
+
25
+ def schedule_channel_broadcasting(channel_id)
26
+ get "/schedule/#{channel_id}/broadcasting.json"
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,18 @@
1
+ module Goraku
2
+ class Client
3
+ module Scheduler
4
+
5
+ def scheduler
6
+ get '/scheduler.json'
7
+ end
8
+
9
+ def exec_scheduler
10
+ put '/scheduler.json'
11
+ end
12
+
13
+ def force_scheduler
14
+ put '/scheduler/force.json'
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,27 @@
1
+ module Goraku
2
+ module Configurable
3
+
4
+ attr_reader :api_endpoint, :login, :password
5
+ attr_reader :connection_options, :middleware, :proxy
6
+ class << self
7
+ def keys
8
+ @keys || [
9
+ :api_endpoint,
10
+ :login,
11
+ :password,
12
+ :connection_options,
13
+ :middleware,
14
+ :proxy
15
+ ]
16
+ end
17
+ end
18
+
19
+ def configure
20
+ yield self
21
+ end
22
+
23
+ def api_endpoint
24
+ File.join(@api_endpoint, "")
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module Goraku
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: goraku
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kinoshita.Yasuhiro
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-10-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sawyer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.6'
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.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
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: wtfpl_init
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: Goraku is API client for Chinachu
98
+ email:
99
+ - WhoIsDissolvedGirl+github@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - CODE_OF_CONDUCT.md
108
+ - Gemfile
109
+ - LICENSE.md
110
+ - README.md
111
+ - Rakefile
112
+ - goraku.gemspec
113
+ - lib/goraku.rb
114
+ - lib/goraku/authentication.rb
115
+ - lib/goraku/client.rb
116
+ - lib/goraku/client/program.rb
117
+ - lib/goraku/client/recorded.rb
118
+ - lib/goraku/client/recording.rb
119
+ - lib/goraku/client/reserves.rb
120
+ - lib/goraku/client/rules.rb
121
+ - lib/goraku/client/schedule.rb
122
+ - lib/goraku/client/scheduler.rb
123
+ - lib/goraku/configurable.rb
124
+ - lib/goraku/version.rb
125
+ homepage: https://github.com/YasuhiroKinoshita/goraku
126
+ licenses:
127
+ - WTFPL
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubyforge_project:
145
+ rubygems_version: 2.4.5
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: Goraku is API client for Chinachu
149
+ test_files: []