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 +4 -4
- data/lib/psd/enginedata.rb +1 -1
- data/lib/psd/enginedata/instruction.rb +5 -1
- data/lib/psd/enginedata/instructions/string.rb +13 -2
- data/lib/psd/enginedata/version.rb +1 -1
- data/spec/files/enginedata +0 -0
- data/spec/files/source.psd +0 -0
- data/spec/parser_spec.rb +31 -0
- metadata +7 -7
- data/spec/files/enginedata_simple +0 -26
- data/spec/integration/parser_spec.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 465b34ea22f9b1ee7d0113b90eb4436919c9212b
|
4
|
+
data.tar.gz: 14949103aecbb7fd7898aea297598dc3139646f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47ca212b1102ff6844cc37028084c51b50591bc5dcb1d9909f922c490a21f6a60b496508a3850a540d5ba8a74db9ed9494714d2e368a731557255f96a94d02ab
|
7
|
+
data.tar.gz: cbcf5c281d8eb7cf59551e26309f7f67ba132dc395021837c1dfa6077c296e665a33dfcbf517bd8363ceac30a477245d0bb4802d87556bdf7ba6ff0b4f21d657
|
data/lib/psd/enginedata.rb
CHANGED
@@ -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
|
-
|
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;
|
6
|
+
def self.token; Regexp.new('^\(\xFE\xFF(.*)\)$'.force_encoding('binary')); end
|
7
7
|
|
8
8
|
def execute!
|
9
|
-
match
|
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
|
data/spec/files/enginedata
CHANGED
Binary file
|
Binary file
|
data/spec/parser_spec.rb
ADDED
@@ -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.
|
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:
|
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/
|
147
|
-
- spec/
|
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.
|
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/
|
176
|
-
- spec/
|
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
|