ruby_do_plugin_execute_application 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +61 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/lib/ruby_do_plugin_execute_application.rb +141 -0
- data/spec/ruby_do_plugin_execute_application_spec.rb +7 -0
- data/spec/spec_helper.rb +12 -0
- metadata +135 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "ruby_do"
|
7
|
+
gem "knjrbfw"
|
8
|
+
|
9
|
+
# Add dependencies to develop your gem here.
|
10
|
+
# Include everything needed to run rake, tests, features, etc.
|
11
|
+
group :development do
|
12
|
+
gem "rspec", "~> 2.8.0"
|
13
|
+
gem "rdoc", "~> 3.12"
|
14
|
+
gem "bundler", ">= 1.0.0"
|
15
|
+
gem "jeweler", "~> 1.8.4"
|
16
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
atk (1.1.3)
|
5
|
+
glib2 (>= 1.1.3)
|
6
|
+
cairo (1.12.2)
|
7
|
+
pkg-config
|
8
|
+
diff-lcs (1.1.3)
|
9
|
+
gdk_pixbuf2 (1.1.3)
|
10
|
+
glib2 (>= 1.1.3)
|
11
|
+
gettext (2.2.1)
|
12
|
+
locale
|
13
|
+
git (1.2.5)
|
14
|
+
glib2 (1.1.3)
|
15
|
+
pkg-config
|
16
|
+
gtk2 (1.1.3)
|
17
|
+
atk (>= 1.1.3)
|
18
|
+
gdk_pixbuf2 (>= 1.1.3)
|
19
|
+
pango (>= 1.1.3)
|
20
|
+
jeweler (1.8.4)
|
21
|
+
bundler (~> 1.0)
|
22
|
+
git (>= 1.2.5)
|
23
|
+
rake
|
24
|
+
rdoc
|
25
|
+
json (1.7.3)
|
26
|
+
knjrbfw (0.0.55)
|
27
|
+
tsafe
|
28
|
+
wref
|
29
|
+
locale (2.0.5)
|
30
|
+
pango (1.1.3)
|
31
|
+
cairo (>= 1.10.0)
|
32
|
+
glib2 (>= 1.1.3)
|
33
|
+
pkg-config (1.1.3)
|
34
|
+
rake (0.9.2.2)
|
35
|
+
rdoc (3.12)
|
36
|
+
json (~> 1.4)
|
37
|
+
rspec (2.8.0)
|
38
|
+
rspec-core (~> 2.8.0)
|
39
|
+
rspec-expectations (~> 2.8.0)
|
40
|
+
rspec-mocks (~> 2.8.0)
|
41
|
+
rspec-core (2.8.0)
|
42
|
+
rspec-expectations (2.8.0)
|
43
|
+
diff-lcs (~> 1.1.2)
|
44
|
+
rspec-mocks (2.8.0)
|
45
|
+
ruby_do (0.0.0)
|
46
|
+
gettext
|
47
|
+
gtk2
|
48
|
+
knjrbfw
|
49
|
+
tsafe (0.0.1)
|
50
|
+
wref (0.0.4)
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
ruby
|
54
|
+
|
55
|
+
DEPENDENCIES
|
56
|
+
bundler (>= 1.0.0)
|
57
|
+
jeweler (~> 1.8.4)
|
58
|
+
knjrbfw
|
59
|
+
rdoc (~> 3.12)
|
60
|
+
rspec (~> 2.8.0)
|
61
|
+
ruby_do
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Kasper Johansen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= ruby_do_plugin_execute_application
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to ruby_do_plugin_execute_application
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 Kasper Johansen. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "ruby_do_plugin_execute_application"
|
18
|
+
gem.homepage = "http://github.com/kaspernj/ruby_do_plugin_execute_application"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{A plugin for Ruby-Do that executes installed applications.}
|
21
|
+
gem.description = %Q{A plugin for Ruby-Do that executes installed applications.}
|
22
|
+
gem.email = "k@spernj.org"
|
23
|
+
gem.authors = ["Kasper Johansen"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "ruby_do_plugin_execute_application #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,141 @@
|
|
1
|
+
class Ruby_do_plugin_execute_application < Ruby_do::Plugin::Base
|
2
|
+
def initialize(*args, &block)
|
3
|
+
super(*args, &block)
|
4
|
+
|
5
|
+
#Find icon-paths to scan for icons.
|
6
|
+
@icon_paths = []
|
7
|
+
|
8
|
+
self.scan_icon_dir("/usr/share/pixmaps")
|
9
|
+
self.scan_icon_dir("/usr/share/icons")
|
10
|
+
|
11
|
+
@icon_exts = ["png", "xpm", "svg"]
|
12
|
+
|
13
|
+
|
14
|
+
#Scan XDG-dirs for .desktop application files.
|
15
|
+
@apps = []
|
16
|
+
ENV["XDG_DATA_DIRS"].split(":").each do |val|
|
17
|
+
path = "#{val}/applications"
|
18
|
+
self.scan_dir(path) if File.exists?(path)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def scan_icon_dir(path)
|
23
|
+
@icon_paths << path
|
24
|
+
|
25
|
+
Dir.foreach(path) do |file|
|
26
|
+
next if file[0, 1] == "."
|
27
|
+
fp = "#{path}/#{file}"
|
28
|
+
|
29
|
+
if File.directory?(fp)
|
30
|
+
self.scan_icon_dir(fp)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def sortmethod(path1, path2)
|
36
|
+
#puts "Paths (#{path1}, #{path2})"
|
37
|
+
|
38
|
+
path1l = path1.downcase
|
39
|
+
path2l = path2.downcase
|
40
|
+
|
41
|
+
sizem1 = path1.match(/(\d+)x(\d+)/)
|
42
|
+
sizem2 = path2.match(/(\d+)x(\d+)/)
|
43
|
+
|
44
|
+
if path1l.index("highcontrast") != nil
|
45
|
+
return 1
|
46
|
+
elsif path2l.index("highcontrast") != nil
|
47
|
+
return -1
|
48
|
+
elsif sizem1 and sizem2
|
49
|
+
return sizem2[1].to_i <=> sizem1[1].to_i
|
50
|
+
else
|
51
|
+
return path2 <=> path1
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def scan_dir(path)
|
56
|
+
Dir.foreach(path) do |file|
|
57
|
+
next if file[0, 1] == "."
|
58
|
+
fp = "#{path}/#{file}"
|
59
|
+
|
60
|
+
if File.directory?(fp)
|
61
|
+
self.scan_dir(fp)
|
62
|
+
else
|
63
|
+
cont = File.read(fp)
|
64
|
+
|
65
|
+
data = {}
|
66
|
+
cont.scan(/^(.+?)=(.+)$/) do |match|
|
67
|
+
data[match[0].to_s.downcase] = match[1]
|
68
|
+
end
|
69
|
+
|
70
|
+
icon_paths = []
|
71
|
+
icon_path = nil
|
72
|
+
|
73
|
+
if icon = data["icon"]
|
74
|
+
if File.exists?(icon)
|
75
|
+
icon_path = icon
|
76
|
+
else
|
77
|
+
@icon_paths.each do |path|
|
78
|
+
@icon_exts.each do |ext|
|
79
|
+
fp = "#{path}/#{icon}.#{ext}"
|
80
|
+
if File.exists?(fp)
|
81
|
+
icon_paths << fp
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
if !icon_paths.empty?
|
89
|
+
icon_paths.sort!(&self.method(:sortmethod))
|
90
|
+
icon_path = icon_paths.first
|
91
|
+
end
|
92
|
+
|
93
|
+
if data["name"] and data["exec"]
|
94
|
+
@apps << {
|
95
|
+
:name => data["name"],
|
96
|
+
:namel => data["name"].to_s.downcase,
|
97
|
+
:exec => data["exec"],
|
98
|
+
:icon => icon,
|
99
|
+
:icon_path => icon_path
|
100
|
+
}
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def on_options
|
107
|
+
return {
|
108
|
+
:widget => Gtk::Label.new("Test execute app")
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
def on_search(args)
|
113
|
+
return Enumerator.new do |yielder|
|
114
|
+
@apps.each do |app|
|
115
|
+
found_all = true
|
116
|
+
args[:words].each do |word|
|
117
|
+
if app[:namel].index(word) == nil
|
118
|
+
found_all = false
|
119
|
+
break
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
if found_all
|
124
|
+
yielder << Ruby_do::Plugin::Result.new(
|
125
|
+
:plugin => self,
|
126
|
+
:title => app[:name],
|
127
|
+
:title_html => "<b>#{Knj::Web.html(app[:name])}</b>",
|
128
|
+
:descr => sprintf(_("Open the application: '%1$s' with the command '%2$s'."), app[:name], app[:exec]),
|
129
|
+
:exec => app[:exec],
|
130
|
+
:icon => app[:icon_path]
|
131
|
+
)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def execute_result(args)
|
138
|
+
Knj::Os.subproc(args[:res].args[:exec])
|
139
|
+
return :close_win_main
|
140
|
+
end
|
141
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'ruby_do_plugin_execute_application'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby_do_plugin_execute_application
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kasper Johansen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2012-07-09 00:00:00 +02:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: ruby_do
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: knjrbfw
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rspec
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.8.0
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rdoc
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "3.12"
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: bundler
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 1.0.0
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: jeweler
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.8.4
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: *id006
|
82
|
+
description: A plugin for Ruby-Do that executes installed applications.
|
83
|
+
email: k@spernj.org
|
84
|
+
executables: []
|
85
|
+
|
86
|
+
extensions: []
|
87
|
+
|
88
|
+
extra_rdoc_files:
|
89
|
+
- LICENSE.txt
|
90
|
+
- README.rdoc
|
91
|
+
files:
|
92
|
+
- .document
|
93
|
+
- .rspec
|
94
|
+
- Gemfile
|
95
|
+
- Gemfile.lock
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.rdoc
|
98
|
+
- Rakefile
|
99
|
+
- VERSION
|
100
|
+
- lib/ruby_do_plugin_execute_application.rb
|
101
|
+
- spec/ruby_do_plugin_execute_application_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
has_rdoc: true
|
104
|
+
homepage: http://github.com/kaspernj/ruby_do_plugin_execute_application
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
hash: 2764426103137546546
|
118
|
+
segments:
|
119
|
+
- 0
|
120
|
+
version: "0"
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: "0"
|
127
|
+
requirements: []
|
128
|
+
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 1.6.2
|
131
|
+
signing_key:
|
132
|
+
specification_version: 3
|
133
|
+
summary: A plugin for Ruby-Do that executes installed applications.
|
134
|
+
test_files: []
|
135
|
+
|