procreate-swatches 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +7 -0
  3. data/.gitignore +16 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +8 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +19 -0
  8. data/.yardopts +5 -0
  9. data/CODE_OF_CONDUCT.md +74 -0
  10. data/Gemfile +6 -0
  11. data/Gemfile.lock +102 -0
  12. data/LICENSE.txt +21 -0
  13. data/README.md +230 -0
  14. data/Rakefile +8 -0
  15. data/bin/console +14 -0
  16. data/bin/setup +8 -0
  17. data/doc/Procreate/Swatches/ColorsHelper.html +693 -0
  18. data/doc/Procreate/Swatches/Errors/InvalidFormat.html +220 -0
  19. data/doc/Procreate/Swatches/Errors/InvalidPath.html +220 -0
  20. data/doc/Procreate/Swatches/Errors.html +128 -0
  21. data/doc/Procreate/Swatches/Exporter.html +754 -0
  22. data/doc/Procreate/Swatches/Parser.html +622 -0
  23. data/doc/Procreate/Swatches/Wrapper.html +1168 -0
  24. data/doc/Procreate/Swatches.html +497 -0
  25. data/doc/Procreate.html +128 -0
  26. data/doc/_index.html +209 -0
  27. data/doc/class_list.html +51 -0
  28. data/doc/css/common.css +1 -0
  29. data/doc/css/full_list.css +58 -0
  30. data/doc/css/style.css +496 -0
  31. data/doc/file.CODE_OF_CONDUCT.html +146 -0
  32. data/doc/file.LICENSE.html +70 -0
  33. data/doc/file.README.html +296 -0
  34. data/doc/file_list.html +66 -0
  35. data/doc/frames.html +17 -0
  36. data/doc/index.html +296 -0
  37. data/doc/js/app.js +292 -0
  38. data/doc/js/full_list.js +216 -0
  39. data/doc/js/jquery.js +4 -0
  40. data/doc/method_list.html +275 -0
  41. data/doc/top-level-namespace.html +110 -0
  42. data/lib/procreate/swatches/colors_helper.rb +83 -0
  43. data/lib/procreate/swatches/errors/invalid_format.rb +19 -0
  44. data/lib/procreate/swatches/errors/invalid_path.rb +16 -0
  45. data/lib/procreate/swatches/exporter.rb +131 -0
  46. data/lib/procreate/swatches/parser.rb +82 -0
  47. data/lib/procreate/swatches/version.rb +8 -0
  48. data/lib/procreate/swatches/wrapper.rb +155 -0
  49. data/lib/procreate/swatches.rb +60 -0
  50. data/procreate-swatches.gemspec +41 -0
  51. metadata +275 -0
@@ -0,0 +1,70 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: LICENSE
8
+
9
+ &mdash; Documentation by YARD 0.9.16
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "LICENSE";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="file_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: LICENSE</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'>The MIT License (MIT)<br/><br/>Copyright (c) 2019 Florinel Gorgan<br/><br/>Permission is hereby granted, free of charge, to any person obtaining a copy<br/>of this software and associated documentation files (the &quot;Software&quot;), to deal<br/>in the Software without restriction, including without limitation the rights<br/>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>copies of the Software, and to permit persons to whom the Software is<br/>furnished to do so, subject to the following conditions:<br/><br/>The above copyright notice and this permission notice shall be included in<br/>all copies or substantial portions of the Software.<br/><br/>THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br/>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br/>THE SOFTWARE.</div></div>
61
+
62
+ <div id="footer">
63
+ Generated on Sat Apr 27 09:32:32 2019 by
64
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
65
+ 0.9.16 (ruby-2.4.3).
66
+ </div>
67
+
68
+ </div>
69
+ </body>
70
+ </html>
@@ -0,0 +1,296 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.16
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="file_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'><h1 id="procreateswatches">Procreate::Swatches</h1>
61
+
62
+ <p>A gem to interact with <a href="https://procreate.art">Procreate</a> <code>.swatches</code> files.</p>
63
+
64
+ <p>This gem offers the possibility to:
65
+ * parse an existing <code>.swatches</code> color palette to an object and extract the colors in various color formats
66
+ * generate a Procreate color palette from an array of colors and export it to a <code>.swatches</code> file</p>
67
+
68
+ <p>Behind the scenes, <code>Procreate::Swatches</code> uses the <a href="https://github.com/jfairbank/chroma">Chroma gem</a> to wrap colors and provide a better experience in interacting with colors. For more in depth use cases, consult the documentation for <code>Chroma::Color</code>, available <a href="https://www.rubydoc.info/gems/chroma/0.2.0/Chroma/Color">here</a>.</p>
69
+
70
+ <h2 id="installation">Installation</h2>
71
+
72
+ <p>Add this line to your application’s Gemfile:</p>
73
+
74
+ <p><code>ruby
75
+ gem 'procreate-swatches'
76
+ </code></p>
77
+
78
+ <p>And then execute:</p>
79
+
80
+ <pre class="code ruby"><code class="ruby">$ bundle
81
+ </code></pre>
82
+
83
+ <p>Or install it yourself as:</p>
84
+
85
+ <pre class="code ruby"><code class="ruby">$ gem install procreate-swatches
86
+ </code></pre>
87
+
88
+ <h2 id="usage">Usage</h2>
89
+
90
+ <p>Before using the gem, you have to require the main file:
91
+ <code>ruby
92
+ require 'procreate/swatches'
93
+ </code></p>
94
+
95
+ <h3 id="parsing">Parsing</h3>
96
+
97
+ <p>The gem allows you to parse an existing <code>.swatches</code> file to a <code>Procreate::Swatches::Wrapper</code> instance, which will allow you to further manipulate the colors.</p>
98
+
99
+ <p><em>For full documentation, refer to <a href="https://www.rubydoc.info/gems/procreate-swatches/Procreate/Swatches/Parser">Procreate::Swatches::Parser documentation</a></em></p>
100
+
101
+ <p><strong><em>Example 1</em></strong>
102
+ <code>ruby
103
+ file_path = '/file/path/to/palette.swatches'
104
+ # Initialize a new instance of `Procreate::Swatches::Parser` with the file path to the `.swatches` file
105
+ parser = Procreate::Swatches::Parser.new(file_path)
106
+ # Use the method `#call` to parse the file; this will return an instance of `Procreate::Swatches::Wrapper`
107
+ wrapper = parser.call
108
+ </code></p>
109
+
110
+ <p><strong><em>Example 2</em></strong></p>
111
+
112
+ <p>For ease of use, a <code>.call</code> method is available:
113
+ <code>ruby
114
+ file_path = '/file/path/to/palette.swatches'
115
+ wrapper = Procreate::Swatches::Parser.call(file_path)
116
+ </code></p>
117
+
118
+ <p><strong><em>Example 3</em></strong></p>
119
+
120
+ <p>For convenience, a top-level method can be used to parse a <code>.swatches</code> file
121
+ <code>ruby
122
+ file_path = '/file/path/to/palette.swatches'
123
+ wrapper = Procreate::Swatches.parse(file_path)
124
+ # which is also aliased as `.from_file`
125
+ wrapper = Procreate::Swatches.from_file(file_path)
126
+ </code></p>
127
+
128
+ <h3 id="interacting-with-a-wrapped-palette">Interacting with a wrapped palette</h3>
129
+
130
+ <p><em>For full documentation, refer to <a href="https://www.rubydoc.info/gems/procreate-swatches/Procreate/Swatches/Wrapper">Procreate::Swatches::Wrapper documentation</a></em></p>
131
+
132
+ <p>After successfully converting a <code>.swatches</code> file to a <code>Procreate::Swatches::Wrapper</code> instance, you can further interact with the palette in a Ruby way.</p>
133
+
134
+ <p>Using the <code>Procreate::Swatches::Wrapper</code>, you can access the name and the colors array of the <code>.swatches</code> file.</p>
135
+
136
+ <p>```ruby
137
+ wrapper.name
138
+ # =&gt; “Snowy Landscape”</p>
139
+
140
+ <p>wrapper.colors
141
+ # =&gt; [hsv(195, 16%, 81%), hsv(288, 6%, 68%), hsv(232, 19%, 67%)]
142
+ ```</p>
143
+
144
+ <p>By default, each color availabe in the colors array is an instance of Chroma::Color
145
+ By providing a format parameter to the <code>#colors</code> method, you can retrieve the colors in one of the availabe formats (supported by Chroma::Color)
146
+ <code>ruby
147
+ # converting to hex
148
+ wrapper.colors(format: :hex)
149
+ # =&gt; ["#aec6cf", "#aba3ad", "#8a8fab"]
150
+ </code></p>
151
+
152
+ <p>All the availabe formats for converting colors:
153
+ ```ruby
154
+ wrapper.available_color_formats
155
+ # =&gt; [:hsv, :hsl, :hex, :hex8, :rgb, :name]</p>
156
+
157
+ <h1 id="the-list-is-also-available-using">the list is also available using</h1>
158
+ <p>Procreate::Swatches::Wrapper::AVAILABLE_COLOR_FORMATS
159
+ ```</p>
160
+
161
+ <p>To add a new color to the wrapper’s colors array, use the <code>push</code> or <code>&lt;&lt;</code> method
162
+ <code>ruby
163
+ wrapper.push("#aaa")
164
+ # =&gt; [hsv(195, 16%, 81%), hsv(288, 6%, 68%), hsv(232, 19%, 67%), #aaa]
165
+ wrapper &lt;&lt; "#bbb"
166
+ # =&gt; [hsv(195, 16%, 81%), hsv(288, 6%, 68%), hsv(232, 19%, 67%), #aaa, #bbb]
167
+ </code>
168
+ This will add the color to the array (if valid) and return the colors array, including the newly-added color. Note that each color is an instance of <code>Chroma::Color</code></p>
169
+
170
+ <p>For convenience, you can directly export a Procreate::Swatches::Wrapper instance to a <code>.swatches</code> file:
171
+ ```ruby
172
+ wrapper.export
173
+ # =&gt; “path/to/your/palette.swatches”</p>
174
+
175
+ <h1 id="which-is-also-aliased-as">which is also aliased as</h1>
176
+ <p>wrapper.to_file
177
+ # =&gt; “path/to/your/palette-1.swatches”
178
+ ```</p>
179
+
180
+ <h3 id="exporting">Exporting</h3>
181
+
182
+ <p><em>For full documentation, refer to <a href="https://www.rubydoc.info/gems/procreate-swatches/Procreate/Swatches/Exporter">Procreate::Swatches::Exporter documentation</a></em></p>
183
+
184
+ <p>You can easily export a <code>Procreate::Swatches::Wrapper</code> to a <code>.swatches</code> file.</p>
185
+
186
+ <p><strong><em>Example 1</em></strong></p>
187
+
188
+ <p>```ruby
189
+ exporter = Procreate::Swatches::Exporter.new(wrapper, options)</p>
190
+
191
+ <p>swatches_path = export.call
192
+ # =&gt; “path/to/your/palette.swatches”
193
+ ```</p>
194
+
195
+ <p>The <code>.swatches</code> path is also available afterwards, using the <code>swatches_path</code> attribute:
196
+ <code>ruby
197
+ exporter.swatches_path
198
+ # =&gt; "path/to/your/palette.swatches"
199
+ </code></p>
200
+
201
+ <p><strong><em>Example 2</em></strong></p>
202
+
203
+ <p>For ease of use, a <code>.call</code> method is available:
204
+ <code>ruby
205
+ swatches_path = Procreate::Swatches::Exporter.call(wrapper, options)
206
+ </code></p>
207
+
208
+ <p><strong><em>Example 3</em></strong></p>
209
+
210
+ <p>For convenience, a top-level method can be used to export an array of colors to a <code>.swatches</code> file:
211
+ ```ruby
212
+ name = ‘Snowy landscape’
213
+ colors = [“#aaa”, “#bbb”, “#ccc”]</p>
214
+
215
+ <p>swatches_path = Procreate::Swatches.export(name, colors)
216
+ # =&gt; “path/to/your/snowy_landscape.swatches”</p>
217
+
218
+ <h1 id="which-is-also-aliased-as-1">which is also aliased as</h1>
219
+ <p>swatches_path = Procreate::Swatches.to_file(name, colors)
220
+ # =&gt; “path/to/your/snowy_landscape-1.swatches”
221
+ ```</p>
222
+
223
+ <h4 id="export-options">Export options</h4>
224
+
225
+ <p>The <code>Procreate::Swatches::Exporter</code> class supports a number of options while exporting to a <code>.swatches</code> file.</p>
226
+
227
+ <p>```ruby
228
+ options = { export_directory: ‘/Users/username/Desktop’ }</p>
229
+
230
+ <p>swatches_path = Procreate::Swatches.to_file(name, colors, options)
231
+ # =&gt; “/Users/username/Desktop/snowy_landscape.swatches”
232
+ ```</p>
233
+
234
+ <p>```ruby
235
+ options = {
236
+ export_directory = ‘/Users/username/Desktop’,
237
+ file_name: ‘gorgeous_palette’
238
+ }</p>
239
+
240
+ <p>swatches_path = Procreate::Swatches.to_file(name, colors, options)
241
+ # =&gt; “/Users/username/Desktop/gorgeous_palette.swatches”
242
+ ```</p>
243
+
244
+ <p>The default values for these options are:
245
+ ```ruby
246
+ # The result of calling <code>Dir.pwd</code>, which returns the current working directory
247
+ export_directory = Dir.pwd</p>
248
+
249
+ <h1 id="the-sanitized-string-of-the-procreateswatcheswrapper-name">The sanitized string of the <code>Procreate::Swatches::Wrapper</code> name</h1>
250
+ <p>file_name = wrapper.name
251
+ ```</p>
252
+
253
+ <p>These options are supported on every method that can export a <code>.swatches</code> file:</p>
254
+
255
+ <p>```ruby
256
+ Procreate::Swatches::Exporter.new(wrapper, options).call</p>
257
+
258
+ <p>Procreate::Swatches::Exporter.call(wrapper, options)</p>
259
+
260
+ <p>Procreate::Swatches.to_file(name, colors, options)</p>
261
+
262
+ <p>Procreate::Swatches.export(name, colors, options)</p>
263
+
264
+ <p>wrapper.export(options)</p>
265
+
266
+ <p>wrapper.to_file(options)
267
+ ```</p>
268
+
269
+ <h2 id="development">Development</h2>
270
+
271
+ <p>After checking out the repo, run <code>bin/setup</code> to install dependencies. Then, run <code>rake spec</code> to run the tests. You can also run <code>bin/console</code> for an interactive prompt that will allow you to experiment.</p>
272
+
273
+ <p>To install this gem onto your local machine, run <code>bundle exec rake install</code>. To release a new version, update the version number in <code>version.rb</code>, and then run <code>bundle exec rake release</code>, which will create a git tag for the version, push git commits and tags, and push the <code>.gem</code> file to <a href="https://rubygems.org">rubygems.org</a>.</p>
274
+
275
+ <h2 id="contributing">Contributing</h2>
276
+
277
+ <p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/laurentzziu/procreate-swatches">https://github.com/laurentzziu/procreate-swatches</a>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the <a href="http://contributor-covenant.org">Contributor Covenant</a> code of conduct.</p>
278
+
279
+ <h2 id="license">License</h2>
280
+
281
+ <p>The gem is available as open source under the terms of the <a href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
282
+
283
+ <h2 id="code-of-conduct">Code of Conduct</h2>
284
+
285
+ <p>Everyone interacting in the <code>Procreate::Swatches</code> project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the <a href="https://github.com/laurentzziu/procreate-swatches/blob/master/CODE_OF_CONDUCT.md">code of conduct</a>.</p>
286
+ </div></div>
287
+
288
+ <div id="footer">
289
+ Generated on Sat Apr 27 09:32:32 2019 by
290
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
291
+ 0.9.16 (ruby-2.4.3).
292
+ </div>
293
+
294
+ </div>
295
+ </body>
296
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <meta charset="utf-8" />
6
+
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
8
+
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
10
+
11
+
12
+
13
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
16
+
17
+
18
+ <title>File List</title>
19
+ <base id="base_target" target="_parent" />
20
+ </head>
21
+ <body>
22
+ <div id="content">
23
+ <div class="fixed_header">
24
+ <h1 id="full_list_header">File List</h1>
25
+ <div id="full_list_nav">
26
+
27
+ <span><a target="_self" href="class_list.html">
28
+ Classes
29
+ </a></span>
30
+
31
+ <span><a target="_self" href="method_list.html">
32
+ Methods
33
+ </a></span>
34
+
35
+ <span><a target="_self" href="file_list.html">
36
+ Files
37
+ </a></span>
38
+
39
+ </div>
40
+
41
+ <div id="search">Search: <input type="text" /></div>
42
+ </div>
43
+
44
+ <ul id="full_list" class="file">
45
+
46
+
47
+ <li id="object_README" class="odd">
48
+ <div class="item"><span class="object_link"><a href="index.html" title="README">README</a></span></div>
49
+ </li>
50
+
51
+
52
+ <li id="object_LICENSE" class="even">
53
+ <div class="item"><span class="object_link"><a href="file.LICENSE.html" title="LICENSE">LICENSE</a></span></div>
54
+ </li>
55
+
56
+
57
+ <li id="object_CODE_OF_CONDUCT" class="odd">
58
+ <div class="item"><span class="object_link"><a href="file.CODE_OF_CONDUCT.html" title="CODE_OF_CONDUCT">CODE_OF_CONDUCT</a></span></div>
59
+ </li>
60
+
61
+
62
+
63
+ </ul>
64
+ </div>
65
+ </body>
66
+ </html>
data/doc/frames.html ADDED
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Documentation by YARD 0.9.16</title>
6
+ </head>
7
+ <script type="text/javascript" charset="utf-8">
8
+ var match = unescape(window.location.hash).match(/^#!(.+)/);
9
+ var name = match ? match[1] : 'index.html';
10
+ name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
11
+ window.top.location = name;
12
+ </script>
13
+ <noscript>
14
+ <h1>Oops!</h1>
15
+ <h2>YARD requires JavaScript!</h2>
16
+ </noscript>
17
+ </html>