ixport 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/app/models/ixport/wallflower_runner.rb +1 -1
- data/lib/ixport/background_runner.rb +1 -1
- data/lib/ixport/version.rb +1 -1
- data/the_local/agents/ixport-develop.md +2 -2
- data/the_local/agents/ixport-info.md +4 -4
- data/the_local/agents/ixport-install.md +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f88d69ec114d492533abe3ec24f1bbe7cc95828e57307ea69a4bb21405d242f5
|
|
4
|
+
data.tar.gz: e3d7deaf43ed37c74985cfa596baca6955c4188f986aecf96b04eb25b588472d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6830a5778d0866975dc9e0f8f3d813405021db9bbcf57a3304c7c81a06d87aa0710b6c8390633021c4d7f9e9f7f66914e5b6ff075f850e9fc05ab23ad9a271c6
|
|
7
|
+
data.tar.gz: 1da289fa0f5e85625242ec0a29d7e9eb60acf87a73cfce8fb60c3b28beee0a4217d1f3d104782c1b5d6adcf716cbecfedd0e90a4a9496101718cc958d5249f2c
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ixport
|
|
2
2
|
|
|
3
|
-
CSV import and export for Rails apps. An app registers the
|
|
3
|
+
CSV import and export for Rails apps. An app registers the types of CSV a person can import and the fields each one maps to, and the CSV downloads a person can export.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -49,7 +49,7 @@ end
|
|
|
49
49
|
|
|
50
50
|
## Mapped imports and importers
|
|
51
51
|
|
|
52
|
-
A mapped import is a
|
|
52
|
+
A mapped import is a type of CSV a person can import into one of the app's records. Register each one in an initializer with its key, its title and the name of its importer class:
|
|
53
53
|
|
|
54
54
|
```ruby
|
|
55
55
|
Ixport.register_import :products, title: "Products", importer: "ProductImporter"
|
|
@@ -180,7 +180,7 @@ The engine's exports page, at `exports` under the mount path, lists every regist
|
|
|
180
180
|
|
|
181
181
|
## Chosen exports and templates
|
|
182
182
|
|
|
183
|
-
An export registered with `chosen: true` lets a person pick its columns instead of taking all of them. It uses the same
|
|
183
|
+
An export registered with `chosen: true` lets a person pick its columns instead of taking all of them. It uses the same type of exporter:
|
|
184
184
|
|
|
185
185
|
```ruby
|
|
186
186
|
Ixport.register_export :products, title: "Products", exporter: "ProductExporter", chosen: true
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Ixport
|
|
4
4
|
class WallflowerRunner
|
|
5
5
|
def self.enqueue(import)
|
|
6
|
-
task = Wallflower.start(
|
|
6
|
+
task = Wallflower.start(task_type: :ixport_import, person: import.person, account: import.account, params: { "import_id" => import.id })
|
|
7
7
|
import.update!(wallflower_task_id: task.id)
|
|
8
8
|
end
|
|
9
9
|
end
|
|
@@ -18,6 +18,6 @@ module Ixport
|
|
|
18
18
|
def self.install_background_runner!
|
|
19
19
|
return unless configuration.background_runner == :wallflower
|
|
20
20
|
|
|
21
|
-
Wallflower.
|
|
21
|
+
Wallflower.register_task_type(:ixport_import, title: "Import", runner: "Ixport::WallflowerTaskRunner")
|
|
22
22
|
end
|
|
23
23
|
end
|
data/lib/ixport/version.rb
CHANGED
|
@@ -9,7 +9,7 @@ This local adds mapped imports, fixed exports and chosen exports to a Rails app
|
|
|
9
9
|
|
|
10
10
|
## What ixport is
|
|
11
11
|
|
|
12
|
-
ixport is a Rails engine that lets a signed-in person import a host app's records from CSV files and download them as CSV files. The app registers each
|
|
12
|
+
ixport is a Rails engine that lets a signed-in person import a host app's records from CSV files and download them as CSV files. The app registers each type of CSV a person can import, called a mapped import, and writes an importer class that names the fields the CSV's columns map to, the field or fields rows are matched on, and the records a row may add to or update. A person picks an import, uploads a CSV file for it, matches each of the file's columns to one of the importer's fields, sees a preview of how many rows will add a record, update one or be refused, runs the import to save those rows, and then sees how many rows were added and updated and each refused row. When the run stops on an error, the import is marked failed, keeps the rows it saved before stopping, and its page shows the error. An import runs within the request by default, or, when the app is set up for it, in the background through wallflower or through a runner class the app writes. The imports page also lists the person's own past imports in the current account, each opening at the step it has reached. The app also registers each CSV a person can download, and writes an exporter class that names the columns the file can hold, in order, and the records it holds one row each for. An export is either fixed or chosen. A fixed export always holds every declared column, and a person downloads it from the exports page. A chosen export lets people in the current account save named templates, each a picked list of the exporter's columns in a picked order, and a person downloads a template from the exports page to get a file holding only those columns. Fire this local when a developer wants people to load one of the app's records from a spreadsheet or download them as one, wants people to pick which columns an export holds, wants to link to an import's upload page, the exports page, an export's download or a template's download, asks what the upload, column-matching, preview, result, exports or template pages do, asks what the list of past imports shows, asks what running an import saves, what happens when a run fails, or what an export's or template's file holds, wants imports run in a background job of the app's own, or when the app fails to boot with `Ixport::MissingImporter` or `Ixport::MissingExporter`.
|
|
13
13
|
|
|
14
14
|
## Interface
|
|
15
15
|
|
|
@@ -192,7 +192,7 @@ Whether imports run within the request, through wallflower, or through the app's
|
|
|
192
192
|
28. Ask the developer whether the export is fixed or chosen. Do not pick one.
|
|
193
193
|
- Fixed: every download holds every column from step 26, in the declared order.
|
|
194
194
|
- Chosen: people in the current account save named templates that each pick some of those columns in an order of their own, and each template downloads only its picked columns.
|
|
195
|
-
29. Write the exporter class in `app/exporters/`, named after the record, inheriting from `Ixport::Exporter`. A fixed export and a chosen export use the same
|
|
195
|
+
29. Write the exporter class in `app/exporters/`, named after the record, inheriting from `Ixport::Exporter`. A fixed export and a chosen export use the same type of class:
|
|
196
196
|
```ruby
|
|
197
197
|
class ProductExporter < Ixport::Exporter
|
|
198
198
|
column :sku, label: "SKU"
|
|
@@ -24,7 +24,7 @@ Where the run happens depends on the host's background runner. With none, the ru
|
|
|
24
24
|
|
|
25
25
|
ixport refuses a file on the upload page, before any import record is kept, when it is not UTF-8 text, when a line's quotes stop it being read, naming that line, or when it has no header row. With no background runner, it also refuses a file with more rows than the host's row limit there. Each refusal says what is wrong with the file.
|
|
26
26
|
|
|
27
|
-
Below the list of imports, the same page lists the person's own past imports in the current account, newest first. Each shows the import's title, the uploaded file's name, its status, the date it was uploaded, and, once it has finished, how many rows were added, updated and refused. A failed import shows its status as Failed and no counts. Each title opens the import at the step it has reached: the mapping when no mapping is saved, the preview when it has a mapping and has not started running, and the result page once it is running, finished or failed. Imports uploaded by other people, or by the same person in another account, are not listed, and neither are the person's imports of a
|
|
27
|
+
Below the list of imports, the same page lists the person's own past imports in the current account, newest first. Each shows the import's title, the uploaded file's name, its status, the date it was uploaded, and, once it has finished, how many rows were added, updated and refused. A failed import shows its status as Failed and no counts. Each title opens the import at the step it has reached: the mapping when no mapping is saved, the preview when it has a mapping and has not started running, and the result page once it is running, finished or failed. Imports uploaded by other people, or by the same person in another account, are not listed, and neither are the person's imports of a type their access rule now refuses.
|
|
28
28
|
|
|
29
29
|
An export is either fixed or chosen. A fixed export's title on the exports page links to a CSV download holding every column the exporter declares. A chosen export's title is not a link. Under it the page lists the templates the account has saved for that export, each linking to a download and to its edit page, with a button to make a new template.
|
|
30
30
|
|
|
@@ -52,8 +52,8 @@ ixport declares nothing for this local to document. Its surface is split between
|
|
|
52
52
|
|
|
53
53
|
## Conventions
|
|
54
54
|
|
|
55
|
-
- **Mapped import** — one
|
|
56
|
-
- **Fixed export** — one
|
|
55
|
+
- **Mapped import** — one type of import the host registers, made of a key, a title shown to people, and the name of its importer class.
|
|
56
|
+
- **Fixed export** — one type of export the host registers, made of a key, a title shown to people, and the name of its exporter class, whose download always holds every declared column. An export is fixed unless the host registers it as chosen.
|
|
57
57
|
- **Chosen export** — an export registered the same way and marked as chosen, which has no download of its own and is downloaded only through the account's templates.
|
|
58
58
|
- **Export template** — a named, ordered pick of a chosen export's columns, saved by one person and shared by everyone in their account.
|
|
59
59
|
- **Picked columns** — the columns a template holds, in the order they were chosen. A slot left on None is dropped, a column picked twice is kept once, and a column the exporter no longer declares is left out of the download.
|
|
@@ -70,7 +70,7 @@ ixport declares nothing for this local to document. Its surface is split between
|
|
|
70
70
|
- **Mapping** — which of the importer's columns each header in the file fills, stored by the header's position in the row. A header left on "Skip" is not stored.
|
|
71
71
|
- **Row limit** — the most data rows an uploaded file may have, not counting the header row. It defaults to 1,000 and the host can change it. It applies only when the host has no background runner, and it does not apply to exports.
|
|
72
72
|
- **Background runner** — what runs an import outside the request: none, wallflower, or a class the host app writes. Having wallflower in the app does not choose it, the host has to.
|
|
73
|
-
- **Wallflower** — a separate gem that runs long tasks in the background and gives each task a page showing its progress. ixport registers its imports with it as a
|
|
73
|
+
- **Wallflower** — a separate gem that runs long tasks in the background and gives each task a page showing its progress. ixport registers its imports with it as a type of task titled Import.
|
|
74
74
|
- **Row number** — a row's line in the file, counting the header as row 1, so the first data row is row 2.
|
|
75
75
|
- **Add** — a row that no existing record equals on every match column, or that is blank in any match column, or comes from a file with no column mapped to one, so it creates a record.
|
|
76
76
|
- **Update** — a row that equals an existing record on every match column, so it changes that record.
|
|
@@ -95,7 +95,7 @@ ixport is a Rails engine with two pages of work for a signed-in person. On the i
|
|
|
95
95
|
bin/rails generate ixport:update
|
|
96
96
|
bin/rails db:migrate
|
|
97
97
|
```
|
|
98
|
-
Until the `error_message` migration has run, an import that fails cannot record its error and the run raises an error naming the missing column. The generator copies whichever of the three migrations step 5 describes are missing, reports each one already present as identical, and touches no other file. Then read the app's `config/initializers/ixport.rb`, or the defaults if it has none. Where the export templates migration was just added, put the current account part of step 9 to the developer, since export templates are shared by that account. Where `config.background_runner` is not set, put step 10 to the developer. Where `config.base_controller` is not set, put step 8 to the developer. Visit the mounted path followed by `/exports` while signed in and check that the page still loads. Then visit the mounted path itself and check that the imports page loads, with a "Your imports" list of the person's earlier imports when they have any. An earlier import of a
|
|
98
|
+
Until the `error_message` migration has run, an import that fails cannot record its error and the run raises an error naming the missing column. The generator copies whichever of the three migrations step 5 describes are missing, reports each one already present as identical, and touches no other file. Then read the app's `config/initializers/ixport.rb`, or the defaults if it has none. Where the export templates migration was just added, put the current account part of step 9 to the developer, since export templates are shared by that account. Where `config.background_runner` is not set, put step 10 to the developer. Where `config.base_controller` is not set, put step 8 to the developer. Visit the mounted path followed by `/exports` while signed in and check that the page still loads. Then visit the mounted path itself and check that the imports page loads, with a "Your imports" list of the person's earlier imports when they have any. An earlier import of a type whose access rule refuses the signed-in person is left off that list. Access rules need no migration and no setting.
|
|
99
99
|
|
|
100
100
|
## Conventions
|
|
101
101
|
|