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