moo 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/LICENSE +19 -0
  2. data/README.mkd +96 -0
  3. data/data/moo/templates/businesscard_bottom_image_dual_column_text_landscape.xml +361 -0
  4. data/data/moo/templates/businesscard_bottom_image_single_column_text_landscape.xml +231 -0
  5. data/data/moo/templates/businesscard_bottom_image_single_column_text_portrait.xml +361 -0
  6. data/data/moo/templates/businesscard_full_details_image_landscape.xml +77 -0
  7. data/data/moo/templates/businesscard_full_details_image_portrait.xml +75 -0
  8. data/data/moo/templates/businesscard_full_image_landscape.xml +73 -0
  9. data/data/moo/templates/businesscard_full_image_portrait.xml +73 -0
  10. data/data/moo/templates/businesscard_full_text_landscape.xml +343 -0
  11. data/data/moo/templates/businesscard_full_text_portrait.xml +342 -0
  12. data/data/moo/templates/businesscard_left_image_landscape.xml +363 -0
  13. data/data/moo/templates/businesscard_right_image_landscape.xml +363 -0
  14. data/data/moo/templates/businesscard_top_image_dual_column_text_landscape.xml +361 -0
  15. data/data/moo/templates/businesscard_top_image_single_column_text_landscape.xml +231 -0
  16. data/data/moo/templates/businesscard_top_image_single_column_text_portrait.xml +361 -0
  17. data/data/moo/templates/minicard_bottom_image_landscape.xml +155 -0
  18. data/data/moo/templates/minicard_full_details_image_landscape.xml +75 -0
  19. data/data/moo/templates/minicard_full_details_image_portrait.xml +74 -0
  20. data/data/moo/templates/minicard_full_image_landscape.xml +75 -0
  21. data/data/moo/templates/minicard_full_image_portrait.xml +74 -0
  22. data/data/moo/templates/minicard_full_text_landscape.xml +221 -0
  23. data/data/moo/templates/minicard_left_image_landscape.xml +238 -0
  24. data/data/moo/templates/minicard_right_image_landscape.xml +239 -0
  25. data/data/moo/templates/minicard_top_image_landscape.xml +154 -0
  26. data/data/moo/templates/postcard_full_details_image_landscape.xml +77 -0
  27. data/data/moo/templates/postcard_full_details_image_portrait.xml +76 -0
  28. data/data/moo/templates/postcard_full_image_landscape.xml +77 -0
  29. data/data/moo/templates/postcard_full_image_portrait.xml +77 -0
  30. data/data/moo/templates/postcard_full_text_portrait.xml +76 -0
  31. data/data/moo/templates/sticker_image.xml +76 -0
  32. data/lib/moo.rb +4 -0
  33. data/lib/moo/client.rb +111 -0
  34. data/lib/moo/core_ext/object.rb +7 -0
  35. data/lib/moo/core_ext/string.rb +6 -0
  36. data/lib/moo/model.rb +20 -0
  37. data/lib/moo/model/bounding_box.rb +70 -0
  38. data/lib/moo/model/box_data.rb +38 -0
  39. data/lib/moo/model/card.rb +12 -0
  40. data/lib/moo/model/colour.rb +100 -0
  41. data/lib/moo/model/data.rb +11 -0
  42. data/lib/moo/model/fixed_image_data.rb +40 -0
  43. data/lib/moo/model/font.rb +66 -0
  44. data/lib/moo/model/image_basket.rb +21 -0
  45. data/lib/moo/model/image_basket_item.rb +88 -0
  46. data/lib/moo/model/image_data.rb +64 -0
  47. data/lib/moo/model/multi_line_text_data.rb +8 -0
  48. data/lib/moo/model/pack.rb +50 -0
  49. data/lib/moo/model/side.rb +72 -0
  50. data/lib/moo/model/template.rb +78 -0
  51. data/lib/moo/model/text_data.rb +72 -0
  52. metadata +160 -0
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011 by Najaf Ali
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,96 @@
1
+ moo.rb
2
+ ===
3
+
4
+ ## A simple ruby client library for the moo.com API
5
+
6
+ ### Basic Usage
7
+
8
+ #### Authentication
9
+
10
+ Set up the moo client with your moo API key/secret like so:
11
+
12
+ ```ruby
13
+ require 'moo'
14
+
15
+ Moo::Client.config |c|
16
+ c.oauth_key = 'your key'
17
+ c.oauth_secret = 'super secret'
18
+ end
19
+ ```
20
+
21
+ Moo uses OAuth. Here's how to get a request token:
22
+
23
+ ```ruby
24
+ client = Moo::Client.new
25
+ request_token = client.get_request_token callback: 'http://my/oauth/callback/url'
26
+ ```
27
+
28
+ You'll then need to get your request token authorized by redirecting your user
29
+ to the authorize url
30
+
31
+ ```ruby
32
+ # something like...
33
+ redirect request_token.authorize_url
34
+ ```
35
+
36
+ After the user has given you access, you'll get an acces token which you can use
37
+ to make calls to the moo API
38
+
39
+ ```ruby
40
+ access_token = request_token.get_access_token
41
+ ```
42
+
43
+
44
+ #### Making Minicards
45
+
46
+ Here's how you would make a basic minicard pack of your last 100 tweets:
47
+
48
+ ```ruby
49
+ include Moo::Model
50
+
51
+ # create a new Pack object
52
+ pack = Pack.new do |p|
53
+ # all moo pack model objects yield themself to a block in their
54
+ # constructors
55
+
56
+ p.product_code = 'minicard'
57
+
58
+ # Grab my last 100 tweets and create a side for each of them
59
+ p.sides = Twitter.user_timeline('alinajaf', count:100).map do |t|
60
+ Side.new do |s|
61
+ s.template_code = 'minicard_full_text_landscape'
62
+ s.type = 'image'
63
+ s.data << TextData.new do |text_data|
64
+ text_data.link_id = 'back_line_1'
65
+ text_data.text = t.text
66
+ end
67
+ end
68
+ end
69
+
70
+ # Create a single details side with my twitter handle on it
71
+ p.sides << Side.new do |s|
72
+ s.template_code = 'minicard_full_text_landscape'
73
+ s.type = 'details'
74
+ s.data << TextData.new do |text_data|
75
+ text_data.link_id = 'back_line_1'
76
+ text_data.text = '@alinajaf'
77
+ end
78
+ end
79
+
80
+ # add side numbers to sides
81
+ p.fill_side_nums
82
+ end
83
+ ```
84
+
85
+ You could then put these in the users cart by doing the following:
86
+
87
+ ```ruby
88
+ client = Moo::Client.new
89
+ response = client.create_pack(access_token, 'minicard', pack.to_json)
90
+ parsed_response = JSON.load(response.body)
91
+
92
+ redirect parsed_response['dropIns']['finish']
93
+ ```
94
+
95
+
96
+
@@ -0,0 +1,361 @@
1
+
2
+ <?xml version="1.0" encoding="UTF-8"?>
3
+ <Template xmlns="http://www.moo.com/xsd/template-1.0">
4
+ <Code>businesscard_bottom_image_dual_column_text_landscape</Code>
5
+ <Version>1</Version>
6
+ <Settings>
7
+ <Units type="millimetres"/>
8
+ <Origin orientation="top-left" offsetX="0" offsetY="0"/>
9
+ <PrintArea>
10
+ <Width>88</Width>
11
+ <Height>59</Height>
12
+ </PrintArea>
13
+ <BleedBox>
14
+ <Centre x="44" y="29.5"/>
15
+ <Width>88</Width>
16
+ <Height>59</Height>
17
+ <Angle>0</Angle>
18
+ </BleedBox>
19
+ <CutBox>
20
+ <Centre x="44" y="29.5"/>
21
+ <Width>84</Width>
22
+ <Height>55</Height>
23
+ <Angle>0</Angle>
24
+ </CutBox>
25
+ <SafeAreaBox>
26
+ <!-- assume safe area matches bleed for now @ 2mm -->
27
+ <Centre x="44" y="29.5"/>
28
+ <Width>80</Width>
29
+ <Height>51</Height>
30
+ <Angle>0</Angle>
31
+ </SafeAreaBox>
32
+ <RotationAngle>0</RotationAngle>
33
+ <FontSubstitutionStrategy>allLinesIfAnyNeeded</FontSubstitutionStrategy>
34
+ </Settings>
35
+ <Items>
36
+ <Box>
37
+ <LinkId>background_box</LinkId>
38
+ <ClippingBox>
39
+ <Centre x="44" y="29.5"/>
40
+ <Width>88</Width>
41
+ <Height>59</Height>
42
+ <Angle>0</Angle>
43
+ </ClippingBox>
44
+ <Colour type="CMYK">
45
+ <Cyan>0</Cyan>
46
+ <Magenta>0</Magenta>
47
+ <Yellow>0</Yellow>
48
+ <Black>0</Black>
49
+ </Colour>
50
+ <Filled>true</Filled>
51
+ <Layout>
52
+ <zIndex>0</zIndex>
53
+ </Layout>
54
+ </Box>
55
+ <Image>
56
+ <LinkId>variable_image_back</LinkId>
57
+ <ClippingBox>
58
+ <Centre x="44" y="47.5"/>
59
+ <Width>88</Width>
60
+ <Height>23</Height>
61
+ <Angle>0</Angle>
62
+ </ClippingBox>
63
+ <Constraints>
64
+ <TopEdge outside="true" betweenBleedAndCut="true" betweenCutAndSafe="true" insideSafe="true"/>
65
+ <LeftEdge outside="true" betweenBleedAndCut="true" betweenCutAndSafe="true" insideSafe="true"/>
66
+ <BottomEdge outside="true" betweenBleedAndCut="true" betweenCutAndSafe="true" insideSafe="true"/>
67
+ <RightEdge outside="true" betweenBleedAndCut="true" betweenCutAndSafe="true" insideSafe="true"/>
68
+ </Constraints>
69
+ <Layout>
70
+ <zIndex>1</zIndex>
71
+ </Layout>
72
+ </Image>
73
+
74
+ <Text>
75
+ <LinkId>back_line_1</LinkId>
76
+ <Font>
77
+ <Family>Helvetica</Family>
78
+ <Bold>false</Bold>
79
+ <Italic>false</Italic>
80
+ </Font>
81
+ <ClippingBox>
82
+ <Centre x="44" y="8.75"/>
83
+ <Width>74</Width>
84
+ <Height>5</Height>
85
+ <Angle>0</Angle>
86
+ </ClippingBox>
87
+ <PointSize>3.527777777</PointSize>
88
+ <Alignment>left</Alignment>
89
+ <Constraints fontFixed="false" colourFixed="false" pointSizeFixed="true" alignmentFixed="false"/>
90
+ <Layout>
91
+ <zIndex>2</zIndex>
92
+ </Layout>
93
+ <Colour type="RGB">
94
+ <Red>0</Red>
95
+ <Green>0</Green>
96
+ <Blue>0</Blue>
97
+ </Colour>
98
+ <Text/>
99
+ </Text>
100
+ <Text>
101
+ <LinkId>back_line_2</LinkId>
102
+ <Font>
103
+ <Family>Helvetica</Family>
104
+ <Bold>false</Bold>
105
+ <Italic>false</Italic>
106
+ </Font>
107
+ <ClippingBox>
108
+ <Centre x="24.75" y="16.125"/>
109
+ <Width>35.5</Width>
110
+ <Height>3.5</Height>
111
+ <Angle>0</Angle>
112
+ </ClippingBox>
113
+ <PointSize>2.82222222</PointSize>
114
+ <Alignment>left</Alignment>
115
+ <Constraints fontFixed="false" colourFixed="false" pointSizeFixed="true" alignmentFixed="false"/>
116
+ <Layout>
117
+ <zIndex>3</zIndex>
118
+ </Layout>
119
+ <Colour type="RGB">
120
+ <Red>0</Red>
121
+ <Green>0</Green>
122
+ <Blue>0</Blue>
123
+ </Colour>
124
+ <Text/>
125
+ </Text>
126
+ <Text>
127
+ <LinkId>back_line_3</LinkId>
128
+ <Font>
129
+ <Family>Helvetica</Family>
130
+ <Bold>false</Bold>
131
+ <Italic>false</Italic>
132
+ </Font>
133
+ <ClippingBox>
134
+ <Centre x="24.75" y="19.625"/>
135
+ <Width>35.5</Width>
136
+ <Height>3.5</Height>
137
+ <Angle>0</Angle>
138
+ </ClippingBox>
139
+ <PointSize>2.82222222</PointSize>
140
+ <Alignment>left</Alignment>
141
+ <Constraints fontFixed="false" colourFixed="false" pointSizeFixed="true" alignmentFixed="false"/>
142
+ <Layout>
143
+ <zIndex>4</zIndex>
144
+ </Layout>
145
+ <Colour type="RGB">
146
+ <Red>0</Red>
147
+ <Green>0</Green>
148
+ <Blue>0</Blue>
149
+ </Colour>
150
+ <Text/>
151
+ </Text>
152
+ <Text>
153
+ <LinkId>back_line_4</LinkId>
154
+ <Font>
155
+ <Family>Helvetica</Family>
156
+ <Bold>false</Bold>
157
+ <Italic>false</Italic>
158
+ </Font>
159
+ <ClippingBox>
160
+ <Centre x="24.75" y="23.125"/>
161
+ <Width>35.5</Width>
162
+ <Height>3.5</Height>
163
+ <Angle>0</Angle>
164
+ </ClippingBox>
165
+ <PointSize>2.82222222</PointSize>
166
+ <Alignment>left</Alignment>
167
+ <Constraints fontFixed="false" colourFixed="false" pointSizeFixed="true" alignmentFixed="false"/>
168
+ <Layout>
169
+ <zIndex>5</zIndex>
170
+ </Layout>
171
+ <Colour type="RGB">
172
+ <Red>0</Red>
173
+ <Green>0</Green>
174
+ <Blue>0</Blue>
175
+ </Colour>
176
+ <Text/>
177
+ </Text>
178
+ <Text>
179
+ <LinkId>back_line_5</LinkId>
180
+ <Font>
181
+ <Family>Helvetica</Family>
182
+ <Bold>false</Bold>
183
+ <Italic>false</Italic>
184
+ </Font>
185
+ <ClippingBox>
186
+ <Centre x="24.75" y="26.625"/>
187
+ <Width>35.5</Width>
188
+ <Height>3.5</Height>
189
+ <Angle>0</Angle>
190
+ </ClippingBox>
191
+ <PointSize>2.82222222</PointSize>
192
+ <Alignment>left</Alignment>
193
+ <Constraints fontFixed="false" colourFixed="false" pointSizeFixed="true" alignmentFixed="false"/>
194
+ <Layout>
195
+ <zIndex>6</zIndex>
196
+ </Layout>
197
+ <Colour type="RGB">
198
+ <Red>0</Red>
199
+ <Green>0</Green>
200
+ <Blue>0</Blue>
201
+ </Colour>
202
+ <Text/>
203
+ </Text>
204
+ <Text>
205
+ <LinkId>back_line_6</LinkId>
206
+ <Font>
207
+ <Family>Helvetica</Family>
208
+ <Bold>false</Bold>
209
+ <Italic>false</Italic>
210
+ </Font>
211
+ <ClippingBox>
212
+ <Centre x="24.75" y="30.125"/>
213
+ <Width>35.5</Width>
214
+ <Height>3.5</Height>
215
+ <Angle>0</Angle>
216
+ </ClippingBox>
217
+ <PointSize>2.82222222</PointSize>
218
+ <Alignment>left</Alignment>
219
+ <Constraints fontFixed="false" colourFixed="false" pointSizeFixed="true" alignmentFixed="false"/>
220
+ <Layout>
221
+ <zIndex>7</zIndex>
222
+ </Layout>
223
+ <Colour type="RGB">
224
+ <Red>0</Red>
225
+ <Green>0</Green>
226
+ <Blue>0</Blue>
227
+ </Colour>
228
+ <Text/>
229
+ </Text>
230
+ <Text>
231
+ <LinkId>back_line_7</LinkId>
232
+ <Font>
233
+ <Family>Helvetica</Family>
234
+ <Bold>false</Bold>
235
+ <Italic>false</Italic>
236
+ </Font>
237
+ <ClippingBox>
238
+ <Centre x="63.25" y="16.125"/>
239
+ <Width>35.5</Width>
240
+ <Height>3.5</Height>
241
+ <Angle>0</Angle>
242
+ </ClippingBox>
243
+ <PointSize>2.82222222</PointSize>
244
+ <Alignment>left</Alignment>
245
+ <Constraints fontFixed="false" colourFixed="false" pointSizeFixed="true" alignmentFixed="false"/>
246
+ <Layout>
247
+ <zIndex>8</zIndex>
248
+ </Layout>
249
+ <Colour type="RGB">
250
+ <Red>0</Red>
251
+ <Green>0</Green>
252
+ <Blue>0</Blue>
253
+ </Colour>
254
+ <Text/>
255
+ </Text>
256
+ <Text>
257
+ <LinkId>back_line_8</LinkId>
258
+ <Font>
259
+ <Family>Helvetica</Family>
260
+ <Bold>false</Bold>
261
+ <Italic>false</Italic>
262
+ </Font>
263
+ <ClippingBox>
264
+ <Centre x="63.25" y="19.625"/>
265
+ <Width>35.5</Width>
266
+ <Height>3.5</Height>
267
+ <Angle>0</Angle>
268
+ </ClippingBox>
269
+ <PointSize>2.82222222</PointSize>
270
+ <Alignment>left</Alignment>
271
+ <Constraints fontFixed="false" colourFixed="false" pointSizeFixed="true" alignmentFixed="false"/>
272
+ <Layout>
273
+ <zIndex>9</zIndex>
274
+ </Layout>
275
+ <Colour type="RGB">
276
+ <Red>0</Red>
277
+ <Green>0</Green>
278
+ <Blue>0</Blue>
279
+ </Colour>
280
+ <Text/>
281
+ </Text>
282
+ <Text>
283
+ <LinkId>back_line_9</LinkId>
284
+ <Font>
285
+ <Family>Helvetica</Family>
286
+ <Bold>false</Bold>
287
+ <Italic>false</Italic>
288
+ </Font>
289
+ <ClippingBox>
290
+ <Centre x="63.25" y="23.125"/>
291
+ <Width>35.5</Width>
292
+ <Height>3.5</Height>
293
+ <Angle>0</Angle>
294
+ </ClippingBox>
295
+ <PointSize>2.82222222</PointSize>
296
+ <Alignment>left</Alignment>
297
+ <Constraints fontFixed="false" colourFixed="false" pointSizeFixed="true" alignmentFixed="false"/>
298
+ <Layout>
299
+ <zIndex>10</zIndex>
300
+ </Layout>
301
+ <Colour type="RGB">
302
+ <Red>0</Red>
303
+ <Green>0</Green>
304
+ <Blue>0</Blue>
305
+ </Colour>
306
+ <Text/>
307
+ </Text>
308
+ <Text>
309
+ <LinkId>back_line_10</LinkId>
310
+ <Font>
311
+ <Family>Helvetica</Family>
312
+ <Bold>false</Bold>
313
+ <Italic>false</Italic>
314
+ </Font>
315
+ <ClippingBox>
316
+ <Centre x="63.25" y="26.625"/>
317
+ <Width>35.5</Width>
318
+ <Height>3.5</Height>
319
+ <Angle>0</Angle>
320
+ </ClippingBox>
321
+ <PointSize>2.82222222</PointSize>
322
+ <Alignment>left</Alignment>
323
+ <Constraints fontFixed="false" colourFixed="false" pointSizeFixed="true" alignmentFixed="false"/>
324
+ <Layout>
325
+ <zIndex>11</zIndex>
326
+ </Layout>
327
+ <Colour type="RGB">
328
+ <Red>0</Red>
329
+ <Green>0</Green>
330
+ <Blue>0</Blue>
331
+ </Colour>
332
+ <Text/>
333
+ </Text>
334
+ <Text>
335
+ <LinkId>back_line_11</LinkId>
336
+ <Font>
337
+ <Family>Helvetica</Family>
338
+ <Bold>false</Bold>
339
+ <Italic>false</Italic>
340
+ </Font>
341
+ <ClippingBox>
342
+ <Centre x="63.25" y="30.125"/>
343
+ <Width>35.5</Width>
344
+ <Height>3.5</Height>
345
+ <Angle>0</Angle>
346
+ </ClippingBox>
347
+ <PointSize>2.82222222</PointSize>
348
+ <Alignment>left</Alignment>
349
+ <Constraints fontFixed="false" colourFixed="false" pointSizeFixed="true" alignmentFixed="false"/>
350
+ <Layout>
351
+ <zIndex>12</zIndex>
352
+ </Layout>
353
+ <Colour type="RGB">
354
+ <Red>0</Red>
355
+ <Green>0</Green>
356
+ <Blue>0</Blue>
357
+ </Colour>
358
+ <Text/>
359
+ </Text>
360
+ </Items>
361
+ </Template>