alfred-workflow 1.0.4 → 1.1.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.
- data/History.txt +8 -0
- data/README.md +14 -20
- data/lib/alfred.rb +3 -119
- data/lib/alfred/version.rb +1 -1
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
=== 1.1.0 / 2013-03-24
|
2
|
+
* 3 major enhancements:
|
3
|
+
|
4
|
+
* reorganize Alfred module to multiple files
|
5
|
+
* use FileItem < Item classes to manage feedback item
|
6
|
+
* add default query match for Item and FileItem
|
7
|
+
|
8
|
+
|
1
9
|
=== 1.0.0 / 2013-03-21
|
2
10
|
|
3
11
|
* 1 major enhancement
|
data/README.md
CHANGED
@@ -6,11 +6,11 @@ Ruby Gem helper for building [Alfred](http://www.alfredapp.com) workflow.
|
|
6
6
|
|
7
7
|
## FEATURES:
|
8
8
|
|
9
|
+
* Use standard [bundler][gembundler] to easily package, manage, and update ruby gems in the workflow.
|
10
|
+
* Friendly exception and debug output to the Mac OS X Console
|
9
11
|
* Functions for finding the bundle ID, cache and storage paths, and query arguments.
|
10
|
-
* Shows exceptions and debug output in the Mac OS X Console
|
11
12
|
* Functions for reading and writing plist files.
|
12
13
|
* Functions to simplify generating feedback XML for Alfred.
|
13
|
-
* Adds ruby gems repositories to the workflow bundle so you can package gems with your workflow.
|
14
14
|
* Functions to simplify saving and retrieving settings.
|
15
15
|
|
16
16
|
|
@@ -37,25 +37,19 @@ and generate the RDoc.
|
|
37
37
|
|
38
38
|
## LICENSE:
|
39
39
|
|
40
|
-
(
|
40
|
+
Copyright (c) 2013 Zhao Cai <caizhaoff@gmail.com>
|
41
41
|
|
42
|
-
|
42
|
+
This program is free software: you can redistribute it and/or modify it under
|
43
|
+
the terms of the GNU General Public License as published by the Free Software
|
44
|
+
Foundation, either version 3 of the License, or (at your option)
|
45
|
+
any later version.
|
43
46
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
48
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
49
|
-
permit persons to whom the Software is furnished to do so, subject to
|
50
|
-
the following conditions:
|
47
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
48
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
49
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
51
50
|
|
52
|
-
|
53
|
-
|
51
|
+
You should have received a copy of the GNU General Public License along with
|
52
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
54
53
|
|
55
|
-
|
56
|
-
|
57
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
58
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
59
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
60
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
61
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
54
|
+
|
55
|
+
[gembundler]: http://gembundler.com/
|
data/lib/alfred.rb
CHANGED
@@ -2,10 +2,9 @@ require 'rubygems' unless defined? Gem # rubygems is only needed in 1.8
|
|
2
2
|
|
3
3
|
require 'plist'
|
4
4
|
require 'fileutils'
|
5
|
-
require 'logging'
|
6
|
-
require "rexml/document"
|
7
5
|
|
8
|
-
require 'alfred/
|
6
|
+
require 'alfred/ui'
|
7
|
+
require 'alfred/feedback'
|
9
8
|
|
10
9
|
module Alfred
|
11
10
|
|
@@ -17,6 +16,7 @@ module Alfred
|
|
17
16
|
|
18
17
|
class ObjCError < AlfredError; status_code(1) ; end
|
19
18
|
class NoBundleIDError < AlfredError; status_code(2) ; end
|
19
|
+
class ArgumentError < AlfredError; status_code(3) ; end
|
20
20
|
class NoMethodError < AlfredError; status_code(13) ; end
|
21
21
|
class PathError < AlfredError; status_code(14) ; end
|
22
22
|
|
@@ -93,121 +93,5 @@ module Alfred
|
|
93
93
|
|
94
94
|
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
class Logger
|
100
|
-
def initialize(id)
|
101
|
-
@id = id
|
102
|
-
end
|
103
|
-
|
104
|
-
def info(msg)
|
105
|
-
logger.info msg
|
106
|
-
end
|
107
|
-
def warn(msg)
|
108
|
-
logger.warn msg
|
109
|
-
end
|
110
|
-
def debug(msg)
|
111
|
-
logger.debug msg
|
112
|
-
end
|
113
|
-
def error(msg)
|
114
|
-
logger.error msg
|
115
|
-
end
|
116
|
-
def fatal(msg)
|
117
|
-
logger.fatal msg
|
118
|
-
end
|
119
|
-
|
120
|
-
def logger
|
121
|
-
@logger ||= init_log
|
122
|
-
end
|
123
|
-
|
124
|
-
private
|
125
|
-
|
126
|
-
def init_log
|
127
|
-
@logger = Logging.logger[@id]
|
128
|
-
logger_file = File.expand_path("~/Library/Logs/Alfred-Workflow.log")
|
129
|
-
@logger.level = :debug
|
130
|
-
@logger.add_appenders(
|
131
|
-
Logging.appenders.file(logger_file)
|
132
|
-
)
|
133
|
-
@logger
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
class Feedback
|
143
|
-
attr_accessor :items
|
144
|
-
|
145
|
-
def initialize
|
146
|
-
@items = []
|
147
|
-
end
|
148
|
-
|
149
|
-
def add_item(opts = {})
|
150
|
-
opts[:subtitle] ||= ""
|
151
|
-
opts[:icon] ||= {:type => "default", :name => "icon.png"}
|
152
|
-
if opts[:uid].nil?
|
153
|
-
opts[:uid] = ''
|
154
|
-
end
|
155
|
-
opts[:arg] ||= opts[:title]
|
156
|
-
opts[:valid] ||= "yes"
|
157
|
-
opts[:autocomplete] ||= opts[:title]
|
158
|
-
opts[:type] ||= "default"
|
159
|
-
|
160
|
-
@items << opts unless opts[:title].nil?
|
161
|
-
end
|
162
|
-
|
163
|
-
def add_file_item(path)
|
164
|
-
item = {}
|
165
|
-
if ['.ennote', '.webbookmark'].include? File.extname(path)
|
166
|
-
item[:title] = %x{mdls -name kMDItemDisplayName -raw '#{path}'}
|
167
|
-
else
|
168
|
-
item[:title] = File.basename(path)
|
169
|
-
end
|
170
|
-
item[:subtitle] = path
|
171
|
-
item[:uid] = path
|
172
|
-
item[:arg] = path
|
173
|
-
item[:icon] = {:type => "fileicon", :name => path}
|
174
|
-
item[:valid] = 'yes'
|
175
|
-
item[:autocomplete] = item[:title]
|
176
|
-
item[:type] = 'file'
|
177
|
-
|
178
|
-
@items << item
|
179
|
-
end
|
180
|
-
|
181
|
-
|
182
|
-
def to_xml(items = @items)
|
183
|
-
document = REXML::Element.new("items")
|
184
|
-
items.each do |item|
|
185
|
-
new_item = REXML::Element.new('item')
|
186
|
-
new_item.add_attributes({
|
187
|
-
'uid' => item[:uid],
|
188
|
-
'arg' => item[:arg],
|
189
|
-
'valid' => item[:valid],
|
190
|
-
'autocomplete' => item[:autocomplete]
|
191
|
-
})
|
192
|
-
new_item.add_attributes('type' => 'file') if item[:type] == "file"
|
193
|
-
|
194
|
-
REXML::Element.new("title", new_item).text = item[:title]
|
195
|
-
REXML::Element.new("subtitle", new_item).text = item[:subtitle]
|
196
|
-
|
197
|
-
icon = REXML::Element.new("icon", new_item)
|
198
|
-
icon.text = item[:icon][:name]
|
199
|
-
icon.add_attributes('type' => 'fileicon') if item[:icon][:type] == "fileicon"
|
200
|
-
|
201
|
-
document << new_item
|
202
|
-
end
|
203
|
-
|
204
|
-
document.to_s
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
96
|
end
|
213
97
|
|
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.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: plist
|