launchy 0.3.2 → 0.3.3

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.
@@ -1,50 +1,50 @@
1
1
  require File.join(File.dirname(__FILE__),"spec_helper.rb")
2
2
  require 'stringio'
3
3
  describe Launchy::Browser do
4
- it "should find a path to a executable" do
5
- File.executable?(Launchy::Browser.new.browser).should == true
6
- end
7
-
8
- it "should handle an http url" do
9
- Launchy::Browser.handle?("http://www.example.com").should == true
10
- end
11
-
12
- it "should handle an https url" do
13
- Launchy::Browser.handle?("https://www.example.com").should == true
14
- end
15
-
16
- it "should handle an ftp url" do
17
- Launchy::Browser.handle?("ftp://download.example.com").should == true
18
- end
19
-
20
- it "should not handle a mailto url" do
21
- Launchy::Browser.handle?("mailto:jeremy@example.com").should == false
22
- end
23
-
24
- it "creates a default unix application list" do
25
- Launchy::Browser.new.nix_app_list.class.should == Array
26
- end
27
-
28
- it "can use environmental variable overrides for the browser" do
29
- { "BROWSER" => "/usr/bin/true",
30
- "LAUNCHY_BROWSER" => "/usr/bin/true"}.each_pair do |e,v|
31
- ENV[e] = v
32
- Launchy::Browser.new.browser.should == v
33
- ENV[e] = nil
34
- end
35
- end
36
-
37
- it "reports when it cannot find an browser" do
38
- old_error = $stderr
39
- $stderr = StringIO.new
40
- ENV["LAUNCHY_HOST_OS"] = "linux"
41
- begin
42
- browser = Launchy::Browser.new
43
- rescue => e
44
- e.message.should =~ /Unable to find browser to launch for os family/m
45
- end
46
- ENV["LAUNCHY_HOST_OS"] = nil
47
- $stderr.string.should =~ /Unable to launch. No Browser application found./m
48
- $stderr = old_error
49
- end
4
+ it "should find a path to a executable" do
5
+ File.executable?(Launchy::Browser.new.browser).should == true
6
+ end
7
+
8
+ it "should handle an http url" do
9
+ Launchy::Browser.handle?("http://www.example.com").should == true
10
+ end
11
+
12
+ it "should handle an https url" do
13
+ Launchy::Browser.handle?("https://www.example.com").should == true
14
+ end
15
+
16
+ it "should handle an ftp url" do
17
+ Launchy::Browser.handle?("ftp://download.example.com").should == true
18
+ end
19
+
20
+ it "should not handle a mailto url" do
21
+ Launchy::Browser.handle?("mailto:jeremy@example.com").should == false
22
+ end
23
+
24
+ it "creates a default unix application list" do
25
+ Launchy::Browser.new.nix_app_list.class.should == Array
26
+ end
27
+
28
+ { "BROWSER" => "/usr/bin/true",
29
+ "LAUNCHY_BROWSER" => "/usr/bin/true"}.each_pair do |e,v|
30
+ it "can use environmental variable overrides of #{e} for the browser" do
31
+ ENV[e] = v
32
+ Launchy::Browser.new.browser.should eql(v)
33
+ ENV[e] = nil
34
+ end
35
+ end
36
+
37
+ it "reports when it cannot find an browser" do
38
+ old_error = $stderr
39
+ $stderr = StringIO.new
40
+ ENV["LAUNCHY_HOST_OS"] = "linux"
41
+ begin
42
+ browser = Launchy::Browser.new
43
+ rescue => e
44
+ e.message.should =~ /Unable to find browser to launch for os family/m
45
+ end
46
+ ENV["LAUNCHY_HOST_OS"] = nil
47
+ $stderr.string.should =~ /Unable to launch. No Browser application found./m
48
+ $stderr = old_error
49
+ end
50
50
  end
@@ -2,17 +2,17 @@ require File.join(File.dirname(__FILE__),"spec_helper.rb")
2
2
  require 'stringio'
3
3
 
4
4
  describe Launchy do
5
- it "instantiates an instance of Launchy::CommandLine for commandline" do
6
- Launchy.command_line.class.should == Launchy::CommandLine
7
- end
8
-
9
- it "logs to stderr when LAUNCHY_DEBUG environment variable is set" do
10
- ENV["LAUNCHY_DEBUG"] = 'true'
11
- old_stderr = $stderr
12
- $stderr = StringIO.new
13
- Launchy.log "This is a test log message"
14
- $stderr.string.strip.should == "LAUNCHY_DEBUG: This is a test log message"
15
- $stderr = old_stderr
16
- ENV["LAUNCHY_DEBUG"] = nil
17
- end
5
+ it "instantiates an instance of Launchy::CommandLine for commandline" do
6
+ Launchy.command_line.class.should eql(Launchy::CommandLine)
7
+ end
8
+
9
+ it "logs to stderr when LAUNCHY_DEBUG environment variable is set" do
10
+ ENV["LAUNCHY_DEBUG"] = 'true'
11
+ old_stderr = $stderr
12
+ $stderr = StringIO.new
13
+ Launchy.log "This is a test log message"
14
+ $stderr.string.strip.should eql("LAUNCHY_DEBUG: This is a test log message")
15
+ $stderr = old_stderr
16
+ ENV["LAUNCHY_DEBUG"] = nil
17
+ end
18
18
  end
@@ -0,0 +1,15 @@
1
+ require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
2
+
3
+ require 'launchy/paths'
4
+
5
+ describe Launchy::Paths do
6
+ it "can access the root dir of the project" do
7
+ Launchy::Paths.root_dir.should == File.expand_path( File.join( File.dirname( __FILE__ ), ".." ) ) + ::File::SEPARATOR
8
+ end
9
+
10
+ %w[ lib ].each do |sub|
11
+ it "can access the #{sub} path of the project" do
12
+ Launchy::Paths.send("#{sub}_path" ).should == File.expand_path( File.join( File.dirname( __FILE__ ), "..", sub ) ) + ::File::SEPARATOR
13
+ end
14
+ end
15
+ end
@@ -2,10 +2,10 @@ require File.join(File.dirname(__FILE__),"spec_helper.rb")
2
2
  require 'yaml'
3
3
 
4
4
  describe "Launchy::VERSION" do
5
- it "should have 2 dots and have 3 numbers" do
6
- Launchy::VERSION.split('.').size.should == 3
7
- Launchy::Version.to_a.each do |n|
8
- n.to_i.should >= 0
9
- end
5
+ it "should have a #.#.# format" do
6
+ Launchy::VERSION.should =~ /\d+\.\d+\.\d+/
7
+ Launchy::Version.to_a.each do |n|
8
+ n.to_i.should >= 0
10
9
  end
11
- end
10
+ end
11
+ end
@@ -0,0 +1,39 @@
1
+ require 'tasks/config'
2
+ #-------------------------------------------------------------------------------
3
+ # announcement methods
4
+ #-------------------------------------------------------------------------------
5
+
6
+ proj_config = Configuration.for('project')
7
+ namespace :announce do
8
+ desc "create email for ruby-talk"
9
+ task :email do
10
+ info = Utils.announcement
11
+
12
+ File.open("email.txt", "w") do |mail|
13
+ mail.puts "From: #{proj_config.author} <#{proj_config.email}>"
14
+ mail.puts "To: ruby-talk@ruby-lang.org"
15
+ mail.puts "Date: #{Time.now.rfc2822}"
16
+ mail.puts "Subject: [ANN] #{info[:subject]}"
17
+ mail.puts
18
+ mail.puts info[:title]
19
+ mail.puts
20
+ mail.puts " gem install #{Launchy::GEM_SPEC.name}"
21
+ mail.puts
22
+ mail.puts info[:urls]
23
+ mail.puts
24
+ mail.puts info[:description]
25
+ mail.puts
26
+ mail.puts "{{ Release notes for Version #{Launchy::VERSION} }}"
27
+ mail.puts
28
+ mail.puts info[:release_notes]
29
+ mail.puts
30
+ end
31
+ puts "Created the following as email.txt:"
32
+ puts "-" * 72
33
+ puts File.read("email.txt")
34
+ puts "-" * 72
35
+ end
36
+
37
+ CLOBBER << "email.txt"
38
+ end
39
+
@@ -0,0 +1,107 @@
1
+ require 'configuration'
2
+
3
+ require 'rake'
4
+ require 'tasks/utils'
5
+
6
+ #-----------------------------------------------------------------------
7
+ # General project configuration
8
+ #-----------------------------------------------------------------------
9
+ Configuration.for('project') {
10
+ name "launchy"
11
+ version Launchy::Version.to_s
12
+ author "Jeremy Hinegardner"
13
+ email "jeremy at copiousfreetime dot org"
14
+ homepage "http://copiousfreetime.rubyforge.org/launchy/"
15
+ description Utils.section_of("README", "description")
16
+ summary description.split(".").first
17
+ history "HISTORY"
18
+ license FileList["LICENSE"]
19
+ readme "README"
20
+ }
21
+
22
+ #-----------------------------------------------------------------------
23
+ # Packaging
24
+ #-----------------------------------------------------------------------
25
+ Configuration.for('packaging') {
26
+ # files in the project
27
+ proj_conf = Configuration.for('project')
28
+ files {
29
+ bin FileList["bin/*"]
30
+ ext FileList["ext/*.{c,h,rb}"]
31
+ examples FileList["examples/*.rb"]
32
+ lib FileList["lib/**/*.rb"]
33
+ test FileList["spec/**/*.rb", "test/**/*.rb"]
34
+ data FileList["data/**/*"]
35
+ tasks FileList["tasks/**/*.r{ake,b}"]
36
+ rdoc FileList[proj_conf.readme, proj_conf.history,
37
+ proj_conf.license] + lib + FileList["ext/*.c"]
38
+ all bin + examples + ext + lib + test + data + rdoc + tasks + FileList["Rakefile"]
39
+ }
40
+
41
+ # ways to package the results
42
+ formats {
43
+ tgz true
44
+ zip true
45
+ rubygem Configuration::Table.has_key?('gem')
46
+ }
47
+ }
48
+
49
+ #-----------------------------------------------------------------------
50
+ # Gem packaging
51
+ #-----------------------------------------------------------------------
52
+ Configuration.for("gem") {
53
+ spec "gemspec.rb"
54
+ Configuration.for('packaging').files.all << spec
55
+ }
56
+
57
+ #-----------------------------------------------------------------------
58
+ # Testing
59
+ # - change mode to 'testunit' to use unit testing
60
+ #-----------------------------------------------------------------------
61
+ Configuration.for('test') {
62
+ mode "spec"
63
+ files Configuration.for("packaging").files.test
64
+ options %w[ --format specdoc --color ]
65
+ ruby_opts %w[ -w ]
66
+ }
67
+
68
+ #-----------------------------------------------------------------------
69
+ # Rcov
70
+ #-----------------------------------------------------------------------
71
+ Configuration.for('rcov') {
72
+ output_dir "coverage"
73
+ libs %w[ lib ]
74
+ rcov_opts %w[ --html ]
75
+ ruby_opts %w[ -w ]
76
+ test_files Configuration.for('packaging').files.test
77
+ }
78
+
79
+ #-----------------------------------------------------------------------
80
+ # Rdoc
81
+ #-----------------------------------------------------------------------
82
+ Configuration.for('rdoc') {
83
+ files Configuration.for('packaging').files.rdoc
84
+ main_page files.first
85
+ title Configuration.for('project').name
86
+ options %w[ --line-numbers --inline-source ]#-f darkfish ]
87
+ output_dir "doc"
88
+ }
89
+
90
+ #-----------------------------------------------------------------------
91
+ # Extension
92
+ #-----------------------------------------------------------------------
93
+ Configuration.for('extension') {
94
+ configs Configuration.for('packaging').files.ext.find_all { |x| %w[ mkrf_conf.rb extconf.rb ].include?(File.basename(x)) }
95
+ }
96
+
97
+ #-----------------------------------------------------------------------
98
+ # Rubyforge
99
+ #-----------------------------------------------------------------------
100
+ Configuration.for('rubyforge') {
101
+ project "copiousfreetime"
102
+ user "jjh"
103
+ host "rubyforge.org"
104
+ rdoc_location "#{user}@#{host}:/var/www/gforge-projects/#{project}/launchy"
105
+ }
106
+
107
+
@@ -0,0 +1,46 @@
1
+ require 'tasks/config'
2
+
3
+ #-------------------------------------------------------------------------------
4
+ # Distribution and Packaging
5
+ #-------------------------------------------------------------------------------
6
+ if pkg_config = Configuration.for_if_exist?("packaging") then
7
+
8
+ require 'gemspec'
9
+ require 'rake/gempackagetask'
10
+ require 'rake/contrib/sshpublisher'
11
+
12
+ namespace :dist do
13
+
14
+ Rake::GemPackageTask.new(Launchy::GEM_SPEC) do |pkg|
15
+ pkg.need_tar = pkg_config.formats.tgz
16
+ pkg.need_zip = pkg_config.formats.zip
17
+ end
18
+
19
+ desc "Install as a gem"
20
+ task :install => [:clobber, :package] do
21
+ sh "sudo gem install pkg/#{Launchy::GEM_SPEC.full_name}.gem"
22
+ end
23
+
24
+ desc "Uninstall gem"
25
+ task :uninstall do
26
+ sh "sudo gem uninstall -x #{Launchy::GEM_SPEC.name}"
27
+ end
28
+
29
+ desc "dump gemspec"
30
+ task :gemspec do
31
+ puts Launchy::GEM_SPEC.to_ruby
32
+ end
33
+
34
+ desc "reinstall gem"
35
+ task :reinstall => [:uninstall, :repackage, :install]
36
+
37
+ desc "distribute copiously"
38
+ task :copious => :package do
39
+ gems = Launchy::SPECS.collect { |s| "#{s.full_name}.gem" }
40
+ Rake::SshFilePublisher.new('jeremy@copiousfreetime.org',
41
+ '/var/www/vhosts/www.copiousfreetime.org/htdocs/gems/gems',
42
+ 'pkg', *gems).upload
43
+ sh "ssh jeremy@copiousfreetime.org rake -f /var/www/vhosts/www.copiousfreetime.org/htdocs/gems/Rakefile"
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,32 @@
1
+ require 'tasks/config'
2
+
3
+ #-----------------------------------------------------------------------
4
+ # Documentation
5
+ #-----------------------------------------------------------------------
6
+
7
+ if rdoc_config = Configuration.for_if_exist?('rdoc') then
8
+
9
+ namespace :doc do
10
+
11
+ require 'rdoc'
12
+ require 'rake/rdoctask'
13
+
14
+ # generating documentation locally
15
+ Rake::RDocTask.new do |rdoc|
16
+ rdoc.rdoc_dir = rdoc_config.output_dir
17
+ rdoc.options = rdoc_config.options
18
+ rdoc.rdoc_files = rdoc_config.files.sort
19
+ rdoc.title = rdoc_config.title
20
+ rdoc.main = rdoc_config.main_page
21
+ end
22
+
23
+ if rubyforge_config = Configuration.for_if_exist?('rubyforge') then
24
+ desc "Deploy the RDoc documentation to #{rubyforge_config.rdoc_location}"
25
+ task :deploy => :rerdoc do
26
+ sh "rsync -zav --delete #{rdoc_config.output_dir}/ #{rubyforge_config.rdoc_location}"
27
+ end
28
+ end
29
+
30
+ end
31
+ end
32
+
@@ -0,0 +1,29 @@
1
+
2
+ require 'tasks/config'
3
+
4
+ #--------------------------------------------------------------------------------
5
+ # configuration for running rspec. This shows up as the test:default task
6
+ #--------------------------------------------------------------------------------
7
+ if spec_config = Configuration.for_if_exist?("test") then
8
+ if spec_config.mode == "spec" then
9
+ namespace :test do
10
+
11
+ task :default => :spec
12
+
13
+ require 'spec/rake/spectask'
14
+ Spec::Rake::SpecTask.new do |r|
15
+ r.ruby_opts = spec_config.ruby_opts
16
+ r.libs = [ Launchy::Paths.lib_path,
17
+ Launchy::Paths.root_dir ]
18
+ r.spec_files = spec_config.files
19
+ r.spec_opts = spec_config.options
20
+
21
+ if rcov_config = Configuration.for_if_exist?('rcov') then
22
+ r.rcov = true
23
+ r.rcov_dir = rcov_config.output_dir
24
+ r.rcov_opts = rcov_config.rcov_opts
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,52 @@
1
+ require 'tasks/config'
2
+
3
+ #-----------------------------------------------------------------------
4
+ # Rubyforge additions to the task library
5
+ #-----------------------------------------------------------------------
6
+ if rf_conf = Configuration.for_if_exist?("rubyforge") then
7
+
8
+ abort("rubyforge gem not installed 'gem install rubyforge'") unless Utils.try_require('rubyforge')
9
+
10
+ proj_conf = Configuration.for('project')
11
+
12
+ namespace :dist do
13
+ desc "Release files to rubyforge"
14
+ task :rubyforge => [:clean, :package ] do
15
+
16
+ rubyforge = RubyForge.new
17
+
18
+ config = {}
19
+ config["release_notes"] = proj_conf.description
20
+ config["release_changes"] = Utils.release_notes_from(proj_conf.history)[Launchy::VERSION]
21
+ config["Prefomatted"] = true
22
+
23
+
24
+ rubyforge.configure config
25
+
26
+ # make sure this release doesn't already exist
27
+ releases = rubyforge.autoconfig['release_ids']
28
+ if releases.has_key?(Launchy::GEM_SPEC.name) and releases[Launchy::GEM_SPEC.name][Launchy::VERSION] then
29
+ abort("Release #{Launchy::VERSION} already exists! Unable to release.")
30
+ end
31
+
32
+ puts "Uploading to rubyforge..."
33
+ files = FileList[File.join("pkg","#{Launchy::GEM_SPEC.name}-#{Launchy::VERSION}*.*")].to_a
34
+ rubyforge.login
35
+ rubyforge.add_release(Launchy::GEM_SPEC.rubyforge_project, Launchy::GEM_SPEC.name, Launchy::VERSION, *files)
36
+ puts "done."
37
+ end
38
+ end
39
+
40
+ namespace :announce do
41
+ desc "Post news of #{proj_conf.name} to #{rf_conf.project} on rubyforge"
42
+ task :rubyforge do
43
+ info = Utils.announcement
44
+ rubyforge = RubyForge.new
45
+ rubyforge.configure
46
+ rubyforge.login
47
+ rubyforge.post_news(rf_conf.project, info[:subject], "#{info[:title]}\n\n#{info[:urls]}\n\n#{info[:release_notes]}")
48
+ puts "Posted to rubyforge"
49
+ end
50
+
51
+ end
52
+ end