ringcentral-avatars 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 547569ee523ed52da761e2bde1736dcb5f10a2aa
4
- data.tar.gz: ab3a0d87fd4ea1b7a70e7137078ac5dd64c8151d
3
+ metadata.gz: e71805854c33ad41768b9be7fea7a4b7d0b7ef68
4
+ data.tar.gz: cd302971a7e19a95769569540c0f04bd57232ed7
5
5
  SHA512:
6
- metadata.gz: 4524892ec62a3e60546d023b8772cc57d74763f784a4d12a7fe1353e7928f7382ffdcdf9fb387600050c3b2a63a9ceed8c7753f0192b98efbf40a5ee84108612
7
- data.tar.gz: af8b99a00ed0c44b0e235b02c3368042423f06e9e776333276e4b46439f9efe682987b3b2554f380d0f7af7fd6f5dbb6caaee44838333735ba63ff31cddecde5
6
+ metadata.gz: d64f64d610d2bcf710645a3018946fb00a0bf036b976b8f12e81813e51c8ccfb31eac6c410a544613de95960ca0fd7f2dd471f5b3bad3491a0fc3fa4c1c15a2b
7
+ data.tar.gz: 7c653fd002b68e77b289803ae96889b8d88fcd0d42de0c0b66b1f45cff49390f15b467b74c50f0e43e3b147bb0a3af7a7cf6ae17c5de1d08e342eddff8da184f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  CHANGELOG
2
2
  ---------
3
+ - **2016-11-19**: 0.4.0
4
+ - Add PNG metadata support
5
+ - Add demo scripts in `./scripts` directory
3
6
  - **2016-11-03**: 0.3.4-0.3.1
4
7
  - Add screenshot image to `gemspec`
5
8
  - Add identicon support
data/README.md CHANGED
@@ -27,6 +27,8 @@ This library uses [Avatarly](https://github.com/lucek/avatarly) to generate the
27
27
 
28
28
  Experimental [Identicon](https://en.wikipedia.org/wiki/Identicon) support is also included via [ruby_identicon](https://github.com/chrisbranson/ruby_identicon). Please see the source for usage until it gets a bit more use.
29
29
 
30
+ PNG metadata is supported which can be uploaded to and downloaded from RingCentral.
31
+
30
32
  ## Pre-requisites
31
33
 
32
34
  * ImageMagick
@@ -64,6 +66,43 @@ avatars.create_avatar ext, overwrite: true # overwrite existing for an extension
64
66
 
65
67
  See [Avatarly](https://github.com/lucek/avatarly) for avatar customization options. The default avatar size is `600`.
66
68
 
69
+ ### Adding PNG Metadata
70
+
71
+ RingCentral Avatars supports adding PNG Metadata per the [W3C PNG Specification](https://www.w3.org/TR/PNG/#11textinfo). This can be useful for tracking avatars created by this library for selective updates vs. avatars uploaded via other means.
72
+
73
+ The default description is `RingCentral Default Avatar`, however it can be modified as shown below.
74
+
75
+ ```ruby
76
+ avatars = RingCentral::Avatars.new client, png_metadata: { 'Description': 'RingCentral Avatar' }
77
+
78
+ avatars.png_metadata['Description'] = 'Updated Description'
79
+ ```
80
+
81
+ ## Sample Scripts
82
+
83
+ The following sample scripts are provided in the GitHub repo under the `./scripts` directory.
84
+
85
+ * `update_avatar.rb` - Updates all or own avatar image with optional rewrite CLI arguments.
86
+ * `get_avatar.rb` - Retrieve and save own avatar image to `_my_avatar.png` file.
87
+ * `avatar_info.rb` - Parses and dumps PNG metadata for validation of `_my_avatar.png` file.
88
+
89
+ To run these files, install dependencies and configure the demo with the following:
90
+
91
+ ```bash
92
+ $ cd scripts
93
+ $ bundle
94
+ $ cp rc_config_sample.env.txt .env
95
+ $ vi .env
96
+ ```
97
+
98
+ Run the scripts with the following:
99
+
100
+ ```bash
101
+ $ ruby update_avatar.rb --overwrite
102
+ $ ruby get_avatar.rb
103
+ $ ruby avatar_info.rb
104
+ ```
105
+
67
106
  ### Change Log
68
107
 
69
108
  See [CHANGELOG.md](CHANGELOG.md)
@@ -82,6 +121,10 @@ RingCentral API Explorer
82
121
 
83
122
  * https://developer.ringcentral.com/api-explorer/latest/index.html
84
123
 
124
+ PNG Info
125
+
126
+ * https://www.w3.org/TR/PNG/#11textinfo
127
+
85
128
  ## Contributing
86
129
 
87
130
  1. Fork it ( http://github.com/ringcentral-ruby/ringcentral-avatars-ruby/fork )
@@ -2,7 +2,7 @@ require 'ringcentral-avatars/creator'
2
2
 
3
3
  module RingCentral
4
4
  module Avatars
5
- VERSION = '0.3.4'
5
+ VERSION = '0.4.0'
6
6
 
7
7
  class << self
8
8
  def new(client, opts = {})
@@ -10,4 +10,4 @@ module RingCentral
10
10
  end
11
11
  end
12
12
  end
13
- end
13
+ end
@@ -1,8 +1,10 @@
1
1
  require 'avatarly'
2
+ require 'chunky_png'
3
+ require 'ruby_identicon'
4
+
2
5
  require 'faraday'
3
6
  require 'mime/types'
4
7
  require 'ringcentral_sdk'
5
- require 'ruby_identicon'
6
8
  require 'tempfile'
7
9
 
8
10
  module RingCentral
@@ -10,11 +12,15 @@ module RingCentral
10
12
  class Creator
11
13
  DEFAULT_SIZE = 600
12
14
  DEFAULT_FORMAT = 'png'
15
+ PNG_DEFAULT_METADATA = {
16
+ 'Description' => 'RingCentral Default Avatar'
17
+ }
13
18
 
14
19
  attr_accessor :avatar_opts
15
20
  attr_accessor :avatars
16
21
  attr_accessor :client
17
22
  attr_accessor :extensions
23
+ attr_accessor :png_metadata
18
24
 
19
25
  ##
20
26
  # Requires RingCentralSdk instance
@@ -24,6 +30,11 @@ module RingCentral
24
30
  if !opts.key?(:initials_opts) && opts.key?(:avatar_opts)
25
31
  opts[:initials_opts] = opts[:avatar_opts]
26
32
  end
33
+ if opts.key(:png_metadata)
34
+ opts[:png_metadata] = PNG_DEFAULT_METADATA.merge(opts[:png_metadata])
35
+ else
36
+ opts[:png_metadata] = PNG_DEFAULT_METADATA
37
+ end
27
38
  @avatars = RingCentral::Avatars::MultiAvatar.new opts
28
39
  load_extensions
29
40
  end
@@ -129,6 +140,7 @@ module RingCentral
129
140
  @avatarly_opts = inflate_avatarly_opts opts[:initials_opts]
130
141
  @identicon_opts = inflate_identicon_opts opts[:identicon_opts]
131
142
  @style = opts.key?(:style) ? opts[:style] : DEFAULT_STYLE
143
+ @png_metadata = opts.key?(:png_metadata) ? opts[:png_metadata] : {}
132
144
  end
133
145
 
134
146
  def inflate_avatarly_opts(avatarly_opts = {})
@@ -146,6 +158,14 @@ module RingCentral
146
158
  blob = @style == 'initials' \
147
159
  ? Avatarly.generate_avatar(text, @avatarly_opts) \
148
160
  : RubyIdenticon.create(text, @identicon_opts)
161
+ inflate_avatar_blob_png blob
162
+ end
163
+
164
+ def inflate_avatar_blob_png(blob)
165
+ return blob unless avatar_format == 'png' && @png_metadata
166
+ img = ChunkyPNG::Image.from_blob blob
167
+ img.metadata = @png_metadata
168
+ img.to_blob
149
169
  end
150
170
 
151
171
  def avatar_temp_file(text, style = nil)
@@ -179,4 +199,4 @@ module RingCentral
179
199
  end
180
200
  end
181
201
  end
182
- end
202
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ringcentral-avatars
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wang
@@ -30,6 +30,26 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.5.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: chunky_png
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.3'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.3.8
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.3'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.3.8
33
53
  - !ruby/object:Gem::Dependency
34
54
  name: faraday
35
55
  requirement: !ruby/object:Gem::Requirement
@@ -193,7 +213,6 @@ files:
193
213
  - Rakefile
194
214
  - lib/ringcentral-avatars.rb
195
215
  - lib/ringcentral-avatars/creator.rb
196
- - ringcentral-avatars.gemspec
197
216
  homepage: https://github.com/grokify/
198
217
  licenses:
199
218
  - MIT
@@ -214,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
233
  version: '0'
215
234
  requirements: []
216
235
  rubyforge_project:
217
- rubygems_version: 2.4.8
236
+ rubygems_version: 2.6.7
218
237
  signing_key:
219
238
  specification_version: 4
220
239
  summary: RingCentral library for auto-generating Gmail style avatars
@@ -1,32 +0,0 @@
1
- lib = 'ringcentral-avatars'
2
- lib_file = File.expand_path("../lib/#{lib}.rb", __FILE__)
3
- File.read(lib_file) =~ /\bVERSION\s*=\s*["'](.+?)["']/
4
- version = $1
5
-
6
- Gem::Specification.new do |s|
7
- s.name = lib
8
- s.version = version
9
- s.date = '2016-11-03'
10
- s.summary = 'RingCentral library for auto-generating Gmail style avatars'
11
- s.description = 'Create RingCentral avatars using Gmail-style avatars'
12
- s.authors = ['John Wang']
13
- s.email = 'johncwang@gmail.com'
14
- s.homepage = 'https://github.com/grokify/'
15
- s.licenses = ['MIT']
16
- s.files = Dir['lib/**/**/*']
17
- s.files += Dir['[A-Z]*'] + Dir['test/**/*']
18
-
19
- s.required_ruby_version = '>= 2.2.2'
20
-
21
- s.add_dependency 'avatarly', '~> 1.5', '>= 1.5.0'
22
- s.add_dependency 'faraday', '~> 0.9', '>= 0.9'
23
- s.add_dependency 'mime-types', '~> 3.0', '>= 3.1'
24
- s.add_dependency 'ringcentral_sdk', '~> 1', '>= 1.3.4'
25
- s.add_dependency 'ruby_identicon', '~> 0', '>= 0.0.5'
26
-
27
- s.add_development_dependency 'coveralls', '~> 0'
28
- s.add_development_dependency 'mocha', '~> 1'
29
- s.add_development_dependency 'rake', '~> 11'
30
- s.add_development_dependency 'simplecov', '~> 0'
31
- s.add_development_dependency 'test-unit', '~> 3'
32
- end