jsong 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jsong/version.rb +1 -1
  3. data/lib/jsong.rb +10 -5
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f05b92d2d4d9c80a01731563832b5d5d930e8830
4
- data.tar.gz: bd7589eb0625f25dea9c691d5ade8c82dd3f1cbe
3
+ metadata.gz: 99c467f0e6a1c61b775db7cc78d7f2032c54422b
4
+ data.tar.gz: d92ccc25ac55046d376d34a8ac932f1071ad2fc6
5
5
  SHA512:
6
- metadata.gz: 7f58ebb56bbacc01599737049e0f4700ba8451c69b2b74b2c4b03caf23f63baa8d7073ffc1b7674d660787241a5c6ea416d6f0433216ab9f8ca0dad536663406
7
- data.tar.gz: 5dbcde6e2f269464a29da18eb29c23fb1893969731463fbab9097bcaf5c4641dcd85289da6391781dcc35cd6b855506db692f165d2037d2daf992affb5fe2277
6
+ metadata.gz: f74f1a134cb4f435b6269b6503ea9a20f5af656d18e7ef910fe76c9d7fa567e700e9bc6755fc893cc263b77f8dcc62d1b20e5bf24ae233a7ded37bc2ac0e1568
7
+ data.tar.gz: 06f7684bab0f24b4a075da57d4c25419ff979adc214d3b44f02ecd7fd09e35b745f59faa1a35c5cf47cc9d5a03c4e2ff2bddbc31f24183a91cc834561d171321
data/lib/jsong/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jsong
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
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
- data.to_json
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(json_text, file_name)
53
- json_text = json_text.read if json_text.respond_to? :read
54
- data = JSON.parse json_text
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsong
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Illia K.