github-api-client 0.2.1.2 → 0.2.2
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/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/api-browser.rb +2 -3
- data/db/migrate/001_create_users.rb +1 -1
- data/db/migrate/002_create_user_followings.rb +1 -1
- data/db/migrate/003_create_repos.rb +1 -1
- data/db/migrate/004_create_repo_watchings.rb +1 -1
- data/db/migrate/005_create_organizations.rb +15 -0
- data/github-api-client.gemspec +4 -2
- data/lib/github-api-client.rb +8 -1
- data/lib/github-api-client/base.rb +6 -3
- data/lib/github-api-client/config.rb +32 -10
- data/lib/github-api-client/organization.rb +16 -0
- metadata +5 -4
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/api-browser.rb
CHANGED
@@ -3,12 +3,11 @@ $:.unshift('./lib/')
|
|
3
3
|
|
4
4
|
require 'github-api-client'
|
5
5
|
|
6
|
-
GitHub::Config::
|
6
|
+
puts GitHub::Config::Version
|
7
7
|
|
8
8
|
unless ARGV.include? 'test'
|
9
9
|
# Dev temporary code here
|
10
|
-
|
11
|
-
GitHub::User.get('schacon').fetch(:self, :followers, :followings)
|
10
|
+
p GitHub::Organization.get('github')
|
12
11
|
else # launches all-features code
|
13
12
|
# Performance tests
|
14
13
|
GitHub::Repo.get('mojombo/jekyll').fetch(:self, :watchers)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateOrganizations < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :organizations do |t|
|
4
|
+
%w(name company location blog type login email gravatar_id billing_email permission).each do |attr|
|
5
|
+
t.string attr
|
6
|
+
end
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table :organizations
|
14
|
+
end
|
15
|
+
end
|
data/github-api-client.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{github-api-client}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jakub Okoński"]
|
12
|
-
s.date = %q{2010-12-
|
12
|
+
s.date = %q{2010-12-23}
|
13
13
|
s.description = %q{Caches retrieved information to your user profile and reuses it when you query again.}
|
14
14
|
s.email = %q{kuba@okonski.org}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
"db/migrate/002_create_user_followings.rb",
|
30
30
|
"db/migrate/003_create_repos.rb",
|
31
31
|
"db/migrate/004_create_repo_watchings.rb",
|
32
|
+
"db/migrate/005_create_organizations.rb",
|
32
33
|
"features/github-api-client.feature",
|
33
34
|
"features/step_definitions/github-api-client_steps.rb",
|
34
35
|
"features/support/env.rb",
|
@@ -39,6 +40,7 @@ Gem::Specification.new do |s|
|
|
39
40
|
"lib/github-api-client/base.rb",
|
40
41
|
"lib/github-api-client/browser.rb",
|
41
42
|
"lib/github-api-client/config.rb",
|
43
|
+
"lib/github-api-client/organization.rb",
|
42
44
|
"lib/github-api-client/repo.rb",
|
43
45
|
"lib/github-api-client/user.rb",
|
44
46
|
"spec/github-api-client_spec.rb",
|
data/lib/github-api-client.rb
CHANGED
@@ -15,11 +15,18 @@ require 'core_ext/habtm'
|
|
15
15
|
require 'rainbow'
|
16
16
|
require 'github-api-client/config'
|
17
17
|
|
18
|
-
|
18
|
+
# This hard-coded if's will be soon replaced by Option Parser
|
19
|
+
GitHub::Config::Options[:verbose] = true if ARGV.include? '--verbose'
|
20
|
+
if ARGV.include? '--reset-db'
|
21
|
+
GitHub::Config.reset
|
22
|
+
else
|
23
|
+
GitHub::Config.setup
|
24
|
+
end
|
19
25
|
|
20
26
|
require 'github-api-client/base'
|
21
27
|
require 'github-api-client/user'
|
22
28
|
require 'github-api-client/repo'
|
29
|
+
require 'github-api-client/organization'
|
23
30
|
require 'github-api-client/browser'
|
24
31
|
|
25
32
|
unless $user = GitHub::User.where(GitHub::Config::Secrets).first
|
@@ -46,16 +46,19 @@ module GitHub
|
|
46
46
|
when :user_get then {:public_repo_count => :nil, :public_gist_count => :nil, :created => :nil, :permission => :nil, :followers_count => :nil, :following_count => :nil}
|
47
47
|
when :user_search then {:name => :login, :username => :login, :fullname => :name, :followers => :nil, :repos => :nil, :created => :nil, :permission => :nil}
|
48
48
|
when :repo_get then {:fork => :b_fork, :watchers => :nil}
|
49
|
+
when :org_get then {:public_gist_count => nil, :public_repo_count => nil, :following_count => :nil, :followers_count => :nil}
|
49
50
|
end
|
51
|
+
# Provides abstraction layer between YAML :keys and 'keys' returned by Hub
|
52
|
+
symbolized_resources = [:repo_get]
|
50
53
|
hash.each do |k, v|
|
51
|
-
unless v == :nil
|
52
|
-
if
|
54
|
+
unless v == :nil || v == nil
|
55
|
+
if symbolized_resources.include? resource
|
53
56
|
attributes[v.to_s] = attributes[k.to_sym]
|
54
57
|
else
|
55
58
|
attributes[v.to_s] = attributes[k.to_s]
|
56
59
|
end
|
57
60
|
end
|
58
|
-
if
|
61
|
+
if symbolized_resources.include? resource
|
59
62
|
attributes.delete k.to_sym
|
60
63
|
else
|
61
64
|
attributes.delete k.to_s
|
@@ -2,18 +2,26 @@ module GitHub
|
|
2
2
|
# Keeps all the configuration stuff
|
3
3
|
module Config
|
4
4
|
# Constant with defined all the paths used in the application
|
5
|
-
Path = {
|
5
|
+
Path = {
|
6
|
+
:dir => ENV['HOME'] + "/.github",
|
7
|
+
:dbfile => ENV['HOME'] + "/.github/github.db",
|
8
|
+
:migrations => Gem.loaded_specs['github-api-client'].full_gem_path + "/db/migrate",
|
9
|
+
:secrets => ENV['HOME'] + "/.github" + "/secrets.yml"
|
10
|
+
}
|
6
11
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
Version = File.read(Dir.pwd + "/VERSION")
|
11
|
-
end
|
12
|
+
Version = File.read(
|
13
|
+
Gem.loaded_specs['github-api-client'].full_gem_path + "/VERSION"
|
14
|
+
)
|
12
15
|
VERSION = Version
|
13
16
|
|
14
17
|
# Secrets array, uses env vars if defined
|
15
|
-
Secrets = {
|
18
|
+
Secrets = {
|
19
|
+
"login" => ENV['GITHUB_USER'],
|
20
|
+
"token" => ENV['GITHUB_TOKEN']
|
21
|
+
} if ENV['GITHUB_USER'] && ENV['GITHUB_TOKEN']
|
22
|
+
|
16
23
|
begin
|
24
|
+
# If not env vars, then ~/.github/secrets.yml
|
17
25
|
Secrets ||= YAML::load_file(GitHub::Config::Path[:secrets])['user']
|
18
26
|
rescue Errno::ENOENT
|
19
27
|
# Eye candy with rainbow
|
@@ -28,16 +36,30 @@ You have two ways of defining your user to have authenticated access to your API
|
|
28
36
|
|
29
37
|
report
|
30
38
|
end
|
39
|
+
|
31
40
|
Secrets ||= nil
|
32
41
|
|
33
|
-
Options = {
|
42
|
+
Options = {
|
43
|
+
:verbose => false
|
44
|
+
}
|
34
45
|
|
35
46
|
# Sets up the database and migrates it
|
36
47
|
# @return [nil]
|
37
48
|
def self.setup
|
38
49
|
Dir.mkdir GitHub::Config::Path[:dir] rescue nil
|
39
|
-
ActiveRecord::Base.establish_connection
|
40
|
-
|
50
|
+
ActiveRecord::Base.establish_connection(
|
51
|
+
:adapter => 'sqlite3',
|
52
|
+
:database => GitHub::Config::Path[:dbfile]
|
53
|
+
)
|
54
|
+
ActiveRecord::Migrator.migrate(
|
55
|
+
GitHub::Config::Path[:migrations],
|
56
|
+
nil
|
57
|
+
) if not File.exists? GitHub::Config::Path[:dbfile]
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.reset
|
61
|
+
system "rm #{Path[:dbfile]}"
|
62
|
+
setup
|
41
63
|
end
|
42
64
|
end
|
43
65
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module GitHub
|
2
|
+
class Organization < ActiveRecord::Base
|
3
|
+
def get
|
4
|
+
self.update_attributes(
|
5
|
+
GitHub::Base.parse_attributes(:org_get,
|
6
|
+
YAML::load(
|
7
|
+
GitHub::Browser.get("/organizations/#{self.login}"))['organization']))
|
8
|
+
self
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.get(login)
|
12
|
+
o = GitHub::Organization.find_by_login(login)
|
13
|
+
o ||= GitHub::Organization.new(:login => login).get
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -5,9 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
- 1
|
9
8
|
- 2
|
10
|
-
version: 0.2.
|
9
|
+
version: 0.2.2
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- "Jakub Oko\xC5\x84ski"
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-23 00:00:00 +01:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -325,6 +324,7 @@ files:
|
|
325
324
|
- db/migrate/002_create_user_followings.rb
|
326
325
|
- db/migrate/003_create_repos.rb
|
327
326
|
- db/migrate/004_create_repo_watchings.rb
|
327
|
+
- db/migrate/005_create_organizations.rb
|
328
328
|
- features/github-api-client.feature
|
329
329
|
- features/step_definitions/github-api-client_steps.rb
|
330
330
|
- features/support/env.rb
|
@@ -335,6 +335,7 @@ files:
|
|
335
335
|
- lib/github-api-client/base.rb
|
336
336
|
- lib/github-api-client/browser.rb
|
337
337
|
- lib/github-api-client/config.rb
|
338
|
+
- lib/github-api-client/organization.rb
|
338
339
|
- lib/github-api-client/repo.rb
|
339
340
|
- lib/github-api-client/user.rb
|
340
341
|
- spec/github-api-client_spec.rb
|
@@ -353,7 +354,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
353
354
|
requirements:
|
354
355
|
- - ">="
|
355
356
|
- !ruby/object:Gem::Version
|
356
|
-
hash:
|
357
|
+
hash: 2851051507290303259
|
357
358
|
segments:
|
358
359
|
- 0
|
359
360
|
version: "0"
|