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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA512:
3
- metadata.gz: 2557094d89a1cdd90790d352f41333a6b4e60a3cc595d85fe581b567091240733314964039e3c3ba94e2b686f935c4b0a1229197d30e91e0827f2552a01d246e
4
- data.tar.gz: 8129bfdbf94145f2c43843ef202e01455bce3485c5b6e8cb7a9aa0870d3794d406a8557bb2c4c578ec9c399f0eb4c02d05ed06a214c1da49e5cec4a7bcd9bc2b
3
+ metadata.gz: 0f6b816d4a18e2c4a85d14cf99407366bfea9a1ab44a0963bfc073540f67cf7e42aa92f3a895d319c3a2150b6a180d63e515cffec6cbbc0ec758e628d78dc819
4
+ data.tar.gz: 06be2ed6bf284ddceb2efb260f58e8d02a141992618f3b52185b5bf982195174e165e41125f645cf85041954e05f69d9bf0998f37ad2d0407c256560817b4105
5
5
  SHA1:
6
- metadata.gz: 1226f27047ece44ef0ad0575371ea92c1a09f827
7
- data.tar.gz: 09a7f2050ef6782e225616bf19bf4fe94de8ea6b
6
+ metadata.gz: 26a4c6ecaf54da2b488919f10c7768414a939510
7
+ data.tar.gz: 2af4b640058cdbd52f31dcce8c9c936150eb4cc1
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
- ![rescue feedback](https://raw.github.com/zhaocai/alfred2-ruby-template/master/screenshots/rescue%20feedback.png)
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
 
@@ -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
- items.each do |item|
26
- document << item.to_xml if item.match?(with_query)
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
@@ -18,6 +18,8 @@ module Alfred
18
18
  @valid = 'yes'
19
19
  @autocomplete = @title
20
20
  @type = 'file'
21
+
22
+ super @title, opts
21
23
  end
22
24
 
23
25
  def match?(query)
@@ -12,52 +12,55 @@ module Alfred
12
12
  if opts[:icon]
13
13
  @icon = opts[:icon]
14
14
  else
15
- @icon = {:type => "default", :name => "icon.png"}
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 = @title
25
+ @arg ||= @title
28
26
  end
29
27
 
30
28
  if opts[:type]
31
29
  @type = opts[:type]
32
30
  else
33
- @type = 'default'
31
+ @type ||= 'default'
34
32
  end
35
33
 
36
34
  if opts[:valid]
37
35
  @valid = opts[:valid]
38
36
  else
39
- @valid = 'yes'
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 match? function, overwrite it.
51
+ ## To customize a new matcher?, define it.
48
52
  #
49
53
  # Module Alfred
50
54
  # class Feedback
51
55
  # class Item
52
- # alias_method :default_match?, :match?
53
- # def match?(query)
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
- title_match?(query)
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 => e
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
@@ -1,3 +1,3 @@
1
1
  module Alfred
2
- VERSION = '1.10.1'
2
+ VERSION = '1.11.0'
3
3
  end
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.10.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-25 00:00:00 Z
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