mosaiq 0.1.1 → 0.1.2
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 +4 -4
- data/.travis.yml +6 -2
- data/Gemfile.lock +9 -1
- data/README.md +21 -13
- data/lib/mosaiq/image.rb +2 -2
- data/lib/mosaiq/svg.rb +13 -13
- data/lib/mosaiq/version.rb +1 -1
- data/mosaiq.gemspec +3 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 544b21c20826297ee626f191b5bd7169f8a82013ab9c35b45554d78c42a9981a
|
4
|
+
data.tar.gz: fa00e04db556682405c99381b434f416a711e2a8318cdc0dec69efabce67cd5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7592c0ca8158c951ae14e07f185fd6ce8e233135a7227e46d4bac449601ed35cc7ebba0820eb14e6ad03fa6ba69c2f9685f085ded8bc9e3daadfcabf1044647
|
7
|
+
data.tar.gz: e814b8e37c71066ec0d159887e9a0f9d4c858f95549cd5ecac10399f21f14d40a107f43d8c2364486e57435d6c36d386917f5c1cee47e7a4b438da7dcc65e7a9
|
data/.travis.yml
CHANGED
@@ -6,7 +6,11 @@ rvm:
|
|
6
6
|
before_install:
|
7
7
|
- "gem update --system"
|
8
8
|
- "gem install bundler"
|
9
|
+
before_script:
|
10
|
+
- "curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter"
|
11
|
+
- "chmod +x ./cc-test-reporter"
|
12
|
+
- "./cc-test-reporter before-build"
|
9
13
|
script:
|
10
14
|
- "bin/test"
|
11
|
-
|
12
|
-
|
15
|
+
after_script:
|
16
|
+
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mosaiq (0.1.
|
4
|
+
mosaiq (0.1.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
ast (2.4.0)
|
10
10
|
byebug (11.0.1)
|
11
|
+
docile (1.3.2)
|
11
12
|
jaro_winkler (1.5.3)
|
13
|
+
json (2.2.0)
|
12
14
|
mini_portile2 (2.4.0)
|
13
15
|
minitest (5.12.2)
|
14
16
|
nokogiri (1.10.4)
|
@@ -26,6 +28,11 @@ GEM
|
|
26
28
|
ruby-progressbar (~> 1.7)
|
27
29
|
unicode-display_width (>= 1.4.0, < 1.7)
|
28
30
|
ruby-progressbar (1.10.1)
|
31
|
+
simplecov (0.17.1)
|
32
|
+
docile (~> 1.1)
|
33
|
+
json (>= 1.8, < 3)
|
34
|
+
simplecov-html (~> 0.10.0)
|
35
|
+
simplecov-html (0.10.2)
|
29
36
|
unicode-display_width (1.6.0)
|
30
37
|
|
31
38
|
PLATFORMS
|
@@ -39,6 +46,7 @@ DEPENDENCIES
|
|
39
46
|
nokogiri
|
40
47
|
rake (~> 10.0)
|
41
48
|
rubocop
|
49
|
+
simplecov
|
42
50
|
|
43
51
|
BUNDLED WITH
|
44
52
|
2.0.2
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
[](https://travis-ci.org/lxxxvi/mosaiq)
|
2
|
+
[](https://codeclimate.com/github/lxxxvi/mosaiq/maintainability)
|
3
|
+
[](https://codeclimate.com/github/lxxxvi/mosaiq/test_coverage)
|
2
4
|
|
3
5
|
# Mosaiq
|
4
6
|
|
@@ -22,14 +24,23 @@ Or install it yourself as:
|
|
22
24
|
|
23
25
|
## Usage
|
24
26
|
|
25
|
-
|
27
|
+
Base usage:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
image = Mosaiq::Image.new(width: 3, height: 4, colors: %w[red green blue])
|
31
|
+
```
|
32
|
+
|
33
|
+
* Unit of `width` and `height` is pixels
|
34
|
+
* `colors` is an `Array` of color names. Any valid HTML color will work. There are also predefined color "Palettes", [see below](#palette).
|
35
|
+
|
26
36
|
|
27
37
|
### SVG
|
28
38
|
|
39
|
+
Currently only SVG is supported.
|
40
|
+
|
29
41
|
```ruby
|
30
|
-
|
31
|
-
|
32
|
-
# => <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%" viewBox="0 0 4 3" version="1.1" xmlns="http://www.w3.org/2000/svg"><rect x="0" y="0" width="1" height="1" style="fill: blue;"/><rect x="0" y="1" width="1" height="1" style="fill: green;"/><rect x="0" y="2" width="1" height="1" style="fill: red;"/><rect x="1" y="0" width="1" height="1" style="fill: red;"/><rect x="1" y="1" width="1" height="1" style="fill: red;"/><rect x="1" y="2" width="1" height="1" style="fill: red;"/><rect x="2" y="0" width="1" height="1" style="fill: blue;"/><rect x="2" y="1" width="1" height="1" style="fill: blue;"/><rect x="2" y="2" width="1" height="1" style="fill: red;"/><rect x="3" y="0" width="1" height="1" style="fill: red;"/><rect x="3" y="1" width="1" height="1" style="fill: blue;"/><rect x="3" y="2" width="1" height="1" style="fill: red;"/></svg>
|
42
|
+
puts image.svg.raw
|
43
|
+
# => <?xml version="1.0" encoding="UTF-8"?> ...
|
33
44
|
```
|
34
45
|
|
35
46
|
which looks like this when saved to a file
|
@@ -38,19 +49,16 @@ which looks like this when saved to a file
|
|
38
49
|
|---------------------------------------------------------------|
|
39
50
|
|  |
|
40
51
|
|
41
|
-
* The first argument is the `width` of the image.
|
42
|
-
* The second argument is the `height` of the image.
|
43
|
-
* The third argument is an array of color names. Any valid HTML color names will do.
|
44
52
|
|
45
53
|
## Palette
|
46
54
|
|
47
55
|
There are three predefined "Palettes" of colors:
|
48
56
|
|
49
|
-
| Palette | Example
|
50
|
-
|
51
|
-
| `black_and_white` | `Mosaiq::Image.new(10, 5, Mosaiq::Palette::black_and_white)` |  |
|
52
|
-
| `grays` | `Mosaiq::Image.new(10, 5, Mosaiq::Palette::grays)` |  |
|
53
|
-
| `random_colors(n)` | `Mosaiq::Image.new(10, 5, Mosaiq::Palette::random_colors(8))` |  |
|
57
|
+
| Palette | Example | Result |
|
58
|
+
|--------------------|--------------------------------------------------------------------------------------|-------------------------------------------------------------------------|
|
59
|
+
| `black_and_white` | `Mosaiq::Image.new(width: 10, height: 5, colors: Mosaiq::Palette::black_and_white)` |  |
|
60
|
+
| `grays` | `Mosaiq::Image.new(width: 10, height: 5, colors: Mosaiq::Palette::grays)` |  |
|
61
|
+
| `random_colors(n)` | `Mosaiq::Image.new(width: 10, height: 5, colors: Mosaiq::Palette::random_colors(8))` |  |
|
54
62
|
|
55
63
|
|
56
64
|
## Development
|
@@ -61,7 +69,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
61
69
|
|
62
70
|
## Contributing
|
63
71
|
|
64
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
72
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/lxxxvi/mosaiq. 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.
|
65
73
|
|
66
74
|
## License
|
67
75
|
|
data/lib/mosaiq/image.rb
CHANGED
@@ -5,7 +5,7 @@ require 'mosaiq/svg'
|
|
5
5
|
module Mosaiq
|
6
6
|
# Main class to create a Mosaiq Image
|
7
7
|
class Image
|
8
|
-
def initialize(width
|
8
|
+
def initialize(width:, height:, colors: Palette.black_and_white)
|
9
9
|
@width = read_positive_integer(width: width)
|
10
10
|
@height = read_positive_integer(height: height)
|
11
11
|
@colors = read_colors(colors)
|
@@ -14,7 +14,7 @@ module Mosaiq
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def svg
|
17
|
-
Mosaiq::Svg.new(@canvas)
|
17
|
+
Mosaiq::Svg.new(@canvas)
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
data/lib/mosaiq/svg.rb
CHANGED
@@ -9,7 +9,7 @@ module Mosaiq
|
|
9
9
|
@height = canvas.count
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def raw
|
13
13
|
%(#{svg_header} #{svg_body}).tr("\n", '').gsub(/ +/, ' ')
|
14
14
|
end
|
15
15
|
|
@@ -17,18 +17,18 @@ module Mosaiq
|
|
17
17
|
|
18
18
|
def svg_header
|
19
19
|
%(<?xml version="1.0" encoding="UTF-8"?>
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
<!DOCTYPE svg
|
21
|
+
PUBLIC
|
22
|
+
"-//W3C//DTD SVG 1.1//EN"
|
23
|
+
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">)
|
24
24
|
end
|
25
25
|
|
26
26
|
def svg_body
|
27
27
|
%(<svg width="100%"
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
height="100%"
|
29
|
+
viewBox="0 0 #{@width} #{@height}"
|
30
|
+
version="1.1"
|
31
|
+
xmlns="http://www.w3.org/2000/svg">#{svg_rectangles.join}</svg>)
|
32
32
|
end
|
33
33
|
|
34
34
|
def svg_rectangles
|
@@ -41,10 +41,10 @@ module Mosaiq
|
|
41
41
|
|
42
42
|
def svg_rectangle(x_coordinates, y_coordinates, color)
|
43
43
|
%(<rect x="#{x_coordinates}"
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
y="#{y_coordinates}"
|
45
|
+
width="1"
|
46
|
+
height="1"
|
47
|
+
style="fill: #{color};"/>)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/lib/mosaiq/version.rb
CHANGED
data/mosaiq.gemspec
CHANGED
@@ -30,10 +30,13 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ['lib']
|
32
32
|
|
33
|
+
spec.required_ruby_version = '>= 2.3'
|
34
|
+
|
33
35
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
34
36
|
spec.add_development_dependency 'byebug'
|
35
37
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
36
38
|
spec.add_development_dependency 'nokogiri'
|
37
39
|
spec.add_development_dependency 'rake', '~> 10.0'
|
38
40
|
spec.add_development_dependency 'rubocop'
|
41
|
+
spec.add_development_dependency 'simplecov'
|
39
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mosaiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lxxxvi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Mosaiq generates images of randomly colored pixels
|
98
112
|
email:
|
99
113
|
- lxxxvi@users.noreply.github.com
|
@@ -139,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
153
|
requirements:
|
140
154
|
- - ">="
|
141
155
|
- !ruby/object:Gem::Version
|
142
|
-
version: '
|
156
|
+
version: '2.3'
|
143
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
158
|
requirements:
|
145
159
|
- - ">="
|