microclimate 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/README.md +4 -2
- data/lib/microclimate/repository.rb +2 -5
- data/lib/microclimate/snapshot.rb +4 -0
- data/lib/microclimate/version.rb +1 -1
- data/microclimate.gemspec +1 -1
- data/spec/features/repository_management_spec.rb +34 -0
- data/spec/{microclimate → lib/microclimate}/branch_spec.rb +0 -0
- data/spec/{microclimate → lib/microclimate}/client_spec.rb +0 -0
- data/spec/{microclimate → lib/microclimate}/repository_spec.rb +1 -1
- data/spec/{microclimate → lib/microclimate}/response_spec.rb +0 -0
- data/spec/{microclimate → lib/microclimate}/snapshot_spec.rb +9 -1
- metadata +18 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5510abc29849c9ff332ebe48cfa16390e894cf0b
|
4
|
+
data.tar.gz: 6f38ba8ccec209d9526066449271b8f91a768cc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1331fc319ca6918f3ea63346daef604e4eaf7353ee3eed0d13051e4c287cf6589fcf82cb723f370d707def5e98e365350951f7b77965ab9ceb7698be31bd768
|
7
|
+
data.tar.gz: 217ce40c151b9ac3e93366f05becefb7305673535e86795335149c1a8d02b65bc56b65dbfecf2a27951574bef5e7e75f66406bc208431c483713025bcc75e8b0
|
data/README.md
CHANGED
@@ -44,13 +44,15 @@ repo.refresh!
|
|
44
44
|
|
45
45
|
```ruby
|
46
46
|
repo.id # => "533329e76956801171001e7e"
|
47
|
-
repo.last_snapshot # =>
|
48
|
-
repo.
|
47
|
+
repo.last_snapshot.gpa # => 2.05
|
48
|
+
repo.last_snapshot.finished_at # => <DateTime>
|
49
|
+
repo.previous_snapshot.gpa # => 2.25
|
49
50
|
```
|
50
51
|
|
51
52
|
### Branches
|
52
53
|
|
53
54
|
```ruby
|
55
|
+
repo.branch_for("my_test_branch").refresh! # => kicks off a new analysis of the branch.
|
54
56
|
repo.branch_for("my_test_branch").last_snapshot # => {"gpa" => 2.40}
|
55
57
|
repo.branch_for("master").last_snapshot # => {"gpa" => 2.25}
|
56
58
|
```
|
@@ -15,8 +15,6 @@ module Microclimate
|
|
15
15
|
|
16
16
|
delegate :api_token => :client,
|
17
17
|
:id => :status,
|
18
|
-
:last_snapshot => :status,
|
19
|
-
:previous_snapshot => :status,
|
20
18
|
:gpa => :last_snapshot
|
21
19
|
|
22
20
|
# Force Code Climate to refresh this repository (at the master branch)
|
@@ -43,12 +41,9 @@ module Microclimate
|
|
43
41
|
"https://codeclimate.com/repos/#{repo_id}"
|
44
42
|
end
|
45
43
|
|
46
|
-
protected
|
47
|
-
|
48
44
|
def last_snapshot
|
49
45
|
snapshot = status.last_snapshot
|
50
46
|
return nil if snapshot.nil?
|
51
|
-
|
52
47
|
Snapshot.new(snapshot)
|
53
48
|
end
|
54
49
|
|
@@ -59,6 +54,8 @@ module Microclimate
|
|
59
54
|
Snapshot.new(snapshot)
|
60
55
|
end
|
61
56
|
|
57
|
+
protected
|
58
|
+
|
62
59
|
def resource_refresh_url
|
63
60
|
"#{resource_url}/refresh"
|
64
61
|
end
|
data/lib/microclimate/version.rb
CHANGED
data/microclimate.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
-
spec.add_development_dependency "rspec"
|
22
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
23
23
|
spec.add_development_dependency "guard"
|
24
24
|
spec.add_development_dependency "guard-rspec"
|
25
25
|
spec.add_development_dependency "webmock"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "repository management" do
|
4
|
+
before(:all) do
|
5
|
+
WebMock.allow_net_connect!
|
6
|
+
@repo_id = "533329e76956801171001e7e"
|
7
|
+
@client = Microclimate::Client.new :api_token => "321786539ec44cb4ae96b86e09209828416542fe"
|
8
|
+
@repo = @client.repository_for @repo_id
|
9
|
+
end
|
10
|
+
|
11
|
+
after :all do
|
12
|
+
WebMock.disable_net_connect!
|
13
|
+
end
|
14
|
+
|
15
|
+
it "gets the GPA of the repository" do
|
16
|
+
expect(@repo.id).to eq @repo_id
|
17
|
+
end
|
18
|
+
|
19
|
+
it "triggers a refresh of the repository" do
|
20
|
+
expect(@repo.refresh!).to eq true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "grabs the most recent snapshot" do
|
24
|
+
expect(@repo.last_snapshot).to be_a Microclimate::Snapshot
|
25
|
+
end
|
26
|
+
|
27
|
+
it "reports the GPA of a repo" do
|
28
|
+
expect(@repo.last_snapshot.gpa).to be_kind_of Float
|
29
|
+
end
|
30
|
+
|
31
|
+
it "reports the time of last snapshot completion" do
|
32
|
+
expect(@repo.last_snapshot.finished_at).to be_instance_of DateTime
|
33
|
+
end
|
34
|
+
end
|
File without changes
|
File without changes
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe Microclimate::Repository do
|
4
4
|
let(:repo_id) { "my_repo_id" }
|
5
5
|
let(:api_token) { "my_api_token" }
|
6
|
-
let(:client) {
|
6
|
+
let(:client) { double("client", :api_token => api_token) }
|
7
7
|
let(:url) { subject.host + "/api/repos/" + repo_id + "?api_token=" + api_token }
|
8
8
|
let(:gpa) { 2.25 }
|
9
9
|
let(:previous_gpa) { 2.50 }
|
File without changes
|
@@ -4,10 +4,12 @@ require "ostruct"
|
|
4
4
|
describe Microclimate::Snapshot do
|
5
5
|
let(:gpa) { 3.00 }
|
6
6
|
let(:sha) { "abcdef1234" }
|
7
|
+
let(:utc_seconds) { 1368165666 }
|
7
8
|
let(:data) do
|
8
9
|
json = {
|
9
10
|
:gpa => gpa,
|
10
|
-
:commit_sha => sha
|
11
|
+
:commit_sha => sha,
|
12
|
+
:finished_at => utc_seconds
|
11
13
|
}
|
12
14
|
OpenStruct.new(json)
|
13
15
|
end
|
@@ -24,4 +26,10 @@ describe Microclimate::Snapshot do
|
|
24
26
|
expect(subject.commit_sha).to eq sha
|
25
27
|
end
|
26
28
|
end
|
29
|
+
|
30
|
+
describe "#finished_at" do
|
31
|
+
it "returns a DateTime" do
|
32
|
+
expect(subject.finished_at).to be_instance_of DateTime
|
33
|
+
end
|
34
|
+
end
|
27
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: microclimate
|
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
|
- Andrew Hao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.1'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '3.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: guard
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -161,11 +161,12 @@ files:
|
|
161
161
|
- lib/microclimate/snapshot.rb
|
162
162
|
- lib/microclimate/version.rb
|
163
163
|
- microclimate.gemspec
|
164
|
-
- spec/
|
165
|
-
- spec/microclimate/
|
166
|
-
- spec/microclimate/
|
167
|
-
- spec/microclimate/
|
168
|
-
- spec/microclimate/
|
164
|
+
- spec/features/repository_management_spec.rb
|
165
|
+
- spec/lib/microclimate/branch_spec.rb
|
166
|
+
- spec/lib/microclimate/client_spec.rb
|
167
|
+
- spec/lib/microclimate/repository_spec.rb
|
168
|
+
- spec/lib/microclimate/response_spec.rb
|
169
|
+
- spec/lib/microclimate/snapshot_spec.rb
|
169
170
|
- spec/spec_helper.rb
|
170
171
|
homepage: ''
|
171
172
|
licenses:
|
@@ -192,9 +193,10 @@ signing_key:
|
|
192
193
|
specification_version: 4
|
193
194
|
summary: An API wrapper for the Code Climate API
|
194
195
|
test_files:
|
195
|
-
- spec/
|
196
|
-
- spec/microclimate/
|
197
|
-
- spec/microclimate/
|
198
|
-
- spec/microclimate/
|
199
|
-
- spec/microclimate/
|
196
|
+
- spec/features/repository_management_spec.rb
|
197
|
+
- spec/lib/microclimate/branch_spec.rb
|
198
|
+
- spec/lib/microclimate/client_spec.rb
|
199
|
+
- spec/lib/microclimate/repository_spec.rb
|
200
|
+
- spec/lib/microclimate/response_spec.rb
|
201
|
+
- spec/lib/microclimate/snapshot_spec.rb
|
200
202
|
- spec/spec_helper.rb
|