graff 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/graff.rb +169 -171
- metadata +3 -3
data/lib/graff.rb
CHANGED
@@ -1,232 +1,230 @@
|
|
1
1
|
require 'plist'
|
2
2
|
require 'zlib'
|
3
3
|
|
4
|
-
|
5
|
-
class Stencil
|
4
|
+
class Graff
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
if File.read(file, 2).unpack('CC') == [0x1f, 0x8b]
|
13
|
-
file = Zlib::GzipReader.open(file).read
|
14
|
-
end
|
6
|
+
def initialize(file)
|
7
|
+
if File.directory?(file)
|
8
|
+
file = file + "/data.plist"
|
9
|
+
end
|
15
10
|
|
16
|
-
|
11
|
+
if File.read(file, 2).unpack('CC') == [0x1f, 0x8b]
|
12
|
+
file = Zlib::GzipReader.open(file).read
|
17
13
|
end
|
14
|
+
|
15
|
+
@stencil = Plist::parse_xml(file)
|
16
|
+
end
|
18
17
|
|
19
|
-
|
18
|
+
# MAPPINGS
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
def active_layer_index
|
21
|
+
@stencil['ActiveLayerIndex']
|
22
|
+
end
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
def application_version
|
25
|
+
@stencil['ApplicationVersion']
|
26
|
+
end
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
def auto_adjust
|
29
|
+
@stencil['AutoAdjust']
|
30
|
+
end
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
def background_graphic
|
33
|
+
@stencil['BackgroundGraphic']
|
34
|
+
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
def base_zoom
|
37
|
+
@stencil['BaseZoom']
|
38
|
+
end
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
def canvas_origin
|
41
|
+
@stencil['CanvasOrigin']
|
42
|
+
end
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
def column_align
|
45
|
+
@stencil['ColumnAlign']
|
46
|
+
end
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
def column_spacing
|
49
|
+
@stencil['ColumnSpacing']
|
50
|
+
end
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
def creation_date
|
53
|
+
@stencil['CreationDate']
|
54
|
+
end
|
56
55
|
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
def creator
|
57
|
+
@stencil['Creator']
|
58
|
+
end
|
60
59
|
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
def display_scale
|
61
|
+
@stencil['DisplayScale']
|
62
|
+
end
|
64
63
|
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
def graph_document_version
|
65
|
+
@stencil['GraphDocumentVersion']
|
66
|
+
end
|
68
67
|
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
def graphics_list
|
69
|
+
@stencil['GraphicsList']
|
70
|
+
end
|
72
71
|
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
def grid_info
|
73
|
+
@stencil['GridInfo']
|
74
|
+
end
|
76
75
|
|
77
|
-
|
78
|
-
|
79
|
-
|
76
|
+
def guides_locked
|
77
|
+
@stencil['GuidesLocked']
|
78
|
+
end
|
80
79
|
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
def guides_visible
|
81
|
+
@stencil['GuidesVisible']
|
82
|
+
end
|
84
83
|
|
85
|
-
|
86
|
-
|
87
|
-
|
84
|
+
def h_pages
|
85
|
+
@stencil['HPages']
|
86
|
+
end
|
88
87
|
|
89
|
-
|
90
|
-
|
91
|
-
|
88
|
+
def image_counter
|
89
|
+
@stencil['ImageCounter']
|
90
|
+
end
|
92
91
|
|
93
|
-
|
94
|
-
|
95
|
-
|
92
|
+
def keep_to_scale
|
93
|
+
@stencil['KeepToScale']
|
94
|
+
end
|
96
95
|
|
97
|
-
|
98
|
-
|
99
|
-
|
96
|
+
def layers
|
97
|
+
@stencil['Layers']
|
98
|
+
end
|
100
99
|
|
101
|
-
|
102
|
-
|
103
|
-
|
100
|
+
def layout_info
|
101
|
+
@stencil['LayoutInfo']
|
102
|
+
end
|
104
103
|
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
def links_visible
|
105
|
+
@stencil['LinksVisible']
|
106
|
+
end
|
108
107
|
|
109
|
-
|
110
|
-
|
111
|
-
|
108
|
+
def magnets_visible
|
109
|
+
@stencil['MagnetsVisible']
|
110
|
+
end
|
112
111
|
|
113
|
-
|
114
|
-
|
115
|
-
|
112
|
+
def master_sheets
|
113
|
+
@stencil['MasterSheets']
|
114
|
+
end
|
116
115
|
|
117
|
-
|
118
|
-
|
119
|
-
|
116
|
+
def modification_date
|
117
|
+
@stencil['ModificationDate']
|
118
|
+
end
|
120
119
|
|
121
|
-
|
122
|
-
|
123
|
-
|
120
|
+
def modifier
|
121
|
+
@stencil['Modifier']
|
122
|
+
end
|
124
123
|
|
125
|
-
|
126
|
-
|
127
|
-
|
124
|
+
def notes_visible
|
125
|
+
@stencil['NotesVisible']
|
126
|
+
end
|
128
127
|
|
129
|
-
|
130
|
-
|
131
|
-
|
128
|
+
def orientation
|
129
|
+
@stencil['Orientation']
|
130
|
+
end
|
132
131
|
|
133
|
-
|
134
|
-
|
135
|
-
|
132
|
+
def origin_visible
|
133
|
+
@stencil['OriginVisible']
|
134
|
+
end
|
136
135
|
|
137
|
-
|
138
|
-
|
139
|
-
|
136
|
+
def page_breaks
|
137
|
+
@stencil['PageBreaks']
|
138
|
+
end
|
140
139
|
|
141
|
-
|
142
|
-
|
143
|
-
|
140
|
+
def print_info
|
141
|
+
@stencil['PrintInfo']
|
142
|
+
end
|
144
143
|
|
145
|
-
|
146
|
-
|
147
|
-
|
144
|
+
def print_one_page
|
145
|
+
@stencil['PrintOnePage']
|
146
|
+
end
|
148
147
|
|
149
|
-
|
150
|
-
|
151
|
-
|
148
|
+
def read_only
|
149
|
+
@stencil['ReadOnly']
|
150
|
+
end
|
152
151
|
|
153
|
-
|
154
|
-
|
155
|
-
|
152
|
+
def row_align
|
153
|
+
@stencil['RowAlign']
|
154
|
+
end
|
156
155
|
|
157
|
-
|
158
|
-
|
159
|
-
|
156
|
+
def row_spacing
|
157
|
+
@stencil['RowSpacing']
|
158
|
+
end
|
160
159
|
|
161
|
-
|
162
|
-
|
163
|
-
|
160
|
+
def sheet_title
|
161
|
+
@stencil['SheetTitle']
|
162
|
+
end
|
164
163
|
|
165
|
-
|
166
|
-
|
167
|
-
|
164
|
+
def sheets
|
165
|
+
@stencil['Sheets']
|
166
|
+
end
|
168
167
|
|
169
|
-
|
170
|
-
|
171
|
-
|
168
|
+
def smart_aligment_guides_active
|
169
|
+
@stencil['SmartAlignmentGuidesActive']
|
170
|
+
end
|
172
171
|
|
173
|
-
|
174
|
-
|
175
|
-
|
172
|
+
def smart_distance_guides_active
|
173
|
+
@stencil['SmartDistanceGuidesActive']
|
174
|
+
end
|
176
175
|
|
177
|
-
|
178
|
-
|
179
|
-
|
176
|
+
def unique_id
|
177
|
+
@stencil['UniqueID']
|
178
|
+
end
|
180
179
|
|
181
|
-
|
182
|
-
|
183
|
-
|
180
|
+
def unique_id
|
181
|
+
@stencil['UniqueID']
|
182
|
+
end
|
184
183
|
|
185
|
-
|
186
|
-
|
187
|
-
|
184
|
+
def use_entire_page
|
185
|
+
@stencil['UseEntirePage']
|
186
|
+
end
|
188
187
|
|
189
|
-
|
190
|
-
|
191
|
-
|
188
|
+
def v_pages
|
189
|
+
@stencil['VPages']
|
190
|
+
end
|
192
191
|
|
193
|
-
|
194
|
-
|
195
|
-
|
192
|
+
def window_info
|
193
|
+
@stencil['WindowInfo']
|
194
|
+
end
|
195
|
+
|
196
|
+
# CONVENIENCE METHODS
|
196
197
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
graphics =
|
202
|
-
self.sheets.each do |sheet|
|
203
|
-
graphics = graphics + sheet['GraphicsList'].count
|
204
|
-
end
|
205
|
-
graphics
|
206
|
-
else
|
207
|
-
self.graphics_list.count
|
198
|
+
def number_of_graphics
|
199
|
+
if self.sheets
|
200
|
+
graphics = 0
|
201
|
+
self.sheets.each do |sheet|
|
202
|
+
graphics = graphics + sheet['GraphicsList'].count
|
208
203
|
end
|
204
|
+
graphics
|
205
|
+
else
|
206
|
+
self.graphics_list.count
|
209
207
|
end
|
208
|
+
end
|
210
209
|
|
211
|
-
|
212
|
-
|
213
|
-
|
210
|
+
def number_of_canvases
|
211
|
+
self.sheets ? self.sheets.count : 1
|
212
|
+
end
|
214
213
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
end
|
221
|
-
layers
|
222
|
-
else
|
223
|
-
self.layers.count || 0
|
214
|
+
def number_of_layers
|
215
|
+
if self.sheets
|
216
|
+
layers = 0
|
217
|
+
self.sheets.each do |sheet|
|
218
|
+
layers = layers + sheet['Layers'].count
|
224
219
|
end
|
220
|
+
layers
|
221
|
+
else
|
222
|
+
self.layers.count || 0
|
225
223
|
end
|
224
|
+
end
|
226
225
|
|
227
|
-
|
228
|
-
|
229
|
-
end
|
230
|
-
|
226
|
+
def version
|
227
|
+
self.graph_document_version
|
231
228
|
end
|
229
|
+
|
232
230
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-06-12 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: plist
|
16
|
-
requirement: &
|
16
|
+
requirement: &70281588609080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70281588609080
|
25
25
|
description: Parse OmniGraffle documents
|
26
26
|
email: patrick@mokolabs.com
|
27
27
|
executables: []
|