github-watched 0.0.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.
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/Rakefile +2 -0
- data/bin/github-watched +9 -0
- data/github-watched.gemspec +20 -0
- data/lib/github-watched/api.rb +42 -0
- data/lib/github-watched/config.rb +10 -0
- data/lib/github-watched/version.rb +3 -0
- data/lib/github-watched.rb +6 -0
- metadata +83 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bin/github-watched
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), "/../lib"))
|
4
|
+
require 'github-watched'
|
5
|
+
|
6
|
+
user = GitHubWatched::API::User.new(GitHubWatched::Config.github_username)
|
7
|
+
user.watched.each do |repo|
|
8
|
+
puts "#{repo.html_url} #{repo.description}"
|
9
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/github-watched/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Jason Weathered"]
|
6
|
+
gem.email = ["jason@jasoncodes.com"]
|
7
|
+
gem.summary = %q{List all watched GitHub repositories}
|
8
|
+
gem.homepage = "https://github.com/jasoncodes/github-watched"
|
9
|
+
|
10
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
11
|
+
gem.files = `git ls-files`.split("\n")
|
12
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
|
+
gem.name = "github-watched"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = GitHubWatched::VERSION
|
16
|
+
|
17
|
+
gem.add_dependency 'octocat_herder', '>= 0.1.2'
|
18
|
+
|
19
|
+
gem.add_development_dependency 'rake'
|
20
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'octocat_herder'
|
2
|
+
|
3
|
+
module GitHubWatched::API
|
4
|
+
class Base
|
5
|
+
def connection
|
6
|
+
@connection ||= OctocatHerder::Connection.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def list(end_point, options = {})
|
10
|
+
paginated = options.delete(:paginated)
|
11
|
+
klass = options.delete(:klass)
|
12
|
+
options[:params] ||= {}
|
13
|
+
options[:params][:per_page] ||= 100
|
14
|
+
|
15
|
+
Enumerator.new do |y|
|
16
|
+
begin
|
17
|
+
result = connection.raw_get(end_point, options)
|
18
|
+
raise "Unable to retrieve #{end_point}" unless result
|
19
|
+
|
20
|
+
result.parsed_response.each do |item|
|
21
|
+
item = klass.new(item, connection) if klass
|
22
|
+
y << item
|
23
|
+
end
|
24
|
+
|
25
|
+
options[:params][:page] = paginated && connection.page_from_headers(result.headers, 'next')
|
26
|
+
end while options[:params][:page]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class User < Base
|
32
|
+
attr_accessor :username
|
33
|
+
|
34
|
+
def initialize(username)
|
35
|
+
@username = username
|
36
|
+
end
|
37
|
+
|
38
|
+
def watched
|
39
|
+
list "/users/#{CGI.escape(username)}/watched", :paginated => true, :klass => OctocatHerder::Repository
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module GitHubWatched::Config
|
2
|
+
def self.git_config(name)
|
3
|
+
value = `git config --get #{name}`.chomp
|
4
|
+
value if $?.success?
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.github_username
|
8
|
+
git_config('github.user') or raise 'GitHub username not set. Use `git config --global github.user username` to set.'
|
9
|
+
end
|
10
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: github-watched
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jason Weathered
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-23 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: octocat_herder
|
16
|
+
requirement: &70104811996880 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.1.2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70104811996880
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &70104811995160 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70104811995160
|
36
|
+
description:
|
37
|
+
email:
|
38
|
+
- jason@jasoncodes.com
|
39
|
+
executables:
|
40
|
+
- github-watched
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- Gemfile
|
46
|
+
- Rakefile
|
47
|
+
- bin/github-watched
|
48
|
+
- github-watched.gemspec
|
49
|
+
- lib/github-watched.rb
|
50
|
+
- lib/github-watched/api.rb
|
51
|
+
- lib/github-watched/config.rb
|
52
|
+
- lib/github-watched/version.rb
|
53
|
+
homepage: https://github.com/jasoncodes/github-watched
|
54
|
+
licenses: []
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
hash: -3746219070733408078
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
hash: -3746219070733408078
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.8.11
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: List all watched GitHub repositories
|
83
|
+
test_files: []
|