Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get browsers and platforms for a gauge.
- Loading branch information
Showing
5 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class Twelve | ||
|
||
# API module encapsulates all of the API endpoints | ||
# | ||
module API | ||
|
||
# The Gauges module handles Gauges on Gauges | ||
# | ||
module Gauges | ||
|
||
# The Technology module handles accessing browsers and platforms | ||
# | ||
module Technology | ||
|
||
# Returns monthly browsers and platforms for a gauge | ||
# | ||
# date - String of date | ||
# | ||
# Returns json | ||
# | ||
def technology(date=nil) | ||
attributes = {} | ||
|
||
connection.get do |request| | ||
request.url "#{path_prefix}/technology" | ||
request.params['date'] = date if date && date.is_a?(String) | ||
end.body | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require 'spec_helper' | ||
|
||
describe Twelve::API::Gauges::Technology do | ||
subject { Twelve.new(ACCESS_TOKEN) } | ||
|
||
describe "#technology" do | ||
context "with no args" do | ||
it "should return top technology" do | ||
VCR.use_cassette('technology') do | ||
response = subject.gauges(GAUGE_ID).technology | ||
response['date'].should_not be_nil | ||
response.should have_key('urls') | ||
|
||
browsers = response['browsers'] | ||
browsers.first['title'].should_not be_nil | ||
browsers.first['views'].should be_instance_of(Fixnum) | ||
browsers.first['versions'].size.should > 0 | ||
browsers.first['key'].should_not be_nil | ||
platforms = response['platforms'] | ||
platforms.first['title'].should_not be_nil | ||
platforms.first['views'].should be_instance_of(Fixnum) | ||
platforms.first['key'].should_not be_nil | ||
end | ||
end | ||
end | ||
|
||
context "with a date" do | ||
it "should return technology for that date" do | ||
VCR.use_cassette('technology("2011-12-8")') do | ||
response = subject.gauges(GAUGE_ID).technology('2011-12-8') | ||
response['date'].should == '2011-12-08' | ||
end | ||
end | ||
end | ||
end | ||
end |