jsong 0.2.2 → 0.3.0
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/jsong/version.rb +1 -1
- data/lib/jsong.rb +10 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99c467f0e6a1c61b775db7cc78d7f2032c54422b
|
4
|
+
data.tar.gz: d92ccc25ac55046d376d34a8ac932f1071ad2fc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f74f1a134cb4f435b6269b6503ea9a20f5af656d18e7ef910fe76c9d7fa567e700e9bc6755fc893cc263b77f8dcc62d1b20e5bf24ae233a7ded37bc2ac0e1568
|
7
|
+
data.tar.gz: 06f7684bab0f24b4a075da57d4c25419ff979adc214d3b44f02ecd7fd09e35b745f59faa1a35c5cf47cc9d5a03c4e2ff2bddbc31f24183a91cc834561d171321
|
data/lib/jsong/version.rb
CHANGED
data/lib/jsong.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'jsong/version'
|
2
2
|
require 'chunky_png'
|
3
3
|
require 'json'
|
4
|
+
require 'yaml'
|
4
5
|
|
5
6
|
module Jsong
|
6
7
|
DEFAULT = {
|
@@ -18,7 +19,7 @@ module Jsong
|
|
18
19
|
}]
|
19
20
|
}.freeze
|
20
21
|
|
21
|
-
def Jsong.to_jsong(file_name, comment = nil)
|
22
|
+
def Jsong.to_jsong(file_name, comment = nil, yaml = false)
|
22
23
|
image = ChunkyPNG::Image.from_file file_name
|
23
24
|
|
24
25
|
if comment.nil? && image.metadata['Title']
|
@@ -46,12 +47,16 @@ module Jsong
|
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
49
|
-
|
50
|
+
if yaml
|
51
|
+
data.to_yaml
|
52
|
+
else
|
53
|
+
data.to_json
|
54
|
+
end
|
50
55
|
end
|
51
56
|
|
52
|
-
def Jsong.from_jsong(
|
53
|
-
|
54
|
-
data = JSON.parse
|
57
|
+
def Jsong.from_jsong(text, file_name, yaml = false)
|
58
|
+
text = text.read if text.respond_to? :read
|
59
|
+
data = if yaml; YAML.load text; else; JSON.parse text; end
|
55
60
|
default_color = Jsong.encode_pixel data['layers'][-1]['default_color']
|
56
61
|
w, h = data['size']['width'], data['size']['height']
|
57
62
|
|