microclimate 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c82b3c12bfd8f56bbe968938ed1294898673e3e
4
- data.tar.gz: c11a6efb39cba29627e5ead5c399f58e91d85fd8
3
+ metadata.gz: 5510abc29849c9ff332ebe48cfa16390e894cf0b
4
+ data.tar.gz: 6f38ba8ccec209d9526066449271b8f91a768cc3
5
5
  SHA512:
6
- metadata.gz: 029d06cf210d599427a513eda38f772416653762936bc6ab01fe86c39bda85505841aea941fd6d33f20d8d6fec0d6f4ed59bf06ab677a6ba9972efe7f6e65d95
7
- data.tar.gz: e683c537c2144f5b7d57b292dc26fddb13935610cb83bc0b84feb5543f42c85e087625b17efd4c6762e07a853b2b67810813bd7134c58444adf88d928758c8ee
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 # => {"gpa" => 2.31}
48
- repo.previous_snapshot # => {"gpa" => 2.25}
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
@@ -8,6 +8,10 @@ module Microclimate
8
8
  @data = data
9
9
  end
10
10
 
11
+ def finished_at
12
+ DateTime.new(data.finished_at)
13
+ end
14
+
11
15
  delegate :gpa => :data,
12
16
  :commit_sha => :data
13
17
  end
@@ -1,3 +1,3 @@
1
1
  module Microclimate
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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
@@ -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) { mock("client", :api_token => api_token) }
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 }
@@ -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.3
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-04-08 00:00:00.000000000 Z
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: '0'
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: '0'
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/microclimate/branch_spec.rb
165
- - spec/microclimate/client_spec.rb
166
- - spec/microclimate/repository_spec.rb
167
- - spec/microclimate/response_spec.rb
168
- - spec/microclimate/snapshot_spec.rb
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/microclimate/branch_spec.rb
196
- - spec/microclimate/client_spec.rb
197
- - spec/microclimate/repository_spec.rb
198
- - spec/microclimate/response_spec.rb
199
- - spec/microclimate/snapshot_spec.rb
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