slack-emoji-download.rb 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE +1 -0
- data/README.md +49 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/downloader.rb +19 -0
- data/exe/slack-emoji-download.rb +5 -0
- data/lib/slack-emoji-download.rb +6 -0
- data/lib/slack-emoji-download/:q +0 -0
- data/lib/slack-emoji-download/cli.rb +45 -0
- data/lib/slack-emoji-download/downloader.rb +39 -0
- data/lib/slack-emoji-download/version.rb +3 -0
- data/slack-emoji-download.rb.gemspec +28 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 87240a2bfb9d85950e90cad36990c556a923939f
|
4
|
+
data.tar.gz: c15cac2350ebe95a65f6e9b9d16bed02f8008f3d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 32e023d11c6ac60af6c7b3510b3927350f6dccac9a220b4f7631d3819164587184063619f9ae82d9bbc57b2f065c890208db141678a6e987644b93abd9b3baa0
|
7
|
+
data.tar.gz: 823a4386da760b2a45f281b994e4f0fd286a053866a819536237139c5f2bfa5652929f0434a3ebccf82de3a229cdacd3491668477b55dfc145fb2519aa46fd4f
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at dummy@email.address. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Please see https://blueberrystream.mit-license.org/
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# slack-emoji-download.rb
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'slack-emoji-download.rb'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install slack-emoji-download.rb
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
First, get your Slack API Token from [Legacy tokens | Slack](https://api.slack.com/custom-integrations/legacy-tokens)
|
22
|
+
|
23
|
+
```
|
24
|
+
Usage:
|
25
|
+
slack-emoji-download.rb -t, --token=TOKEN
|
26
|
+
|
27
|
+
Options:
|
28
|
+
-t, --token=TOKEN # Slack API Token
|
29
|
+
-d, [--dest=DEST] # direcotry for the dowload destination
|
30
|
+
# Default: emoji
|
31
|
+
```
|
32
|
+
|
33
|
+
## Development
|
34
|
+
|
35
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
36
|
+
|
37
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
38
|
+
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).
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/blueberrystream/slack-emoji-download.rb.
|
43
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
44
|
+
|
45
|
+
|
46
|
+
## License
|
47
|
+
|
48
|
+
The gem is available as open source under the terms of the [MIT License](https://blueberrystream.mit-license.org/).
|
49
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "slack-emoji-download"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/downloader.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/bin/env ruby
|
2
|
+
|
3
|
+
require 'open-uri'
|
4
|
+
require 'JSON'
|
5
|
+
|
6
|
+
team = ARGV[0]
|
7
|
+
dest_dir = team
|
8
|
+
Dir.mkdir dest_dir unless Dir.exist? dest_dir
|
9
|
+
|
10
|
+
json = File.open("#{team}.json").read
|
11
|
+
json = JSON.parse json
|
12
|
+
json['emoji'].each do |key, url|
|
13
|
+
unless url.start_with? 'alias'
|
14
|
+
puts key
|
15
|
+
|
16
|
+
ext = File.extname url
|
17
|
+
File.binwrite dest_dir + '/' + key + ext, OpenURI.open_uri(url).read
|
18
|
+
end
|
19
|
+
end
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module SlackEmojiDownload
|
4
|
+
class CLI < Thor
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
default_command :download
|
8
|
+
|
9
|
+
desc 'download', 'download slack custom emoji.'
|
10
|
+
option :token, required: true, type: :string, aliases: '-t', desc: 'Slack API Token'
|
11
|
+
option :dest, type: :string, default: 'emoji', aliases: '-d', desc: 'direcotry for the dowload destination'
|
12
|
+
def download
|
13
|
+
return unless create_dest options[:dest]
|
14
|
+
|
15
|
+
list = SlackEmojiDownload::Downloader::get_emoji_list options[:token]
|
16
|
+
SlackEmojiDownload::Downloader::download_emoji list, options[:dest]
|
17
|
+
rescue OpenURI::HTTPError
|
18
|
+
say 'Can not to access the Slack API', :red
|
19
|
+
rescue SlackApiError => e
|
20
|
+
say 'Failed to call the Slack API.', :red
|
21
|
+
say 'See the below messages from Slack API.', :red
|
22
|
+
say e.message, :red
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def create_dest(path)
|
28
|
+
if FileTest.exist? path
|
29
|
+
say "Already exist: #{path}", :red
|
30
|
+
|
31
|
+
if FileTest.directory? path
|
32
|
+
return yes? 'Overwrite files in this directory? (y/N)'
|
33
|
+
else
|
34
|
+
say 'However this path is not a direcotry.', :red
|
35
|
+
say 'Please specify the destination directory path to use --dest option.'
|
36
|
+
return false
|
37
|
+
end
|
38
|
+
else
|
39
|
+
empty_directory path, verbose: false
|
40
|
+
end
|
41
|
+
|
42
|
+
true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'ruby-progressbar'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module SlackEmojiDownload
|
6
|
+
class SlackApiError < RuntimeError; end
|
7
|
+
class Downloader
|
8
|
+
class << self
|
9
|
+
def get_emoji_list(token)
|
10
|
+
uri = "https://slack.com/api/emoji.list?token=#{token}"
|
11
|
+
response = OpenURI.open_uri(uri).read
|
12
|
+
response = JSON.parse response
|
13
|
+
|
14
|
+
unless response['ok']
|
15
|
+
raise SlackApiError.new response['error']
|
16
|
+
end
|
17
|
+
|
18
|
+
response['emoji']
|
19
|
+
end
|
20
|
+
|
21
|
+
def download_emoji(list, dest)
|
22
|
+
puts
|
23
|
+
progress_bar = ProgressBar.create(
|
24
|
+
title: 'Downloading',
|
25
|
+
total: list.count,
|
26
|
+
format: '%t |%B| %J%%(%c/%C) %a %E'
|
27
|
+
)
|
28
|
+
list.each do |key, uri|
|
29
|
+
unless uri.start_with? 'alias'
|
30
|
+
ext = File.extname uri
|
31
|
+
File.binwrite dest + '/' + key + ext, OpenURI.open_uri(uri).read
|
32
|
+
progress_bar.increment
|
33
|
+
end
|
34
|
+
end
|
35
|
+
progress_bar.finish
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -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 'slack-emoji-download/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "slack-emoji-download.rb"
|
8
|
+
spec.version = SlackEmojiDownload::VERSION
|
9
|
+
spec.authors = ["KID the Euforia"]
|
10
|
+
spec.email = ["kid0725@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "A downloader for Slack cutom emoji."
|
13
|
+
spec.homepage = "https://github.com/blueberrystream/slack-emoji-download.rb"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
|
26
|
+
spec.add_dependency "thor"
|
27
|
+
spec.add_dependency "ruby-progressbar"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slack-emoji-download.rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- KID the Euforia
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ruby-progressbar
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- kid0725@gmail.com
|
72
|
+
executables:
|
73
|
+
- slack-emoji-download.rb
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- CODE_OF_CONDUCT.md
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- downloader.rb
|
86
|
+
- exe/slack-emoji-download.rb
|
87
|
+
- lib/slack-emoji-download.rb
|
88
|
+
- lib/slack-emoji-download/:q
|
89
|
+
- lib/slack-emoji-download/cli.rb
|
90
|
+
- lib/slack-emoji-download/downloader.rb
|
91
|
+
- lib/slack-emoji-download/version.rb
|
92
|
+
- slack-emoji-download.rb.gemspec
|
93
|
+
homepage: https://github.com/blueberrystream/slack-emoji-download.rb
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.6.11
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: A downloader for Slack cutom emoji.
|
117
|
+
test_files: []
|