badgerkit 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/badgerkit.gemspec +3 -1
- data/lib/badgerkit/archive.rb +33 -0
- data/lib/badgerkit/client.rb +4 -3
- data/lib/badgerkit/version.rb +1 -1
- data/lib/badgerkit.rb +12 -0
- data/spec/badgerkit/client_spec.rb +2 -2
- metadata +32 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e594cf55d638cf8ac0b7b0c7ecef5d6a9e346388
|
4
|
+
data.tar.gz: e3864260b4daba681705c18b6551cf93d80b0ae7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f055e1f3dad2e40a72bd1245ee23efc8b78af66858eba783aca0a9a93d592e7a7d4f3390129d2d95977ecccc5fe60f376865e8243ee6bf52cfb71b937c6d4d0
|
7
|
+
data.tar.gz: 74dff31d16f0bc8e06ade90d87bdbff6fc307ae2960404b03f22841b8b7378409c95b4577a0620feb19f2fe2475b70f199317b32be6224dcea9b869f62f89344
|
data/badgerkit.gemspec
CHANGED
@@ -23,6 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency 'coveralls'
|
24
24
|
spec.add_development_dependency 'rspec', '>= 2.3'
|
25
25
|
|
26
|
-
spec.add_dependency "
|
26
|
+
spec.add_dependency "httmultiparty"
|
27
27
|
spec.add_dependency "hashie"
|
28
|
+
spec.add_dependency 'rubyzip', '>= 1.0.0'
|
29
|
+
spec.add_dependency 'zip-zip'
|
28
30
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Badgerkit
|
2
|
+
class Archive
|
3
|
+
require 'rubygems'
|
4
|
+
require 'zip'
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
##
|
9
|
+
# Archives a directory.
|
10
|
+
#
|
11
|
+
# @param directory [String] the directory to zip.
|
12
|
+
# @return [File]
|
13
|
+
#
|
14
|
+
def archive(directory)
|
15
|
+
filename = "tmp/#{directory.split('/').last}.zip"
|
16
|
+
|
17
|
+
File.delete(filename) rescue nil # Make sure there's not already an archive
|
18
|
+
|
19
|
+
## Zip the direvory
|
20
|
+
Zip::File.open(filename, Zip::File::CREATE) do |zipfile|
|
21
|
+
Dir[File.join(directory, '**', '**')].each do |file|
|
22
|
+
zipfile.add(file.sub(directory, ''), file)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
## Return the newly archived directory
|
27
|
+
File.new(filename)
|
28
|
+
end
|
29
|
+
|
30
|
+
end # class << self
|
31
|
+
|
32
|
+
end # Archive
|
33
|
+
end # Badgerkit
|
data/lib/badgerkit/client.rb
CHANGED
@@ -3,12 +3,13 @@ module Badgerkit
|
|
3
3
|
# Responsible for constructing a client which is able to post values.
|
4
4
|
#
|
5
5
|
class Client
|
6
|
-
require '
|
6
|
+
require 'httmultiparty'
|
7
7
|
require 'hashie'
|
8
8
|
|
9
9
|
attr_reader :path, :access_token, :source, :repo
|
10
10
|
|
11
|
-
BASE_URI = 'http://badgerhq.com/'
|
11
|
+
#BASE_URI = 'http://badgerhq.com/'
|
12
|
+
BASE_URI = 'http://badger.dev/'
|
12
13
|
|
13
14
|
##
|
14
15
|
# Construct a new Badgekit::Client
|
@@ -61,7 +62,7 @@ module Badgerkit
|
|
61
62
|
#
|
62
63
|
def post(badge, attributes={})
|
63
64
|
attributes = { :value => attributes, :access_token => access_token }
|
64
|
-
response =
|
65
|
+
response = HTTMultiParty.post("#{BASE_URI}#{path_for(badge)}", :body => attributes).parsed_response
|
65
66
|
response = Hashie::Mash.new(response)
|
66
67
|
end
|
67
68
|
|
data/lib/badgerkit/version.rb
CHANGED
data/lib/badgerkit.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "badgerkit/version"
|
2
2
|
require "badgerkit/client"
|
3
|
+
require "badgerkit/archive"
|
3
4
|
|
4
5
|
module Badgerkit
|
5
6
|
|
@@ -7,6 +8,7 @@ module Badgerkit
|
|
7
8
|
|
8
9
|
class << self
|
9
10
|
|
11
|
+
##
|
10
12
|
# Alias for Badgerkit::Client.new
|
11
13
|
#
|
12
14
|
# @return [Badgerkit::Client]
|
@@ -23,6 +25,16 @@ module Badgerkit
|
|
23
25
|
new.post(*args)
|
24
26
|
end
|
25
27
|
|
28
|
+
##
|
29
|
+
# Alias for {Badgerkit::Archive.archive}.
|
30
|
+
#
|
31
|
+
# @param directory [String] the directory to archive.
|
32
|
+
# @return [File]
|
33
|
+
#
|
34
|
+
def archive(directory)
|
35
|
+
Badgerkit::Archive.archive(directory)
|
36
|
+
end
|
37
|
+
|
26
38
|
end # class << self
|
27
39
|
|
28
40
|
end # Badgerkit
|
@@ -39,8 +39,8 @@ describe Badgerkit::Client do
|
|
39
39
|
:repo => 'saladdays/badgerkit.rb',
|
40
40
|
)
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
HTTMultiParty.stub(:post).and_return(HTTPartyProxy.new)
|
43
|
+
HTTMultiParty.should_receive(:post).with("http://badgerhq.com/github/saladdays/badgerkit.rb/Documentation",
|
44
44
|
:body => {
|
45
45
|
:value => {
|
46
46
|
:value => 90,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: badgerkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johan van Zonneveld
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: httmultiparty
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -94,6 +94,34 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubyzip
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.0.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.0.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: zip-zip
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
97
125
|
description: Write a description
|
98
126
|
email:
|
99
127
|
- johan@vzonneveld.nl
|
@@ -109,6 +137,7 @@ files:
|
|
109
137
|
- Rakefile
|
110
138
|
- badgerkit.gemspec
|
111
139
|
- lib/badgerkit.rb
|
140
|
+
- lib/badgerkit/archive.rb
|
112
141
|
- lib/badgerkit/client.rb
|
113
142
|
- lib/badgerkit/version.rb
|
114
143
|
- spec/badgerkit/client_spec.rb
|