shutwork 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +63 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +60 -0
- data/LICENSE.txt +21 -0
- data/README.md +29 -0
- data/Rakefile +6 -0
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/exe/shutwork +5 -0
- data/lib/shutwork/cli.rb +61 -0
- data/lib/shutwork/client.rb +48 -0
- data/lib/shutwork/command/base.rb +17 -0
- data/lib/shutwork/command/help.rb +22 -0
- data/lib/shutwork/command/me.rb +34 -0
- data/lib/shutwork/command/rooms.rb +58 -0
- data/lib/shutwork/command/token.rb +44 -0
- data/lib/shutwork/token.rb +42 -0
- data/lib/shutwork/version.rb +3 -0
- data/lib/shutwork.rb +7 -0
- data/shell.nix +8 -0
- data/shutwork.gemspec +29 -0
- metadata +149 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 27c8118a2da9dde8199128291e41636ded1192012ec449bc723afc9df5101de7
|
|
4
|
+
data.tar.gz: 9dce3362c8013fdd214ec2957cda9fdb5407c02bf7ff5cd77978478df03b2626
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 65d2c5f4622333fe47c50fdf1296c261e7298784fca38166aaa632dbe94427ea851b131da610bbc7f24c2cccd92370f62dc4cf65b3f1d7c9d18a24613f952a50
|
|
7
|
+
data.tar.gz: 23e38ebca5b76c5472928c001e1b08e84763fe20b2ae50c6b522520eb4ab3646c14ae6e3ae2f35f88c00851e74ecf2d0d63e7434d5f2e0cee0c90d9b3fddc0ea
|
data/.gitignore
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
.envrc
|
|
2
|
+
.rspec_status
|
|
3
|
+
|
|
4
|
+
### https://raw.github.com/github/gitignore/3df9bc0bd9cb0c3f5ea0904e88b9df5a378ccd59/Ruby.gitignore
|
|
5
|
+
|
|
6
|
+
*.gem
|
|
7
|
+
*.rbc
|
|
8
|
+
/.config
|
|
9
|
+
/coverage/
|
|
10
|
+
/InstalledFiles
|
|
11
|
+
/pkg/
|
|
12
|
+
/spec/reports/
|
|
13
|
+
/spec/examples.txt
|
|
14
|
+
/test/tmp/
|
|
15
|
+
/test/version_tmp/
|
|
16
|
+
/tmp/
|
|
17
|
+
|
|
18
|
+
# Used by dotenv library to load environment variables.
|
|
19
|
+
# .env
|
|
20
|
+
|
|
21
|
+
# Ignore Byebug command history file.
|
|
22
|
+
.byebug_history
|
|
23
|
+
|
|
24
|
+
## Specific to RubyMotion:
|
|
25
|
+
.dat*
|
|
26
|
+
.repl_history
|
|
27
|
+
build/
|
|
28
|
+
*.bridgesupport
|
|
29
|
+
build-iPhoneOS/
|
|
30
|
+
build-iPhoneSimulator/
|
|
31
|
+
|
|
32
|
+
## Specific to RubyMotion (use of CocoaPods):
|
|
33
|
+
#
|
|
34
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
|
35
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
|
36
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
|
37
|
+
#
|
|
38
|
+
# vendor/Pods/
|
|
39
|
+
|
|
40
|
+
## Documentation cache and generated files:
|
|
41
|
+
/.yardoc/
|
|
42
|
+
/_yardoc/
|
|
43
|
+
/doc/
|
|
44
|
+
/rdoc/
|
|
45
|
+
|
|
46
|
+
## Environment normalization:
|
|
47
|
+
/.bundle/
|
|
48
|
+
/vendor/bundle
|
|
49
|
+
/lib/bundler/man/
|
|
50
|
+
|
|
51
|
+
# for a library or gem, you might want to ignore these files since the code is
|
|
52
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
53
|
+
# Gemfile.lock
|
|
54
|
+
# .ruby-version
|
|
55
|
+
# .ruby-gemset
|
|
56
|
+
|
|
57
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
58
|
+
.rvmrc
|
|
59
|
+
|
|
60
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
|
61
|
+
# .rubocop-https?--*
|
|
62
|
+
|
|
63
|
+
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
shutwork (0.1.0)
|
|
5
|
+
faraday (>= 1.0.0, < 2.0)
|
|
6
|
+
thor (>= 1.0.0, < 2.0)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
addressable (2.7.0)
|
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
13
|
+
coderay (1.1.2)
|
|
14
|
+
crack (0.4.3)
|
|
15
|
+
safe_yaml (~> 1.0.0)
|
|
16
|
+
diff-lcs (1.3)
|
|
17
|
+
faraday (1.0.1)
|
|
18
|
+
multipart-post (>= 1.2, < 3)
|
|
19
|
+
hashdiff (1.0.1)
|
|
20
|
+
method_source (1.0.0)
|
|
21
|
+
multipart-post (2.1.1)
|
|
22
|
+
pry (0.13.1)
|
|
23
|
+
coderay (~> 1.1)
|
|
24
|
+
method_source (~> 1.0)
|
|
25
|
+
public_suffix (4.0.4)
|
|
26
|
+
rake (12.3.3)
|
|
27
|
+
rspec (3.9.0)
|
|
28
|
+
rspec-core (~> 3.9.0)
|
|
29
|
+
rspec-expectations (~> 3.9.0)
|
|
30
|
+
rspec-mocks (~> 3.9.0)
|
|
31
|
+
rspec-core (3.9.1)
|
|
32
|
+
rspec-support (~> 3.9.1)
|
|
33
|
+
rspec-expectations (3.9.1)
|
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
35
|
+
rspec-support (~> 3.9.0)
|
|
36
|
+
rspec-mocks (3.9.1)
|
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
38
|
+
rspec-support (~> 3.9.0)
|
|
39
|
+
rspec-support (3.9.2)
|
|
40
|
+
safe_yaml (1.0.5)
|
|
41
|
+
thor (1.0.1)
|
|
42
|
+
vcr (5.1.0)
|
|
43
|
+
webmock (3.8.3)
|
|
44
|
+
addressable (>= 2.3.6)
|
|
45
|
+
crack (>= 0.3.2)
|
|
46
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
|
47
|
+
|
|
48
|
+
PLATFORMS
|
|
49
|
+
ruby
|
|
50
|
+
|
|
51
|
+
DEPENDENCIES
|
|
52
|
+
pry
|
|
53
|
+
rake (~> 12.0)
|
|
54
|
+
rspec (~> 3.0)
|
|
55
|
+
shutwork!
|
|
56
|
+
vcr
|
|
57
|
+
webmock
|
|
58
|
+
|
|
59
|
+
BUNDLED WITH
|
|
60
|
+
1.17.2
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Hideaki Kawai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Shutwork
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.com/kayhide/shutwork)
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install `shutwork` as:
|
|
8
|
+
|
|
9
|
+
$ gem install shutwork
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
TBD
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Development
|
|
17
|
+
|
|
18
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
19
|
+
|
|
20
|
+
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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
21
|
+
|
|
22
|
+
## Contributing
|
|
23
|
+
|
|
24
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kayhide/shutwork.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## License
|
|
28
|
+
|
|
29
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
data/exe/shutwork
ADDED
data/lib/shutwork/cli.rb
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require "optparse"
|
|
2
|
+
require "shutwork/command/help"
|
|
3
|
+
require "shutwork/command/me"
|
|
4
|
+
require "shutwork/command/rooms"
|
|
5
|
+
require "shutwork/command/token"
|
|
6
|
+
|
|
7
|
+
module Shutwork
|
|
8
|
+
class Cli
|
|
9
|
+
def initialize args
|
|
10
|
+
@args = args
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def options
|
|
14
|
+
@options ||= {}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def run
|
|
18
|
+
opts = OptionParser.new
|
|
19
|
+
opts.on("-v", "--version") do
|
|
20
|
+
puts "Version: #{Shutwork::VERSION}"
|
|
21
|
+
exit 0
|
|
22
|
+
end
|
|
23
|
+
opts.on("-h", "--help") do
|
|
24
|
+
Shutwork::Command::Help.new.run
|
|
25
|
+
return
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
opts.order! ARGV
|
|
30
|
+
command = ARGV.shift
|
|
31
|
+
|
|
32
|
+
case command
|
|
33
|
+
when "me"
|
|
34
|
+
Shutwork::Command::Me.new.run
|
|
35
|
+
when "rooms"
|
|
36
|
+
Shutwork::Command::Rooms.new.run
|
|
37
|
+
when "token"
|
|
38
|
+
Shutwork::Command::Token.new.run
|
|
39
|
+
when nil
|
|
40
|
+
Shutwork::Command::Help.new.run
|
|
41
|
+
else
|
|
42
|
+
puts "Unknown command: #{command}"
|
|
43
|
+
Shutwork::Command::Help.new.run
|
|
44
|
+
exit 1
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
rescue Shutwork::AuthError
|
|
48
|
+
$stderr.puts "Chatwork Token is invalid or not supplied."
|
|
49
|
+
$stderr.puts
|
|
50
|
+
$stderr.puts "1. Get your token as instructed:"
|
|
51
|
+
$stderr.puts " https://help.chatwork.com/hc/ja/articles/115000172402-API%E3%83%88%E3%83%BC%E3%82%AF%E3%83%B3%E3%82%92%E7%99%BA%E8%A1%8C%E3%81%99%E3%82%8B"
|
|
52
|
+
$stderr.puts
|
|
53
|
+
$stderr.puts "2. Set it as:"
|
|
54
|
+
$stderr.puts " shutwork token <YOUR_TOKEN>"
|
|
55
|
+
$stderr.puts
|
|
56
|
+
$stderr.puts "3. Check if it works as:"
|
|
57
|
+
$stderr.puts " shutwork me"
|
|
58
|
+
$stderr.puts
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require "faraday"
|
|
2
|
+
require "json"
|
|
3
|
+
|
|
4
|
+
require "shutwork"
|
|
5
|
+
|
|
6
|
+
module Shutwork
|
|
7
|
+
class Client
|
|
8
|
+
attr_reader :base_url
|
|
9
|
+
|
|
10
|
+
def initialize opts = {}
|
|
11
|
+
@base_url = opts[:base_url] || "https://api.chatwork.com/v2/"
|
|
12
|
+
@token = opts[:token]
|
|
13
|
+
@verbose = opts[:verbose]
|
|
14
|
+
@conn = Faraday.new(
|
|
15
|
+
url: @base_url,
|
|
16
|
+
headers: {
|
|
17
|
+
"X-ChatWorkToken" => @token
|
|
18
|
+
}
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def me
|
|
23
|
+
process @conn.get("me")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def rooms
|
|
27
|
+
process @conn.get("rooms")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def room_messages room_id
|
|
31
|
+
process @conn.get("rooms/#{room_id}/messages?force=1")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def process res
|
|
35
|
+
if @verbose
|
|
36
|
+
$stderr.puts res.headers.to_json
|
|
37
|
+
end
|
|
38
|
+
verify! res
|
|
39
|
+
res.body
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def verify! res
|
|
43
|
+
if res.status.to_s !~ /2../
|
|
44
|
+
raise Shutwork::AuthError.new(res.body)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "forwardable"
|
|
2
|
+
|
|
3
|
+
require "thor/shell/color"
|
|
4
|
+
|
|
5
|
+
module Shutwork
|
|
6
|
+
module Command
|
|
7
|
+
class Base
|
|
8
|
+
extend Forwardable
|
|
9
|
+
|
|
10
|
+
def_delegators :@shell, :say, :say_status
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
@shell = Thor::Shell::Color.new
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require "shutwork/command/base"
|
|
2
|
+
|
|
3
|
+
module Shutwork
|
|
4
|
+
module Command
|
|
5
|
+
class Help < Base
|
|
6
|
+
def run
|
|
7
|
+
puts <<EOS
|
|
8
|
+
Usage: shutwork COMMAND
|
|
9
|
+
|
|
10
|
+
Available options:
|
|
11
|
+
-h,--help Show this help text
|
|
12
|
+
--version Show version
|
|
13
|
+
-r,--raw Show result in raw format
|
|
14
|
+
|
|
15
|
+
Available commands:
|
|
16
|
+
me Me
|
|
17
|
+
rooms Rooms
|
|
18
|
+
EOS
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
require "optparse"
|
|
3
|
+
|
|
4
|
+
require "shutwork/client"
|
|
5
|
+
require "shutwork/command/base"
|
|
6
|
+
require "shutwork/token"
|
|
7
|
+
|
|
8
|
+
module Shutwork
|
|
9
|
+
module Command
|
|
10
|
+
class Me < Base
|
|
11
|
+
def parse_args
|
|
12
|
+
opts = OptionParser.new
|
|
13
|
+
opts.program_name = "shutwork #{self.class.name.split(/::/).last.downcase}"
|
|
14
|
+
opts.on("-r", "--raw", "Show results in raw format") { @raw = true }
|
|
15
|
+
opts.on("-v", "--verbose", "Verbose") { @verbose = true }
|
|
16
|
+
opts.parse ARGV
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def run
|
|
20
|
+
parse_args
|
|
21
|
+
token = Shutwork::Token.read
|
|
22
|
+
@client = Shutwork::Client.new token: token, verbose: @verbose
|
|
23
|
+
|
|
24
|
+
item = @client.me
|
|
25
|
+
if @raw
|
|
26
|
+
puts item
|
|
27
|
+
else
|
|
28
|
+
me = JSON.parse(item)
|
|
29
|
+
puts ("%10s %s" % [me["account_id"], me["name"]])
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
require "optparse"
|
|
3
|
+
|
|
4
|
+
require "shutwork/client"
|
|
5
|
+
require "shutwork/command/base"
|
|
6
|
+
require "shutwork/token"
|
|
7
|
+
|
|
8
|
+
module Shutwork
|
|
9
|
+
module Command
|
|
10
|
+
class Rooms < Base
|
|
11
|
+
def parse_args
|
|
12
|
+
opts = OptionParser.new
|
|
13
|
+
opts.program_name = "shutwork #{self.class.name.split(/::/).last.downcase}"
|
|
14
|
+
opts.on("-r", "--raw", "Show results in raw format") { @raw = true }
|
|
15
|
+
opts.on("-v", "--verbose", "Verbose") { @verbose = true }
|
|
16
|
+
opts.parse ARGV
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def run
|
|
20
|
+
@args = parse_args
|
|
21
|
+
token = Shutwork::Token.read
|
|
22
|
+
@client = Shutwork::Client.new token: token, verbose: @verbose
|
|
23
|
+
|
|
24
|
+
if @args.first
|
|
25
|
+
show @args.first
|
|
26
|
+
else
|
|
27
|
+
list
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def list
|
|
32
|
+
items = @client.rooms
|
|
33
|
+
if @raw
|
|
34
|
+
puts items
|
|
35
|
+
else
|
|
36
|
+
rooms = JSON.parse(items)
|
|
37
|
+
rooms.each do |room|
|
|
38
|
+
puts ("%10s %s" % [room["room_id"], room["name"]])
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def show room_id
|
|
44
|
+
items = @client.room_messages room_id
|
|
45
|
+
if @raw
|
|
46
|
+
puts items
|
|
47
|
+
else
|
|
48
|
+
messages = JSON.parse(items)
|
|
49
|
+
messages.each do |message|
|
|
50
|
+
puts "----------------"
|
|
51
|
+
puts ("%s %s" % [Time.at(message["send_time"]), message.dig("account", "name")])
|
|
52
|
+
puts message["body"]
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require "shutwork/command/base"
|
|
2
|
+
require "shutwork/token"
|
|
3
|
+
|
|
4
|
+
module Shutwork
|
|
5
|
+
module Command
|
|
6
|
+
class Token < Base
|
|
7
|
+
def parse_args
|
|
8
|
+
opts = OptionParser.new
|
|
9
|
+
opts.program_name = "shutwork #{self.class.name.split(/::/).last.downcase}"
|
|
10
|
+
opts.on("--skip-verify", "Skips validity check") { @skip_verify = true }
|
|
11
|
+
opts.on("-v", "--verbose", "Verbose") { @verbose = true }
|
|
12
|
+
opts.parse ARGV
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def run
|
|
16
|
+
@token = parse_args.first&.strip
|
|
17
|
+
|
|
18
|
+
if @token
|
|
19
|
+
unless @skip_verify
|
|
20
|
+
verify_token!
|
|
21
|
+
end
|
|
22
|
+
Shutwork::Token.store @token
|
|
23
|
+
say_status "save", Shutwork::Token.token_path, :green
|
|
24
|
+
else
|
|
25
|
+
token_ = Shutwork::Token.from_user_default
|
|
26
|
+
if token_
|
|
27
|
+
puts token_
|
|
28
|
+
else
|
|
29
|
+
puts "(Token is not stored)"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
rescue Shutwork::AuthError
|
|
34
|
+
$stderr.puts "Invalid token: #{@token}"
|
|
35
|
+
exit 1
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def verify_token!
|
|
39
|
+
@client = Shutwork::Client.new token: @token, verbose: @verbose
|
|
40
|
+
@client.me
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require "pathname"
|
|
2
|
+
|
|
3
|
+
module Shutwork
|
|
4
|
+
module Token
|
|
5
|
+
extend self
|
|
6
|
+
|
|
7
|
+
def read
|
|
8
|
+
from_env || from_user_default
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def from_env
|
|
12
|
+
ENV.fetch("CHATWORK_ACCESS_TOKEN", nil)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def from_user_default
|
|
16
|
+
from_store "default"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def from_store name
|
|
20
|
+
file = token_path name
|
|
21
|
+
if File.exist? file
|
|
22
|
+
open(file, &:read)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def store token, name = "default"
|
|
27
|
+
file = token_path name
|
|
28
|
+
FileUtils.mkdir_p file.dirname
|
|
29
|
+
open(file, 'w') do |io|
|
|
30
|
+
io << token.strip
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def storage_dir
|
|
35
|
+
Pathname.new("~/.shutwork/token").expand_path
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def token_path name = "default"
|
|
39
|
+
storage_dir.join name
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
data/lib/shutwork.rb
ADDED
data/shell.nix
ADDED
data/shutwork.gemspec
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require_relative 'lib/shutwork/version'
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "shutwork"
|
|
5
|
+
spec.version = Shutwork::VERSION
|
|
6
|
+
spec.authors = ["Hideaki Kawai"]
|
|
7
|
+
spec.email = ["kayhide@gmail.com"]
|
|
8
|
+
|
|
9
|
+
spec.summary = "Chatwork CLI"
|
|
10
|
+
spec.description = "Chatwork CLI"
|
|
11
|
+
spec.homepage = "http://github.com/kayhide/shutwork"
|
|
12
|
+
spec.license = "MIT"
|
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
|
14
|
+
|
|
15
|
+
# Specify which files should be added to the gem when it is released.
|
|
16
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
17
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
19
|
+
end
|
|
20
|
+
spec.bindir = "exe"
|
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
22
|
+
spec.require_paths = ["lib"]
|
|
23
|
+
|
|
24
|
+
spec.add_runtime_dependency "faraday", [">= 1.0.0", "< 2.0"]
|
|
25
|
+
spec.add_runtime_dependency "thor", [">= 1.0.0", "< 2.0"]
|
|
26
|
+
spec.add_development_dependency "pry"
|
|
27
|
+
spec.add_development_dependency "vcr"
|
|
28
|
+
spec.add_development_dependency "webmock"
|
|
29
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: shutwork
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Hideaki Kawai
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 1970-01-01 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: faraday
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 1.0.0
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '2.0'
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: 1.0.0
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '2.0'
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: thor
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: 1.0.0
|
|
40
|
+
- - "<"
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '2.0'
|
|
43
|
+
type: :runtime
|
|
44
|
+
prerelease: false
|
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: 1.0.0
|
|
50
|
+
- - "<"
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '2.0'
|
|
53
|
+
- !ruby/object:Gem::Dependency
|
|
54
|
+
name: pry
|
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '0'
|
|
60
|
+
type: :development
|
|
61
|
+
prerelease: false
|
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
- - ">="
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '0'
|
|
67
|
+
- !ruby/object:Gem::Dependency
|
|
68
|
+
name: vcr
|
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - ">="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '0'
|
|
74
|
+
type: :development
|
|
75
|
+
prerelease: false
|
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - ">="
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '0'
|
|
81
|
+
- !ruby/object:Gem::Dependency
|
|
82
|
+
name: webmock
|
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - ">="
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '0'
|
|
88
|
+
type: :development
|
|
89
|
+
prerelease: false
|
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
description: Chatwork CLI
|
|
96
|
+
email:
|
|
97
|
+
- kayhide@gmail.com
|
|
98
|
+
executables:
|
|
99
|
+
- shutwork
|
|
100
|
+
extensions: []
|
|
101
|
+
extra_rdoc_files: []
|
|
102
|
+
files:
|
|
103
|
+
- ".gitignore"
|
|
104
|
+
- ".rspec"
|
|
105
|
+
- ".travis.yml"
|
|
106
|
+
- Gemfile
|
|
107
|
+
- Gemfile.lock
|
|
108
|
+
- LICENSE.txt
|
|
109
|
+
- README.md
|
|
110
|
+
- Rakefile
|
|
111
|
+
- bin/console
|
|
112
|
+
- bin/setup
|
|
113
|
+
- exe/shutwork
|
|
114
|
+
- lib/shutwork.rb
|
|
115
|
+
- lib/shutwork/cli.rb
|
|
116
|
+
- lib/shutwork/client.rb
|
|
117
|
+
- lib/shutwork/command/base.rb
|
|
118
|
+
- lib/shutwork/command/help.rb
|
|
119
|
+
- lib/shutwork/command/me.rb
|
|
120
|
+
- lib/shutwork/command/rooms.rb
|
|
121
|
+
- lib/shutwork/command/token.rb
|
|
122
|
+
- lib/shutwork/token.rb
|
|
123
|
+
- lib/shutwork/version.rb
|
|
124
|
+
- shell.nix
|
|
125
|
+
- shutwork.gemspec
|
|
126
|
+
homepage: http://github.com/kayhide/shutwork
|
|
127
|
+
licenses:
|
|
128
|
+
- MIT
|
|
129
|
+
metadata: {}
|
|
130
|
+
post_install_message:
|
|
131
|
+
rdoc_options: []
|
|
132
|
+
require_paths:
|
|
133
|
+
- lib
|
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: 2.3.0
|
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
|
+
requirements:
|
|
141
|
+
- - ">="
|
|
142
|
+
- !ruby/object:Gem::Version
|
|
143
|
+
version: '0'
|
|
144
|
+
requirements: []
|
|
145
|
+
rubygems_version: 3.1.2
|
|
146
|
+
signing_key:
|
|
147
|
+
specification_version: 4
|
|
148
|
+
summary: Chatwork CLI
|
|
149
|
+
test_files: []
|