launchy_opensearch 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,4 +1,18 @@
1
+ === 1.1.0 / 2009-03-08
2
+
3
+ * 1 major enhancements
4
+
5
+ * Better commandline outputs
6
+ * Now compatibile with ruby 1.9.1
7
+
8
+ * 3 minor enhancement
9
+
10
+ * Added a --version command to output version and licensing information
11
+ * Added automated tests
12
+ * Some more comments
13
+
1
14
  === 1.0.0 / 2009-02-24
2
15
 
3
- * Initial release
16
+ * 1 major enhancement
4
17
 
18
+ * Birthday!
data/Manifest.txt CHANGED
@@ -4,4 +4,10 @@ README.txt
4
4
  COPYING.txt
5
5
  Rakefile
6
6
  bin/launchy_opensearch
7
- lib/launchy_opensearch.rb
7
+ lib/launchy_opensearch.rb
8
+ spec/launchy_opensearch_spec.rb
9
+ spec/fixtures/launchy.ini
10
+ spec/fixtures/discogs.xml
11
+ spec/fixtures/secure-wikipedia-english.xml
12
+ spec/fixtures/youtube.xml
13
+
data/README.txt CHANGED
@@ -11,9 +11,11 @@ Launchy's ini config file.
11
11
 
12
12
  == FEATURES/PROBLEMS:
13
13
 
14
- * Usable as library and commandline tool.
15
- * Tested on Ubuntu Linux
16
- * Written for Ruby 1.8
14
+ * Usable as library and commandline tool
15
+ * Tested and fully working on:
16
+ * Windows XP i386 (Ruby 1.8.6)
17
+ * Ubuntu Linux 8.10 i386_64 (Ruby 1.8.7 and 1.9.1p0)
18
+ * The commandline tool doesn't work with Ruby 1.9.x because the user-choices gem is not yet updated. A patch is available here: https://rubyforge.org/tracker/index.php?func=detail&aid=24307&group_id=4192&atid=16176
17
19
 
18
20
  == SYNOPSIS:
19
21
 
@@ -60,10 +62,12 @@ Launchy should be closed while using OpenSearchLaunchy
60
62
  * hpricot (for XML parsing)
61
63
  * facets (for ini parsing)
62
64
  * sys-uname (for operating system detection)
65
+ * user-choices (for commandline tool)
63
66
 
64
67
  == INSTALL:
65
68
 
66
69
  * gem install launchy_opensearch
70
+ * gem install user-choices (only for commandline tool)
67
71
 
68
72
  == LICENSE:
69
73
 
data/Rakefile CHANGED
@@ -8,6 +8,9 @@ Hoe.new('launchy_opensearch', LaunchyOpenSearch::VERSION) do |p|
8
8
  p.rubyforge_name = 'aef'
9
9
  p.developer('Alexander E. Fischer', 'aef@raxys.net')
10
10
  p.extra_deps = %w{facets hpricot sys-uname}
11
+ p.extra_dev_deps = %w{user-choices}
12
+ p.testlib = 'spec'
13
+ p.test_globs = ['spec/**/*_spec.rb']
11
14
  end
12
15
 
13
16
  # vim: syntax=Ruby
@@ -17,13 +17,21 @@
17
17
  # You should have received a copy of the GNU General Public License
18
18
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
- require 'rubygems'
21
- require 'launchy_opensearch'
20
+ # TODO: If user-choices patch gets accepted, use :one_way => true for --version
22
21
 
22
+ # If library is not locally accessible, use gem to include it.
23
+ begin
24
+ require 'lib/launchy_opensearch'
25
+ rescue LoadError
26
+ require 'rubygems'
27
+ require 'launchy_opensearch'
28
+ end
29
+
30
+ # User friendly message if user-choices is not available
23
31
  begin
24
32
  require 'user-choices'
25
33
  rescue LoadError
26
- puts 'This command needs the user-choices gem to be installed'; exit
34
+ warn "This command needs the user-choices gem to be installed.\n\nSolution: gem install user-choices"; exit false
27
35
  end
28
36
 
29
37
  class LaunchyOpenSearch::Application < UserChoices::Command
@@ -35,8 +43,8 @@ class LaunchyOpenSearch::Application < UserChoices::Command
35
43
  def add_sources(builder)
36
44
  builder.add_source(
37
45
  CommandLineSource, :usage,
38
- "Usage: #$PROGRAM_NAME [options] opensearch-files",
39
- 'Import OpenSearch XML files into the Weby plugin of the keystroke application launcher Launchy'
46
+ "Usage: #$PROGRAM_NAME [options] opensearch-files\n\n",
47
+ "Import OpenSearch XML files into the Weby plugin of the keystroke application launcher Launchy\n"
40
48
  )
41
49
  end
42
50
 
@@ -52,18 +60,31 @@ class LaunchyOpenSearch::Application < UserChoices::Command
52
60
  "Insert mode. Possible settings: #{MODES.join(', ')}. Default is #{MODES.first}.")
53
61
  end
54
62
 
63
+ builder.add_choice(:version, :default => false, :type => :boolean) do |cli|
64
+ cli.uses_switch('-v', '--version', 'Display version and licensing information')
65
+ end
66
+
55
67
  builder.add_choice(:filenames) {|cli| cli.uses_arglist }
56
68
  end
57
69
 
58
70
  # Main program
59
71
  def execute
60
- raise 'No OpenSearch files specified' if @user_choices[:filenames].empty?
72
+ if @user_choices[:version]
73
+ klass = LaunchyOpenSearch
74
+ puts "\n#{klass.name} #{klass::VERSION}"
75
+ puts DATA.read; exit
76
+ end
77
+
78
+ if @user_choices[:filenames].empty?
79
+ warn 'No OpenSearch files specified'; exit false
80
+ end
61
81
 
62
82
  @user_choices[:filenames].each do |filename|
63
- warn "Ignoring #{filename}. Not readble or missing." unless File.readable?(filename)
83
+ warn "Ignoring #{filename}. Not readable or missing." unless File.readable?(filename)
64
84
  end
65
85
 
66
86
  new_engines = LaunchyOpenSearch.parse_opensearch_files(@user_choices[:filenames])
87
+ count = new_engines.size
67
88
  config = LaunchyOpenSearch.read_config_hash(@user_choices[:config_path])
68
89
 
69
90
  if @user_choices[:mode] == 'append'
@@ -73,7 +94,29 @@ class LaunchyOpenSearch::Application < UserChoices::Command
73
94
 
74
95
  LaunchyOpenSearch.patch_config_hash(config, new_engines)
75
96
  LaunchyOpenSearch.write_config_hash(config, @user_choices[:config_path])
97
+
98
+ puts "#{count} search engines installed."
76
99
  end
77
100
  end
78
101
 
79
102
  S4tUtils.with_pleasant_exceptions {LaunchyOpenSearch::Application.new.execute}
103
+
104
+ __END__
105
+
106
+ Project: https://rubyforge.org/projects/aef/
107
+ RDoc: http://aef.rubyforge.org/launchy_opensearch/
108
+
109
+ Copyright 2009 Alexander E. Fischer <aef@raxys.net>
110
+
111
+ LaunchyOpenSearch is free software: you can redistribute it and/or modify
112
+ it under the terms of the GNU General Public License as published by
113
+ the Free Software Foundation, either version 3 of the License, or
114
+ (at your option) any later version.
115
+
116
+ This program is distributed in the hope that it will be useful,
117
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
118
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
119
+ GNU General Public License for more details.
120
+
121
+ You should have received a copy of the GNU General Public License
122
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -21,13 +21,14 @@ require 'uri'
21
21
  require 'rubygems'
22
22
  require 'hpricot'
23
23
  require 'facets/ini'
24
+ require 'facets/version'
24
25
  require 'sys/uname'
25
26
 
26
27
  # Offers static methods for all steps in parsing usefull information out of the
27
28
  # OpenSearch XML format and modifying the configuration of Launchy's Weby plugin
28
29
  module LaunchyOpenSearch
29
30
 
30
- VERSION = '1.0.0'
31
+ VERSION = '1.1.0'
31
32
 
32
33
  # Determines the location of Launchy's configuration Ini file on different
33
34
  # platforms
@@ -87,7 +88,12 @@ module LaunchyOpenSearch
87
88
  def self.read_config_hash(path)
88
89
  # Ini class doesn't like empty lines and can only read from files.
89
90
  original = File.read(path)
90
- cleaned = original.map{|line| line.chomp.squeeze(' ')}.reject{|line| line == ''}.join("\n")
91
+
92
+ if VersionNumber.new(RUBY_VERSION) >= VersionNumber.new('1.9.0')
93
+ cleaned = original.lines.map{|line| line.chomp.squeeze(' ')}.reject{|line| line == ''}.join("\n")
94
+ else
95
+ cleaned = original.map{|line| line.chomp.squeeze(' ')}.reject{|line| line == ''}.join("\n")
96
+ end
91
97
 
92
98
  temp_file = Tempfile.open('launchy')
93
99
  temp_file.write(cleaned)
@@ -137,7 +143,7 @@ module LaunchyOpenSearch
137
143
  new_section["sites\\#{i + 1}\\#{key}"] = value
138
144
  }
139
145
  end
140
- new_section['sites\\size'] = engines.size
146
+ new_section['sites\\size'] = engines.size.to_s
141
147
  config_hash['weby'] = new_section
142
148
  config_hash
143
149
  end
@@ -150,7 +156,12 @@ module LaunchyOpenSearch
150
156
  File.open("#{path}.bak", 'w') do |f|
151
157
  f.write(original)
152
158
  end
159
+ end
153
160
 
161
+ if VersionNumber.new(RUBY_VERSION) >= VersionNumber.new('1.9.0')
162
+ # Facets ini parser doesn't seems to use the .lines enumerator yet
163
+ Ini.write_to_file(path, config_hash)
164
+ else
154
165
  Ini.write_to_file(path, config_hash, "Written by LaunchyOpenSearch #{Time.now}\n")
155
166
  end
156
167
  end
@@ -0,0 +1,12 @@
1
+ <SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/">
2
+ <os:ShortName>Discogs</os:ShortName>
3
+ <os:Description>Discogs search all</os:Description>
4
+ <os:InputEncoding>UTF-8</os:InputEncoding>
5
+ <os:Image width="16" height="16">data:image/x-icon;base64,AAABAAIAEBAAAAAAAABoAwAAJgAAACAgAAAAAAAAqAwAAI4DAAAoAAAAEAAAACAAAAABABgAAAAAAEADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa3N7a3N7a3N7a3N7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa3N7QkJCQkJCKTk5EBAQEBAQAAAAEBAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAQkJCvcbGa3N7QkJCISkpEBAQEBAQAAAAAAAAEBAQAAAAAAAAAAAAAAAAAAAAISkpQkJCa3N7vcbGa3N7ISkpEBAQEBAQAAAAAAAAAAAAEBAQAAAAAAAAAAAAISkpKTk5QkJCQkJCa3N7a3N7KTk5ISkpEBAQAAAAAAAAAAAAAAAAISkpAAAAAAAAEBAQISkpISkpKTk5KTk5EBAQGGNrGGNrCAgICAgIAAAAAAAAAAAAAAAAAAAAa3N7AAAAEBAQEBAQEBAQEBAQAMbWAMbWAMbWAMbWCAgIAAAAAAAAAAAAAAAAa3N7a3N7AAAAAAAAAAAAAAgIGGNrAMbWAMbWAMbWAMbWGGNrAAAAAAAAAAAAAAAAa3N7a3N7AAAAAAAAAAAAAAAAGGNrAMbWAMbWAMbWAMbWGGNrEBAQEBAQEBAQEBAQa3N7a3N7AAAAAAAAAAA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GBgYGBgYGBgYGBgxMTExMTExMTExMTExMTFKSkpaY2O9ra29ra0xMTEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxMTEAAAAAAAAAAAAYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgxMTExMTExMTExMTEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxMTEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxMTEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABaY2NKSkpKSkpKSkpKSkpaY2MAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/8A///4AB//4AAH/8AAA/8AAAD/AAAA/gAAAHwAAAA8AAAAOAAAABgAAAAYAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAYAAAAGAAAABwAAAA8AAAAPgAAAH8AAAD/AAAA/4AAAf/gAAf/8AAP//wAP///gf/w==</os:Image>
6
+ <UpdateInterval>7</UpdateInterval>
7
+ <UpdateUrl>http://mycroft.mozdev.org/updateos.php/id0/discogs.xml</UpdateUrl>
8
+ <IconUpdateUrl>http://mycroft.mozdev.org/updateos.php/id0/discogs.ico</IconUpdateUrl>
9
+ <SearchForm>http://www.discogs.com/</SearchForm>
10
+ <os:Url type="text/html" method="GET" template="http://www.discogs.com/search?type=all&amp;q={searchTerms}&amp;btn=Search">
11
+ </os:Url>
12
+ </SearchPlugin>
@@ -0,0 +1,60 @@
1
+ [GenOps]
2
+ skin=/usr/share/launchy/skins/Default
3
+
4
+ [General]
5
+ donateTime=@Variant(\0\0\0\x10\0%u\x85\x2\a\xe3L\xff)
6
+ version=212
7
+
8
+ [runner]
9
+ cmds\1\name=cmd
10
+ cmds\1\file=/usr/bin/xterm
11
+ cmds\1\args=-hold -e $$
12
+ cmds\size=1
13
+ version=2
14
+
15
+ [weby]
16
+ sites\1\name=Google
17
+ sites\1\base=http://www.google.com/
18
+ sites\1\query="search?source=launchy&q=%s"
19
+ sites\1\default=true
20
+ sites\2\name=Live Search
21
+ sites\2\base=http://search.live.com/
22
+ sites\2\query="results.aspx?q=%s"
23
+ sites\3\name=Yahoo
24
+ sites\3\base=http://search.yahoo.com/
25
+ sites\3\query="search?p=%s"
26
+ sites\4\name=MSN
27
+ sites\4\base=http://search.msn.com/
28
+ sites\4\query="results.aspx?q=%s"
29
+ sites\5\name=Weather
30
+ sites\5\base=http://www.weather.com/
31
+ sites\5\query=weather/local/%s
32
+ sites\6\name=Amazon
33
+ sites\6\base=http://www.amazon.com/
34
+ sites\6\query="gp/search/?keywords=%s&index=blended"
35
+ sites\7\name=YouTube
36
+ sites\7\base=http://www.youtube.com/
37
+ sites\7\query="results?search_query=%s"
38
+ sites\8\name=Wikipedia
39
+ sites\8\base=http://en.wikipedia.com/
40
+ sites\8\query="wiki/Special:Search?search=%s&fulltext=Search"
41
+ sites\9\name=Dictionary
42
+ sites\9\base=http://www.dictionary.com/
43
+ sites\9\query=browse/%s
44
+ sites\10\name=Thesaurus
45
+ sites\10\base=http://www.thesaurus.com/
46
+ sites\10\query=browse/%s
47
+ sites\11\name=Netflix
48
+ sites\11\base=http://www.netflix.com/
49
+ sites\11\query="Search?v1=%s"
50
+ sites\12\name=E-Mail
51
+ sites\12\base=mailto:
52
+ sites\12\query=%s
53
+ sites\13\name=IMDB
54
+ sites\13\base=http://www.imdb.com/
55
+ sites\13\query="find?s=all&q=%s"
56
+ sites\14\name=Maps
57
+ sites\14\base=http://maps.google.com/
58
+ sites\14\query="maps?f=q&hl=en&geocode=&q=%s&ie=UTF8&z=12&iwloc=addr&om=1"
59
+ sites\size=14
60
+ version=2
@@ -0,0 +1,13 @@
1
+ <SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/">
2
+ <os:ShortName>SSL Wikipedia (English)</os:ShortName>
3
+ <os:Description>Return articles from english wikipedia using https url</os:Description>
4
+ <os:InputEncoding>UTF-8</os:InputEncoding>
5
+ <os:Image width="16" height="16">data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAABzklEQVQ4y6WTL6vycBTHP9stgmETGWIaF6bFNA0qWMQZxDIQ34cv4WLwDYhJsK1o0CQKDhUMNllQg2tiERQUBMGwGx7Y83i9T/LArxzO+XK+f36CKIoeb5TIm/U+QKFQwLIshsMhhUIBgGq1ynA4pF6vo2kaAPV6Hcuy0DQNTdNoNptYloVo2zbr9RpVVX3UXq8HQKVSAUBRFO73O7PZDNd1uVwuAMxmsz8Uut0usixjmiaKogDQ7/eRZRld1/n8/CQajdJut5/Ob7fbfAiC8HU+n0mlUpRKJcbjMYfDgev1SjKZxDRNbrcbq9WKzWYDQDab5Xg8stls/orY6XQAMAwDANd16ff7xGIxEomET0tRFNLpNOfz+dkF27ZxHIdcLucLN51OWS6XhEIh/2xJkggEAti2/WrjYrHAMAx0XX/iqqqq71A+n2e/3/+eg0ajwW6388XUdR3HcTidTpim6VMYDAb+zocgCF//gsiyTCqVIhKJcDweGQwGSJJEuVzm8XgQDAYZj8f/T+JutyMcDvsZcF2X+XwOQK1WYzKZ/IiiKHo/32g08kajkRePx/1eq9Xyttvty+yvAMVi0ctkMk+9eDzuFYvFl1nh3e/8DVlGxpnqRIOzAAAAAElFTkSuQmCC</os:Image>
6
+ <UpdateInterval>7</UpdateInterval>
7
+ <UpdateUrl>http://mycroft.mozdev.org/updateos.php/id0/securewikipedia.xml</UpdateUrl>
8
+ <IconUpdateUrl>http://mycroft.mozdev.org/updateos.php/id0/securewikipedia.png</IconUpdateUrl>
9
+ <SearchForm>https://secure.wikimedia.org/wikipedia/en/wiki/</SearchForm>
10
+ <os:Url type="text/html" method="GET" template="https://secure.wikimedia.org/wikipedia/en/wiki/Special:Search?go=Go&amp;search={searchTerms}">
11
+ </os:Url><os:Url type="application/x-suggestions+json" method="GET" template="https://secure.wikimedia.org/wikipedia/en/w/api.php?action=opensearch&amp;search={searchTerms}">
12
+ </os:Url>
13
+ </SearchPlugin>
@@ -0,0 +1,13 @@
1
+ <SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/">
2
+ <os:ShortName>YouTube</os:ShortName>
3
+ <os:Description>YouTube - Videos</os:Description>
4
+ <os:InputEncoding>UTF-8</os:InputEncoding>
5
+ <os:Image width="16" height="16">data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAABMLAAATCwAAAAAAAAAAAAD//////////4OD//9paf//bm7//2Fh//9ZWf//Wlr//1pa//9WVv//ZGT//3Bw//9jY///goL//////////////////11d//8sLP//QUH//ygo//84OP//RET//y4u//8xMf//UVH//y4u//8PD///ZWX//x0d//9aWv////////////88PP//Cgr///////8zM///1NT///////+lpf//ubn///////+urv//fHz////////g4P//Fhb/////////////MzP//woK////////NDT//8vL//9ycv//paX//7Cw//9jY///s7P//8nJ//9XV///eXn//yIi/////////////zMz//8LC///+/v//zMz///Gxv//hYX//6Ki//+srP//W1v//6ys//+3t///2tr//93d//8PD/////////////80NP//AgL///b2//8nJ///5ub//56e//+5uf//oaH//+/v//+5uf//oKD//+Li///f3///AgL/////////////MzP//wUF////////Skr//0pK//9NTf//NTX//97e//+ysv//Nzf//xIS//+mpv//Kyv//z09/////////////xkZ///Y2P////////////8nJ///EBD//wAA///y8v//Ly///wAA//8mJv//Hh7//6mp//92dv////////////+vr///Jib//xMS//8eIP//MzP//zY2//84OP//Hh///y4u//9XV///hoj//8LC///R0f//qqr/////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAA/8zMzP/u7u7/IiIi/wAAAP8iIiL//////zMzM/8AAAD/AAAA/////////////////////////////////wAAAP/MzMz//////yIiIv/u7u7/ERER/7u7u/8AAAD/iIiI/xEREf///////////////////////////+7u7v8AAAD/zMzM//////8iIiL/7u7u/xEREf+7u7v/AAAA/8zMzP8RERH///////////////////////////93d3f/AAAA/1VVVf/u7u7/IiIi/wAAAP8iIiL//////wAAAP/MzMz/ERER///////////////////////d3d3/AAAA/4iIiP8AAAD/3d3d/////////////////////////////////////////////////////////////////wAAAP//////AAAA////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</os:Image>
6
+ <UpdateInterval>7</UpdateInterval>
7
+ <UpdateUrl>http://mycroft.mozdev.org/updateos.php/id0/youtube.xml</UpdateUrl>
8
+ <IconUpdateUrl>http://mycroft.mozdev.org/updateos.php/id0/youtube.ico</IconUpdateUrl>
9
+ <SearchForm>http://www.youtube.com/index</SearchForm>
10
+ <os:Url type="text/html" method="GET" template="http://www.youtube.com/results?search_query={searchTerms}&amp;search=Search">
11
+ </os:Url><os:Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?hl=en&amp;ds=yt&amp;json=t&amp;q={searchTerms}">
12
+ </os:Url>
13
+ </SearchPlugin>
@@ -0,0 +1,245 @@
1
+ # Copyright 2009 Alexander E. Fischer <aef@raxys.net>
2
+ #
3
+ # This file is part of LaunchyOpenSearch.
4
+ #
5
+ # LaunchyOpenSearch is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require 'lib/launchy_opensearch'
19
+ require 'tempfile'
20
+
21
+ require 'rubygems'
22
+ require 'sys/uname'
23
+
24
+ # If there is a way to get the executable path of the currently running ruby
25
+ # interpreter, please tell me how.
26
+ warn 'Attention: If the ruby interpreter to be tested with is not ruby in the' +
27
+ 'default path, you have to change this manually in spec/breakverter_spec.rb'
28
+ RUBY_PATH = 'ruby'
29
+
30
+ module LaunchyOpenSearchSpecHelper
31
+ def windows?
32
+ Sys::Uname.sysname.downcase.include?('windows')
33
+ end
34
+
35
+ def info_youtube
36
+ {
37
+ :name => 'YouTube',
38
+ :base => 'http://www.youtube.com/',
39
+ :query => '"results?search_query=%s&search=Search"',
40
+ :default => 'false'
41
+ }
42
+ end
43
+
44
+ def info_discogs
45
+ {
46
+ :name => 'Discogs',
47
+ :base => 'http://www.discogs.com/',
48
+ :query => '"search?type=all&q=%s&btn=Search"',
49
+ :default => 'false'
50
+ }
51
+ end
52
+
53
+ def info_wikipedia
54
+ {
55
+ :name => 'SSL Wikipedia (English)',
56
+ :base => 'https://secure.wikimedia.org/',
57
+ :query => '"wikipedia/en/wiki/Special:Search?go=Go&search=%s"',
58
+ :default => 'false'
59
+ }
60
+ end
61
+ end
62
+
63
+ describe LaunchyOpenSearch do
64
+ include LaunchyOpenSearchSpecHelper
65
+
66
+ describe 'library' do
67
+ it "should be able to determine Launchy's config file path correctly" do
68
+ if windows?
69
+ path = File.join(ENV['APPDATA'], 'Launchy', 'Launchy.ini')
70
+ else
71
+ path = File.join(ENV['HOME'], '.launchy', 'launchy.ini')
72
+ end
73
+
74
+ LaunchyOpenSearch.launchy_config_path.should eql(path)
75
+ end
76
+
77
+ it "should be able to parse useful information out of OpenSearch XML documents" do
78
+ content = File.read('spec/fixtures/youtube.xml')
79
+ result = LaunchyOpenSearch.parse_opensearch(content)
80
+
81
+ result.should be_an_instance_of(Hash)
82
+
83
+ result[:name].should eql(info_youtube[:name])
84
+ result[:base].should eql(info_youtube[:base])
85
+ result[:query].should eql(info_youtube[:query])
86
+ result[:default].should eql(info_youtube[:default])
87
+ end
88
+
89
+ it "should be able to parse useful information out of OpenSearch XML document files" do
90
+ result = LaunchyOpenSearch.parse_opensearch_file('spec/fixtures/discogs.xml')
91
+
92
+ result.should be_an_instance_of(Hash)
93
+
94
+ result[:name].should eql(info_discogs[:name])
95
+ result[:base].should eql(info_discogs[:base])
96
+ result[:query].should eql(info_discogs[:query])
97
+ result[:default].should eql(info_discogs[:default])
98
+ end
99
+
100
+ it "should be able to parse useful information out of multiple OpenSearch XML document files" do
101
+ files = [
102
+ 'spec/fixtures/youtube.xml',
103
+ 'spec/fixtures/discogs.xml',
104
+ 'spec/fixtures/secure-wikipedia-english.xml'
105
+ ]
106
+
107
+ result = LaunchyOpenSearch.parse_opensearch_files(files)
108
+
109
+ result.should be_an_instance_of(Array)
110
+ result.should include(info_youtube)
111
+ result.should include(info_discogs)
112
+ result.should include(info_wikipedia)
113
+ end
114
+
115
+ it "should be able to read a Launchy configuration ini file" do
116
+ result = LaunchyOpenSearch.read_config_hash('spec/fixtures/launchy.ini')
117
+
118
+ result.should be_an_instance_of(Hash)
119
+
120
+ result.keys.sort.should eql(['General', 'GenOps', 'runner', 'weby'].sort)
121
+
122
+ result['General'].should have(2).items
123
+ result['General']['version'].should eql('212')
124
+
125
+ result['runner'].should have(5).items
126
+ result['runner']['cmds\\1\\file'].should eql('/usr/bin/xterm')
127
+
128
+ result['GenOps'].should have(1).items
129
+ result['GenOps']['skin'].should eql('/usr/share/launchy/skins/Default')
130
+
131
+ result['weby'].should have(45).items
132
+ result['weby']['sites\\size'].should eql('14')
133
+ result['weby']['sites\\6\\query'].should eql('"gp/search/?keywords=%s&index=blended"')
134
+ end
135
+
136
+ it "should be able to extract an array of engine hashes from a config file hash" do
137
+ config_hash = LaunchyOpenSearch.read_config_hash('spec/fixtures/launchy.ini')
138
+
139
+ result = LaunchyOpenSearch.extract_config_hash(config_hash)
140
+
141
+ result.should be_an_instance_of(Array)
142
+ result.should have(14).items
143
+
144
+ result.should include(:name => 'Live Search',
145
+ :base => 'http://search.live.com/',
146
+ :query => '"results.aspx?q=%s"')
147
+
148
+ result.should include(:name => 'Dictionary',
149
+ :base => 'http://www.dictionary.com/',
150
+ :query => 'browse/%s')
151
+ end
152
+
153
+ it "should be able to patch an array of engines with additional engines" do
154
+ config_hash = LaunchyOpenSearch.read_config_hash('spec/fixtures/launchy.ini')
155
+
156
+ engines = LaunchyOpenSearch.extract_config_hash(config_hash)
157
+ engines << info_discogs
158
+
159
+ lambda {
160
+ LaunchyOpenSearch.patch_config_hash(config_hash, engines)
161
+ }.should change{ config_hash['weby'].size }.from(45).to(49)
162
+
163
+ name_key = config_hash['weby'].find {|key, value| value == 'Discogs'}.first
164
+ name_key =~ /^.*\\(.*)\\.*$/
165
+
166
+ config_hash['weby']["sites\\#$1\\base"].should eql(info_discogs[:base])
167
+ config_hash['weby']["sites\\#$1\\query"].should eql(info_discogs[:query])
168
+ config_hash['weby']["sites\\#$1\\default"].should eql(info_discogs[:default])
169
+ end
170
+
171
+ it "should be able to write a config hash to ini file" do
172
+ temp_file = Tempfile.new('launchy_opensearch_spec')
173
+ location = temp_file.path
174
+ temp_file.close
175
+ temp_file.unlink
176
+
177
+ config_hash = LaunchyOpenSearch.read_config_hash('spec/fixtures/launchy.ini')
178
+
179
+ engines = LaunchyOpenSearch.extract_config_hash(config_hash)
180
+ engines << info_discogs
181
+
182
+ LaunchyOpenSearch.patch_config_hash(config_hash, engines)
183
+
184
+ LaunchyOpenSearch.write_config_hash(config_hash, location)
185
+ File.exist?(location).should be_true
186
+
187
+ LaunchyOpenSearch.read_config_hash(location)['weby'].sort.should eql(config_hash['weby'].sort)
188
+
189
+ File.unlink(location)
190
+ end
191
+ end
192
+
193
+ describe 'commandline tool' do
194
+ it "should be able add an engine from an OpenSearch XML file to Launchy's ini-file" do
195
+ temp_file = Tempfile.new('launchy_opensearch_spec')
196
+ location = temp_file.path
197
+ temp_file.close
198
+ temp_file.unlink
199
+
200
+ FileUtils.copy('spec/fixtures/launchy.ini', location)
201
+
202
+ lambda {
203
+ `#{RUBY_PATH} bin/launchy_opensearch -c #{location} spec/fixtures/discogs.xml`
204
+ }.should change{
205
+ LaunchyOpenSearch.read_config_hash(location)['weby']['sites\\size']
206
+ }.from('14').to('15')
207
+
208
+ File.unlink(location)
209
+ end
210
+
211
+ it "should be able replace current engines with an engine from an OpenSearch XML file" do
212
+ temp_file = Tempfile.new('launchy_opensearch_spec')
213
+ location = temp_file.path
214
+ temp_file.close
215
+ temp_file.unlink
216
+
217
+ FileUtils.copy('spec/fixtures/launchy.ini', location)
218
+
219
+ lambda {
220
+ `#{RUBY_PATH} bin/launchy_opensearch --mode replace -c #{location} spec/fixtures/discogs.xml`
221
+ }.should change{
222
+ LaunchyOpenSearch.read_config_hash(location)['weby']['sites\\size']
223
+ }.from('14').to('1')
224
+
225
+ File.unlink(location)
226
+ end
227
+
228
+ it "should be able to replace current engines with multiple engines from OpenSearch XML files" do
229
+ temp_file = Tempfile.new('launchy_opensearch_spec')
230
+ location = temp_file.path
231
+ temp_file.close
232
+ temp_file.unlink
233
+
234
+ FileUtils.copy('spec/fixtures/launchy.ini', location)
235
+
236
+ lambda {
237
+ `#{RUBY_PATH} bin/launchy_opensearch -m replace --config #{location} spec/fixtures/discogs.xml spec/fixtures/youtube.xml spec/fixtures/secure-wikipedia-english.xml`
238
+ }.should change{
239
+ LaunchyOpenSearch.read_config_hash(location)['weby']['sites\\size']
240
+ }.from('14').to('3')
241
+
242
+ File.unlink(location)
243
+ end
244
+ end
245
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: launchy_opensearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander E. Fischer
@@ -29,7 +29,7 @@ cert_chain:
29
29
  55akF+N8NbO6tpVDy6TMagqa10LfEpiQH6dvDHe/xdAqYOCrXKpmqzwu2PI=
30
30
  -----END CERTIFICATE-----
31
31
 
32
- date: 2009-02-25 00:00:00 +01:00
32
+ date: 2009-03-08 00:00:00 +01:00
33
33
  default_executable:
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
@@ -62,6 +62,16 @@ dependencies:
62
62
  - !ruby/object:Gem::Version
63
63
  version: "0"
64
64
  version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: user-choices
67
+ type: :development
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
65
75
  - !ruby/object:Gem::Dependency
66
76
  name: hoe
67
77
  type: :development
@@ -92,6 +102,11 @@ files:
92
102
  - Rakefile
93
103
  - bin/launchy_opensearch
94
104
  - lib/launchy_opensearch.rb
105
+ - spec/launchy_opensearch_spec.rb
106
+ - spec/fixtures/launchy.ini
107
+ - spec/fixtures/discogs.xml
108
+ - spec/fixtures/secure-wikipedia-english.xml
109
+ - spec/fixtures/youtube.xml
95
110
  has_rdoc: true
96
111
  homepage: "Project: https://rubyforge.org/projects/aef/"
97
112
  post_install_message:
@@ -119,5 +134,5 @@ rubygems_version: 1.3.1
119
134
  signing_key:
120
135
  specification_version: 2
121
136
  summary: This program allows to parse OpenSearch XML files and include them as search engines in the Weby plugin of the keystroke app launcher Launchy by editing Launchy's ini config file.
122
- test_files: []
123
-
137
+ test_files:
138
+ - spec/launchy_opensearch_spec.rb
metadata.gz.sig CHANGED
Binary file