psd-enginedata 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1957969e897d576400ab12b55602144ed46d35cf
4
- data.tar.gz: 62f0f5c777a3abdd50090ebfeb5a94b4a01a2dff
3
+ metadata.gz: 465b34ea22f9b1ee7d0113b90eb4436919c9212b
4
+ data.tar.gz: 14949103aecbb7fd7898aea297598dc3139646f1
5
5
  SHA512:
6
- metadata.gz: 425deaa7d82ddce71ce370648481a1414c34b5ca80610598591240f023690df82a0f415c2c6725d128ed207e0cac73e3010039272b983adc0b278428c0320428
7
- data.tar.gz: 32b3e197b45ce9b132cb4555be9e9a160800abe6e44ea44ef4e15159b09f57c16bcd89d8a6263c1303104472acc033f631e5bc64de37da59246c9c191dd40e32
6
+ metadata.gz: 47ca212b1102ff6844cc37028084c51b50591bc5dcb1d9909f922c490a21f6a60b496508a3850a540d5ba8a74db9ed9494714d2e368a731557255f96a94d02ab
7
+ data.tar.gz: cbcf5c281d8eb7cf59551e26309f7f67ba132dc395021837c1dfa6077c296e665a33dfcbf517bd8363ceac30a477245d0bb4802d87556bdf7ba6ff0b4f21d657
@@ -37,7 +37,7 @@ class PSD
37
37
 
38
38
  # Read a file containing EngineData markup and initialize a new instance.
39
39
  def self.load(file)
40
- self.new File.read(file)
40
+ self.new File.new(file, 'rb').read
41
41
  end
42
42
 
43
43
  # Create a new Text instance and initialize our parsing stacks.
@@ -8,7 +8,11 @@ class PSD
8
8
 
9
9
  # Checks to see if the given text is a match for this token.
10
10
  def self.match(text)
11
- token.match(text)
11
+ begin
12
+ token.match(text)
13
+ rescue Encoding::CompatibilityError
14
+ nil
15
+ end
12
16
  end
13
17
 
14
18
  # Stores a reference to the EngineData document and the current
@@ -3,10 +3,21 @@ class PSD
3
3
  class EngineData
4
4
  class Instruction
5
5
  class String < Instruction
6
- def self.token; /^\(\u{2db}\u{2c7}(.*)\)$/; end
6
+ def self.token; Regexp.new('^\(\xFE\xFF(.*)\)$'.force_encoding('binary')); end
7
7
 
8
8
  def execute!
9
- match[1].gsub(/\r/, "\n").strip
9
+ data = self.class.token.match(
10
+ @text.force_encoding('binary')
11
+ )[1]
12
+
13
+ begin
14
+ data
15
+ .force_encoding('UTF-16BE')
16
+ .encode('UTF-8', 'UTF-16BE', universal_newline: true)
17
+ .strip
18
+ rescue
19
+ data
20
+ end
10
21
  end
11
22
  end
12
23
  end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  class PSD
3
3
  class EngineData
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  end
6
6
  end
Binary file
Binary file
@@ -0,0 +1,31 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe 'Parser' do
5
+ let(:parser) { PSD::EngineData.load('spec/files/enginedata') }
6
+
7
+ it "is ready to parse" do
8
+ expect(parser.text).to_not be_nil
9
+ expect(parser).to_not be_parsed
10
+ end
11
+
12
+ it "does not error when parsing" do
13
+ parser.parse!
14
+ expect(parser).to be_parsed
15
+ end
16
+
17
+ describe "result data" do
18
+ before(:each) do
19
+ parser.parse!
20
+ end
21
+
22
+ it "contains the proper data" do
23
+ expect(parser.result.EngineDict.Editor.Text).to eq("PSD · Enginedata")
24
+ end
25
+
26
+ it "parses font data" do
27
+ names = parser.result.ResourceDict.FontSet.map(&:Name)
28
+ expect(names).to include 'MyriadPro-Regular'
29
+ end
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psd-enginedata
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan LeFevre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-25 00:00:00.000000000 Z
11
+ date: 2014-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -143,8 +143,8 @@ files:
143
143
  - lib/psd/enginedata/version.rb
144
144
  - psd-enginedata.gemspec
145
145
  - spec/files/enginedata
146
- - spec/files/enginedata_simple
147
- - spec/integration/parser_spec.rb
146
+ - spec/files/source.psd
147
+ - spec/parser_spec.rb
148
148
  - spec/spec_helper.rb
149
149
  homepage: http://cosmos.layervault.com/psdrb.html
150
150
  licenses:
@@ -166,12 +166,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  version: '0'
167
167
  requirements: []
168
168
  rubyforge_project:
169
- rubygems_version: 2.0.3
169
+ rubygems_version: 2.2.1
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: Parser for the markup format used in the PSD file format
173
173
  test_files:
174
174
  - spec/files/enginedata
175
- - spec/files/enginedata_simple
176
- - spec/integration/parser_spec.rb
175
+ - spec/files/source.psd
176
+ - spec/parser_spec.rb
177
177
  - spec/spec_helper.rb
@@ -1,26 +0,0 @@
1
- <<
2
- /EngineDict
3
- <<
4
- /Editor
5
- <<
6
- /Text (˛ˇMake a change and save.)
7
- >>
8
- >>
9
- /Font
10
- <<
11
- /Name (˛ˇHelveticaNeue-Light)
12
- /Script 0
13
- /FontType 1
14
- /Synthetic 0
15
- /FillColor
16
- <<
17
- /Type 1
18
- /Values [ 1.0 0.0 0.0 0.0 ]
19
- >>
20
- /StyleSheetSet [
21
- <<
22
- /Name (˛ˇNormal RGB)
23
- >>
24
- ]
25
- >>
26
- >>
@@ -1,25 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe 'Parser' do
5
- before(:each) do
6
- @parser = PSD::EngineData.load('spec/files/enginedata')
7
- end
8
-
9
- it "is ready to parse" do
10
- expect(@parser.text).to_not be_nil
11
- expect(@parser).to_not be_parsed
12
- end
13
-
14
- it "does not error when parsing" do
15
- @parser.parse!
16
- expect(@parser).to be_parsed
17
- end
18
-
19
- it "contains the proper data" do
20
- @parser.parse!
21
-
22
- expect(@parser.result.EngineDict.Editor.Text).to eq("Make a change and save.")
23
- expect(@parser.result.ResourceDict.FontSet.first.Name).to eq("HelveticaNeue-Light")
24
- end
25
- end