graff 0.0.3 → 0.0.4

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