bitbucket2 0.2.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 61e1dec5f46928d3064f538addecd150918700d2
4
+ data.tar.gz: 5525e48f84419947466a1d517baa628bf0f10b91
5
+ SHA512:
6
+ metadata.gz: f22d3178f94b79fc149e7f14639bba734662ab8c124e5868b85b23cb949557cf687a2b87ca001a036fda682fdd06ba518bea87416c8aeb5d9bbab3445887b5bc
7
+ data.tar.gz: 881d510105c1b4012c94fb5bf77df70d11d8d29fed3c57236259126813c273d4cd0c9f0a9a813e036fdd051e2adf1f8b8c99e2a52ad1c56e65a6b0a60a18ee92
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ defaults.yml
11
+ .byebug_history
12
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ bitbucket2
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.2.3
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ before_install: gem install bundler -v 1.10.5
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bitbucket2.gemspec
4
+ gem 'oauth2_rake', path: '../oauth2_rake'
5
+
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Fairfax Media
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # Bitbucket2
2
+
3
+ Bitbucket2 is a wrapper gem for the BitBucket API - exploiting the new (2.0) version, and support for OAuth2.
4
+
5
+ It leverages [Restroom](https://github.com/fairfaxmedia/bitbucket2) (a wrapper meta gem) which was built in parallel to Bitbucket2.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'bitbucket2'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install bitbucket2
22
+
23
+ ## Usage
24
+
25
+ Use the Bitbucket2::Client class to get all public repositories like this:
26
+
27
+ ```
28
+ Bitbucket2::Client.new.repositories.all
29
+ ```
30
+
31
+ To collect private data, pass an oauth_token into the constructor:
32
+ ```
33
+ Bitbucket2.configure do |config|
34
+ config.stack = -> (faraday) {
35
+ #faraday.use :http_cache, store: cache_store
36
+ faraday.request :oauth2, valid_oauth_token
37
+ faraday.response :logger
38
+ }
39
+ end
40
+
41
+ Bitbucket2::Client.new.repositories.all
42
+ ```
43
+
44
+ These tokens can be collected in a variety of ways - the Rakefile provides a number of tasks to facilitate this.
45
+
46
+ If you have client credentials for BitBucket's OAuth service, you can put them in `defaults.yml` like this:
47
+
48
+ ```
49
+ credentials:
50
+ key: <key>
51
+ secret: <secret>
52
+ ```
53
+
54
+ ...and then run `rake oauth` - you'll be guided through an authentication cycle and at the end your `defaults.yml` will have an access token in it.
55
+
56
+ `rake console` will then allow you to use that token in a prebuilt client object, via a helper method at `Bitbucket2.default_client`.
57
+
58
+ ## Development
59
+
60
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
61
+
62
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
63
+
64
+ ## Contributing
65
+
66
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fairfaxmedia/bitbucket2.
67
+
68
+
69
+ ## License
70
+
71
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ begin
5
+ require 'oauth2_rake'
6
+ rescue LoadError
7
+ end
8
+
9
+ RSpec::Core::RakeTask.new(:spec)
10
+
11
+ task :default => :spec
12
+
13
+
14
+ desc "Console task for quick setup"
15
+ task :console do
16
+ require 'irb'
17
+ require 'irb/completion'
18
+ require 'bitbucket2'
19
+
20
+ if defined? Oauth2Rake
21
+ defaults = Oauth2Rake::Configuration.new(
22
+ path: File.expand_path('defaults.yml', Dir.getwd),
23
+ site: 'https://bitbucket.org',
24
+ authorize_url: '/site/oauth2/authorize',
25
+ token_url: '/site/oauth2/access_token'
26
+ )
27
+
28
+ Bitbucket2.configure do |config|
29
+ config.stack = -> (faraday) {
30
+ #faraday.use :http_cache, store: cache_store
31
+ faraday.request :oauth2, defaults.refreshed_token
32
+ faraday.response :logger
33
+ }
34
+ end
35
+ end
36
+
37
+ ARGV.clear
38
+ IRB.start
39
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bitbucket2"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bitbucket2/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bitbucket2"
8
+ spec.version = Bitbucket2::VERSION
9
+ spec.authors = ["Simon Hildebrandt"]
10
+ spec.email = ["simon.hildebrandt@fairfaxmedia.com.au"]
11
+
12
+ spec.summary = %q{A simple wrapper gem around Bitbucket's 2.0 API.}
13
+ spec.description = %q{A simple wrapper gem around Bitbucket's 2.0 API.}
14
+ spec.homepage = "https://github.com/fairfaxmedia/bitbucket2"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+ spec.add_runtime_dependency "restroom"
22
+ spec.add_runtime_dependency 'virtus'
23
+ spec.add_runtime_dependency 'oauth2'
24
+ spec.add_runtime_dependency 'activemodel'
25
+ spec.add_runtime_dependency 'faraday_middleware'
26
+ spec.add_runtime_dependency 'faraday-http-cache'
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.10"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec"
31
+ spec.add_development_dependency "byebug"
32
+ spec.add_development_dependency "webmock"
33
+ end
@@ -0,0 +1,11 @@
1
+ require 'bitbucket2/model'
2
+ require 'bitbucket2/user'
3
+
4
+ module Bitbucket2
5
+ class Author
6
+ include Model
7
+
8
+ attribute :raw, String
9
+ attribute :user, User
10
+ end
11
+ end
@@ -0,0 +1,40 @@
1
+ require 'bitbucket2/commit'
2
+ require 'bitbucket2/repository'
3
+ require 'bitbucket2/pull_request'
4
+ require 'restroom'
5
+
6
+
7
+ module Bitbucket2
8
+ class Client
9
+ include Restroom
10
+
11
+ def initialize
12
+ end
13
+
14
+ def self.stack(config)
15
+ Bitbucket2.configuration.stack.call(config) if Bitbucket2.configuration.stack
16
+ end
17
+
18
+
19
+ restroom 'https://api.bitbucket.org', base_path: '2.0' do
20
+
21
+ response_filter lambda {|mode, response|
22
+ return response unless mode == :plural
23
+
24
+ begin
25
+ response.fetch('values')
26
+ rescue KeyError
27
+ raise Restroom::DataError, "Weird response: #{response[0..100]}"
28
+ end
29
+ }
30
+
31
+ exposes :repositories, model: Repository, id: :full_name do
32
+ exposes :pull_requests, resource: 'pullrequests', model: PullRequest do
33
+ exposes :commits, model: Commit, id: :hash
34
+ end
35
+ exposes :commits, model: Commit, id: :hash
36
+ exposes :commit, model: Commit, id: :hash
37
+ end
38
+ end.dump
39
+ end
40
+ end
@@ -0,0 +1,14 @@
1
+ require 'virtus'
2
+ require 'bitbucket2/author'
3
+ require 'bitbucket2/model'
4
+
5
+ module Bitbucket2
6
+ class Commit
7
+ include Model
8
+
9
+ attribute :hash, String
10
+ attribute :date, DateTime
11
+ attribute :message, String
12
+ attribute :author, Author
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ require 'virtus'
2
+ require 'active_model'
3
+
4
+ module Bitbucket2
5
+ module Model
6
+ def self.included(base)
7
+ base.include Virtus.model
8
+ base.include ActiveModel::Serializers::JSON
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'bitbucket2/model'
2
+
3
+ module Bitbucket2
4
+ class Participant
5
+ include Model
6
+
7
+ attribute :role, String
8
+ attribute :user, User
9
+ attribute :approved, Boolean
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ require 'bitbucket2/model'
2
+ require 'bitbucket2/user'
3
+ require 'bitbucket2/participant'
4
+
5
+ module Bitbucket2
6
+ class PullRequest
7
+ include Model
8
+
9
+ attribute :id, String
10
+ attribute :description, String
11
+ attribute :created_on, DateTime
12
+ attribute :author, User
13
+ attribute :reviewers, [User]
14
+ attribute :participants, [Participant]
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ require 'bitbucket2/model'
2
+
3
+ module Bitbucket2
4
+ class Repository
5
+ include Model
6
+
7
+ attribute :name, String
8
+ attribute :full_name, String
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require 'bitbucket2/model'
2
+
3
+ module Bitbucket2
4
+ class User
5
+ include Model
6
+
7
+ attribute :username, String
8
+ attribute :display_name, String
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module Bitbucket2
2
+ VERSION = "0.2.0"
3
+ end
data/lib/bitbucket2.rb ADDED
@@ -0,0 +1,17 @@
1
+ require "bitbucket2/version"
2
+ require 'bitbucket2/client'
3
+
4
+
5
+ module Bitbucket2
6
+ def self.configuration
7
+ @configuration ||= Configuration.new
8
+ end
9
+
10
+ def self.configure
11
+ yield self.configuration
12
+ end
13
+
14
+ class Configuration
15
+ attr_accessor :stack
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,220 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bitbucket2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Simon Hildebrandt
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: restroom
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: virtus
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: oauth2
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activemodel
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday_middleware
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
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: faraday-http-cache
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
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: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.10'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.10'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '10.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '10.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
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: byebug
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
+ - !ruby/object:Gem::Dependency
154
+ name: webmock
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description: A simple wrapper gem around Bitbucket's 2.0 API.
168
+ email:
169
+ - simon.hildebrandt@fairfaxmedia.com.au
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".rspec"
176
+ - ".ruby-gemset"
177
+ - ".ruby-version"
178
+ - ".travis.yml"
179
+ - Gemfile
180
+ - LICENSE.txt
181
+ - README.md
182
+ - Rakefile
183
+ - bin/console
184
+ - bin/setup
185
+ - bitbucket2.gemspec
186
+ - lib/bitbucket2.rb
187
+ - lib/bitbucket2/author.rb
188
+ - lib/bitbucket2/client.rb
189
+ - lib/bitbucket2/commit.rb
190
+ - lib/bitbucket2/model.rb
191
+ - lib/bitbucket2/participant.rb
192
+ - lib/bitbucket2/pull_request.rb
193
+ - lib/bitbucket2/repository.rb
194
+ - lib/bitbucket2/user.rb
195
+ - lib/bitbucket2/version.rb
196
+ homepage: https://github.com/fairfaxmedia/bitbucket2
197
+ licenses:
198
+ - MIT
199
+ metadata: {}
200
+ post_install_message:
201
+ rdoc_options: []
202
+ require_paths:
203
+ - lib
204
+ required_ruby_version: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ required_rubygems_version: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - ">="
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ requirements: []
215
+ rubyforge_project:
216
+ rubygems_version: 2.4.5.1
217
+ signing_key:
218
+ specification_version: 4
219
+ summary: A simple wrapper gem around Bitbucket's 2.0 API.
220
+ test_files: []