|
1 | | -# Red DataStock |
| 1 | +# Red Remote Input |
2 | 2 |
|
3 | | -:alembic: This project is currently under preparation :canned_food: The project name will be changed. |
4 | | - |
5 | | -## Description |
6 | | - |
7 | | -Red DataStock is a Ruby library designed to manage data download, cache, and extraction from specific URLs. |
| 3 | +Red Remote Input is a Ruby library designed to manage data download, cache, and extraction from specific URLs. |
8 | 4 | Useful when you need to consistently retrieve, cache, and process data files from the Internet. |
9 | 5 |
|
10 | 6 | ## Installation |
11 | 7 |
|
12 | | -To install Red DataStock: |
| 8 | +To install Red Remote Input: |
13 | 9 |
|
14 | 10 | ``` |
15 | | -gem install red-datastock |
| 11 | +gem install red-remote-input |
16 | 12 | ``` |
17 | 13 |
|
18 | 14 | ## Usage |
19 | 15 |
|
20 | | -To use Red DataStock in your code, you need to require it first: |
| 16 | +To use Red Remote Input in your code, you need to require it first: |
21 | 17 |
|
22 | 18 | ```rb |
23 | | -require 'datastock' |
| 19 | +require 'remote_input' |
24 | 20 | ``` |
25 | 21 |
|
26 | 22 | Now you can use the `Downloader`, `CachePath`, and `ZipExtractor` classes for managing your data. |
27 | 23 |
|
28 | | -Here's an example of how to download, cache, and extract a zip file using Red DataStock: |
| 24 | +Here's an example of how to download, cache, and extract a zip file using Red Remote Input: |
29 | 25 |
|
30 | 26 | ```rb |
31 | | -require 'datastock' |
| 27 | +require 'remote_input' |
32 | 28 |
|
33 | 29 | # Prepare the Downloader with your desired URL |
34 | | -downloader = DataStock::Downloader.new("http://example.com/data.zip") |
| 30 | +downloader = RemoteInput::Downloader.new("http://example.com/data.zip") |
35 | 31 |
|
36 | 32 | # Define where you want to cache the downloaded data |
37 | | -cache_path = DataStock::CachePath.new("my_data_id") |
| 33 | +cache_path = RemoteInput::CachePath.new("my_data_id") |
38 | 34 |
|
39 | 35 | # Define your output path |
40 | 36 | output_path = cache_path.base_dir + "data.zip" |
41 | 37 |
|
42 | 38 | # Download and cache the data if it's not already cached |
43 | | -downloader.download(cache_path) unless File.exist?(output_path) |
| 39 | +downloader.download(output_path) unless File.exist?(output_path) |
44 | 40 |
|
45 | 41 | # Prepare the ZipExtractor with your cached data |
46 | | -zip_extractor = DataStock::ZipExtractor.new(output_path) |
| 42 | +zip_extractor = RemoteInput::ZipExtractor.new(output_path) |
47 | 43 |
|
48 | 44 | # Extract files from the zip |
49 | 45 | zip_extractor.extract_files do |input| |
50 | 46 | # Your code to process each input file |
51 | 47 | end |
52 | 48 |
|
53 | 49 | # Clean up the cache directory |
54 | | -cache_path.clean |
| 50 | +cache_path.remove |
55 | 51 | ``` |
56 | 52 |
|
57 | 53 | In this example, we download a zip file from `http://example.com/data.zip`, store it in a cache directory, and then extract all files from the zip. You can replace the URL with your actual data source. |
|
0 commit comments