graff 0.0.2 → 0.0.3

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