magick_minimalistic 0.1.0 → 0.1.1
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/lib/magick_minimalistic.rb +7 -3
- data/lib/magick_minimalistic/sanitize.rb +6 -3
- data/test/test_magick_minimalistic.rb +18 -7
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 72c7f4af10b7e46e3af510398930144494a16d86a985271f4f3ed5d5e5673617
|
|
4
|
+
data.tar.gz: 5e45e0dd5207e78124a39dbff84d9e5f075644541116d161bcc2c82703346b5e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c8967de13f0365a0fc8b67f919bdd100279be4b2177aeda73935d7955a64c76d0179a3bb46a664d2e2bf6ab63ab9966efaa10dccdb57f559f4c06ab68371b73f
|
|
7
|
+
data.tar.gz: '089ac4a07cac312d97cbc962f0e00bc092387457bb60e3efd94a9348524decd2a25201bb7e129400fcda7cb452b0f26c56499a4967d11c656377f6dd0b0b48de'
|
data/lib/magick_minimalistic.rb
CHANGED
|
@@ -23,11 +23,15 @@ module MagickMinimalistic
|
|
|
23
23
|
def command
|
|
24
24
|
cmd = 'magick '
|
|
25
25
|
puts 'Checking source file...'
|
|
26
|
-
|
|
26
|
+
@source = Sanitize::filename(source, true)
|
|
27
|
+
cmd += "#{source} "
|
|
27
28
|
puts 'Checking attributes...'
|
|
28
|
-
|
|
29
|
+
attrs = Sanitize::attributes(config)
|
|
30
|
+
@config = attrs[0]
|
|
31
|
+
cmd += "#{attrs[1]} "
|
|
29
32
|
puts 'Checking destiny file...'
|
|
30
|
-
|
|
33
|
+
@destiny = Sanitize::filename(destiny, false)
|
|
34
|
+
cmd += "#{destiny}"
|
|
31
35
|
cmd
|
|
32
36
|
end
|
|
33
37
|
end
|
|
@@ -10,17 +10,20 @@ module Sanitize
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def self.attributes(attrs)
|
|
13
|
-
|
|
13
|
+
config_hash, config_string = {}, ""
|
|
14
|
+
puts 'There is no config to apply' unless attrs.length != -1
|
|
14
15
|
attrs.each do |key, value|
|
|
15
16
|
unless /^(gravity|crop|resize)$/ =~ key
|
|
16
17
|
puts 'The key is not a valid one'
|
|
18
|
+
puts 'Ignoring wrong key...'
|
|
17
19
|
next
|
|
18
20
|
end
|
|
19
21
|
value = type(key, value) if /^(gravity)$/ =~ key
|
|
20
22
|
value = geometry(key, value) if /^(crop|resize)$/ =~ key
|
|
21
|
-
|
|
23
|
+
config_hash[key] = value
|
|
24
|
+
config_string += Option.send(key, value)
|
|
22
25
|
end
|
|
23
|
-
|
|
26
|
+
[config_hash, config_string]
|
|
24
27
|
end
|
|
25
28
|
|
|
26
29
|
def self.geometry(key, value)
|
|
@@ -1,15 +1,26 @@
|
|
|
1
|
+
require 'pry'
|
|
1
2
|
require 'minitest/autorun'
|
|
2
|
-
require_relative '../magick_minimalistic.rb'
|
|
3
|
+
require_relative '../lib/magick_minimalistic.rb'
|
|
3
4
|
|
|
4
5
|
class TestMagickMinimalistic < MiniTest::Test
|
|
5
6
|
def setup
|
|
6
7
|
@empty = MagickMinimalistic::Configurator.new
|
|
7
|
-
@
|
|
8
|
-
@
|
|
9
|
-
@wrong_attrs = MagickMinimalistic::Configurator.new({source: 'kirby-up.png', config: {gravities: 'Center', crops: "50%", resiz: "100x100"}, destiny: 'kirby.png'})
|
|
10
|
-
@correct = im = MagickMinimalistic::Configurator.new({source: 'kirby-up.png', config: {gravity: 'Center', crop: "50%", resize: "100x100"}, destiny: 'kirby.png'})
|
|
8
|
+
@wrong = MagickMinimalistic::Configurator.new({source: 'kirby.png', config: {gravities: 'Center', crops: "50%", resize: "50x50"}, destiny: 'kirby-2.png'})
|
|
9
|
+
@correct = im = MagickMinimalistic::Configurator.new({source: 'kirby.png', config: {gravity: 'Center', crop: "50%", resize: "100x100"}, destiny: 'kirby-3.png'})
|
|
11
10
|
end
|
|
12
11
|
|
|
13
|
-
def
|
|
14
|
-
|
|
12
|
+
def test_that_an_empty_initialization_just_move_the_source_file_into_the_destiny
|
|
13
|
+
@empty.run
|
|
14
|
+
assert(File.exist?(@empty.destiny))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_that_wrong_attrs_will_not_be_used
|
|
18
|
+
@wrong.run
|
|
19
|
+
assert(File.exist?(@wrong.destiny))
|
|
20
|
+
end
|
|
15
21
|
|
|
22
|
+
def test_that_correct_attrs_will_create_the_avatar_properly
|
|
23
|
+
@correct.run
|
|
24
|
+
assert(File.exist?(@correct.destiny))
|
|
25
|
+
end
|
|
26
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: magick_minimalistic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- YourSouLisMine
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-02-
|
|
11
|
+
date: 2019-02-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: |2
|
|
14
14
|
Magick Minimalistic allows you to use some commands from the imagemagick's
|