Permalink
Browse files

Removing requirement for launchy. It will enable installation of gem …

…with reduced functionality.
  • Loading branch information...
1 parent 33354f2 commit 67048556a30c6756d3301fd8ed4c34feebcf2ffe @snowblink snowblink committed Jun 18, 2008
Showing with 62 additions and 42 deletions.
  1. +1 −1 Rakefile
  2. +4 −1 commands/helpers.rb
  3. +1 −1 github-gem.gemspec
  4. +12 −1 lib/github.rb
  5. +7 −5 spec/helper_spec.rb
  6. +37 −33 spec/spec_helper.rb
View
2 Rakefile
@@ -11,7 +11,7 @@ begin
p.url = "http://github.com/"
p.author = ['Chris Wanstrath', 'Kevin Ballard']
p.email = "chris@ozmm.org"
- p.dependencies = ["launchy"]
+ # p.dependencies = ["launchy"]
end
rescue LoadError => boom
View
5 commands/helpers.rb
@@ -106,5 +106,8 @@
end
helper :open do |url|
- Launchy::Browser.new.visit url
+ has_launchy? do
+ Launchy::Browser.new.visit url
+ end
end
+
View
2 github-gem.gemspec
@@ -21,5 +21,5 @@ Gem::Specification.new do |s|
s.rubygems_version = %q{1.1.1}
s.summary = %q{The official `github` command line helper for simplifying your GitHub experience.}
- s.add_dependency(%q<launchy>, [">= 0"])
+ # s.add_dependency(%q<launchy>, [">= 0"])
end
View
13 lib/github.rb
@@ -3,7 +3,16 @@
require 'github/command'
require 'github/helper'
require 'rubygems'
-require 'launchy'
+# require 'launchy'
+
+def has_launchy?(&blk)
+ begin
+ gem 'launchy'
+ yield
+ rescue Gem::LoadError
+ $stderr.puts "Sorry, you need to install launchy: `gem install launchy`"
+ end
+end
##
# Starting simple.
@@ -109,6 +118,8 @@ def debug(*messages)
def debug?
!!@debug
end
+
+
end
GitHub.command :default do
View
12 spec/helper_spec.rb
@@ -192,11 +192,13 @@ def self.helper(name, &block)
helper :open do
it "should launch the URL" do
- Launchy::Browser.next_instance.tap do |browser|
- browser.should_receive(:my_os_family).any_number_of_times.and_return :windows # avoid forking
- browser.should_receive(:system).with("/usr/bin/open http://www.google.com")
+ has_launchy? do
+ Launchy::Browser.next_instance.tap do |browser|
+ browser.should_receive(:my_os_family).any_number_of_times.and_return :windows # avoid forking
+ browser.should_receive(:system).with("/usr/bin/open http://www.google.com")
+ end
+ @helper.open "http://www.google.com"
end
- @helper.open "http://www.google.com"
end
end
-end
+end
View
70 spec/spec_helper.rb
@@ -47,46 +47,50 @@ def next_instance
end
end
-module Spec::Example::ExampleGroupSubclassMethods
- def add_guard(klass, name, is_class = false)
- guarded = nil # define variable now for scoping
- target = (is_class ? klass.metaclass : klass)
- sep = (is_class ? "." : "#")
- target.class_eval do
- guarded = instance_method(name)
- define_method name do |*args|
- raise "Testing guards violated: Cannot call #{klass}#{sep}#{name}"
+module Spec
+ module Example
+ module ExampleGroupSubclassMethods
+ def add_guard(klass, name, is_class = false)
+ guarded = nil # define variable now for scoping
+ target = (is_class ? klass.metaclass : klass)
+ sep = (is_class ? "." : "#")
+ target.class_eval do
+ guarded = instance_method(name)
+ define_method name do |*args|
+ raise "Testing guards violated: Cannot call #{klass}#{sep}#{name}"
+ end
+ end
+ @guards ||= []
+ @guards << [klass, name, is_class, guarded]
end
- end
- @guards ||= []
- @guards << [klass, name, is_class, guarded]
- end
- def add_class_guard(klass, name)
- add_guard(klass, name, true)
- end
+ def add_class_guard(klass, name)
+ add_guard(klass, name, true)
+ end
- def unguard(klass, name, is_class = false)
- row = @guards.find { |(k,n,i)| k == klass and n == name and i == is_class }
- raise "#{klass}#{is_class ? "." : "#"}#{name} is not guarded" if row.nil?
- (is_class ? klass.metaclass : klass).class_eval do
- define_method name, row.last
- end
- @guards.delete row
- end
+ def unguard(klass, name, is_class = false)
+ row = @guards.find { |(k,n,i)| k == klass and n == name and i == is_class }
+ raise "#{klass}#{is_class ? "." : "#"}#{name} is not guarded" if row.nil?
+ (is_class ? klass.metaclass : klass).class_eval do
+ define_method name, row.last
+ end
+ @guards.delete row
+ end
- def class_unguard(klass, name)
- unguard(klass, name, true)
- end
+ def class_unguard(klass, name)
+ unguard(klass, name, true)
+ end
- def unguard_all
- @guards ||= []
- @guards.each do |klass, name, is_class, guarded|
- (is_class ? klass.metaclass : klass).class_eval do
- define_method name, guarded
+ def unguard_all
+ @guards ||= []
+ @guards.each do |klass, name, is_class, guarded|
+ (is_class ? klass.metaclass : klass).class_eval do
+ define_method name, guarded
+ end
+ end
+ @guards.clear
end
end
- @guards.clear
end
end

0 comments on commit 6704855

Please sign in to comment.