forked from deanishe/alfred-workflow
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Alfred-Workflow 2.0.ft
73 lines (53 loc) · 3.06 KB
/
Alfred-Workflow 2.0.ft
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Alfred-Workflow 2.0
## New features
- `sqlite FTS`-based filtering (search)
- Last-version-run. Workflow can ask for the last version of itself to run. Should enable the migration of old data/settings to the newer version.
- Turn automatic update checks on/off
- Add `kill_process()` to `background.py`
- Add locking around data and cache files
- Generalise update functionality via plugin system
- `filter()` should warn when comparing Unicode to non-Unicode
- `filter()` should replace "smart" puncutation with "dumb" punctuation
- `max_age` arg of `cached_data()` should default to `0` This is currently the only API-breaking feature @api_breaking
- Add logging to `web.py`
### Utility features
- `run_alfred(query)` — Call Alfred via AppleScript
- `applescriptify(text)` — Escape `text` for inclusion in AppleScript.
- `get_clipboard()` — Return clipboard text as `Unicode`
- `set_clipboard(text)` — Set clipboard text
## Refactoring of existing code
Move code from `workflow.py` to other modules.
### Aims
- Make `Workflow` a composed class, whereby core functionality can be overriden fairly easily (as with serialisation)
- Make `workflow.py` easier to read and reason about
- Make writing unit tests easier. Currently, it's a horror show, as so much depends on creating a `Workflow` instance and therefore on `info.plist` file being present.
### Requirements to meet refactoring aims.todo
- Allow most individual test modules to be run without the test environment
- Put tests requiring special conditions (presence of `info.plist`, non-ASCII characters in path to `workflow/`) in separate modules
### Modules
The following modules are envisaged after the refactoring.
#### `__init__.py`
`Workflow` class and imports to form the main API.
#### `constants.py`
All constants from other modules to make them more readable (`ASCII_REPLACEMENTS` in particular is distractingly long)
#### `core.py`
Move functionality required by multiple modules to this module, so it's not necessary for `update.py`/`background.py` to instantiate `Workflow`. This includes:
- Alfred environmental variables
- `info.plist` parsing
- logging
Should have functions for the most commonly-required functionality (getting a bundle identifier, data/cache paths, values from `info.plist`). These functions should be memoised for performance (in most cases, the info *should* come from environmental variables, but that isn't ensured).
#### `index.py`
The home of the suggested `sqlite`-based search module. Possibly combine with `search.py`?
#### `persistence.py`
Data storage/caching API and Keychain access. `Settings` should probably go in here, too.
#### `search.py`
The `filter()` and `_filter_item()` methods of `Workflow` are excessively long. Put 'em in here for cleanliness. Possibly combine with `index.py`?
#### `util.py`
- `run_alfred()`
- `applescriptify()`
- `get_clipboard()`
- `set_clipboard()`
#### `update.py`
Mostly as before (some default values may be moved to `constants.py`. (This doesn't take into account the proposed generalisation of the update mechanism.)
#### `web.py`
As before