nachos 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +23 -0
- data/Rakefile +53 -0
- data/bin/nachos +8 -0
- data/features/nachos.feature +29 -0
- data/features/step_definitions/nachos_steps.rb +49 -0
- data/features/support/env.rb +38 -0
- data/features/support/fakeweb/fakes.rb +2 -0
- data/lib/nachos/cli.rb +76 -0
- data/lib/nachos/github.rb +17 -0
- data/lib/nachos/main.rb +4 -0
- data/lib/nachos/version.rb +3 -0
- data/lib/nachos.rb +37 -0
- data/nachos.gemspec +83 -0
- data/spec/nachos/cli_spec.rb +52 -0
- data/spec/nachos/github_spec.rb +26 -0
- data/spec/nachos_spec.rb +4 -0
- data/spec/spec_helper.rb +27 -0
- metadata +168 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Rob Sanheim
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
= nachos
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Workflow
|
6
|
+
|
7
|
+
* watch a project on github
|
8
|
+
* run 'nachos sync'
|
9
|
+
* magic - it is now up to date in your local repo and ready to go
|
10
|
+
|
11
|
+
== Note on Patches/Pull Requests
|
12
|
+
|
13
|
+
* Fork the project.
|
14
|
+
* Make your feature addition or bug fix.
|
15
|
+
* Add tests for it. This is important so I don't break it in a
|
16
|
+
future version unintentionally.
|
17
|
+
* Commit, do not mess with rakefile, version, or history.
|
18
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
19
|
+
* Send me a pull request. Bonus points for topic branches.
|
20
|
+
|
21
|
+
== Copyright
|
22
|
+
|
23
|
+
Copyright (c) 2010 Rob Sanheim. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require File.join(File.dirname(__FILE__), *%w[lib nachos version])
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.version = Nachos::VERSION
|
8
|
+
gem.name = "nachos"
|
9
|
+
gem.summary = %Q{Nachos - sync and stuff with Github}
|
10
|
+
gem.description = %Q{Because everyone loves Nachos!}
|
11
|
+
gem.email = "rsanheim@gmail.com"
|
12
|
+
gem.homepage = "http://github.com/rsanheim/nachos"
|
13
|
+
gem.authors = ["Rob Sanheim"]
|
14
|
+
gem.add_dependency "octopussy"
|
15
|
+
# may want to vendor this...could conflict with the manual install folks
|
16
|
+
gem.add_dependency "git-hub"
|
17
|
+
gem.add_development_dependency "rspec", "~> 2.0.0.beta.12"
|
18
|
+
gem.add_development_dependency "faker"
|
19
|
+
gem.add_development_dependency "mocha"
|
20
|
+
gem.add_development_dependency "fakeweb"
|
21
|
+
end
|
22
|
+
Jeweler::GemcutterTasks.new
|
23
|
+
rescue LoadError
|
24
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
25
|
+
end
|
26
|
+
|
27
|
+
require 'rspec/core/rake_task'
|
28
|
+
|
29
|
+
RSpec::Core::RakeTask.new(:spec)
|
30
|
+
|
31
|
+
if RUBY_VERSION <= "1.8.7"
|
32
|
+
RSpec::Core::RakeTask.new(:coverage) do |spec|
|
33
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
34
|
+
spec.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,/Library/Ruby/*,config/*" --text-summary --sort coverage]
|
35
|
+
spec.rcov = true
|
36
|
+
end
|
37
|
+
else
|
38
|
+
task :coverage => :spec
|
39
|
+
end
|
40
|
+
|
41
|
+
task :spec => :check_dependencies
|
42
|
+
|
43
|
+
task :default => [:check_dependencies, :coverage]
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "nachos #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/bin/nachos
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
Feature: General diagnostic info
|
2
|
+
In order to something something
|
3
|
+
A user something something
|
4
|
+
something something something
|
5
|
+
|
6
|
+
Scenario: Displaying user info
|
7
|
+
Given I am locally configured for Github as "john-doe"
|
8
|
+
When I execute nachos "info"
|
9
|
+
Then I should see "You are running nachos as john-doe"
|
10
|
+
And the exit status should be 0
|
11
|
+
|
12
|
+
Scenario: Syncing watched repos
|
13
|
+
Given I am locally configured for Github as "john-doe"
|
14
|
+
And I have "3" watched repositories on Github
|
15
|
+
And I expect nachos to clone all watched repositories
|
16
|
+
When I execute nachos "sync"
|
17
|
+
Then the exit status should be 0
|
18
|
+
And the stdout should contain "About to sync 3 repositories"
|
19
|
+
|
20
|
+
@announce @wip
|
21
|
+
Scenario: Syncing watched repos when some are already cloned
|
22
|
+
Given I am locally configured for Github as "john-doe"
|
23
|
+
And I have a watched repo named "jdoe/twitter" that is cloned locally
|
24
|
+
And I have a watched repo named "rspec/rspec" that is not cloned locally
|
25
|
+
And I expect nachos to fetch "jdoe/twitter"
|
26
|
+
And I expect nachos to clone "rspec/rspec"
|
27
|
+
When I execute nachos "sync"
|
28
|
+
Then the exit status should be 0
|
29
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
Given /^I am locally configured for Github as "([^\"]*)"$/ do |username|
|
2
|
+
Helper.current_user = username
|
3
|
+
Nachos.any_instance.stubs(:github_user).returns(username)
|
4
|
+
Nachos.any_instance.stubs(:github_token).returns("some-valid-token")
|
5
|
+
end
|
6
|
+
|
7
|
+
When /^I execute nachos "([^"]*)"$/ do |args|
|
8
|
+
require 'stringio'
|
9
|
+
begin # emulating how Aruba works, so we can use the same matchers
|
10
|
+
Nachos.stdout, @original_stdout = StringIO.new, Nachos.stdout
|
11
|
+
nachos = Nachos.execute(args)
|
12
|
+
output = nachos.out
|
13
|
+
output.rewind
|
14
|
+
@last_stdout = output.read
|
15
|
+
# @last_stderr...
|
16
|
+
@last_exit_status = nachos.exit_code
|
17
|
+
rescue => e
|
18
|
+
p e; e.message
|
19
|
+
puts e.backtrace[0..10].join("\n")
|
20
|
+
ensure
|
21
|
+
Nachos.stdout = @original_stdout
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Given /^I have "([^\"]*)" watched repositories on Github$/ do |num_repos|
|
26
|
+
Helper.watched_repos = []
|
27
|
+
num_repos.to_i.times do |i|
|
28
|
+
Helper.watched_repos << {
|
29
|
+
"url" => "http://github.com/jnunemaker/twitter_#{i}",
|
30
|
+
"description" => "API wrapper for Twitter and Twitter Search API's",
|
31
|
+
"open_issues" => 7,
|
32
|
+
"homepage" => "http://twitter.rubyforge.org/",
|
33
|
+
"watchers" => 609,
|
34
|
+
"fork" => false,
|
35
|
+
"forks" => 120,
|
36
|
+
"private" => false,
|
37
|
+
"name" => "twitter_#{i}",
|
38
|
+
"owner" => "jnunemaker",
|
39
|
+
"pledgie" => 1193
|
40
|
+
}
|
41
|
+
end
|
42
|
+
body = { "repositories" => Helper.watched_repos }.to_json
|
43
|
+
url = "http://github.com/api/v2/json/repos/watched/#{Helper.current_user}?"
|
44
|
+
FakeWeb.register_uri(:get, url, :body => body)
|
45
|
+
end
|
46
|
+
|
47
|
+
Given /^I expect nachos to clone all watched repositories$/ do
|
48
|
+
Nachos.any_instance.stubs(:system).with(includes("git clone"))
|
49
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
+
require 'log_buddy'
|
3
|
+
require 'nachos'
|
4
|
+
require 'aruba'
|
5
|
+
require 'mocha'
|
6
|
+
require 'json'
|
7
|
+
require 'rspec/core'
|
8
|
+
|
9
|
+
Before do
|
10
|
+
bin_path = File.join(File.dirname(__FILE__), *%w[.. .. bin])
|
11
|
+
ENV["PATH"] = "#{ENV["PATH"]}:#{bin_path}"
|
12
|
+
system('which nachos > /dev/null') || abort('nachos not on the path - binary features will not work')
|
13
|
+
end
|
14
|
+
|
15
|
+
module ArubaOverrides
|
16
|
+
def detect_ruby_script(cmd)
|
17
|
+
if cmd =~ /^nachos/
|
18
|
+
"ruby -I../../lib -I./fakeweb -S ../../bin/#{cmd}"
|
19
|
+
else
|
20
|
+
super(cmd)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module Helper
|
26
|
+
extend self
|
27
|
+
attr_accessor :watched_repos
|
28
|
+
def current_user=(user)
|
29
|
+
@current_user = user
|
30
|
+
end
|
31
|
+
def current_user
|
32
|
+
@current_user || raise("No current user set")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
World(Mocha::API)
|
37
|
+
World(ArubaOverrides)
|
38
|
+
World(Helper)
|
data/lib/nachos/cli.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
class Nachos::CLI < Thor
|
2
|
+
|
3
|
+
LGHCONF = "http://github.com/guides/local-github-config"
|
4
|
+
GIT_CONFIG = Hash.new do |cache, cmd|
|
5
|
+
result = %x{git #{cmd}}.chomp
|
6
|
+
cache[cmd] = $?.success? && !result.empty? ? result : nil
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "info", "Displays current setup for Nachos"
|
10
|
+
def info
|
11
|
+
shell.say <<-EOL
|
12
|
+
You are running Nachos #{Nachos::VERSION} as #{github_user}.
|
13
|
+
#{github_summary}
|
14
|
+
Current configuration: #{config}
|
15
|
+
EOL
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "watched", "Display your watched repos on Github"
|
19
|
+
def watched
|
20
|
+
github.watched.each do |repo|
|
21
|
+
shell.say "#{repo.owner}/#{repo.name} - #{repo.description}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "sync", "Sync repositories"
|
26
|
+
def sync
|
27
|
+
repos = github.watched
|
28
|
+
shell.say "About to sync #{repos.size} repositories"
|
29
|
+
repos.each do |repo|
|
30
|
+
system Hub("clone #{repo.url}").command
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def github_summary
|
37
|
+
"You have #{github.watched.size} watched repos, and #{github.client.list_repos.size} owned repos."
|
38
|
+
end
|
39
|
+
|
40
|
+
def config
|
41
|
+
config_path.exist? ? load_config : "No config found - run nachos config to create one"
|
42
|
+
end
|
43
|
+
|
44
|
+
def config_path
|
45
|
+
Pathname(ENV["HOME"]).join(".nachos")
|
46
|
+
end
|
47
|
+
|
48
|
+
def load_config
|
49
|
+
YAML.load_file(config_path)
|
50
|
+
end
|
51
|
+
|
52
|
+
def github
|
53
|
+
@github ||= Nachos::Github.new(github_user, github_token)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Either returns the GitHub user as set by git-config(1) or aborts
|
57
|
+
# with an error message.
|
58
|
+
def github_user(fatal = true)
|
59
|
+
if user = GIT_CONFIG['config github.user']
|
60
|
+
user
|
61
|
+
elsif fatal
|
62
|
+
abort("** No GitHub user set. See #{LGHCONF}")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def github_token(fatal = true)
|
67
|
+
if token = GIT_CONFIG['config github.token']
|
68
|
+
token
|
69
|
+
elsif fatal
|
70
|
+
abort("** No GitHub token set. See #{LGHCONF}")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Nachos
|
2
|
+
|
3
|
+
class Github
|
4
|
+
attr_reader :client
|
5
|
+
|
6
|
+
def initialize(github_user, github_token)
|
7
|
+
@client = Octopussy::Client.new(:login => github_user, :token => github_token)
|
8
|
+
end
|
9
|
+
|
10
|
+
def watched
|
11
|
+
client.watched.sort_by do |repo|
|
12
|
+
[repo["owner"], repo["name"]].join("/")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/lib/nachos/main.rb
ADDED
data/lib/nachos.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "octopussy"
|
2
|
+
require "hub"
|
3
|
+
require "thor"
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
5
|
+
|
6
|
+
require 'nachos/version'
|
7
|
+
require 'nachos/cli'
|
8
|
+
require 'nachos/github'
|
9
|
+
|
10
|
+
class Nachos
|
11
|
+
|
12
|
+
attr_reader :args, :command
|
13
|
+
attr_accessor :out, :err, :exit_code
|
14
|
+
|
15
|
+
def initialize(*args)
|
16
|
+
@args = args
|
17
|
+
@command = args.first || "help"
|
18
|
+
@exit_code = 0
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.execute(*args)
|
22
|
+
new(*args).execute
|
23
|
+
end
|
24
|
+
|
25
|
+
def runner
|
26
|
+
@runner ||= Runner.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def execute
|
30
|
+
Nachos::CLI.start
|
31
|
+
exit 0
|
32
|
+
end
|
33
|
+
|
34
|
+
def Hub(args)
|
35
|
+
Hub::Runner.new(*args.split(' '))
|
36
|
+
end
|
37
|
+
end
|
data/nachos.gemspec
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{nachos}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Rob Sanheim"]
|
12
|
+
s.date = %q{2010-08-06}
|
13
|
+
s.default_executable = %q{nachos}
|
14
|
+
s.description = %q{Because everyone loves Nachos!}
|
15
|
+
s.email = %q{rsanheim@gmail.com}
|
16
|
+
s.executables = ["nachos"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"bin/nachos",
|
28
|
+
"features/nachos.feature",
|
29
|
+
"features/step_definitions/nachos_steps.rb",
|
30
|
+
"features/support/env.rb",
|
31
|
+
"features/support/fakeweb/fakes.rb",
|
32
|
+
"lib/nachos.rb",
|
33
|
+
"lib/nachos/cli.rb",
|
34
|
+
"lib/nachos/github.rb",
|
35
|
+
"lib/nachos/main.rb",
|
36
|
+
"lib/nachos/version.rb",
|
37
|
+
"nachos.gemspec",
|
38
|
+
"spec/nachos/cli_spec.rb",
|
39
|
+
"spec/nachos/github_spec.rb",
|
40
|
+
"spec/nachos_spec.rb",
|
41
|
+
"spec/spec_helper.rb"
|
42
|
+
]
|
43
|
+
s.homepage = %q{http://github.com/rsanheim/nachos}
|
44
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
45
|
+
s.require_paths = ["lib"]
|
46
|
+
s.rubygems_version = %q{1.3.7}
|
47
|
+
s.summary = %q{Nachos - sync and stuff with Github}
|
48
|
+
s.test_files = [
|
49
|
+
"spec/nachos/cli_spec.rb",
|
50
|
+
"spec/nachos/github_spec.rb",
|
51
|
+
"spec/nachos_spec.rb",
|
52
|
+
"spec/spec_helper.rb"
|
53
|
+
]
|
54
|
+
|
55
|
+
if s.respond_to? :specification_version then
|
56
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
57
|
+
s.specification_version = 3
|
58
|
+
|
59
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
60
|
+
s.add_runtime_dependency(%q<octopussy>, [">= 0"])
|
61
|
+
s.add_runtime_dependency(%q<git-hub>, [">= 0"])
|
62
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.0.0.beta.12"])
|
63
|
+
s.add_development_dependency(%q<faker>, [">= 0"])
|
64
|
+
s.add_development_dependency(%q<mocha>, [">= 0"])
|
65
|
+
s.add_development_dependency(%q<fakeweb>, [">= 0"])
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<octopussy>, [">= 0"])
|
68
|
+
s.add_dependency(%q<git-hub>, [">= 0"])
|
69
|
+
s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.12"])
|
70
|
+
s.add_dependency(%q<faker>, [">= 0"])
|
71
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
72
|
+
s.add_dependency(%q<fakeweb>, [">= 0"])
|
73
|
+
end
|
74
|
+
else
|
75
|
+
s.add_dependency(%q<octopussy>, [">= 0"])
|
76
|
+
s.add_dependency(%q<git-hub>, [">= 0"])
|
77
|
+
s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.12"])
|
78
|
+
s.add_dependency(%q<faker>, [">= 0"])
|
79
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
80
|
+
s.add_dependency(%q<fakeweb>, [">= 0"])
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Nachos::CLI do
|
4
|
+
it "works" do
|
5
|
+
Nachos::CLI.any_instance.stubs(:github_user).returns("johndoe")
|
6
|
+
watched_repos = []
|
7
|
+
names = %w[zaphod matt aaron]
|
8
|
+
3.to_i.times do |i|
|
9
|
+
watched_repos << {
|
10
|
+
"url" => "http://github.com/jnunemaker/twitter_#{i}",
|
11
|
+
"description" => "API wrapper for Twitter and Twitter Search API's",
|
12
|
+
"open_issues" => 7,
|
13
|
+
"homepage" => "http://twitter.rubyforge.org/",
|
14
|
+
"watchers" => 609,
|
15
|
+
"fork" => false,
|
16
|
+
"forks" => 120,
|
17
|
+
"private" => false,
|
18
|
+
"name" => "twitter_#{i}",
|
19
|
+
"owner" => names[i],
|
20
|
+
"pledgie" => 1193
|
21
|
+
}
|
22
|
+
end
|
23
|
+
body = { "repositories" => watched_repos }.to_json
|
24
|
+
url = "http://github.com/api/v2/json/repos/watched/johndoe?"
|
25
|
+
FakeWeb.register_uri(:get, url, :body => body)
|
26
|
+
|
27
|
+
Nachos::CLI.start(["watched"])
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "info" do
|
31
|
+
before do
|
32
|
+
Thor::Base.shell = FakeShell
|
33
|
+
end
|
34
|
+
|
35
|
+
it "loads config and displays it, if found" do
|
36
|
+
cli = Nachos::CLI.new
|
37
|
+
cli.stubs(:github_summary).returns("You have n repos...")
|
38
|
+
cli.stubs(:config_path).returns(mock(:exist? => true))
|
39
|
+
cli.stubs(:load_config).returns("config here")
|
40
|
+
cli.invoke(:info)
|
41
|
+
cli.shell.output.should include("Current configuration: config here")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "tells user there is no config yet" do
|
45
|
+
Thor::Base.shell = FakeShell
|
46
|
+
cli = Nachos::CLI.new
|
47
|
+
cli.stubs(:github_summary).returns("You have n repos...")
|
48
|
+
cli.invoke(:info)
|
49
|
+
cli.shell.output.should include("No config found - run nachos config to create one")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Nachos::CLI do
|
4
|
+
it "sorts watched repos" do
|
5
|
+
watched_repos = []
|
6
|
+
repos = %w[zaphod/beta zaphod/aardvark matt/foo aaron/baz]
|
7
|
+
repos.each do |repo|
|
8
|
+
owner, name = repo.split("/")
|
9
|
+
watched_repos << {
|
10
|
+
"url" => "http://github.com/#{repo}",
|
11
|
+
"name" => name,
|
12
|
+
"owner" => owner
|
13
|
+
}
|
14
|
+
end
|
15
|
+
body = { "repositories" => watched_repos }.to_json
|
16
|
+
url = "http://github.com/api/v2/json/repos/watched/johndoe?"
|
17
|
+
FakeWeb.register_uri(:get, url, :body => body)
|
18
|
+
|
19
|
+
github = Nachos::Github.new("johndoe", "token")
|
20
|
+
github.watched.map {|r| r["url"] }.should == %w[
|
21
|
+
http://github.com/aaron/baz
|
22
|
+
http://github.com/matt/foo
|
23
|
+
http://github.com/zaphod/aardvark
|
24
|
+
http://github.com/zaphod/beta]
|
25
|
+
end
|
26
|
+
end
|
data/spec/nachos_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'nachos'
|
4
|
+
require 'rspec'
|
5
|
+
require 'fakeweb'
|
6
|
+
require 'faker'
|
7
|
+
require 'json'
|
8
|
+
require 'log_buddy'
|
9
|
+
LogBuddy.init
|
10
|
+
|
11
|
+
FakeWeb.allow_net_connect = false
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.mock_with :mocha
|
15
|
+
config.formatter = :documentation
|
16
|
+
config.color_enabled = true
|
17
|
+
config.alias_example_to :fit, :focused => true
|
18
|
+
config.filter_run :options => { :focused => true }
|
19
|
+
config.run_all_when_everything_filtered = true
|
20
|
+
end
|
21
|
+
|
22
|
+
class FakeShell
|
23
|
+
attr_reader :output
|
24
|
+
def say(msg, *args)
|
25
|
+
(@output ||= "") << msg
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nachos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Rob Sanheim
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-08-06 00:00:00 -04:00
|
18
|
+
default_executable: nachos
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: octopussy
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: git-hub
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 2
|
56
|
+
- 0
|
57
|
+
- 0
|
58
|
+
- beta
|
59
|
+
- 12
|
60
|
+
version: 2.0.0.beta.12
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: faker
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
type: :development
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: mocha
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
type: :development
|
88
|
+
version_requirements: *id005
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: fakeweb
|
91
|
+
prerelease: false
|
92
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
segments:
|
98
|
+
- 0
|
99
|
+
version: "0"
|
100
|
+
type: :development
|
101
|
+
version_requirements: *id006
|
102
|
+
description: Because everyone loves Nachos!
|
103
|
+
email: rsanheim@gmail.com
|
104
|
+
executables:
|
105
|
+
- nachos
|
106
|
+
extensions: []
|
107
|
+
|
108
|
+
extra_rdoc_files:
|
109
|
+
- LICENSE
|
110
|
+
- README.rdoc
|
111
|
+
files:
|
112
|
+
- .document
|
113
|
+
- .gitignore
|
114
|
+
- LICENSE
|
115
|
+
- README.rdoc
|
116
|
+
- Rakefile
|
117
|
+
- bin/nachos
|
118
|
+
- features/nachos.feature
|
119
|
+
- features/step_definitions/nachos_steps.rb
|
120
|
+
- features/support/env.rb
|
121
|
+
- features/support/fakeweb/fakes.rb
|
122
|
+
- lib/nachos.rb
|
123
|
+
- lib/nachos/cli.rb
|
124
|
+
- lib/nachos/github.rb
|
125
|
+
- lib/nachos/main.rb
|
126
|
+
- lib/nachos/version.rb
|
127
|
+
- nachos.gemspec
|
128
|
+
- spec/nachos/cli_spec.rb
|
129
|
+
- spec/nachos/github_spec.rb
|
130
|
+
- spec/nachos_spec.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
has_rdoc: true
|
133
|
+
homepage: http://github.com/rsanheim/nachos
|
134
|
+
licenses: []
|
135
|
+
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options:
|
138
|
+
- --charset=UTF-8
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
segments:
|
147
|
+
- 0
|
148
|
+
version: "0"
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
segments:
|
155
|
+
- 0
|
156
|
+
version: "0"
|
157
|
+
requirements: []
|
158
|
+
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 1.3.7
|
161
|
+
signing_key:
|
162
|
+
specification_version: 3
|
163
|
+
summary: Nachos - sync and stuff with Github
|
164
|
+
test_files:
|
165
|
+
- spec/nachos/cli_spec.rb
|
166
|
+
- spec/nachos/github_spec.rb
|
167
|
+
- spec/nachos_spec.rb
|
168
|
+
- spec/spec_helper.rb
|