alfred-workflow 2.0.1 → 2.0.2

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
  SHA1:
3
- metadata.gz: 64ee366993693d75c97ac4e0b7d578a9874721dd
4
- data.tar.gz: 9def2870e5c324c723d913b2c1a3d6759b79b63d
3
+ metadata.gz: c46c948baa33e334a81a7a9cb828a30080201a9a
4
+ data.tar.gz: 7612b59e92b7a65251e50f0f01d686d66d3d95a7
5
5
  SHA512:
6
- metadata.gz: da21d87b846ca231258650ce9cf2099e67e15b1c78823e0bb0ca2c8f034aae3c51b4d58deaaf723a206556ed4b165853a356489bf43e612da9adf330346cbe3e
7
- data.tar.gz: 98e932532fbdfe9e83c33203a2798a2cc378eace608914cf145cc02148494a3b5a73d47a360409359d08a7a40dfc929879858ca8b99be4742bed856add0562f7
6
+ metadata.gz: c048fe616f7c59fcf4b636a1151a94c3fcdd962ecc93e721515aa735aff4d046b925fe177f0376aa267d2caf7a58a481b7ddc0d0c4f8eaafb29b9a62d8336d24
7
+ data.tar.gz: a9ede3a26cbd8bffac326282541a32196097f94e112db9853af28eb96a2c9528fa51f15c56dbcd2c4221ef15f0fab819f9a415cebce9203d532bbaef569068a8
Binary file
data.tar.gz.sig CHANGED
@@ -1,4 +1,3 @@
1
- ����:4�n����M=�G<)!L��~�~a{4"��9�w ? g
2
- H@$���@���~WƱ��a_}/� "�:�7&Tgmj��
3
- %J/g��y��ye���S&ϩ��n���B��5���ǞHV
4
- ���t����Ӻ�u��R85bp��ؚ�|ĮN�B� B�W���)�K�h����\�lx�R ��=Ia�C�1x�6cc�.�Y�b�✧�{ �� ҵEW�)�^s�[_�I�Dj�J�
1
+ P��Z-eTY���B� J�R-v���_�IS`\��n˙k
2
+ *ϲM�����)C�J(IN1�v ŧ����0?��ҝ���W��K��BY.��썤t��e��؁ͮB��ܕ�E8do�1��uj��̐�+�k�`u�P�Y<F��ʒQb����)se��."�(�M˓z�*f%3��6X[�{��
3
+ h�
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- alfred-workflow (2.0.1.20131023022544)
4
+ alfred-workflow (2.0.1.20131023093234)
5
5
  fuzzy_match (>= 2.0.4)
6
6
  gyoku (>= 1.1.0)
7
7
  moneta (>= 0.7.19)
data/Guardfile CHANGED
@@ -15,7 +15,7 @@ end
15
15
 
16
16
  group :singleruby do
17
17
 
18
- guard 'rspec', :rvm => ['default'], :notification => true do
18
+ guard 'rspec', :rvm => ['system'], :notification => true do
19
19
 
20
20
  watch(%r{^spec/.+_spec\.rb$})
21
21
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
@@ -26,7 +26,7 @@ end
26
26
 
27
27
  group :multirubies do
28
28
 
29
- guard 'rspec', :rvm => ['default', '1.9.3', '1.8.7'], :notification => true do
29
+ guard 'rspec', :rvm => ['system', '1.9.3', '1.8.7'], :notification => true do
30
30
 
31
31
  watch(%r{^spec/.+_spec\.rb$})
32
32
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
@@ -2,11 +2,10 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "alfred-workflow"
5
- s.version = "2.0.1.20131023022544"
5
+ s.version = "2.0.1.20131023093234"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Zhao Cai"]
9
- s.cert_chain = ["/Users/zhaocai/.gem/gem-public_cert.pem"]
10
9
  s.date = "2013-10-23"
11
10
  s.description = "alfred-workflow is a ruby Gem helper for building [Alfred](http://www.alfredapp.com) workflow."
12
11
  s.email = ["caizhaoff@gmail.com"]
@@ -18,7 +17,6 @@ Gem::Specification.new do |s|
18
17
  s.require_paths = ["lib"]
19
18
  s.rubyforge_project = "alfred-workflow"
20
19
  s.rubygems_version = "2.0.3"
21
- s.signing_key = "/Users/zhaocai/.gem/gem-private_key.pem"
22
20
  s.summary = "alfred-workflow is a ruby Gem helper for building [Alfred](http://www.alfredapp.com) workflow."
23
21
 
24
22
  if s.respond_to? :specification_version then
@@ -44,9 +44,41 @@ module Alfred
44
44
  # MyHandler.new(alfred).register
45
45
  # end
46
46
  #
47
- def with_friendly_error(alfred = Alfred::Core.new, &blk)
47
+ def with_friendly_error(alfred_core = nil, &blk)
48
48
  begin
49
+ if alfred_core.nil? or !alfred_core.is_a?(::Alfred::Core)
50
+ alfred = Alfred::Core.new
51
+ end
52
+ rescue Exception => e
53
+ log_file = File.expand_path("~/Library/Logs/Alfred-Workflow.log")
54
+ rescue_feedback = %Q{
55
+ <items>
56
+ <item autocomplete="" uid="Rescue Feedback" valid="no">
57
+ <title>Alfred Gem Fail to Initialize.</title>
58
+ <arg>Alfred::NoBundleIDError: Wrong Bundle ID Test!</arg>
59
+ <subtitle>Check log #{log_file} for extra debug info.</subtitle>
60
+ <icon>/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns</icon>
61
+ </item>
62
+ <item autocomplete="Alfred-Workflow.log" type="file" valid="yes">
63
+ <title>Alfred-Workflow.log</title>
64
+ <arg>#{log_file}</arg>
65
+ <subtitle>#{log_file}</subtitle>
66
+ <icon type="fileicon">/Applications/Utilities/Console.app</icon>
67
+ </item>
68
+ </items>
69
+ }
70
+ puts rescue_feedback
49
71
 
72
+ File.open(log_file, "a+") do |log|
73
+ log.puts "Alfred Gem Fail to Initialize.\n #{e.message}"
74
+ log.puts e.backtrace.join(" \n")
75
+ log.flush
76
+ end
77
+
78
+ exit e.status_code
79
+ end
80
+
81
+ begin
50
82
  yield alfred
51
83
  alfred.start_handler
52
84
 
@@ -76,14 +108,16 @@ module Alfred
76
108
  " #{e.inspect}\n #{e.backtrace.join(" \n")}\n")
77
109
  puts alfred.rescue_feedback(
78
110
  :title => "Fatal Error!") if alfred.with_rescue_feedback
79
- exit(-1)
111
+ exit(-1)
80
112
  end
81
113
  end
82
114
 
115
+
83
116
  def workflow_folder
84
117
  Dir.pwd
85
118
  end
86
119
 
120
+
87
121
  # launch alfred with query
88
122
  def search(query = "")
89
123
  %x{osascript <<__APPLESCRIPT__
@@ -2,13 +2,13 @@ require 'yaml'
2
2
 
3
3
  module Alfred
4
4
 
5
- class Setting < ::Hash
5
+ class Setting
6
6
  attr_accessor :backend_file
7
7
  attr_reader :format
8
8
 
9
9
  def initialize(alfred, &block)
10
- super()
11
10
  @core = alfred
11
+ @table = {}
12
12
 
13
13
  instance_eval(&block) if block_given?
14
14
 
@@ -18,36 +18,106 @@ module Alfred
18
18
  raise InvalidFormat, "#{format} is not suported." unless validate_format
19
19
 
20
20
  unless File.exist?(@backend_file)
21
- self.merge!({:id => @core.bundle_id})
21
+ @table.merge!({:id => @core.bundle_id})
22
22
  dump(:flush => true)
23
23
  else
24
24
  load
25
25
  end
26
26
  end
27
27
 
28
+
28
29
  def validate_format
29
30
  ['yaml'].include?(format)
30
31
  end
31
32
 
33
+
32
34
  def load
33
35
  send("load_from_#{format}".to_sym)
34
36
  end
35
37
 
38
+
36
39
  def dump(opts = {})
37
40
  send("dump_to_#{format}".to_sym, opts)
38
41
  end
39
42
 
40
43
  alias_method :close, :dump
41
44
 
45
+ #
46
+ # Provides marshalling support for use by the Marshal library.
47
+ #
48
+ def marshal_dump
49
+ @table
50
+ end
51
+
52
+ #
53
+ # Provides marshalling support for use by the Marshal library.
54
+ #
55
+ def marshal_load(x)
56
+ @table.merge! x
57
+ end
58
+ #
59
+ # Converts to hash
60
+ #
61
+ def to_h
62
+ @table.dup
63
+ end
64
+
65
+ def each_pair
66
+ return to_enum __method__ unless block_given?
67
+ @table.each_pair{|p| yield p}
68
+ end
69
+
70
+
71
+ def [](name)
72
+ @table[name]
73
+ end
74
+
75
+ #
76
+ # Sets the value of a member.
77
+ #
78
+ # person = Alfred::Setting.new('name' => 'John Smith', 'age' => 70)
79
+ # person[:age] = 42
80
+ #
81
+ def []=(name, value)
82
+ @table[name] = value
83
+ end
84
+
85
+ def has_key?(key)
86
+ @table.has_key?(key)
87
+ end
88
+ alias_method :key?, :has_key?
89
+
90
+
91
+ def ==(other)
92
+ return false unless other.kind_of?(Alfred::Setting)
93
+ @table == other.table
94
+ end
95
+
96
+ def eql?(other)
97
+ return false unless other.kind_of?(Alfred::Setting)
98
+ @table.eql?(other.table)
99
+ end
100
+
101
+ attr_reader :table # :nodoc:
102
+ protected :table
103
+
104
+
105
+ #
106
+ # Send missing method to @table to mimic a hash
107
+ #
108
+ def method_missing (name, *args, &block) # :nodoc:
109
+ @table.send(name, *args, &block)
110
+ end
111
+
42
112
  protected
43
113
 
44
114
  def load_from_yaml
45
- self.merge!(YAML::load_file(@backend_file))
115
+ @table.merge!(YAML::load_file(@backend_file))
46
116
  end
47
117
 
48
118
  def dump_to_yaml(opts = {})
49
119
  File.open(@backend_file, File::WRONLY|File::TRUNC|File::CREAT) { |f|
50
- YAML::dump(self, f)
120
+ YAML::dump(@table, f)
51
121
  f.flush if opts[:flush]
52
122
  }
53
123
  end
@@ -41,7 +41,20 @@ __APPLESCRIPT__}
41
41
 
42
42
  def open_url(url)
43
43
  uri = URI.parse(url)
44
- %x{open #{uri.to_s}}
44
+ %x{/usr/bin/open #{uri.to_s}}
45
+ end
46
+
47
+ def open_with(app, path)
48
+ %x{osascript <<__APPLESCRIPT__
49
+ tell application "#{app}"
50
+ try
51
+ open "#{path}"
52
+ activate
53
+ on error err_msg number err_num
54
+ return err_msg
55
+ end try
56
+ end tell
57
+ __APPLESCRIPT__}
45
58
  end
46
59
 
47
60
  def reveal_in_finder(path)
@@ -1,3 +1,3 @@
1
1
  module Alfred
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  end
@@ -136,7 +136,7 @@ describe "Feedback" do
136
136
  after :all do
137
137
  @alfred.with_cached_feedback
138
138
  fb = @alfred.feedback
139
- Fil.unlink(fb.backend_file)
139
+ File.unlink(fb.backend_file)
140
140
  reset_workflow
141
141
  end
142
142
 
@@ -7,25 +7,32 @@ describe "Setting with yaml as backend" do
7
7
  end
8
8
 
9
9
  it "should use yaml as defualt backend" do
10
- @alfred.setting.format.should == "yaml"
10
+ @alfred.workflow_setting.format.should == "yaml"
11
11
  end
12
12
 
13
13
  it "should correctly load settings" do
14
- @alfred.setting[:id].should == "me.zhaowu.alfred-workflow-gem"
14
+ @alfred.workflow_setting[:id].should == "me.zhaowu.alfred-workflow-gem"
15
15
  end
16
16
 
17
17
  it "should correctly save settings" do
18
- @alfred.setting[:language] = "Chinese"
19
- @alfred.setting.dump(:flush => true)
18
+ rand = Random.rand(100000)
19
+
20
+ @alfred.workflow_setting[:rand] = rand
21
+ @alfred.workflow_setting.dump(:flush => true)
22
+
23
+ @alfred.workflow_setting.load
24
+ @alfred.workflow_setting[:rand].should == rand
20
25
 
21
- @alfred.setting.load
22
- @alfred.setting[:language].should == "Chinese"
23
26
  end
24
27
 
28
+ it "should handle common hash methods" do
29
+ @alfred.workflow_setting.delete :rand
30
+
31
+ @alfred.workflow_setting[:rand].should == nil
32
+ end
25
33
 
26
34
  after :all do
27
35
  reset_workflow
28
- File.unlink(@alfred.setting.backend_file)
29
36
  end
30
37
 
31
38
  end
@@ -33,36 +40,4 @@ end
33
40
 
34
41
 
35
42
 
36
- # describe "Setting with plist as backend" do
37
- # before :all do
38
- # setup_workflow
39
- # @alfred = Alfred::Core.new
40
-
41
- # @alfred.setting do
42
- # @format = 'plist'
43
- # end
44
- # end
45
-
46
- # it "should correctly load settings" do
47
- # @alfred.setting['id'].should == "me.zhaowu.alfred-workflow-gem"
48
- # end
49
-
50
- # it "should correctly save settings" do
51
- # @alfred.setting['language'] = "English"
52
- # @alfred.setting.dump(:flush => true)
53
-
54
- # @alfred.setting['language'].should == "English"
55
- # end
56
-
57
-
58
- # after :all do
59
- # reset_workflow
60
- # File.unlink(@alfred.setting.backend_file)
61
- # end
62
-
63
- # end
64
-
65
-
66
-
67
-
68
43
 
@@ -1,9 +1,11 @@
1
- ---
1
+ ---
2
2
  :id: me.zhaowu.alfred-workflow-gem
3
- :help:
4
- - :kind: url
5
- :title: Check the Homepage for help
6
- :webloc: homepage.webloc
7
- :subtitle: https://github.com/zhaocai/alfred-workflow
8
- :url: https://github.com/zhaocai/alfred-workflow
9
- - :kind: url
3
+ :help:
4
+ - :kind: url
5
+ :title: Check the Homepage for help
6
+ :webloc: homepage.webloc
7
+ :subtitle: https://github.com/zhaocai/alfred-workflow
8
+ :url: https://github.com/zhaocai/alfred-workflow
9
+ - :kind: file
10
+ :path: README.pdf
11
+ :rand: 59510
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: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zhao Cai
metadata.gz.sig CHANGED
Binary file