Skip to content
This repository
Browse code

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

…with reduced functionality.
  • Loading branch information...
commit 67048556a30c6756d3301fd8ed4c34feebcf2ffe 1 parent 33354f2
Jonathan Lim authored June 18, 2008
2  Rakefile
@@ -11,7 +11,7 @@ begin
11 11
     p.url          = "http://github.com/"
12 12
     p.author       = ['Chris Wanstrath', 'Kevin Ballard']
13 13
     p.email        = "chris@ozmm.org"
14  
-    p.dependencies = ["launchy"]
  14
+    # p.dependencies = ["launchy"]
15 15
   end
16 16
 
17 17
 rescue LoadError => boom
5  commands/helpers.rb
@@ -106,5 +106,8 @@
106 106
 end
107 107
 
108 108
 helper :open do |url|
109  
-  Launchy::Browser.new.visit url
  109
+  has_launchy? do
  110
+    Launchy::Browser.new.visit url
  111
+  end
110 112
 end
  113
+
2  github-gem.gemspec
@@ -21,5 +21,5 @@ Gem::Specification.new do |s|
21 21
   s.rubygems_version = %q{1.1.1}
22 22
   s.summary = %q{The official `github` command line helper for simplifying your GitHub experience.}
23 23
 
24  
-  s.add_dependency(%q<launchy>, [">= 0"])
  24
+  # s.add_dependency(%q<launchy>, [">= 0"])
25 25
 end
13  lib/github.rb
@@ -3,7 +3,16 @@
3 3
 require 'github/command'
4 4
 require 'github/helper'
5 5
 require 'rubygems'
6  
-require 'launchy'
  6
+# require 'launchy'
  7
+
  8
+def has_launchy?(&blk)
  9
+  begin
  10
+    gem 'launchy'
  11
+    yield
  12
+  rescue Gem::LoadError
  13
+    $stderr.puts "Sorry, you need to install launchy: `gem install launchy`"
  14
+  end
  15
+end
7 16
 
8 17
 ##
9 18
 # Starting simple.
@@ -109,6 +118,8 @@ def debug(*messages)
109 118
   def debug?
110 119
     !!@debug
111 120
   end
  121
+  
  122
+
112 123
 end
113 124
 
114 125
 GitHub.command :default do
12  spec/helper_spec.rb
@@ -192,11 +192,13 @@ def self.helper(name, &block)
192 192
 
193 193
   helper :open do
194 194
     it "should launch the URL" do
195  
-      Launchy::Browser.next_instance.tap do |browser|
196  
-        browser.should_receive(:my_os_family).any_number_of_times.and_return :windows # avoid forking
197  
-        browser.should_receive(:system).with("/usr/bin/open http://www.google.com")
  195
+      has_launchy? do
  196
+        Launchy::Browser.next_instance.tap do |browser|
  197
+            browser.should_receive(:my_os_family).any_number_of_times.and_return :windows # avoid forking
  198
+            browser.should_receive(:system).with("/usr/bin/open http://www.google.com")
  199
+          end
  200
+        @helper.open "http://www.google.com"
198 201
       end
199  
-      @helper.open "http://www.google.com"
200 202
     end
201 203
   end
202  
-end
  204
+end
70  spec/spec_helper.rb
@@ -47,46 +47,50 @@ def next_instance
47 47
   end
48 48
 end
49 49
 
50  
-module Spec::Example::ExampleGroupSubclassMethods
51  
-  def add_guard(klass, name, is_class = false)
52  
-    guarded = nil # define variable now for scoping
53  
-    target = (is_class ? klass.metaclass : klass)
54  
-    sep = (is_class ? "." : "#")
55  
-    target.class_eval do
56  
-      guarded = instance_method(name)
57  
-      define_method name do |*args|
58  
-        raise "Testing guards violated: Cannot call #{klass}#{sep}#{name}"
  50
+module Spec
  51
+  module Example
  52
+    module ExampleGroupSubclassMethods
  53
+      def add_guard(klass, name, is_class = false)
  54
+        guarded = nil # define variable now for scoping
  55
+        target = (is_class ? klass.metaclass : klass)
  56
+        sep = (is_class ? "." : "#")
  57
+        target.class_eval do
  58
+          guarded = instance_method(name)
  59
+          define_method name do |*args|
  60
+            raise "Testing guards violated: Cannot call #{klass}#{sep}#{name}"
  61
+          end
  62
+        end
  63
+        @guards ||= []
  64
+        @guards << [klass, name, is_class, guarded]
59 65
       end
60  
-    end
61  
-    @guards ||= []
62  
-    @guards << [klass, name, is_class, guarded]
63  
-  end
64 66
 
65  
-  def add_class_guard(klass, name)
66  
-    add_guard(klass, name, true)
67  
-  end
  67
+      def add_class_guard(klass, name)
  68
+        add_guard(klass, name, true)
  69
+      end
68 70
 
69  
-  def unguard(klass, name, is_class = false)
70  
-    row = @guards.find { |(k,n,i)| k == klass and n == name and i == is_class }
71  
-    raise "#{klass}#{is_class ? "." : "#"}#{name} is not guarded" if row.nil?
72  
-    (is_class ? klass.metaclass : klass).class_eval do
73  
-      define_method name, row.last
74  
-    end
75  
-    @guards.delete row
76  
-  end
  71
+      def unguard(klass, name, is_class = false)
  72
+        row = @guards.find { |(k,n,i)| k == klass and n == name and i == is_class }
  73
+        raise "#{klass}#{is_class ? "." : "#"}#{name} is not guarded" if row.nil?
  74
+        (is_class ? klass.metaclass : klass).class_eval do
  75
+          define_method name, row.last
  76
+        end
  77
+        @guards.delete row
  78
+      end
77 79
 
78  
-  def class_unguard(klass, name)
79  
-    unguard(klass, name, true)
80  
-  end
  80
+      def class_unguard(klass, name)
  81
+        unguard(klass, name, true)
  82
+      end
81 83
 
82  
-  def unguard_all
83  
-    @guards ||= []
84  
-    @guards.each do |klass, name, is_class, guarded|
85  
-      (is_class ? klass.metaclass : klass).class_eval do
86  
-        define_method name, guarded
  84
+      def unguard_all
  85
+        @guards ||= []
  86
+        @guards.each do |klass, name, is_class, guarded|
  87
+          (is_class ? klass.metaclass : klass).class_eval do
  88
+            define_method name, guarded
  89
+          end
  90
+        end
  91
+        @guards.clear
87 92
       end
88 93
     end
89  
-    @guards.clear
90 94
   end
91 95
 end
92 96
 

0 notes on commit 6704855

Please sign in to comment.
Something went wrong with that request. Please try again.