yourub 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile +3 -4
- data/README.md +52 -40
- data/README.md~ +91 -0
- data/lib/yourub/client.rb +184 -0
- data/lib/yourub/reader.rb +19 -0
- data/lib/yourub/validator.rb +92 -0
- data/lib/yourub/version.rb +4 -1
- data/lib/yourub.rb +3 -1
- data/spec/client_spec.rb +57 -0
- data/spec/validator_spec.rb +94 -0
- data/yourub.gemspec +2 -2
- metadata +39 -21
- data/lib/yourub/search.rb +0 -178
- data/spec/search_spec.rb +0 -52
- data/yourub.sublime-workspace +0 -338
data/yourub.sublime-workspace
DELETED
@@ -1,338 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"auto_complete":
|
3
|
-
{
|
4
|
-
"selected_items":
|
5
|
-
[
|
6
|
-
[
|
7
|
-
"https",
|
8
|
-
"https"
|
9
|
-
],
|
10
|
-
[
|
11
|
-
"be",
|
12
|
-
"be_true"
|
13
|
-
],
|
14
|
-
[
|
15
|
-
"is",
|
16
|
-
"is_alive"
|
17
|
-
],
|
18
|
-
[
|
19
|
-
"ra",
|
20
|
-
"raise_error"
|
21
|
-
],
|
22
|
-
[
|
23
|
-
"res",
|
24
|
-
"rescue"
|
25
|
-
],
|
26
|
-
[
|
27
|
-
"Ar",
|
28
|
-
"ArgumentError"
|
29
|
-
],
|
30
|
-
[
|
31
|
-
"sel",
|
32
|
-
"self"
|
33
|
-
],
|
34
|
-
[
|
35
|
-
"N",
|
36
|
-
"NATIONS"
|
37
|
-
]
|
38
|
-
]
|
39
|
-
},
|
40
|
-
"buffers":
|
41
|
-
[
|
42
|
-
{
|
43
|
-
"contents": "module Yourub\n class Page\n include Logging\n\n attr_accessor :url\n\n def initialize(nation = \"US\", category = \"Sports\", type = \"most_recent\")\n @nation = nation\n @category = category\n @type = type\n @api_url = \"https://gdata.youtube.com/feeds/api/standardfeeds/\"\n @json = \"?v=2&alt=json&prettyprint=true\"\n @required_fields = \"(title,media:group(media:player(@url)))\"\n @url = set_url\n end\n\n NATIONS = [\n 'AR','AU','AT','BE','BR','CA','CL','CO','CZ','EG','FR','DE','GB','HK',\n 'HU','IN','IE','IL','IT','JP','JO','MY','MX','MA','NL','NZ','PE','PH',\n 'PL','RU','SA','SG','ZA','KR','ES','SE','CH','TW','AE','US']\n\n CATEGORIES = [\n 'Comedy', 'People', 'Entertainment', 'Music', 'Howto',\n 'Sports', 'Autos', 'Education', 'Film', 'News', 'Animals',\n 'Tech', 'Travel','Games', 'Shortmov']\n\n TYPES = [ \n 'top_rated', 'top_favorites', 'most_viewed', 'most_popular',\n 'most_recent', 'most_discussed', 'most_linked', 'most_responded',\n 'recently_featured', 'watch_on_mobile'] \n\n def valid?\n raise ArgumentError.new('params not available') unless(\n NATIONS.include?(@nation) && \n CATEGORIES.include?(@category) && \n TYPES.include?(@type)\n )\n true\n end\n\n def is_alive?\n begin\n Net::HTTP.start(@url.host, @url.port,\n :use_ssl => @url.scheme == 'https') do |https|\n request = Net::HTTP::Get.new @url\n response = https.request request\n if response.code == \"200\"\n return true\n else\n logger.error \"page #{@url} return code #{res.code}\"\n return false\n end\n end\n rescue StandardError => e\n return false\n logger.error \"Error #{e} trying to connect to the given url #{@url}\" \n end\n end\n\n def set_url\n url = \"#{@api_url}#{@nation}/#{@type}_#{@category}#{@json}#{@required_fields}\"\n @url = URI.parse(url)\n return @url if (valid? && is_alive?)\n\n # begin\n # valid?\n # is_alive?\n # puts @url\n # return @url\n # rescue ArgumentError => e\n # return false\n # logger.error \"#{e}\"\n # end\n end\n\n # TODO\n\n # Va capito bene cosa e' un modulo e come si usa in una classe composta da diversi files\n # http://stackoverflow.com/questions/151505/difference-between-a-class-and-a-module\n\n # Gemme, due modi per organizzarle, il primo\n # nel file lib/gemma.rb vengono inclusi tutti i sotto files.\n # Ogninu di questi comincica con \n # module NomeGemma e puo' includere classi o vattelapesca\n # un esempio e' tire\n # https://github.com/karmi/tire/blob/master/lib/tire.rb\n # e rake\n # https://github.com/jimweirich/rake/blob/master/lib/rake.rb\n\n # oppure nel file lib/gemma.rb\n # come in thor\n # https://github.com/erikhuda/thor/blob/master/lib/thor.rb\n # crei una classe col nome della gemma\n\n # esempio piu' chiaro e' faraday\n # https://github.com/lostisland/faraday/blob/master/lib/faraday.rb'\n \n # integrare un logger\n # tire ha un logger https://github.com/karmi/tire/blob/master/lib/tire/logger.rb\n # aggiungere diversi tipi di exception, far si che queste possano dialogre con la classe Logger\n # unire i due metodi di sopra\n # fare un test ciclando due url\n # aggiungere le Exception, facendo si che il ciclo passi alla seconda ulr se la prima non passa\n\n # pushare su github\n\n\n end\nend",
|
44
|
-
"file": "lib/yourub/page.rb",
|
45
|
-
"file_size": 3554,
|
46
|
-
"file_write_time": 1378764534000000,
|
47
|
-
"settings":
|
48
|
-
{
|
49
|
-
"buffer_size": 3553,
|
50
|
-
"line_ending": "Unix"
|
51
|
-
}
|
52
|
-
}
|
53
|
-
],
|
54
|
-
"build_system": "Packages/Ruby/Ruby.sublime-build",
|
55
|
-
"command_palette":
|
56
|
-
{
|
57
|
-
"height": 364.0,
|
58
|
-
"selected_items":
|
59
|
-
[
|
60
|
-
[
|
61
|
-
"Pac",
|
62
|
-
"Package Control: Install Package"
|
63
|
-
],
|
64
|
-
[
|
65
|
-
"pack",
|
66
|
-
"Package Control: Install Package"
|
67
|
-
]
|
68
|
-
],
|
69
|
-
"width": 593.0
|
70
|
-
},
|
71
|
-
"console":
|
72
|
-
{
|
73
|
-
"height": 208.0
|
74
|
-
},
|
75
|
-
"distraction_free":
|
76
|
-
{
|
77
|
-
"menu_visible": true,
|
78
|
-
"show_minimap": false,
|
79
|
-
"show_open_files": false,
|
80
|
-
"show_tabs": false,
|
81
|
-
"side_bar_visible": false,
|
82
|
-
"status_bar_visible": false
|
83
|
-
},
|
84
|
-
"file_history":
|
85
|
-
[
|
86
|
-
"/home/da/iocose/Gemfile",
|
87
|
-
"/home/da/iocose/app/assets/stylesheets/application.css.scss",
|
88
|
-
"/home/da/iocose/config/environments/development.rb",
|
89
|
-
"/home/da/iocose/config/routes.rb",
|
90
|
-
"/home/da/iocose/app/views/layouts/_admin_navigation.html.haml",
|
91
|
-
"/home/da/iocose/app/views/layouts/admin.html.haml",
|
92
|
-
"/home/da/iocose/config/database.yml",
|
93
|
-
"/home/da/iocose/config/application.yml",
|
94
|
-
"/home/da/iocose/config/application.rb",
|
95
|
-
"/home/da/iocose/db/schema.rb",
|
96
|
-
"/home/da/codebeispiel/WeightedQuickUnionUF.rb",
|
97
|
-
"/home/da/codebeispiel/README.txt",
|
98
|
-
"/home/da/codebeispiel/mediumUF.txt",
|
99
|
-
"/home/da/yourub/lib/yourub.rb",
|
100
|
-
"/home/da/yourub/lib/yourub/logging.rb",
|
101
|
-
"/home/da/yourub/lib/yourub/page.rb",
|
102
|
-
"/home/da/yourub/lib/yourub/parser.rb",
|
103
|
-
"/home/da/yourub/spec/page_spec.rb",
|
104
|
-
"/home/da/yourub/spec/yourub_spec.rb",
|
105
|
-
"/home/da/public_html/cake/app/webroot/websites/aca/theories.php",
|
106
|
-
"/home/da/ruby/poignant/module_ex/logging.rb",
|
107
|
-
"/home/da/ruby/poignant/module_ex/use_logger.rb",
|
108
|
-
"/home/da/yourub/lib/yourub/logger.rb",
|
109
|
-
"/home/da/ruby/module_use_me.rb",
|
110
|
-
"/home/da/ruby/modulo_serre_prati.rb",
|
111
|
-
"/home/da/ruby/watchful_saint_agnes.rb",
|
112
|
-
"/home/da/yourub/lib/yourub/connect.rb",
|
113
|
-
"/home/da/yourub/lib/yourub/watchful_saint_agnes.rb",
|
114
|
-
"/home/da/ruby/fibonacci.rb",
|
115
|
-
"/home/da/ruby/test.rb",
|
116
|
-
"/home/da/yourub/lib/yourub/old.rb",
|
117
|
-
"/home/da/Desktop/todo",
|
118
|
-
"/home/da/.config/sublime-text-2/Packages/Default/Preferences.sublime-settings",
|
119
|
-
"/home/da/public_html/unique/app/assets/javascripts/application.js",
|
120
|
-
"/home/da/public_html/unique/app/views/pages/_archiv.html.erb",
|
121
|
-
"/home/da/public_html/unique/app/views/shared/_thumbs.html.erb",
|
122
|
-
"/home/da/public_html/unique/app/assets/javascripts/unique.js",
|
123
|
-
"/home/da/public_html/unique/app/views/pages/_weare.html.erb",
|
124
|
-
"/home/da/public_html/unique/app/views/uber-uns.html",
|
125
|
-
"/home/da/yourub/spec/parser_spec.rb",
|
126
|
-
"/home/da/yourub/spec/connect_spec.rb",
|
127
|
-
"/home/da/yourub/features/parser.feature",
|
128
|
-
"/home/da/yourub/lib/yourub/cli.rb",
|
129
|
-
"/home/da/yourub/bin/yourub",
|
130
|
-
"/home/da/yourub/yourub.gemspec",
|
131
|
-
"/home/da/.config/sublime-text-2/Packages/Default/Default (Linux).sublime-keymap",
|
132
|
-
"/home/da/.config/sublime-text-2/Packages/User/Preferences.sublime-settings",
|
133
|
-
"/home/da/yourub/features/support/setup.rb",
|
134
|
-
"/home/da/yourub/Gemfile",
|
135
|
-
"/media/kurt_ext2/backup/da/ruby/code_basic/variables.rb",
|
136
|
-
"/media/kurt_ext2/backup/da/ruby/everyday_scripting/code/affinity-trip/affinity-trip.rb",
|
137
|
-
"/media/kurt_ext2/backup/da/ruby/google.rb",
|
138
|
-
"/media/kurt_ext2/backup/da/ruby/code_basic/array.rb",
|
139
|
-
"/home/da/public_html/unique/app/assets/stylesheets/user/base.css.scss",
|
140
|
-
"/home/da/public_html/cake/app/views/pages/home_random.ctp",
|
141
|
-
"/home/da/public_html/cake/app/config/routes.php",
|
142
|
-
"/home/da/public_html/unique/config/application.rb",
|
143
|
-
"/home/da/public_html/unique/config/environments/production.rb",
|
144
|
-
"/home/da/public_html/unique/app/views/pages/show.html.erb",
|
145
|
-
"/home/da/public_html/unique/app/views/pages/_googlemap.html.erb",
|
146
|
-
"/home/da/public_html/unique/app/views/pages/_kontakt.html.erb",
|
147
|
-
"/home/da/public_html/unique/app/views/pages/_kataloge.html.erb",
|
148
|
-
"/home/da/public_html/unique/app/assets/stylesheets/uberuns.css",
|
149
|
-
"/home/da/public_html/unique/config/database.yml",
|
150
|
-
"/home/da/public_html/unique/db/seeds.rb",
|
151
|
-
"/home/da/public_html/unique/config/environment.rb",
|
152
|
-
"/home/da/public_html/unique/config/routes.rb",
|
153
|
-
"/home/da/public_html/unique/config/boot.rb",
|
154
|
-
"/home/da/public_html/unique/app/controllers/application_controller.rb",
|
155
|
-
"/home/da/public_html/unique/config.ru",
|
156
|
-
"/home/da/public_html/unique/app/models/item.rb",
|
157
|
-
"/home/da/public_html/unique/app/models/image.rb",
|
158
|
-
"/home/da/public_html/unique/app/models/gallery.rb"
|
159
|
-
],
|
160
|
-
"find":
|
161
|
-
{
|
162
|
-
"height": 34.0
|
163
|
-
},
|
164
|
-
"find_in_files":
|
165
|
-
{
|
166
|
-
"height": 0.0,
|
167
|
-
"where_history":
|
168
|
-
[
|
169
|
-
"/home/da/Downloads/tire-master",
|
170
|
-
"/home/da/public_html/unique"
|
171
|
-
]
|
172
|
-
},
|
173
|
-
"find_state":
|
174
|
-
{
|
175
|
-
"case_sensitive": false,
|
176
|
-
"find_history":
|
177
|
-
[
|
178
|
-
"betterman94",
|
179
|
-
"dapx",
|
180
|
-
"kundali",
|
181
|
-
"pizza hut is",
|
182
|
-
"to communicate with us",
|
183
|
-
"Playsta",
|
184
|
-
"Secretly",
|
185
|
-
"Playstation hac",
|
186
|
-
"to control",
|
187
|
-
"ericsson is ",
|
188
|
-
"<sup",
|
189
|
-
"<sup>",
|
190
|
-
"<sup></sup>",
|
191
|
-
"<sup>",
|
192
|
-
"<sup></sup>",
|
193
|
-
"<sup>",
|
194
|
-
"Jinn",
|
195
|
-
"120",
|
196
|
-
"Jinn",
|
197
|
-
"($",
|
198
|
-
"</iframe>\"",
|
199
|
-
"\\\"></",
|
200
|
-
"\"audio\" =>",
|
201
|
-
"\"audio\" => ",
|
202
|
-
"Logger",
|
203
|
-
"@format",
|
204
|
-
"@type",
|
205
|
-
"User",
|
206
|
-
"end",
|
207
|
-
"@most_recent",
|
208
|
-
"ET",
|
209
|
-
"select",
|
210
|
-
"ctrl+alt",
|
211
|
-
"foodie",
|
212
|
-
"background",
|
213
|
-
"cboxLoadedContent",
|
214
|
-
"inline_content",
|
215
|
-
"order",
|
216
|
-
"by_join_position"
|
217
|
-
],
|
218
|
-
"highlight": true,
|
219
|
-
"in_selection": false,
|
220
|
-
"preserve_case": false,
|
221
|
-
"regex": false,
|
222
|
-
"replace_history":
|
223
|
-
[
|
224
|
-
"1994immortality",
|
225
|
-
"postgres",
|
226
|
-
"",
|
227
|
-
"\"audio\" => \"<iframe width=\\\"100%\\\" height=\\\"166\\\" scrolling=\\\"no\\\" frameborder=\\\"no\\\" src=\\\"https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F104440492\\\"></iframe>\"",
|
228
|
-
"yourub"
|
229
|
-
],
|
230
|
-
"reverse": false,
|
231
|
-
"show_context": true,
|
232
|
-
"use_buffer2": true,
|
233
|
-
"whole_word": false,
|
234
|
-
"wrap": true
|
235
|
-
},
|
236
|
-
"groups":
|
237
|
-
[
|
238
|
-
{
|
239
|
-
"sheets":
|
240
|
-
[
|
241
|
-
{
|
242
|
-
"buffer": 0,
|
243
|
-
"file": "lib/yourub/page.rb",
|
244
|
-
"settings":
|
245
|
-
{
|
246
|
-
"buffer_size": 3553,
|
247
|
-
"regions":
|
248
|
-
{
|
249
|
-
},
|
250
|
-
"selection":
|
251
|
-
[
|
252
|
-
[
|
253
|
-
725,
|
254
|
-
512
|
255
|
-
]
|
256
|
-
],
|
257
|
-
"settings":
|
258
|
-
{
|
259
|
-
"syntax": "Packages/Ruby/Ruby.tmLanguage",
|
260
|
-
"tab_size": 2,
|
261
|
-
"translate_tabs_to_spaces": true
|
262
|
-
},
|
263
|
-
"translation.x": 0.0,
|
264
|
-
"translation.y": 675.0,
|
265
|
-
"zoom_level": 1.0
|
266
|
-
},
|
267
|
-
"type": "text"
|
268
|
-
}
|
269
|
-
]
|
270
|
-
}
|
271
|
-
],
|
272
|
-
"incremental_find":
|
273
|
-
{
|
274
|
-
"height": 0.0
|
275
|
-
},
|
276
|
-
"input":
|
277
|
-
{
|
278
|
-
"height": 31.0
|
279
|
-
},
|
280
|
-
"layout":
|
281
|
-
{
|
282
|
-
"cells":
|
283
|
-
[
|
284
|
-
[
|
285
|
-
0,
|
286
|
-
0,
|
287
|
-
1,
|
288
|
-
1
|
289
|
-
]
|
290
|
-
],
|
291
|
-
"cols":
|
292
|
-
[
|
293
|
-
0.0,
|
294
|
-
1.0
|
295
|
-
],
|
296
|
-
"rows":
|
297
|
-
[
|
298
|
-
0.0,
|
299
|
-
1.0
|
300
|
-
]
|
301
|
-
},
|
302
|
-
"menu_visible": true,
|
303
|
-
"output.exec":
|
304
|
-
{
|
305
|
-
"height": 228.0
|
306
|
-
},
|
307
|
-
"replace":
|
308
|
-
{
|
309
|
-
"height": 62.0
|
310
|
-
},
|
311
|
-
"save_all_on_build": true,
|
312
|
-
"select_file":
|
313
|
-
{
|
314
|
-
"height": 0.0,
|
315
|
-
"selected_items":
|
316
|
-
[
|
317
|
-
],
|
318
|
-
"width": 0.0
|
319
|
-
},
|
320
|
-
"select_project":
|
321
|
-
{
|
322
|
-
"height": 500.0,
|
323
|
-
"selected_items":
|
324
|
-
[
|
325
|
-
[
|
326
|
-
"",
|
327
|
-
"/home/da/yourub/yourub.sublime-project"
|
328
|
-
]
|
329
|
-
],
|
330
|
-
"width": 380.0
|
331
|
-
},
|
332
|
-
"show_minimap": true,
|
333
|
-
"show_open_files": false,
|
334
|
-
"show_tabs": true,
|
335
|
-
"side_bar_visible": true,
|
336
|
-
"side_bar_width": 249.0,
|
337
|
-
"status_bar_visible": true
|
338
|
-
}
|