feed_into 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,944 @@
1
+ <a href="#table-of-contents">
2
+ <img src="https://raw.githubusercontent.com//a6b8/a6b8/main/assets/headlines/custom/feed-into-for-ruby.svg" height="45px" name="# Feed Into for Ruby" alt="Feed Into for Ruby">
3
+ </a>
4
+
5
+ Merge multiple different data streams to a custom structure based on categories. Also easy to expand by a custom module system.
6
+ <br>
7
+ <br>
8
+ <br>
9
+ <a href="#table-of-contents">
10
+ <img src="https://raw.githubusercontent.com/a6b8/a6b8/main/assets/headlines/default/examples.svg" height="45px" name="examples" alt="Examples">
11
+ </a>
12
+
13
+ **Merge multiple Streams**
14
+ ```ruby
15
+ require 'feed_into'
16
+
17
+ channels_settings = {
18
+ name: :blockchain,
19
+ sym: :web,
20
+ options: {},
21
+ regexs: [ [ /https:\/\/your*website.com/ ] ],
22
+ download: :general,
23
+ mining: :rss_one,
24
+ pre: [],
25
+ transform: nil,
26
+ post: [ :pre_titles ]
27
+ }
28
+
29
+ feeds = FeedInto::Group.new(
30
+ single: { channels: [ channels_settings ] }
31
+ )
32
+
33
+ urls = [
34
+ 'https://your*website.com/1.xml',
35
+ 'https://your*website.com/2.xml'
36
+ ]
37
+
38
+ feeds
39
+ .analyse( items: urls )
40
+ .merge
41
+ .to_rss( key: :unknown )
42
+ ```
43
+ <br>
44
+
45
+ **Create .rss Categories from multiple Streams**
46
+ ```ruby
47
+ require 'feed_into'
48
+
49
+ channels_settings = {
50
+ name: :blockchain,
51
+ sym: :web,
52
+ options: {},
53
+ regexs: [ [ /https:\/\/your*website.com/ ] ],
54
+ download: :general,
55
+ mining: :rss_one,
56
+ pre: [],
57
+ transform: nil,
58
+ post: [ :pre_titles ]
59
+ }
60
+
61
+ feeds = FeedInto::Group.new(
62
+ single: { channels: [ channels_settings ] }
63
+ )
64
+
65
+ item = [
66
+ {
67
+ name: 'Channel 1',
68
+ url: 'https://your*website.com/1.xml',
69
+ category: :nft
70
+ },
71
+ {
72
+ name: 'Channel 2',
73
+ url: 'https://your*website.com/2.xml',
74
+ category: :crypto
75
+ }
76
+ ]
77
+
78
+ feeds
79
+ .analyse( items: urls )
80
+ .merge
81
+ .to_rss_all
82
+ ```
83
+ <br>
84
+ <br>
85
+ <a href="#headline">
86
+ <img src="https://raw.githubusercontent.com/a6b8/a6b8/main/assets/headlines/default/table-of-contents.svg" height="45px" name="table-of-contents" alt="Table of Contents">
87
+ </a>
88
+ <br>
89
+
90
+ 1. [Examples](#examples)<br>
91
+ 2. [Quickstart](#quickstart)<br>
92
+ 3. [Setup](#setup)<br>
93
+ 4. [Input Types](#input-types)<br>
94
+ - [Single](#FeedIntosingle)<br>
95
+ [String URL](#a-1-string-url)<br>
96
+ [Hash Structure](#a2-hash-structure-cmd)<br>
97
+ - Group<br>
98
+ [Array of Strings](#b1-array-of-string)<br>
99
+ [Array of Hashs](#b2-array-of-hash-cmds)<br>
100
+ 5. [Methods](#methods)<br>
101
+ - [Single](#FeedIntosingle-1)<br>
102
+ [.analyse()](#analyse-item-)<br>
103
+ - [Group](#FeedIntogroup)<br>
104
+ [.analyse()](#analyse-items--silent-false-)<br>
105
+ [.merge](#merge)<br>
106
+ [.to_h()](#to_h-type-)<br>
107
+ [.to_rss()](#to_rss-key-silent-)<br>
108
+ [.to_rss_all](#to_rss_all-silent-)<br>
109
+ [.status](#status)<br>
110
+ 6. [Structure](#structure)<br>
111
+ 7. [Options](#options)<br>
112
+ - [Single](#FeedIntosingle-2)<br>
113
+ - [Group](#FeedIntogroup-1)<br>
114
+ 8. [Channels](#channels)<br>
115
+ - [Settings Structure](#settings-structure)
116
+ - [Standard Components](#standard-components)<br>
117
+ - [Custom Components](#custom-components)<br>
118
+ 9. [Contributing](#contributing)
119
+ 10. [Limitations](#limitations)
120
+ 11. [Credits](#credits)<br>
121
+ 12. [License](#license)<br>
122
+ 13. [Code of Conduct](#code-of-conduct)<br>
123
+ 14. [Support my Work](#support-my-work)<br>
124
+
125
+ <br>
126
+ <br>
127
+ <a href="#table-of-contents">
128
+ <img src="https://raw.githubusercontent.com/a6b8/a6b8/main/assets/headlines/default/quickstart.svg" height="45px" name="quickstart" alt="Quickstart">
129
+ </a>
130
+
131
+ ```ruby
132
+ require 'feed_into'
133
+
134
+ channels = [
135
+ {
136
+ name: :blockchain,
137
+ sym: :web,
138
+ options: {},
139
+ regexs: [ [ /https:\/\/your*website.com/ ] ],
140
+ download: :general,
141
+ mining: :rss_one,
142
+ pre: [],
143
+ transform: nil,
144
+ post: [ :pre_titles ]
145
+ }
146
+ ]
147
+
148
+ feed = FeedInto::Group.new(
149
+ single: { channels: channels }
150
+ )
151
+
152
+ urls = [ 'https://your*website.com/1.xml' ]
153
+ feed
154
+ .analyse( items: urls )
155
+ .status
156
+ ```
157
+ <br>
158
+ <br>
159
+ <a href="#table-of-contents">
160
+ <img src="https://raw.githubusercontent.com/a6b8/a6b8/main/assets/headlines/default/setup.svg" height="45px" name="setup" alt="Setup">
161
+ </a>
162
+
163
+ Add this line to your application's Gemfile:
164
+
165
+ ```ruby
166
+ gem 'feed_into'
167
+ ```
168
+
169
+ And then execute:
170
+
171
+ $ bundle install
172
+
173
+ Or install it yourself as:
174
+
175
+ $ gem install feed_into
176
+
177
+
178
+ On Rubygems:
179
+ - Gem: https://rubygems.org/gems/feed_into
180
+ - Profile: https://rubygems.org/profiles/a6b8
181
+
182
+ <br>
183
+ <br>
184
+ <a href="#table-of-contents">
185
+ <img src="https://raw.githubusercontent.com/a6b8/a6b8/main/assets/headlines/default/input-types.svg" height="45px" name="input-types" alt="Input Types">
186
+ </a>
187
+
188
+ A valid url string is required. If you use ```::Group``` you need to wrap your strings in an array. Consider to use a ```Hash Structure``` for best results.
189
+
190
+ ## FeedInto::Single
191
+
192
+ 2 types of inputs are allowed ```String``` and ```Hash```.
193
+ - ```String``` must be a valid url.
194
+ - ```Hash``` needs minimum an ```url:``` key with a valid url string. ```name:``` and ```category``` are optional.
195
+
196
+ <br name="input-a-1">
197
+
198
+ ### A. 1. ```String URL```
199
+
200
+ **Input**
201
+ ```ruby
202
+ cmd = 'https://your*website.com/1.xml'
203
+ feed.analyse( item: cmd )
204
+ ```
205
+ Url must be from type ```String``` and a ```valid url```.
206
+
207
+ **Internal Transformation to:**
208
+ ```ruby
209
+ {
210
+ name: 'Unknown',
211
+ url: 'https://your*website.com/1.xml',
212
+ category: :unknown
213
+ }
214
+ ```
215
+
216
+ | **Name** | **Default** | **Description** |
217
+ |------:|:------|:------|
218
+ | **name:** | 'Unknown' | Set Name of Feed. If empty or not delivered the Name will set to 'Unknown' |
219
+ | **category:** | :unknown | Set Category of Feed. If empty or not delivered the Category will set to :unknown |
220
+
221
+ The keys ```name:``` and ```category``` are required internally. If not set by the user both will be added with the default values: "Unknown" and :unknown. See [A.2.](#input-a-2) for more Informations
222
+
223
+ <br name="input-a-2">
224
+
225
+ ### A.2. ```Hash Structure``` (cmd)
226
+
227
+ **Struct**
228
+ ```ruby
229
+ {
230
+ name: String,
231
+ url: String,
232
+ category: Symbol
233
+ }
234
+ ```
235
+
236
+ **Example**
237
+ ```ruby
238
+ cmd = {
239
+ name: 'Channel 1',
240
+ url: 'https://your*website.com/1.xml',
241
+ category: :nft
242
+ }
243
+
244
+ feed.analyse( item: cmd )
245
+ ```
246
+
247
+ **Validation**
248
+ | **Name** | **Type / Regex** | **Required** | **Default** | **Description** |
249
+ |------:|:------|:------|:------|:------|
250
+ | **name:** | ```String``` | No | "Unknown" | Set Name of Feed. If empty or not delivered the Name will set to 'Channel 1' |
251
+ | **url** | ```String``` and ```valid url``` | Yes | | Set url of Feed. |
252
+ | **category** | ```Symbol``` | No | :unknown | Set Category of Feed. If empty or not delivered the Category will set to 'Channel 1' |
253
+ <br>
254
+
255
+ ## FeedInto::Group
256
+
257
+ 2 types of Arrays are allowed: ```Array of String``` or ```Array of Hash```.
258
+ - ```Array of String``` must be a valid urls strings.
259
+ - ```Array of Hash``` needs minimum an ```url:``` key with a valid url string per Hash.
260
+
261
+ <br name="input-b-1">
262
+
263
+ ### B.1. ```Array of String```
264
+
265
+ **Example**
266
+ ```ruby
267
+ cmds = [
268
+ 'https://your*website.com/1.xml',
269
+ 'https://your*website.com/2.xml'
270
+ ]
271
+
272
+ feeds.analyse( items: cmds )
273
+ ```
274
+ Validation Info see [A.1.](#input-a-1)
275
+
276
+ <br name="input-b-2">
277
+
278
+ ### B.2. ```Array of Hash``` (cmds)
279
+
280
+ **Example**
281
+ ```ruby
282
+ cmds = [
283
+ {
284
+ name: 'Channel 1',
285
+ url: 'https://your*website.com/1.xml',
286
+ category: :nft
287
+ },
288
+ {
289
+ name: 'Channel 2',
290
+ url: 'https://your*website.com/2.xml',
291
+ category: :crypto
292
+ }
293
+ ]
294
+
295
+ feeds.analyse( items: cmds )
296
+ ```
297
+ Validation Info see [A.2.](#input-a-2)
298
+
299
+ <br>
300
+
301
+ <a href="#table-of-contents">
302
+ <img src="https://raw.githubusercontent.com/a6b8/a6b8/main/assets/headlines/default/methods.svg" height="45px" name="methods" alt="Methods">
303
+ </a>
304
+
305
+ The methods are split in 2 classes "Single" and "Group". Single process only one url and inherit from Single and have all methods for bulk/group processing. For more details see [Structure](#structure).
306
+
307
+ ## FeedInto::Single
308
+ ### .new( modules: , options: )
309
+ Create a new Single Object to interact with.
310
+ ```ruby
311
+ require 'feed_into'
312
+
313
+ feed = FeedInto::Single.new(
314
+ modules: './a/b/c/',
315
+ options: {}
316
+ )
317
+ ```
318
+
319
+
320
+ **Input**
321
+ | **Name** | **Type** | **Required** | **Default** | **Example** | **Description** |
322
+ |------:|:------|:------|:------|:------|:------|
323
+ | **module folder** | ```String``` | No | ```nil``` | ```modules: './a/b/c/'``` | Set Module Folder path. |
324
+ | **options** | ```Hash``` | No | ```{}``` | see [#options](#options) | Set options |
325
+
326
+ <br>
327
+
328
+ ### .analyse( item: )
329
+ Start process of downloading, mining, modification and transforming based on your module setups.
330
+ ```ruby
331
+ require 'feed_into'
332
+
333
+ feed = FeedInto::Single.new(
334
+ modules: './a/b/c/',
335
+ options: {}
336
+ )
337
+
338
+ cmd = {
339
+ name: 'Channel 1',
340
+ url: 'https://your*website.com/1.xml',
341
+ category: :crypto
342
+ }
343
+
344
+ feed.analyse( item: cmd )
345
+
346
+ # feed.analyse( item: 'https://your*website.com/1.xml' )
347
+ ```
348
+
349
+
350
+ **Input**
351
+ | **Name** | **Type** | **Required** | **Example** | **Description** |
352
+ |------:|:------|:------|:------|:------|
353
+ | **item** | ```String``` or ```Hash Structure``` (see [Input A.2.](#input-a-2)) | Yes | item: 'https://your*website.com/1.xml' | Insert Url by String or Hash Structure |
354
+ <br>
355
+
356
+ ## FeedInto::Group
357
+ ### .new( modules:, group:, single: )
358
+ Create a new Group Object to interact with.
359
+ ```ruby
360
+ require 'feed_into'
361
+
362
+ feed = FeedInto::Group.new(
363
+ modules: './a/b/c/',
364
+ group: {},
365
+ single: {}
366
+ )
367
+ ```
368
+
369
+
370
+ **Input**
371
+ | **Name** | **Type** | **Required** | **Default** | **Example** | **Description** |
372
+ |------:|:------|:------|:------|:------|:------|
373
+ | **module folder** | ```String``` | No | ```nil``` | ```modules: './a/b/c/'``` | Set Module Folder path. |
374
+ | **group** | ```Hash``` | No | ```{}``` | see [Options](#options) | Set group options |
375
+ | **single** | ```Hash``` | No | ```{}``` | see [Options](#options) | Set group options |
376
+
377
+ **Return**<br>
378
+ Hash
379
+ <br>
380
+
381
+ ### .analyse( items: [], silent: false )
382
+ Start process of bulk execution.
383
+ ```ruby
384
+ require 'feed_into'
385
+
386
+ feed = FeedInto::Group.new(
387
+ modules: './a/b/c/',
388
+ group: {},
389
+ single: {}
390
+ )
391
+
392
+ cmds = [
393
+ {
394
+ name: 'Channel 1',
395
+ url: 'https://your*website.com/1.xml',
396
+ category: :nft
397
+ },
398
+ {
399
+ name: 'Channel 2',
400
+ url: 'https://your*website.com/2.xml',
401
+ category: :crypto
402
+ }
403
+ ]
404
+
405
+ feed.analyse( items: cmds )
406
+ ```
407
+
408
+
409
+ **Input**
410
+ | **Name** | **Type** | **Required** | **Default** | **Example** | **Description** |
411
+ |------:|:------|:------|:------|:------|:------|
412
+ | **items** | ```Array of String``` or ```Array of Hash``` | Yes | | See [Input B.1.](#input-b-1) and [B.2.](#input-b-1) for examples and more details. | Set Inputs URLs |
413
+ | **silent** | ```boolean``` | No | ```false``` | silent: false | Print status messages |
414
+
415
+ **Return**<br>
416
+ Self
417
+
418
+ > To return result use ```.to_h```
419
+
420
+ <br>
421
+
422
+ ### .merge
423
+ Re-arrange items by category and simplify data for rss output.
424
+
425
+ ```ruby
426
+ require 'feed_into'
427
+
428
+ feed = FeedInto::Group.new(
429
+ modules: './a/b/c/',
430
+ group: {},
431
+ single: {}
432
+ )
433
+
434
+ cmds = [
435
+ {
436
+ name: 'Channel 1',
437
+ url: 'https://your*website.com/1.xml',
438
+ category: :nft
439
+ },
440
+ {
441
+ name: 'Channel 2',
442
+ url: 'https://your*website.com/2.xml',
443
+ category: :crypto
444
+ }
445
+ ]
446
+
447
+ feed
448
+ .analyse( items: cmds )
449
+ .merge
450
+ ```
451
+
452
+ **Return**<br>
453
+ Self
454
+
455
+ > To return result use ```.to_h```
456
+
457
+ <br>
458
+
459
+ ### .to_h( type: )
460
+ Output data to string.
461
+ ```ruby
462
+ require 'feed_into'
463
+
464
+ feed = FeedInto::Group.new(
465
+ modules: './a/b/c/',
466
+ group: {},
467
+ single: {}
468
+ )
469
+
470
+ cmds = [
471
+ {
472
+ name: 'Channel 1',
473
+ url: 'https://your*website.com/1.xml',
474
+ category: :nft
475
+ },
476
+ {
477
+ name: 'Channel 2',
478
+ url: 'https://your*website.com/2.xml',
479
+ category: :crypto
480
+ }
481
+ ]
482
+
483
+ feed
484
+ .analyse( items: cmds )
485
+ .merge
486
+ .to_h( type: :analyse )
487
+ ```
488
+
489
+
490
+ **Input**
491
+ | **Name** | **Type** | **Required** | **Default** | **Example** | **Description** |
492
+ |------:|:------|:------|:------|:------|:------|
493
+ | **type** | ```Symbol``` | No | ```nil``` | ```:analyse``` or ```:merge``` | Define explizit which hash should be returned. If not set .to_h will return ```:merge``` if not nil otherwise ```:analyse``` |
494
+
495
+ **Return**<br>
496
+ Hash
497
+ <br>
498
+
499
+ ### .to_rss( key:, silent: )
500
+ Output a ```.merge()``` category to a valid rss feed.
501
+
502
+ ```ruby
503
+ require 'feed_into'
504
+
505
+ feed = FeedInto::Group.new(
506
+ modules: './a/b/c/',
507
+ group: {},
508
+ single: {}
509
+ )
510
+
511
+ cmds = [
512
+ {
513
+ name: 'Channel 1',
514
+ url: 'https://your*website.com/1.xml',
515
+ category: :nft
516
+ },
517
+ {
518
+ name: 'Channel 2',
519
+ url: 'https://your*website.com/2.xml',
520
+ category: :crypto
521
+ }
522
+ ]
523
+
524
+ feed
525
+ .analyse( items: cmds )
526
+ .merge
527
+ .to_rss( key: :analyse )
528
+ ```
529
+
530
+
531
+ **Input**
532
+ | **Name** | **Type** | **Required** | **Default** | **Example** | **Description** |
533
+ |------:|:------|:------|:------|:------|:------|
534
+ | **key** | ```Symbol``` | Yes | ```nil``` | :nft | Only a single category will be transformed to rss. Define category here. |
535
+ | **silent** | ```Boolean``` | No | ```false``` | | Print status messages |
536
+
537
+ **Return**<br>
538
+ Hash
539
+ <br>
540
+
541
+ ### .to_rss_all( silent: )
542
+ Output ```.merge()``` categories to a valid rss feeds.
543
+ ```ruby
544
+ require 'feed_into'
545
+
546
+ feed = FeedInto::Group.new(
547
+ modules: './a/b/c/',
548
+ group: {},
549
+ single: {}
550
+ )
551
+
552
+ cmds = [
553
+ {
554
+ name: 'Channel 1',
555
+ url: 'https://your*website.com/1.xml',
556
+ category: :nft
557
+ },
558
+ {
559
+ name: 'Channel 2',
560
+ url: 'https://your*website.com/2.xml',
561
+ category: :crypto
562
+ }
563
+ ]
564
+
565
+ feed
566
+ .analyse( items: cmds )
567
+ .merge
568
+ .to_rss_all
569
+ ```
570
+
571
+
572
+ **Input**
573
+ | **Name** | **Type** | **Required** | **Default** | **Example** | **Description** |
574
+ |------:|:------|:------|:------|:------|:------|
575
+ | **silent** | ```Boolean``` | No | ```false``` | | Print status messages |
576
+
577
+ **Return**<br>
578
+ Hash
579
+ <br>
580
+
581
+
582
+ ### .status
583
+ Outputs useful informations about the ```.analyse()``` pipeline.
584
+ ```ruby
585
+ require 'feed_into'
586
+
587
+ feed = FeedInto::Group.new(
588
+ modules: './a/b/c/',
589
+ group: {},
590
+ single: {}
591
+ )
592
+
593
+ cmds = [
594
+ {
595
+ name: 'Channel 1',
596
+ url: 'https://your*website.com/1.xml',
597
+ category: :nft
598
+ },
599
+ {
600
+ name: 'Channel 2',
601
+ url: 'https://your*website.com/2.xml',
602
+ category: :crypto
603
+ }
604
+ ]
605
+
606
+ feed
607
+ .analyse( items: cmds )
608
+ .status
609
+ ```
610
+
611
+
612
+ **Input**
613
+ | **Name** | **Type** | **Required** | **Default** | **Example** | **Description** |
614
+ |------:|:------|:------|:------|:------|:------|
615
+ | **silent** | ```Boolean``` | No | ```false``` | | Print status messages |
616
+
617
+ **Return**<br>
618
+ Hash
619
+
620
+ <br>
621
+ <a href="#table-of-contents">
622
+ <img src="https://raw.githubusercontent.com/a6b8/a6b8/main/assets/headlines/default/structure.svg" height="45px" name="structure" alt="Structure">
623
+ </a>
624
+
625
+ Class Overview
626
+
627
+ ```
628
+ FeedInto::Single
629
+ FeedInto::Group
630
+
631
+ --> CLASS: Group
632
+ ---------------------------------------
633
+ | - new( modules:, sgl:{}, grp:{} ) |
634
+ | - analyse( items:, silent: false ) |
635
+ | - merge |
636
+ | - to_h( type: nil ) |
637
+ | - to_rss( key: Symbol ) |
638
+ | - to_rss_all( silent: false ) |
639
+ | |
640
+ ------> CLASS: Single |
641
+ | -------------------------------- |
642
+ | | - new( modules:, opts:{} ) <---- MODULE FOLDER
643
+ | | - analyse( item: ) | |
644
+ | | | |
645
+ | | FUNCTIONS: General | |
646
+ | | ------------------------- | |
647
+ | | | - crl_general | | |
648
+ | | | :download | | |
649
+ | | | :pre_titles | | |
650
+ | | | :mining_rss_one | | |
651
+ | | | :mining_rss_two | | |
652
+ | | | :format_url_s3 | | |
653
+ | | | :format_html_remove | | |
654
+ | | ------------------------- | |
655
+ | -------------------------------- |
656
+ ---------------------------------------
657
+ ```
658
+
659
+ Custom Modules
660
+ ```
661
+
662
+ MODULE FOLDER "./a/b/c/"
663
+ -----------------------------------------------
664
+ | |
665
+ | MODULE: #{Module_Name} |
666
+ | FILE: #{module_name}.rb |
667
+ | ------------------------------------- |
668
+ | | Required: | |
669
+ | | - crl_#{module_name} |--- |
670
+ | | - crl_#{module_name}_settings | | |
671
+ | | | | |
672
+ | | Custom: | | |
673
+ | | - crl_#{module_name}_custom_name | | |
674
+ | ------------------------------------- | |
675
+ | | | |
676
+ | ------------------------------------- |
677
+ | |
678
+ -----------------------------------------------
679
+ ```
680
+ See [Channels](#channels) for more details.
681
+
682
+ </a>
683
+ <br>
684
+ <a href="#table-of-contents">
685
+ <img src="https://raw.githubusercontent.com/a6b8/a6b8/main/assets/headlines/default/options.svg" height="45px" name="options" alt="Options">
686
+ </a>
687
+
688
+ Options are split in 2 section: Single and Group.
689
+
690
+ - In ```::Single``` use ```.new( ... options: )``` to set options.
691
+ - In ```::Group``` use ```.new( ... single:, group: )``` to set options.
692
+
693
+ **Example**
694
+ ```ruby
695
+ options = {
696
+ single: {
697
+ format__title__symbol__vide: "🐨",
698
+ format__title__symbol__custom: "👽"
699
+ },
700
+ group: {
701
+ sleep__scores__user__value: 5,
702
+ sleep__scores__server__value: 10
703
+ }
704
+ }
705
+
706
+ # Single
707
+ feed = FeedInto::Single.new(
708
+ modules: './a/b/c/',
709
+ options: options[:single]
710
+ )
711
+
712
+ # Group
713
+ feeds = FeedInto::Group.new(
714
+ modules: './a/b/c/',
715
+ single: options[:single],
716
+ group: options[:group]
717
+ )
718
+ ```
719
+
720
+ ## FeedInto::Single
721
+
722
+ | Nr | Name | Key | Default | Type | Description |
723
+ | :-- | :-- | :-- | :-- | :-- | :-- |
724
+ | 1. | Title Symbol Video |:format__title__symbol__video | `"👾"` | String | Set Symbol for Video, used in :pre_title |
725
+ | 2. | Title Symbol Custom |:format__title__symbol__custom | `"⚙️ "` | String | Set Symbol for Custom, used in :pre_title |
726
+ | 3. | Title Symbol Web |:format__title__symbol__web | `"🤖"` | String | Set Symbol for Web, used in :pre_title |
727
+ | 4. | Title Separator |:format__title__separator | `"\|"` | String | Change separator, used in :pre_title |
728
+ | 5. | Title More |:format__title__more | `"..."` | String | Used in :pre_title |
729
+ | 6. | Title Length |:format__title__length | `100` | Integer | Set a maximum length, used in :pre_title |
730
+ | 7. | Title Str |:format__title__str | `"{{sym}} {{cmd_name__upcase}} ({{channel_name__upcase}}) {{separator}} {{title_item__titleize}}"` | String | Set Title Structure, used in :pre_title |
731
+ | 8. | Download Agent |:format__download__agent | `""` | String | Set a Agent for Header Request. Use {version} to generate a random version. |
732
+
733
+ ## FeedInto::Group
734
+
735
+ | Nr | Name | Key | Default | Type | Description |
736
+ | :-- | :-- | :-- | :-- | :-- | :-- |
737
+ | 1. | Range | :sleep__range | `15` | Integer | Set how many items are relevant to calculate score for sleeping time. |
738
+ | 2. | Varieties |:sleep__varieties | `[{:variety=>1, :sleep=>2}, {:variety=>2, :sleep=>1}, {:variety=>3, :sleep=>0.5}, {:variety=>4, :sleep=>0.25}, {:variety=>5, :sleep=>0.15}, {:variety=>6, :sleep=>0.1}]` | Array | Set diffrent sleep times by diffrent variety levels |
739
+ | 3. | Scores Ok Value |:sleep__scores__ok__value | `0` | Integer | Sleeping Time for :ok download. |
740
+ | 4. | Scores User Value |:sleep__scores__user__value | `1` | Integer | Sleeping Time for :user download errors. |
741
+ | 5. | Scores Server Value |:sleep__scores__server__value | `3` | Integer | Sleeping Time for :server download errors. |
742
+ | 6. | Scores Other Value |:sleep__scores__other__value | `0` | Integer | Sleeping Time for :other download errors. |
743
+ | 7. | Stages |:sleep__stages | `[{:name=>"Default", :range=>[0, 2], :skip=>false, :sleep=>0}, {:name=>"Low", :range=>[3, 5], :skip=>false, :sleep=>2}, {:name=>"High", :range=>[6, 8], :skip=>false, :sleep=>5}, {:name=>"Stop", :range=>[9, 999], :skip=>true}]` | Array | Set Sleep range for diffrent scores. |
744
+
745
+ <br>
746
+
747
+ <a href="#table-of-contents">
748
+ <img src="https://raw.githubusercontent.com/a6b8/a6b8/main/assets/headlines/default/channels.svg" height="45px" name="channels" alt="Channels">
749
+ </a>
750
+
751
+ To recognize an url, a "channel" must be created. A channel requires a ```Hash``` which defines the pipeline for the given regex urls. You don´t need to write your own module if you use the standard components. To extend the functionalities you can write your own module and initialize by refer to your module folder.
752
+
753
+
754
+ ## Settings Structure
755
+
756
+ Every Channel need a Settings Structure to get recognized.
757
+ ```ruby
758
+ {
759
+ name: Symbol,
760
+ sym: Symbol,
761
+ options: Hash,
762
+ regexs: Nested Array,
763
+ download: Symbol,
764
+ mining: Symbol,
765
+ pre: Array of Symbols,
766
+ transform: Symbol,
767
+ post: Array of Symbols
768
+ }
769
+ ```
770
+
771
+
772
+ | **Name** | **Type** | **Required** | **Example** | **Description** |
773
+ |------:|:------|:------|:------|:------|
774
+ | **name** | ```Symbol``` | Yes | ```:module_name``` | Set your unique channel name as symbol class |
775
+ | **sym** | ```Symbol``` | Yes | ```:web``` | Assign a category sym to your channel. See [Options](#options) for more details. |
776
+ | **options** | ```Hash``` | Yes | ```{ length: 23 }``` | Set specific channel variable here |
777
+ | **regexs** | ```Nested Array``` | Yes | ```[ [ /https:\/\/module_name/ ] ]```| To assign a given url to your channel use an Array (with multiple regexs) and wrap them in an Array. All Regexs from only **one** array must be true. |
778
+ | **download** | ```Symbol``` | Yes | ```:general``` | Select which 'download' method you prefer. |
779
+ | **mining** | ```Symbol``` | Yes | ```:rss_one``` | Select which 'mining' method you prefer. |
780
+ | **pre** | ```Array``` | Yes | ```[]``` | Select which 'pre' methods you prefer. |
781
+ | **transform** | ```Symbol``` | ```nil``` | | Select which 'transform' methods you prefer. |
782
+ | **post** | ```Array``` | Yes | ```[ :pre_titles ]``` | Select which 'post' methods you prefer. |
783
+
784
+
785
+ ## Standard Components
786
+ Inject a struct with **only** standard components in this way. You can find more informations about the available components in [Structure](#structure)
787
+
788
+ ```ruby
789
+ require 'feed_into'
790
+
791
+ channels_settings = {
792
+ name: :blockchain,
793
+ sym: :web,
794
+ options: {},
795
+ regexs: [ [ /https:\/\/your*website.com/ ] ],
796
+ download: :general,
797
+ mining: :rss_one,
798
+ pre: [],
799
+ transform: nil,
800
+ post: [ :pre_titles ]
801
+ }
802
+
803
+ feeds = FeedInto::Group.new(
804
+ single: { channels: [ channels_settings ] }
805
+ )
806
+
807
+ feeds.analyse( items: [ 'https://your*website.com/1.xml' ] )
808
+
809
+ # feed = FeedInto::Single.new(
810
+ # options: { channels: struct }
811
+ # )
812
+ # feed.analyse( item: 'https://your*website.com/1.xml' )
813
+ ```
814
+
815
+ ## Custom Components
816
+
817
+ For custom functionalities you need to define a Module. Use the following boilerplate for a quickstart. Please note:
818
+ - Every function name starts with the prefix 'crl_'
819
+ - The channel will be automatically initialized by search for 'crl_module_name_settings'.
820
+ - Every pipeline contains five stages ```download```, ```mining```, ```pre```, ```transform```, ```post```.
821
+ - The interaction with your Module is only over the function ```crl_module_name```. Delegate the traffic by a case statement.
822
+ - For later tasks you should give back a least ```:title```, ```:url``` and ```[:time][:stamp]```.
823
+
824
+ **Step 1:** Create Module
825
+
826
+ ./path/module_name.rb
827
+ ```ruby
828
+ module ModuleName
829
+ def crl_module_name( sym, cmd, channel, response, data, obj )
830
+ messages = []
831
+
832
+ case sym
833
+ when :settings
834
+ data = crl_module_name_settings()
835
+ when :transform
836
+ data = crl_module_name_transform( data, obj, cmd, channel )
837
+ else
838
+ messages.push( "module_name: #{sym} not found." )
839
+ end
840
+
841
+ return data, messages
842
+ end
843
+
844
+
845
+ private
846
+
847
+
848
+ def crl_module_name_settings()
849
+ {
850
+ name: :module_name,
851
+ sym: :video,
852
+ options: {},
853
+ regexs: [ [ /www.module_name.com/, /www.module_name.com/ ] ],
854
+ download: :general,
855
+ mining: :rss_two,
856
+ pre: [],
857
+ transform: :self,
858
+ post: [ :pre_titles ]
859
+ }
860
+ end
861
+
862
+
863
+ def crl_module_name_transform( data, obj, cmd, channel )
864
+ data[:items] = data[:items].map do | item |
865
+ item = {
866
+ title: '',
867
+ time: { stamp: 1632702548 },
868
+ url: 'https://....'
869
+ }
870
+ end
871
+ return data
872
+ end
873
+ end
874
+ ```
875
+
876
+
877
+ **Step 2:** Initialize Module
878
+ ```ruby
879
+ require 'feed_into'
880
+
881
+ feeds = FeedInto::Group.new(
882
+ modules: './path/'
883
+ )
884
+
885
+ feeds
886
+ .analyse( items: [ 'module_name.com/rss' ] )
887
+ .merge
888
+ .rss_to_all
889
+ ```
890
+ <br>
891
+
892
+ <a href="#table-of-contents">
893
+ <img src="https://raw.githubusercontent.com/a6b8/a6b8/main/assets/headlines/default/contributing.svg" height="45px" name="contributing" alt="Contributing">
894
+ </a>
895
+
896
+ Bug reports and pull requests are welcome on GitHub at https:https://raw.githubusercontent.com/feed-into-for-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https:https://raw.githubusercontent.com/feed-into-for-ruby/blob/master/CODE_OF_CONDUCT.md).
897
+
898
+ <br>
899
+
900
+ <a href="#table-of-contents">
901
+ <img src="https://raw.githubusercontent.com/a6b8/a6b8/main/assets/headlines/default/limitations.svg" height="45px" name="limitations" alt="Limitations">
902
+ </a>
903
+
904
+ - Proof of Concept, not battle-tested.
905
+ <br>
906
+ <br>
907
+
908
+ <a href="#table-of-contents">
909
+ <img src="https://raw.githubusercontent.com/a6b8/a6b8/main/assets/headlines/default/credits.svg" height="45px" name="credits" alt="Credits">
910
+ </a>
911
+
912
+ This gem use following gems:
913
+
914
+ - [nokogiri](https://nokogiri.org)
915
+ - [net/http](https://github.com/ruby/net-http)
916
+ - [time](https://ruby-doc.org/core-2.6.3/Time.html)
917
+ - [tzinfo](https://github.com/tzinfo/tzinfo)
918
+ - [cgi](https://ruby-doc.org/stdlib-2.5.3/libdoc/cgi/rdoc/CGI.html)
919
+ - json
920
+ - [rss](https://github.com/ruby/rsshttps://github.com/ruby/rss)
921
+
922
+ <br>
923
+
924
+ <a href="#table-of-contents">
925
+ <img src="https://raw.githubusercontent.com/a6b8/a6b8/main/assets/headlines/default/license.svg" height="45px" name="license" alt="License">
926
+ </a>
927
+
928
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
929
+ <br>
930
+ <br>
931
+
932
+ <a href="#table-of-contents">
933
+ <img src="https://raw.githubusercontent.com/a6b8/a6b8/main/assets/headlines/default/code-of-conduct.svg" height="45px" name="code-of-conduct" alt="Code of Conduct">
934
+ </a>
935
+
936
+ Everyone interacting in the feed-into-for-ruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https:https://raw.githubusercontent.com/feed-into-for-ruby/blob/master/CODE_OF_CONDUCT.md).
937
+ <br>
938
+ <br>
939
+
940
+ <a href="#table-of-contents">
941
+ <img href="#table-of-contents" src="https://raw.githubusercontent.com/a6b8/a6b8/main/assets/headlines/default/star-us.svg" height="45px" name="star-us" alt="Star Us">
942
+ </a>
943
+
944
+ Please ⭐️ star this Project, every ⭐️ star makes us very happy!