barkeep-client 0.1.5 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- barkeep-client (0.0.2)
4
+ barkeep-client (0.1.6)
5
5
  dedent (~> 0.0.2)
6
+ rest-client
6
7
  trollop (~> 1.16.2)
7
8
 
8
9
  GEM
9
10
  remote: http://rubygems.org/
10
11
  specs:
11
12
  dedent (0.0.2)
13
+ mime-types (1.17.2)
14
+ rest-client (1.6.7)
15
+ mime-types (>= 1.16)
12
16
  trollop (1.16.2)
13
17
 
14
18
  PLATFORMS
data/README.md CHANGED
@@ -3,4 +3,4 @@ Barkeep Client
3
3
 
4
4
  This is a commandline tool to make use of the Barkeep REST API.
5
5
 
6
- See usage instructions in the Barkeep readme.
6
+ See usage instructions in the Barkeep documentation.
@@ -21,4 +21,5 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.add_dependency "trollop", "~> 1.16.2"
23
23
  s.add_dependency "dedent", "~> 0.0.2"
24
+ s.add_dependency "rest-client"
24
25
  end
@@ -1,7 +1,7 @@
1
1
  require "rubygems"
2
2
  require "trollop"
3
3
  require "dedent"
4
- require "net/http"
4
+ require "rest_client"
5
5
  require "json"
6
6
 
7
7
  require "barkeep/constants"
@@ -29,7 +29,7 @@ module BarkeepClient
29
29
  end
30
30
 
31
31
  begin
32
- result = BarkeepClient.commits(configuration, repo, [sha])[sha]
32
+ result = BarkeepClient.commits(configuration, repo, [sha]).values[0]
33
33
  rescue RuntimeError => e
34
34
  puts e.message
35
35
  exit 1
@@ -55,21 +55,21 @@ module BarkeepClient
55
55
  end
56
56
 
57
57
  # Core method for calling Barkeep's commit API call.
58
- # TODO: Support querying lots of commits at once using the altered API call.
59
- def self.commits(configuration, repo, shas)
58
+ def self.commits(configuration, repo, shas, fields = [])
60
59
  result = {}
61
- shas.each do |sha|
62
- uri = URI.parse(File.join(configuration["barkeep_server"], "/api/commits/#{repo}/#{sha}"))
63
- begin
64
- response = Net::HTTP.get_response uri
65
- rescue SocketError
66
- raise "Cannot connect to the Barkeep server."
67
- end
68
- if response.code.to_i != 200
69
- error = JSON.parse(response.body)["message"] rescue nil
70
- raise error ? "Error: #{error}" : "Unspecified server error."
71
- end
72
- info = JSON.parse(response.body)
60
+ params = { :shas => shas.join(",") }
61
+ params[:fields] = fields.join(",") unless fields.empty?
62
+ begin
63
+ response = RestClient.post "http://#{configuration["barkeep_server"]}/api/commits/#{repo}", params
64
+ rescue SocketError
65
+ raise "Cannot connect to the Barkeep server at http:#{configuration["barkeep_server"]}."
66
+ end
67
+ if response.code != 200
68
+ error = JSON.parse(response.body)["message"] rescue nil
69
+ raise error ? "Error: #{error}" : "Unspecified server error."
70
+ end
71
+ commits = JSON.parse(response.body)
72
+ commits.each do |sha, info|
73
73
  commit_data = {}
74
74
  info.each do |key, value|
75
75
  next if value.nil?
@@ -23,6 +23,10 @@ module BarkeepClient
23
23
  REQUIRED_CONFIG_KEYS.join(', ')
24
24
  raise error
25
25
  end
26
+
27
+ # Tweak parameters for backwards compatibility:
28
+ configuration["barkeep_server"].sub! %r{^http://}, ""
29
+
26
30
  configuration
27
31
  end
28
32
  end
@@ -1,7 +1,6 @@
1
1
  require "rubygems"
2
2
  require "trollop"
3
3
  require "dedent"
4
- require "net/http"
5
4
  require "json"
6
5
 
7
6
  require "barkeep/constants"
@@ -41,7 +40,7 @@ module BarkeepClient
41
40
  if commits.empty?
42
41
  puts "No commits in range."
43
42
  exit 0
44
- elsif commits.size > 100
43
+ elsif commits.size > 1000
45
44
  puts "Warning: #{commits.size} commits in range. Lookup could be very slow. Proceed? [yN]"
46
45
  unless STDIN.gets.downcase.strip =~ /^y(es)?/
47
46
  puts "Aborting."
@@ -50,7 +49,7 @@ module BarkeepClient
50
49
  end
51
50
 
52
51
  begin
53
- commit_data = BarkeepClient.commits(configuration, repo, commits)
52
+ commit_data = BarkeepClient.commits(configuration, repo, commits, ["approved"])
54
53
  rescue RuntimeError => e
55
54
  puts e.message
56
55
  exit 1
@@ -1,3 +1,3 @@
1
1
  module BarkeepClient
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -26,7 +26,7 @@ module BarkeepClient
26
26
  end
27
27
 
28
28
  begin
29
- result = BarkeepClient.commits(configuration, repo, [sha])[sha]
29
+ result = BarkeepClient.commits(configuration, repo, [sha]).values[0]
30
30
  rescue RuntimeError => e
31
31
  puts e.message
32
32
  exit 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barkeep-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-26 00:00:00.000000000Z
12
+ date: 2012-05-21 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: trollop
16
- requirement: &11751060 !ruby/object:Gem::Requirement
16
+ requirement: &23208580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.16.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *11751060
24
+ version_requirements: *23208580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: dedent
27
- requirement: &11741280 !ruby/object:Gem::Requirement
27
+ requirement: &23201960 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,18 @@ dependencies:
32
32
  version: 0.0.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *11741280
35
+ version_requirements: *23201960
36
+ - !ruby/object:Gem::Dependency
37
+ name: rest-client
38
+ requirement: &23198240 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *23198240
36
47
  description: A command-line client for Barkeep's REST API.
37
48
  email:
38
49
  - caleb@ooyala.com
@@ -43,7 +54,6 @@ extra_rdoc_files: []
43
54
  files:
44
55
  - .gitignore
45
56
  - .rbenv-version
46
- - CHANGES.markdown
47
57
  - Gemfile
48
58
  - Gemfile.lock
49
59
  - README.md
@@ -1,15 +0,0 @@
1
- Barkeep Client Changes
2
- ======================
3
-
4
- This file summarizes changes between barkeep-client gem versions.
5
-
6
- 0.1.1
7
- -----
8
-
9
- * Make it easier to pass in arbitrary arguments to `git log` from the `unapproved` command using `--`.
10
-
11
-
12
- 0.1.0
13
- -----
14
-
15
- Initial version, including `commit` and `unapproved` commands.