alfred-workflow 1.5.0 → 1.5.1
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 +5 -5
- data/.travis.yml +10 -0
- data/Manifest.txt +4 -0
- data/Rakefile +0 -1
- data/lib/alfred/setting.rb +41 -0
- data/lib/alfred/version.rb +1 -1
- data/spec/alfred_spec.rb +120 -0
- data/test/workflow/info.plist +143 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
SHA512:
|
3
|
-
data.tar.gz: 23623140489e12203cca05b87d40364423b37f3e01ade13d1df9909566feaf9a5304e1e3d5803228787791114ba1402f0e8b5654e5e4cb4f9ea14f59059fe844
|
4
|
-
metadata.gz: 32d00acc1222bc5d87b257a8304e3055a3e2b87bfa1ed6bb150cc8c6ad5e48c51ae92bae30625cf7c59c90e3b87656b3fcb78d9580e568217ed2b3eabcbbfcc4
|
5
2
|
SHA1:
|
6
|
-
|
7
|
-
|
3
|
+
metadata.gz: 79e36d00d13052a06d8c027c14f3cebfb7945d70
|
4
|
+
data.tar.gz: ac953e08ccddc38d43a547a9d9ae8477348df767
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ec207bfaaa6ec6c98f5ab53725087522aa6546458b3a058f7b665a56d5385e42d04e5d0839df720e5d55c102f678fc893111652f7cb29bd638cbdb63f9fc5402
|
7
|
+
data.tar.gz: f179f376c0a7b6e272c498bba66638a502405113345989cdcba83c4fab600840d1369e8fc662a10afa5159357adcf5ea323805d4878cec4e3776767aa9c48b1c
|
data/.travis.yml
ADDED
data/Manifest.txt
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
.gemtest
|
3
3
|
.rspec
|
4
4
|
.ruby-version
|
5
|
+
.travis.yml
|
5
6
|
Gemfile
|
6
7
|
Gemfile.lock
|
7
8
|
History.txt
|
@@ -13,8 +14,11 @@ lib/alfred.rb
|
|
13
14
|
lib/alfred/feedback.rb
|
14
15
|
lib/alfred/feedback/file_item.rb
|
15
16
|
lib/alfred/feedback/item.rb
|
17
|
+
lib/alfred/setting.rb
|
16
18
|
lib/alfred/ui.rb
|
17
19
|
lib/alfred/version.rb
|
20
|
+
spec/alfred_spec.rb
|
18
21
|
spec/feedback_spec.rb
|
19
22
|
spec/item_spec.rb
|
20
23
|
spec/spec_helper.rb
|
24
|
+
test/workflow/info.plist
|
data/Rakefile
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Alfred
|
4
|
+
|
5
|
+
class Setting
|
6
|
+
attr_accessor :settings
|
7
|
+
|
8
|
+
def initialize(alfred, setting_file = nil)
|
9
|
+
@core = alfred
|
10
|
+
@setting_file = setting_file if setting_file
|
11
|
+
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
# settings
|
16
|
+
def setting_file
|
17
|
+
@setting_file ||= File.join(@core.storage_path, 'setting.yml')
|
18
|
+
end
|
19
|
+
|
20
|
+
def load
|
21
|
+
unless File.exist?(setting_file)
|
22
|
+
@settings = {:id => @core.bundle_id}
|
23
|
+
dump
|
24
|
+
end
|
25
|
+
|
26
|
+
@settings = YAML::load( File.read(setting_file) )
|
27
|
+
end
|
28
|
+
|
29
|
+
def dump(settings = nil, opts = {})
|
30
|
+
settings = @settings unless settings
|
31
|
+
|
32
|
+
File.open(setting_file, "wb") { |f|
|
33
|
+
YAML::dump(settings, f)
|
34
|
+
f.flush if opts[:flush]
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
data/lib/alfred/version.rb
CHANGED
data/spec/alfred_spec.rb
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Alfred" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@alfred = Alfred::Core.new
|
7
|
+
Dir.chdir("test/workflow/")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return a valid bundle id" do
|
11
|
+
@alfred.bundle_id.should == "me.zhaowu.alfred-workflow-gem"
|
12
|
+
end
|
13
|
+
|
14
|
+
context "Setting" do
|
15
|
+
before :all do
|
16
|
+
@setting = @alfred.setting
|
17
|
+
end
|
18
|
+
it "should correctly load settings" do
|
19
|
+
settings = @setting.load
|
20
|
+
settings[:id].should == "me.zhaowu.alfred-workflow-gem"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should correctly save settings" do
|
24
|
+
settings = @setting.load
|
25
|
+
settings[:language] = "Chinese"
|
26
|
+
@setting.dump(settings, :flush => true)
|
27
|
+
|
28
|
+
settings = @alfred.setting.load
|
29
|
+
settings[:language].should == "Chinese"
|
30
|
+
end
|
31
|
+
|
32
|
+
after :all do
|
33
|
+
File.unlink(@setting.setting_file)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
context "Cached Feedback" do
|
40
|
+
it "should have correct default cache file" do
|
41
|
+
@alfred.with_cached_feedback do
|
42
|
+
use_cache_file :expire => 10
|
43
|
+
end
|
44
|
+
fb = @alfred.feedback
|
45
|
+
fb.cache_file.should == File.join(@alfred.volatile_storage_path, "cached_feedback")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should set correct cache file" do
|
49
|
+
@alfred.with_cached_feedback do
|
50
|
+
use_cache_file :file => "cached_feedback"
|
51
|
+
end
|
52
|
+
fb = @alfred.feedback
|
53
|
+
fb.cache_file.should == "cached_feedback"
|
54
|
+
end
|
55
|
+
|
56
|
+
context "With Valid Cached File" do
|
57
|
+
before :all do
|
58
|
+
@alfred.with_cached_feedback do
|
59
|
+
use_cache_file
|
60
|
+
end
|
61
|
+
|
62
|
+
fb = @alfred.feedback
|
63
|
+
|
64
|
+
fb.add_item(:uid => "uid" ,
|
65
|
+
:arg => "arg" ,
|
66
|
+
:autocomplete => "autocomplete" ,
|
67
|
+
:title => "Title" ,
|
68
|
+
:subtitle => "Subtitle")
|
69
|
+
|
70
|
+
@xml_data = <<-END.strip_heredoc
|
71
|
+
<?xml version="1.0"?>
|
72
|
+
<items>
|
73
|
+
<item valid="yes" arg="arg" autocomplete="autocomplete" uid="uid">
|
74
|
+
<title>Title</title>
|
75
|
+
<subtitle>Subtitle</subtitle>
|
76
|
+
<icon>icon.png</icon>
|
77
|
+
</item>
|
78
|
+
</items>
|
79
|
+
END
|
80
|
+
fb.put_cached_feedback
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
it "should correctly load cached feedback" do
|
85
|
+
alfred = Alfred::Core.new
|
86
|
+
alfred.with_cached_feedback do
|
87
|
+
use_cache_file
|
88
|
+
end
|
89
|
+
|
90
|
+
fb = alfred.feedback
|
91
|
+
|
92
|
+
compare_xml(@xml_data, fb.get_cached_feedback.to_xml).should == true
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should expire as defined" do
|
96
|
+
alfred = Alfred::Core.new
|
97
|
+
alfred.with_cached_feedback do
|
98
|
+
use_cache_file :expire => 1
|
99
|
+
end
|
100
|
+
sleep 1
|
101
|
+
fb = alfred.feedback
|
102
|
+
fb.get_cached_feedback.should == nil
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
after :all do
|
110
|
+
@alfred.with_cached_feedback
|
111
|
+
fb = @alfred.feedback
|
112
|
+
File.unlink(fb.cache_file)
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
|
@@ -0,0 +1,143 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>bundleid</key>
|
6
|
+
<string>me.zhaowu.alfred-workflow-gem</string>
|
7
|
+
<key>connections</key>
|
8
|
+
<dict>
|
9
|
+
<key>21557827-8003-42B7-A042-16D4C9278FEC</key>
|
10
|
+
<array>
|
11
|
+
<dict>
|
12
|
+
<key>destinationuid</key>
|
13
|
+
<string>42D05639-3F0F-4760-8214-317167E4173D</string>
|
14
|
+
<key>modifiers</key>
|
15
|
+
<integer>0</integer>
|
16
|
+
<key>modifiersubtext</key>
|
17
|
+
<string></string>
|
18
|
+
</dict>
|
19
|
+
</array>
|
20
|
+
<key>BA17BE41-176A-4E9A-B958-A3F0BEA36829</key>
|
21
|
+
<array>
|
22
|
+
<dict>
|
23
|
+
<key>destinationuid</key>
|
24
|
+
<string>42D05639-3F0F-4760-8214-317167E4173D</string>
|
25
|
+
<key>modifiers</key>
|
26
|
+
<integer>0</integer>
|
27
|
+
<key>modifiersubtext</key>
|
28
|
+
<string></string>
|
29
|
+
</dict>
|
30
|
+
</array>
|
31
|
+
</dict>
|
32
|
+
<key>createdby</key>
|
33
|
+
<string>Zhao Cai</string>
|
34
|
+
<key>description</key>
|
35
|
+
<string>A starting place for developing Ruby based workflow in Alfred</string>
|
36
|
+
<key>disabled</key>
|
37
|
+
<false/>
|
38
|
+
<key>name</key>
|
39
|
+
<string>Ruby Based Workflow Template</string>
|
40
|
+
<key>objects</key>
|
41
|
+
<array>
|
42
|
+
<dict>
|
43
|
+
<key>config</key>
|
44
|
+
<dict>
|
45
|
+
<key>argumenttype</key>
|
46
|
+
<integer>1</integer>
|
47
|
+
<key>escaping</key>
|
48
|
+
<integer>62</integer>
|
49
|
+
<key>keyword</key>
|
50
|
+
<string>test feedback</string>
|
51
|
+
<key>runningsubtext</key>
|
52
|
+
<string>working...</string>
|
53
|
+
<key>script</key>
|
54
|
+
<string>/usr/bin/ruby ./main.rb {query}</string>
|
55
|
+
<key>subtext</key>
|
56
|
+
<string>Ruby Based Workflow Template</string>
|
57
|
+
<key>title</key>
|
58
|
+
<string>Test Alfred Feedback</string>
|
59
|
+
<key>type</key>
|
60
|
+
<integer>0</integer>
|
61
|
+
<key>withspace</key>
|
62
|
+
<true/>
|
63
|
+
</dict>
|
64
|
+
<key>type</key>
|
65
|
+
<string>alfred.workflow.input.scriptfilter</string>
|
66
|
+
<key>uid</key>
|
67
|
+
<string>21557827-8003-42B7-A042-16D4C9278FEC</string>
|
68
|
+
</dict>
|
69
|
+
<dict>
|
70
|
+
<key>config</key>
|
71
|
+
<dict>
|
72
|
+
<key>lastpathcomponent</key>
|
73
|
+
<false/>
|
74
|
+
<key>onlyshowifquerypopulated</key>
|
75
|
+
<true/>
|
76
|
+
<key>output</key>
|
77
|
+
<integer>0</integer>
|
78
|
+
<key>removeextension</key>
|
79
|
+
<false/>
|
80
|
+
<key>sticky</key>
|
81
|
+
<false/>
|
82
|
+
<key>text</key>
|
83
|
+
<string>{query}</string>
|
84
|
+
<key>title</key>
|
85
|
+
<string>Ruby Script</string>
|
86
|
+
</dict>
|
87
|
+
<key>type</key>
|
88
|
+
<string>alfred.workflow.output.notification</string>
|
89
|
+
<key>uid</key>
|
90
|
+
<string>42D05639-3F0F-4760-8214-317167E4173D</string>
|
91
|
+
</dict>
|
92
|
+
<dict>
|
93
|
+
<key>config</key>
|
94
|
+
<dict>
|
95
|
+
<key>argumenttype</key>
|
96
|
+
<integer>2</integer>
|
97
|
+
<key>escaping</key>
|
98
|
+
<integer>63</integer>
|
99
|
+
<key>keyword</key>
|
100
|
+
<string>test rescue feedback</string>
|
101
|
+
<key>runningsubtext</key>
|
102
|
+
<string>...</string>
|
103
|
+
<key>script</key>
|
104
|
+
<string>/usr/bin/ruby ./main_with_rescue_feedback.rb {query}</string>
|
105
|
+
<key>subtext</key>
|
106
|
+
<string>Ruby Based Workflow Template</string>
|
107
|
+
<key>title</key>
|
108
|
+
<string>Test Alfred Rescue Feedback</string>
|
109
|
+
<key>type</key>
|
110
|
+
<integer>0</integer>
|
111
|
+
<key>withspace</key>
|
112
|
+
<false/>
|
113
|
+
</dict>
|
114
|
+
<key>type</key>
|
115
|
+
<string>alfred.workflow.input.scriptfilter</string>
|
116
|
+
<key>uid</key>
|
117
|
+
<string>BA17BE41-176A-4E9A-B958-A3F0BEA36829</string>
|
118
|
+
</dict>
|
119
|
+
</array>
|
120
|
+
<key>readme</key>
|
121
|
+
<string></string>
|
122
|
+
<key>uidata</key>
|
123
|
+
<dict>
|
124
|
+
<key>21557827-8003-42B7-A042-16D4C9278FEC</key>
|
125
|
+
<dict>
|
126
|
+
<key>ypos</key>
|
127
|
+
<real>250</real>
|
128
|
+
</dict>
|
129
|
+
<key>42D05639-3F0F-4760-8214-317167E4173D</key>
|
130
|
+
<dict>
|
131
|
+
<key>ypos</key>
|
132
|
+
<real>140</real>
|
133
|
+
</dict>
|
134
|
+
<key>BA17BE41-176A-4E9A-B958-A3F0BEA36829</key>
|
135
|
+
<dict>
|
136
|
+
<key>ypos</key>
|
137
|
+
<real>370</real>
|
138
|
+
</dict>
|
139
|
+
</dict>
|
140
|
+
<key>webaddress</key>
|
141
|
+
<string>http://github.com/zhaocai/alfred2-ruby-template</string>
|
142
|
+
</dict>
|
143
|
+
</plist>
|
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.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zhao Cai
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- .gemtest
|
77
77
|
- .rspec
|
78
78
|
- .ruby-version
|
79
|
+
- .travis.yml
|
79
80
|
- Gemfile
|
80
81
|
- Gemfile.lock
|
81
82
|
- History.txt
|
@@ -87,11 +88,14 @@ files:
|
|
87
88
|
- lib/alfred/feedback.rb
|
88
89
|
- lib/alfred/feedback/file_item.rb
|
89
90
|
- lib/alfred/feedback/item.rb
|
91
|
+
- lib/alfred/setting.rb
|
90
92
|
- lib/alfred/ui.rb
|
91
93
|
- lib/alfred/version.rb
|
94
|
+
- spec/alfred_spec.rb
|
92
95
|
- spec/feedback_spec.rb
|
93
96
|
- spec/item_spec.rb
|
94
97
|
- spec/spec_helper.rb
|
98
|
+
- test/workflow/info.plist
|
95
99
|
homepage: https://github.com/zhaocai/alfred-workflow
|
96
100
|
licenses:
|
97
101
|
- GPL-3
|