alfred-workflow 1.10.1 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +31 -1
- data/lib/alfred/feedback.rb +8 -2
- data/lib/alfred/feedback/file_item.rb +2 -0
- data/lib/alfred/feedback/item.rb +16 -13
- data/lib/alfred/feedback/webloc_item.rb +2 -2
- data/lib/alfred/version.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA512:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f6b816d4a18e2c4a85d14cf99407366bfea9a1ab44a0963bfc073540f67cf7e42aa92f3a895d319c3a2150b6a180d63e515cffec6cbbc0ec758e628d78dc819
|
4
|
+
data.tar.gz: 06be2ed6bf284ddceb2efb260f58e8d02a141992618f3b52185b5bf982195174e165e41125f645cf85041954e05f69d9bf0998f37ad2d0407c256560817b4105
|
5
5
|
SHA1:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26a4c6ecaf54da2b488919f10c7768414a939510
|
7
|
+
data.tar.gz: 2af4b640058cdbd52f31dcce8c9c936150eb4cc1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -33,6 +33,7 @@ alfred-workflow is a ruby Gem helper for building [Alfred](http://www.alfredapp.
|
|
33
33
|
|
34
34
|
* [alfred2-top-workflow]( https://github.com/zhaocai/alfred2-top-workflow )
|
35
35
|
* [alfred2-google-workflow]( https://github.com/zhaocai/alfred2-google-workflow )
|
36
|
+
* [alfred2-keylue-workflow]( https://github.com/zhaocai/alfred2-keylue-workflow )
|
36
37
|
* [alfred2-sourcetree-workflow]( https://github.com/zhaocai/alfred2-sourcetree-workflow )
|
37
38
|
|
38
39
|
## SYNOPSIS:
|
@@ -76,7 +77,7 @@ Alfred.with_friendly_error do |alfred|
|
|
76
77
|
end
|
77
78
|
```
|
78
79
|
|
79
|
-
![
|
80
|
+
![](https://raw.github.com/zhaocai/alfred2-ruby-template/master/screenshots/rescue%20feedback.png)
|
80
81
|
|
81
82
|
|
82
83
|
### Automate saving and loading cached feedback
|
@@ -104,8 +105,37 @@ Alfred.with_friendly_error do |alfred|
|
|
104
105
|
end
|
105
106
|
```
|
106
107
|
|
108
|
+
### Customize feedback item matcher
|
107
109
|
|
110
|
+
```ruby
|
111
|
+
fb = alfred.feedback
|
112
|
+
fb.add_item(:uid => "uid" ,
|
113
|
+
:arg => "arg" ,
|
114
|
+
:autocomplete => "autocomplete" ,
|
115
|
+
:title => "Title" ,
|
116
|
+
:subtitle => "Subtitle" ,
|
117
|
+
:match? => :all_title_match?)
|
118
|
+
|
119
|
+
fb.add_file_item(File.expand_path "~/Applications/", :match? => :all_title_match?)
|
120
|
+
```
|
121
|
+
|
122
|
+
`:title_match?` and `:all_title_match?` are built in.
|
123
|
+
|
124
|
+
To define your new matcher
|
125
|
+
```ruby
|
126
|
+
Module Alfred
|
127
|
+
class Feedback
|
128
|
+
class Item
|
129
|
+
# define new matcher function here
|
130
|
+
def your_match?(query)
|
131
|
+
return true
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
```
|
108
137
|
|
138
|
+
Check the code in [alfred/feedback/item.rb]( https://github.com/zhaocai/alfred-workflow/blob/master/lib/alfred/feedback/item.rb#L63 ) for more information.
|
109
139
|
|
110
140
|
|
111
141
|
|
data/lib/alfred/feedback.rb
CHANGED
@@ -22,8 +22,14 @@ module Alfred
|
|
22
22
|
|
23
23
|
def to_xml(with_query = '', items = @items)
|
24
24
|
document = REXML::Element.new("items")
|
25
|
-
|
26
|
-
|
25
|
+
if with_query.empty?
|
26
|
+
items.each do |item|
|
27
|
+
document << item.to_xml
|
28
|
+
end
|
29
|
+
else
|
30
|
+
items.each do |item|
|
31
|
+
document << item.to_xml if item.match?(with_query)
|
32
|
+
end
|
27
33
|
end
|
28
34
|
document.to_s
|
29
35
|
end
|
data/lib/alfred/feedback/item.rb
CHANGED
@@ -12,52 +12,55 @@ module Alfred
|
|
12
12
|
if opts[:icon]
|
13
13
|
@icon = opts[:icon]
|
14
14
|
else
|
15
|
-
@icon
|
15
|
+
@icon ||= {:type => "default", :name => "icon.png"}
|
16
16
|
end
|
17
17
|
|
18
18
|
if opts[:uid]
|
19
19
|
@uid = opts[:uid]
|
20
|
-
else
|
21
|
-
@uid = nil
|
22
20
|
end
|
23
21
|
|
24
22
|
if opts[:arg]
|
25
23
|
@arg = opts[:arg]
|
26
24
|
else
|
27
|
-
@arg
|
25
|
+
@arg ||= @title
|
28
26
|
end
|
29
27
|
|
30
28
|
if opts[:type]
|
31
29
|
@type = opts[:type]
|
32
30
|
else
|
33
|
-
@type
|
31
|
+
@type ||= 'default'
|
34
32
|
end
|
35
33
|
|
36
34
|
if opts[:valid]
|
37
35
|
@valid = opts[:valid]
|
38
36
|
else
|
39
|
-
@valid
|
37
|
+
@valid ||= 'yes'
|
40
38
|
end
|
41
39
|
|
42
40
|
if opts[:autocomplete]
|
43
41
|
@autocomplete = opts[:autocomplete]
|
44
42
|
end
|
43
|
+
|
44
|
+
if opts[:match?]
|
45
|
+
@matcher = opts[:match?].to_sym
|
46
|
+
else
|
47
|
+
@matcher ||= :title_match?
|
48
|
+
end
|
45
49
|
end
|
46
50
|
|
47
|
-
## To customize a new
|
51
|
+
## To customize a new matcher?, define it.
|
48
52
|
#
|
49
53
|
# Module Alfred
|
50
54
|
# class Feedback
|
51
55
|
# class Item
|
52
|
-
#
|
53
|
-
#
|
54
|
-
# # define new match? function here
|
56
|
+
# def your_match?(query)
|
57
|
+
# # define new matcher here
|
55
58
|
# end
|
56
59
|
# end
|
57
60
|
# end
|
58
61
|
# end
|
59
62
|
def match?(query)
|
60
|
-
|
63
|
+
send(@matcher, query)
|
61
64
|
end
|
62
65
|
|
63
66
|
def title_match?(query)
|
@@ -105,7 +108,7 @@ module Alfred
|
|
105
108
|
'valid' => @valid,
|
106
109
|
'autocomplete' => @autocomplete
|
107
110
|
})
|
108
|
-
|
111
|
+
|
109
112
|
end
|
110
113
|
xml_element.add_attributes('type' => 'file') if @type == "file"
|
111
114
|
|
@@ -125,7 +128,7 @@ module Alfred
|
|
125
128
|
def build_regexp(query, option)
|
126
129
|
begin
|
127
130
|
Regexp.compile(".*#{query.gsub(/\s+/,'.*')}.*", option)
|
128
|
-
rescue RegexpError
|
131
|
+
rescue RegexpError
|
129
132
|
Regexp.compile(".*#{Regexp.escape(query)}.*", option)
|
130
133
|
end
|
131
134
|
end
|
@@ -10,11 +10,11 @@ module Alfred
|
|
10
10
|
opts[:webloc] = ::Alfred::Util.make_webloc(
|
11
11
|
opts[:title], opts[:url], File.dirname(opts[:webloc]))
|
12
12
|
end
|
13
|
-
super opts[:webloc], opts
|
14
13
|
|
15
|
-
@title = title if title
|
16
14
|
@subtitle = opts[:url]
|
17
15
|
@uid = opts[:url]
|
16
|
+
|
17
|
+
super title, opts
|
18
18
|
end
|
19
19
|
|
20
20
|
end
|
data/lib/alfred/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alfred-workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zhao Cai
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
S6w/KYMnbhUxfyEU1MX10sJv87WIrtgF
|
32
32
|
-----END CERTIFICATE-----
|
33
33
|
|
34
|
-
date: 2013-09-
|
34
|
+
date: 2013-09-26 00:00:00 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: plist
|
metadata.gz.sig
CHANGED
Binary file
|