ringcentral-avatars 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +3 -0
- data/LICENSE.md +22 -0
- data/README.md +85 -0
- data/Rakefile +19 -0
- data/lib/ringcentral-avatars/creator.rb +78 -0
- data/lib/ringcentral-avatars.rb +11 -0
- metadata +180 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e54f32761102a609bd4076cf6ffbe88261ac5ee0
|
4
|
+
data.tar.gz: ccdf57695c53e2662927b203ae10705369574c6c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 55588a39b9a842c70aaa38611d6f7dc2e0fc61dbe62af89425815e644db2c9b9fed4189b4b4b0ff3a5c3915344707c9e0805907e31f98e58fe67181d0f774dcd
|
7
|
+
data.tar.gz: f59211bf0735da463841934547afc1deb3ca4f0760729e893ba166567654936ebec566fa3d1dc4b3e94a1f5433d6e73a10d0dbbcd69ee85f519f7f9b536e22b4
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 John Wang
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
RingCentral Avatars
|
2
|
+
===================
|
3
|
+
|
4
|
+
[![Gem Version][gem-version-svg]][gem-version-link]
|
5
|
+
[![Build Status][build-status-svg]][build-status-link]
|
6
|
+
[![Dependency Status][dependency-status-svg]][dependency-status-link]
|
7
|
+
[![Code Climate][codeclimate-status-svg]][codeclimate-status-link]
|
8
|
+
[![Scrutinizer Code Quality][scrutinizer-status-svg]][scrutinizer-status-link]
|
9
|
+
[![Downloads][downloads-svg]][downloads-link]
|
10
|
+
[![Docs][docs-readthedocs-svg]][docs-readthedocs-link]
|
11
|
+
[![Docs][docs-rubydoc-svg]][docs-rubydoc-link]
|
12
|
+
[![License][license-svg]][license-link]
|
13
|
+
|
14
|
+
## Overview
|
15
|
+
|
16
|
+
This library will build RingCentral avatars using Gmail-like initial avatars. It requires ImageMagick.
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
require 'ringcentral-avatars'
|
22
|
+
require 'ringcentral_sdk'
|
23
|
+
|
24
|
+
client = RingCentralSdk.new [...]
|
25
|
+
|
26
|
+
avatars = RingCentralAvatars.new client
|
27
|
+
|
28
|
+
avatars.create_all # create defaults only
|
29
|
+
avatars.create_all true # overwrite existing avatars
|
30
|
+
|
31
|
+
avatars.create_mine # create for authorized user only
|
32
|
+
```
|
33
|
+
|
34
|
+
### Change Log
|
35
|
+
|
36
|
+
See [CHANGELOG.md](CHANGELOG.md)
|
37
|
+
|
38
|
+
## Links
|
39
|
+
|
40
|
+
Project Repo
|
41
|
+
|
42
|
+
* https://github.com/ringcentral-ruby/ringcentral-avatars-ruby
|
43
|
+
|
44
|
+
RingCentral Ruby SDK
|
45
|
+
|
46
|
+
* https://github.com/ringcentral-ruby/ringcentral-sdk-ruby
|
47
|
+
|
48
|
+
RingCentral API Explorer
|
49
|
+
|
50
|
+
* http://ringcentral.github.io/api-explorer
|
51
|
+
|
52
|
+
## Contributing
|
53
|
+
|
54
|
+
1. Fork it ( http://github.com/ringcentral-ruby/ringcentral-avatars-ruby/fork )
|
55
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
56
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
57
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
58
|
+
5. Create new Pull Request
|
59
|
+
|
60
|
+
## License
|
61
|
+
|
62
|
+
RingCentral Avatars is available under an MIT-style license. See [LICENSE.txt](LICENSE.txt) for details.
|
63
|
+
|
64
|
+
RingCentral Avatars © 2016 by John Wang
|
65
|
+
|
66
|
+
[gem-version-svg]: https://badge.fury.io/rb/ringcentral-avatars.svg
|
67
|
+
[gem-version-link]: http://badge.fury.io/rb/ringcentral-avatars
|
68
|
+
[downloads-svg]: http://ruby-gem-downloads-badge.herokuapp.com/ringcentral-avatars
|
69
|
+
[downloads-link]: https://rubygems.org/gems/ringcentral-avatars
|
70
|
+
[build-status-svg]: https://api.travis-ci.org/ringcentral-ruby/ringcentral-avatars-ruby.svg?branch=master
|
71
|
+
[build-status-link]: https://travis-ci.org/ringcentral-ruby/ringcentral-avatars-ruby
|
72
|
+
[coverage-status-svg]: https://coveralls.io/repos/ringcentral-ruby/ringcentral-avatars-ruby/badge.svg?branch=master
|
73
|
+
[coverage-status-link]: https://coveralls.io/r/ringcentral-ruby/ringcentral-avatars-ruby?branch=master
|
74
|
+
[dependency-status-svg]: https://gemnasium.com/ringcentral-ruby/ringcentral-avatars-ruby.svg
|
75
|
+
[dependency-status-link]: https://gemnasium.com/ringcentral-ruby/ringcentral-avatars-ruby
|
76
|
+
[codeclimate-status-svg]: https://codeclimate.com/github/ringcentral-ruby/ringcentral-avatars-ruby/badges/gpa.svg
|
77
|
+
[codeclimate-status-link]: https://codeclimate.com/github/ringcentral-ruby/ringcentral-avatars-ruby
|
78
|
+
[scrutinizer-status-svg]: https://scrutinizer-ci.com/g/ringcentral-ruby/ringcentral-avatars-ruby/badges/quality-score.png?b=master
|
79
|
+
[scrutinizer-status-link]: https://scrutinizer-ci.com/g/ringcentral-ruby/ringcentral-avatars-ruby/?branch=master
|
80
|
+
[docs-readthedocs-svg]: https://img.shields.io/badge/docs-readthedocs-blue.svg
|
81
|
+
[docs-readthedocs-link]: http://ringcentral-avatars-ruby.readthedocs.org/
|
82
|
+
[docs-rubydoc-svg]: https://img.shields.io/badge/docs-rubydoc-blue.svg
|
83
|
+
[docs-rubydoc-link]: http://www.rubydoc.info/gems/ringcentral-avatars/
|
84
|
+
[license-svg]: https://img.shields.io/badge/license-MIT-blue.svg
|
85
|
+
[license-link]: https://github.com/ringcentral-ruby/ringcentral-avatars-ruby/blob/master/LICENSE.md
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
desc 'Default: run unit tests.'
|
5
|
+
task default: :test
|
6
|
+
|
7
|
+
desc 'Test the library.'
|
8
|
+
Rake::TestTask.new do |t|
|
9
|
+
t.libs << 'lib'
|
10
|
+
t.pattern = 'test/**/test_*.rb'
|
11
|
+
t.verbose = false
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Generate YARD documentation.'
|
15
|
+
task :gendoc do
|
16
|
+
# puts 'yard doc generation disabled until JRuby build native extensions for redcarpet or yard removes the dependency.'
|
17
|
+
system 'yardoc'
|
18
|
+
system 'yard stats --list-undoc'
|
19
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'avatarly'
|
2
|
+
require 'faraday'
|
3
|
+
require 'ringcentral_sdk'
|
4
|
+
require 'tempfile'
|
5
|
+
|
6
|
+
module RingCentralAvatars
|
7
|
+
class Creator
|
8
|
+
DEFAULT_SIZE = 600
|
9
|
+
|
10
|
+
attr_accessor :client
|
11
|
+
attr_accessor :extensions
|
12
|
+
|
13
|
+
def initialize(client)
|
14
|
+
@client = client
|
15
|
+
load_extensions
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_all(overwrite = false)
|
19
|
+
@extensions.extensions_hash.each do |ext_id, ext|
|
20
|
+
create_avatar ext, overwrite
|
21
|
+
end
|
22
|
+
load_extensions
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_mine(overwrite = false)
|
26
|
+
res = @client.http.get 'account/~/extension/~'
|
27
|
+
create_avatar res.body, overwrite
|
28
|
+
load_extensions
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_avatar(ext, overwrite = false)
|
32
|
+
return if has_avatar(ext) && !overwrite
|
33
|
+
avatar_temp = get_avatar_tmp_file ext
|
34
|
+
url = "account/~/extension/#{ext['id']}/profile-image"
|
35
|
+
image = Faraday::UploadIO.new(avatar_temp.path, 'image/png')
|
36
|
+
@client.http.put url, image: image
|
37
|
+
end
|
38
|
+
|
39
|
+
def has_avatar(ext)
|
40
|
+
return ext['profileImage'].key?('etag') ? true : false
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_avatar_tmp_file(ext)
|
44
|
+
avatar_blob = Avatarly.generate_avatar(ext['name'], size: DEFAULT_SIZE)
|
45
|
+
avatar_temp = Tempfile.new(['avatar', '.png'])
|
46
|
+
avatar_temp.binmode
|
47
|
+
avatar_temp.write(avatar_blob)
|
48
|
+
avatar_temp.flush
|
49
|
+
avatar_temp
|
50
|
+
end
|
51
|
+
|
52
|
+
def load_extensions
|
53
|
+
@extensions = RingCentralSdk::REST::Cache::Extensions.new client
|
54
|
+
@extensions.retrieve_all
|
55
|
+
end
|
56
|
+
|
57
|
+
def avatar_urls(include_token = false)
|
58
|
+
urls = []
|
59
|
+
@extensions.extensions_hash.keys.sort.each do |ext_id|
|
60
|
+
ext = @extensions.extensions_hash[ext_id]
|
61
|
+
urls.push avatar_url(ext, include_token)
|
62
|
+
end
|
63
|
+
return urls
|
64
|
+
end
|
65
|
+
|
66
|
+
def my_avatar_url(include_token = false)
|
67
|
+
res = @client.http.get 'account/~/extension/~'
|
68
|
+
avatar_url(res.body, include_token)
|
69
|
+
end
|
70
|
+
|
71
|
+
def avatar_url(ext, include_token = false)
|
72
|
+
token = @client.token.to_hash[:access_token]
|
73
|
+
url = ext['profileImage']['uri']
|
74
|
+
url += "?access_token=#{token}" if include_token
|
75
|
+
return url
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
metadata
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ringcentral-avatars
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Wang
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: avatarly
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.5.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.5'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.5.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: faraday
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.9'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.9'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.9'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.9'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: ringcentral_sdk
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.3.4
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.3.4
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: coveralls
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
type: :development
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: mocha
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
type: :development
|
95
|
+
prerelease: false
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: rake
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
type: :development
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: simplecov
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
name: test-unit
|
131
|
+
requirement: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
type: :development
|
137
|
+
prerelease: false
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
description: Create RingCentral default avatars using Gmail-style initial avatars
|
144
|
+
email: johncwang@gmail.com
|
145
|
+
executables: []
|
146
|
+
extensions: []
|
147
|
+
extra_rdoc_files: []
|
148
|
+
files:
|
149
|
+
- CHANGELOG.md
|
150
|
+
- Gemfile
|
151
|
+
- LICENSE.md
|
152
|
+
- README.md
|
153
|
+
- Rakefile
|
154
|
+
- lib/ringcentral-avatars.rb
|
155
|
+
- lib/ringcentral-avatars/creator.rb
|
156
|
+
homepage: https://github.com/grokify/
|
157
|
+
licenses:
|
158
|
+
- MIT
|
159
|
+
metadata: {}
|
160
|
+
post_install_message:
|
161
|
+
rdoc_options: []
|
162
|
+
require_paths:
|
163
|
+
- lib
|
164
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: 2.2.2
|
169
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
requirements: []
|
175
|
+
rubyforge_project:
|
176
|
+
rubygems_version: 2.6.7
|
177
|
+
signing_key:
|
178
|
+
specification_version: 4
|
179
|
+
summary: RingCentral library for auto-generating Gmail style avatars
|
180
|
+
test_files: []
|