wfarr-github 0.4.1

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.
@@ -0,0 +1,165 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ require 'activerecord'
4
+
5
+ require File.dirname(__FILE__) + '/../lib/github'
6
+
7
+ class Module
8
+ def metaclass
9
+ class << self;self;end
10
+ end
11
+ end
12
+
13
+ class Spec::NextInstanceProxy
14
+ def initialize
15
+ @deferred = []
16
+ end
17
+
18
+ def method_missing(sym, *args)
19
+ proxy = Spec::NextInstanceProxy.new
20
+ @deferred << [sym, args, proxy]
21
+ proxy
22
+ end
23
+
24
+ def should_receive(*args)
25
+ method_missing(:should_receive, *args)
26
+ end
27
+ alias stub! should_receive
28
+
29
+ def invoke(obj)
30
+ @deferred.each do |(sym, args, proxy)|
31
+ result = obj.send(sym, *args)
32
+ proxy.invoke(result)
33
+ end
34
+ end
35
+ end
36
+
37
+ class Class
38
+ def next_instance
39
+ meth = metaclass.instance_method(:new)
40
+ proxy = Spec::NextInstanceProxy.new
41
+ metaclass.send :define_method, :new do |*args|
42
+ instance = meth.bind(self).call(*args)
43
+ proxy.invoke(instance)
44
+ metaclass.send :define_method, :new, meth
45
+ instance
46
+ end
47
+ proxy
48
+ end
49
+ end
50
+
51
+ module Spec::Example::ExampleGroupSubclassMethods
52
+ def add_guard(klass, name, is_class = false)
53
+ guarded = nil # define variable now for scoping
54
+ target = (is_class ? klass.metaclass : klass)
55
+ sep = (is_class ? "." : "#")
56
+ target.class_eval do
57
+ guarded = instance_method(name)
58
+ define_method name do |*args|
59
+ raise "Testing guards violated: Cannot call #{klass}#{sep}#{name} with args #{args.inspect}"
60
+ end
61
+ end
62
+ @guards ||= []
63
+ @guards << [klass, name, is_class, guarded]
64
+ end
65
+
66
+ def add_class_guard(klass, name)
67
+ add_guard(klass, name, true)
68
+ end
69
+
70
+ def unguard(klass, name, is_class = false)
71
+ row = @guards.find { |(k,n,i)| k == klass and n == name and i == is_class }
72
+ raise "#{klass}#{is_class ? "." : "#"}#{name} is not guarded" if row.nil?
73
+ (is_class ? klass.metaclass : klass).class_eval do
74
+ define_method name, row.last
75
+ end
76
+ @guards.delete row
77
+ end
78
+
79
+ def class_unguard(klass, name)
80
+ unguard(klass, name, true)
81
+ end
82
+
83
+ def unguard_all
84
+ @guards ||= []
85
+ @guards.each do |klass, name, is_class, guarded|
86
+ (is_class ? klass.metaclass : klass).class_eval do
87
+ define_method name, guarded
88
+ end
89
+ end
90
+ @guards.clear
91
+ end
92
+ end
93
+
94
+ # prevent the use of `` in tests
95
+ Spec::Runner.configure do |configuration|
96
+ # load this here so it's covered by the `` guard
97
+ configuration.prepend_before(:all) do
98
+ module GitHub
99
+ load 'helpers.rb'
100
+ load 'commands.rb'
101
+ load 'network.rb'
102
+ load 'issues.rb'
103
+ end
104
+ end
105
+
106
+ configuration.prepend_after(:each) do
107
+ GitHub.instance_variable_set :'@options', nil
108
+ GitHub.instance_variable_set :'@debug', nil
109
+ end
110
+
111
+ configuration.prepend_before(:all) do
112
+ self.class.send :include, Spec::Example::ExampleGroupSubclassMethods
113
+ end
114
+
115
+ configuration.prepend_before(:each) do
116
+ add_guard Kernel, :`
117
+ add_guard Kernel, :system
118
+ add_guard Kernel, :fork
119
+ add_guard Kernel, :exec
120
+ add_class_guard Process, :fork
121
+ end
122
+
123
+ configuration.append_after(:each) do
124
+ unguard_all
125
+ end
126
+ end
127
+
128
+ # include this in any example group that defines @helper
129
+ module SetupMethods
130
+ def setup_url_for(remote = "origin", user = nil, project = "project")
131
+ if user.nil?
132
+ user = remote
133
+ user = "user" if remote == "origin"
134
+ end
135
+ @helper.should_receive(:url_for).any_number_of_times.with(remote).and_return("git://github.com/#{user}/#{project}.git")
136
+ @helper.should_receive(:origin).any_number_of_times.and_return(remote.to_s)
137
+ end
138
+
139
+ def setup_user_and_branch(user = :user, branch = :master)
140
+ @helper.should_receive(:user_and_branch).any_number_of_times.and_return([user, branch])
141
+ end
142
+
143
+ def setup_github_token(user = 'drnic', token = 'MY_GITHUB_TOKEN')
144
+ @command.should_receive(:github_user).any_number_of_times.and_return(user)
145
+ @command.should_receive(:github_token).any_number_of_times.and_return(token)
146
+ end
147
+ end
148
+
149
+ # When running specs in TextMate, provide an rputs method to cleanly print objects into HTML display
150
+ # From http://talklikeaduck.denhaven2.com/2009/09/23/rspec-textmate-pro-tip
151
+ module Kernel
152
+ if ENV.keys.find {|env_var| env_var.index("TM_")}
153
+ def rputs(*args)
154
+ require 'cgi'
155
+ puts( *["<pre>", args.collect {|a| CGI.escapeHTML(a.to_s)}, "</pre>"])
156
+ end
157
+ def rp(*args)
158
+ require 'cgi'
159
+ puts( *["<pre>", args.collect {|a| CGI.escapeHTML(a.inspect)}, "</pre>"])
160
+ end
161
+ else
162
+ alias_method :rputs, :puts
163
+ alias_method :rp, :p
164
+ end
165
+ end
@@ -0,0 +1,38 @@
1
+ # this is an extremely hacky spec
2
+ # intended purely to test the Windoze-specific code
3
+
4
+ require 'rubygems'
5
+ require 'spec'
6
+
7
+ describe "github/command.rb" do
8
+ before(:all) do
9
+ @orig_platform = RUBY_PLATFORM
10
+ Object.send :remove_const, :RUBY_PLATFORM
11
+ Object.const_set :RUBY_PLATFORM, "mswin"
12
+ end
13
+
14
+ after(:all) do
15
+ Object.send :remove_const, :RUBY_PLATFORM
16
+ Object.const_set :RUBY_PLATFORM, @orig_platform
17
+ end
18
+
19
+ before(:each) do
20
+ @filename = File.dirname(__FILE__) + "/../lib/github/command.rb"
21
+ @data = File.read(@filename)
22
+ end
23
+
24
+ it "should require win32/open3 under Windows" do
25
+ mod = Module.new
26
+ mod.should_receive(:require).with("fileutils")
27
+ mod.should_receive(:require).with("win32/open3")
28
+ mod.class_eval @data, @filename
29
+ end
30
+
31
+ it "should blow up if win32/open3 isn't present under Windows" do
32
+ mod = Module.new
33
+ mod.should_receive(:require).with("fileutils")
34
+ mod.should_receive(:require).with("win32/open3").and_return { raise LoadError }
35
+ mod.should_receive(:warn).with("You must 'gem install win32-open3' to use the github command on Windows")
36
+ lambda { mod.class_eval @data, @filename }.should raise_error(SystemExit)
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wfarr-github
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris Wanstrath, Kevin Ballard, Scott Chacon, Dr Nic Williams
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-11 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: text-format
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.0
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: highline
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.5.1
34
+ version:
35
+ description: The official `github` command line helper for simplifying your GitHub experience.
36
+ email: chris@ozmm.org
37
+ executables:
38
+ - gh
39
+ - github
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - LICENSE
44
+ - README.md
45
+ - bin/gh
46
+ - bin/github
47
+ - lib/commands/commands.rb
48
+ - lib/commands/helpers.rb
49
+ - lib/commands/issues.rb
50
+ - lib/commands/network.rb
51
+ - lib/github.rb
52
+ - lib/github/command.rb
53
+ - lib/github/extensions.rb
54
+ - lib/github/helper.rb
55
+ - lib/github/ui.rb
56
+ files:
57
+ - History.txt
58
+ - LICENSE
59
+ - Manifest
60
+ - README.md
61
+ - Rakefile
62
+ - bin/gh
63
+ - bin/github
64
+ - lib/commands/commands.rb
65
+ - lib/commands/helpers.rb
66
+ - lib/commands/issues.rb
67
+ - lib/commands/network.rb
68
+ - lib/github.rb
69
+ - lib/github/command.rb
70
+ - lib/github/extensions.rb
71
+ - lib/github/helper.rb
72
+ - lib/github/ui.rb
73
+ - setup.rb
74
+ - spec/command_spec.rb
75
+ - spec/commands/command_browse_spec.rb
76
+ - spec/commands/command_clone_spec.rb
77
+ - spec/commands/command_create-from-local_spec.rb
78
+ - spec/commands/command_fetch_spec.rb
79
+ - spec/commands/command_fork_spec.rb
80
+ - spec/commands/command_helper.rb
81
+ - spec/commands/command_home_spec.rb
82
+ - spec/commands/command_info_spec.rb
83
+ - spec/commands/command_issues_spec.rb
84
+ - spec/commands/command_network_spec.rb
85
+ - spec/commands/command_pull-request_spec.rb
86
+ - spec/commands/command_pull_spec.rb
87
+ - spec/commands/command_search_spec.rb
88
+ - spec/commands/command_track_spec.rb
89
+ - spec/commands_spec.rb
90
+ - spec/extensions_spec.rb
91
+ - spec/github_spec.rb
92
+ - spec/helper_spec.rb
93
+ - spec/spec_helper.rb
94
+ - spec/windoze_spec.rb
95
+ - github.gemspec
96
+ has_rdoc: true
97
+ homepage: http://github.com/
98
+ post_install_message:
99
+ rdoc_options:
100
+ - --line-numbers
101
+ - --inline-source
102
+ - --title
103
+ - Github
104
+ - --main
105
+ - README.md
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: "0"
113
+ version:
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: "1.2"
119
+ version:
120
+ requirements: []
121
+
122
+ rubyforge_project: github
123
+ rubygems_version: 1.3.1
124
+ signing_key:
125
+ specification_version: 2
126
+ summary: The official `github` command line helper for simplifying your GitHub experience.
127
+ test_files: []
128
+