git-layer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4cbb0bebca82b86ea11ae6a2eb66f7add11a64fe
4
+ data.tar.gz: a4b1f053eca049071b27b51e167108b31378cd82
5
+ SHA512:
6
+ metadata.gz: 2189a1024e11e10bebf4e3cec2f3678b6f351f3dd3b3d4071cf7a77d410099b68619d22514d955d1afacf817b9ae70e57953b22fde9f15889c6a67c57d7ae722
7
+ data.tar.gz: 1f7e8d6e44899a684a5b44e0239d690b201170a23d02c777f83dcac56c4b35e867038672370dddfe8a7e10d4e7981101f2e25d08387e191f3c9abc5d0a8c912d
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 2.8.0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.0"
12
+ gem "jeweler", "~> 1.8.7"
13
+ gem 'simplecov'
14
+ gem 'dotenv'
15
+ gem 'webmock'
16
+ gem 'rest-client'
17
+ gem 'json'
18
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,82 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.5)
5
+ builder (3.2.2)
6
+ crack (0.4.1)
7
+ safe_yaml (~> 0.9.0)
8
+ diff-lcs (1.1.3)
9
+ dotenv (0.9.0)
10
+ faraday (0.8.8)
11
+ multipart-post (~> 1.2.0)
12
+ git (1.2.6)
13
+ github_api (0.10.1)
14
+ addressable
15
+ faraday (~> 0.8.1)
16
+ hashie (>= 1.2)
17
+ multi_json (~> 1.4)
18
+ nokogiri (~> 1.5.2)
19
+ oauth2
20
+ hashie (2.0.5)
21
+ highline (1.6.19)
22
+ httpauth (0.2.0)
23
+ jeweler (1.8.7)
24
+ builder
25
+ bundler (~> 1.0)
26
+ git (>= 1.2.5)
27
+ github_api (= 0.10.1)
28
+ highline (>= 1.6.15)
29
+ nokogiri (= 1.5.10)
30
+ rake
31
+ rdoc
32
+ json (1.8.0)
33
+ jwt (0.1.8)
34
+ multi_json (>= 1.5)
35
+ mime-types (1.25)
36
+ multi_json (1.8.1)
37
+ multi_xml (0.5.5)
38
+ multipart-post (1.2.0)
39
+ nokogiri (1.5.10)
40
+ oauth2 (0.9.2)
41
+ faraday (~> 0.8)
42
+ httpauth (~> 0.2)
43
+ jwt (~> 0.1.4)
44
+ multi_json (~> 1.0)
45
+ multi_xml (~> 0.5)
46
+ rack (~> 1.2)
47
+ rack (1.5.2)
48
+ rake (10.1.0)
49
+ rdoc (3.12.2)
50
+ json (~> 1.4)
51
+ rest-client (1.6.7)
52
+ mime-types (>= 1.16)
53
+ rspec (2.8.0)
54
+ rspec-core (~> 2.8.0)
55
+ rspec-expectations (~> 2.8.0)
56
+ rspec-mocks (~> 2.8.0)
57
+ rspec-core (2.8.0)
58
+ rspec-expectations (2.8.0)
59
+ diff-lcs (~> 1.1.2)
60
+ rspec-mocks (2.8.0)
61
+ safe_yaml (0.9.7)
62
+ simplecov (0.7.1)
63
+ multi_json (~> 1.0)
64
+ simplecov-html (~> 0.7.1)
65
+ simplecov-html (0.7.1)
66
+ webmock (1.14.0)
67
+ addressable (>= 2.2.7)
68
+ crack (>= 0.3.2)
69
+
70
+ PLATFORMS
71
+ ruby
72
+
73
+ DEPENDENCIES
74
+ bundler (~> 1.0)
75
+ dotenv
76
+ jeweler (~> 1.8.7)
77
+ json
78
+ rdoc (~> 3.12)
79
+ rest-client
80
+ rspec (~> 2.8.0)
81
+ simplecov
82
+ webmock
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Theodore Cleveland
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,21 @@
1
+ {<img src="http://ga.bling.phillbaker.com/images/shield_imagined_ga_wdi.png" />}[https://generalassemb.ly/education/web-development-immersive]
2
+
3
+ = git-layer-gem
4
+
5
+ A lightweight wrapper for the Github API V3
6
+
7
+ == Contributing to git-layer
8
+
9
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
10
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
11
+ * Fork the project.
12
+ * Start a feature/bugfix branch.
13
+ * Commit and push until you are happy with your contribution.
14
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
15
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
16
+
17
+ == Copyright
18
+
19
+ Copyright (c) 2013 Theodore Cleveland. See LICENSE.txt for
20
+ further details.
21
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "git-layer"
18
+ gem.homepage = "http://github.com/tcclevela/git-layer"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A simple github api wrapper for my app}
21
+ gem.description = %Q{Just writing a gem to get user information through the github api}
22
+ gem.email = "tcclevela@gmail.com"
23
+ gem.authors = ["Theodore Cleveland"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "git-layer #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
data/lib/github.rb ADDED
@@ -0,0 +1,10 @@
1
+ require_relative 'github/client'
2
+
3
+ module Github
4
+
5
+ def new(options={})
6
+ Client.new(options)
7
+ end
8
+
9
+ module_function :new
10
+ end
@@ -0,0 +1,39 @@
1
+ require 'rest-client'
2
+
3
+ module Github
4
+ class Client
5
+
6
+
7
+ DEFAULT_OPTIONS = {
8
+ access_token: nil,
9
+ }
10
+
11
+ attr_accessor :options
12
+
13
+ def initialize(options={})
14
+ store_options options
15
+ check_token
16
+ end
17
+
18
+ def access_token
19
+ @options[:access_token]
20
+ end
21
+
22
+ def user
23
+ RestClient.get("https://api.github.com/user", {params: {:access_token => self.access_token}})
24
+ end
25
+
26
+
27
+ private
28
+
29
+ def store_options(options)
30
+ @options ||= DEFAULT_OPTIONS.dup
31
+ @options.merge!(options)
32
+ end
33
+
34
+ def check_token
35
+ raise ArgumentError, "No access token provided" if !access_token
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/helper')
2
+ require 'webmock/rspec'
3
+
4
+ describe "Github" do
5
+ it 'should return raise error if initialized without token' do
6
+ expect do
7
+ Github.new()
8
+ end.to raise_error(ArgumentError)
9
+ end
10
+
11
+ context 'after initialization with token' do
12
+ subject{Github.new(access_token: 'token')}
13
+ it 'should return the authentication token after initialization' do
14
+ subject.access_token.should eq('token')
15
+ end
16
+ it "should load the current user\'s information" do
17
+ stub_request(:get, "https://api.github.com/user?access_token=token")
18
+ .to_return(body: {user: {username: 'uname'}}, status: 200)
19
+ subject.user.should eq(user: {username: 'uname'})
20
+ end
21
+
22
+ end
23
+ end
data/spec/helper.rb ADDED
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'github'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,197 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git-layer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Theodore Cleveland
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 2.8.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 2.8.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '3.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '3.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jeweler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.7
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 1.8.7
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: dotenv
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rest-client
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: json
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: Just writing a gem to get user information through the github api
154
+ email: tcclevela@gmail.com
155
+ executables: []
156
+ extensions: []
157
+ extra_rdoc_files:
158
+ - LICENSE.txt
159
+ - README.rdoc
160
+ files:
161
+ - .document
162
+ - .rspec
163
+ - Gemfile
164
+ - Gemfile.lock
165
+ - LICENSE.txt
166
+ - README.rdoc
167
+ - Rakefile
168
+ - VERSION
169
+ - lib/github.rb
170
+ - lib/github/client.rb
171
+ - spec/git-layer_spec.rb
172
+ - spec/helper.rb
173
+ homepage: http://github.com/tcclevela/git-layer
174
+ licenses:
175
+ - MIT
176
+ metadata: {}
177
+ post_install_message:
178
+ rdoc_options: []
179
+ require_paths:
180
+ - lib
181
+ required_ruby_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - '>='
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ required_rubygems_version: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - '>='
189
+ - !ruby/object:Gem::Version
190
+ version: '0'
191
+ requirements: []
192
+ rubyforge_project:
193
+ rubygems_version: 2.0.3
194
+ signing_key:
195
+ specification_version: 4
196
+ summary: A simple github api wrapper for my app
197
+ test_files: []