startupstats 0.0.5 → 0.0.6
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.
- data/.gitignore +1 -0
- data/.rvmrc +1 -1
- data/lib/startupstats.rb +24 -0
- data/lib/startupstats/configurable.rb +2 -2
- data/lib/startupstats/countdb/client.rb +30 -0
- data/lib/startupstats/countdb/counts.rb +92 -0
- data/lib/startupstats/countdb/models/count.rb +7 -0
- data/lib/startupstats/error/params_error.rb +9 -0
- data/lib/startupstats/formd/filings.rb +2 -2
- data/lib/startupstats/response/api_result.rb +38 -1
- data/lib/startupstats/version.rb +1 -1
- data/spec/api_result_spec.rb +71 -0
- data/spec/countdb/client_spec.rb +27 -0
- data/spec/countdb/count_spec.rb +13 -0
- data/spec/countdb/counts_spec.rb +136 -0
- data/spec/factories.rb +33 -0
- data/spec/formd/filings_spec.rb +1 -0
- data/spec/spec_helper.rb +6 -1
- data/spec/support/vcr_support.rb +2 -5
- metadata +15 -3
data/.gitignore
CHANGED
data/.rvmrc
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
7
|
# Only full ruby name is supported here, for short names use:
|
8
8
|
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
-
environment_id="ruby-1.9.3-
|
9
|
+
environment_id="ruby-1.9.3-p327@startupstats-client"
|
10
10
|
|
11
11
|
# Uncomment the following lines if you want to verify rvm version per project
|
12
12
|
# rvmrc_rvm_version="1.14.12 ()" # 1.10.1 seams as a safe start
|
data/lib/startupstats.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "startupstats/version"
|
2
2
|
require "startupstats/configurable"
|
3
3
|
require "startupstats/formd/client"
|
4
|
+
require "startupstats/countdb/client"
|
4
5
|
#Dir[File.dirname(__FILE__) + '/startupstats/formd/*'].each {|file| require file }
|
5
6
|
|
6
7
|
module StartupStats
|
@@ -28,4 +29,27 @@ module StartupStats
|
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
32
|
+
module Countdb
|
33
|
+
class << self
|
34
|
+
include StartupStats::Configurable
|
35
|
+
|
36
|
+
# Delegate to a StartupStats::Countdb::Client
|
37
|
+
#
|
38
|
+
# @return [StartupStats::Countdb::Client]
|
39
|
+
def client
|
40
|
+
@client = StartupStats::Countdb::Client.new(options) unless defined?(@client) && @client.cache_key == options.hash
|
41
|
+
@client
|
42
|
+
end
|
43
|
+
|
44
|
+
def respond_to_missing?(method_name, include_private=false); client.respond_to?(method_name, include_private); end if RUBY_VERSION >= "1.9"
|
45
|
+
def respond_to?(method_name, include_private=false); client.respond_to?(method_name, include_private) || super; end if RUBY_VERSION < "1.9"
|
46
|
+
|
47
|
+
private
|
48
|
+
def method_missing(method_name, *args, &block)
|
49
|
+
return super unless client.respond_to?(method_name)
|
50
|
+
client.send(method_name, *args, &block)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
31
55
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'startupstats/default'
|
2
2
|
module StartupStats
|
3
3
|
module Configurable
|
4
|
-
attr_writer :access_token
|
5
|
-
attr_accessor :endpoint, :connection_options, :middleware
|
4
|
+
attr_writer :access_token
|
5
|
+
attr_accessor :endpoint, :connection_options, :middleware, :access_token_key
|
6
6
|
|
7
7
|
class << self
|
8
8
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'startupstats/configurable'
|
2
|
+
require 'startupstats/requestable'
|
3
|
+
require 'startupstats/countdb/counts'
|
4
|
+
require 'startupstats/error/client_error'
|
5
|
+
require 'startupstats/error/decode_error'
|
6
|
+
require 'startupstats/error/params_error'
|
7
|
+
|
8
|
+
module StartupStats
|
9
|
+
module Countdb
|
10
|
+
class Client #< StartupStats::Client
|
11
|
+
attr_accessor :db_id
|
12
|
+
# StartupStats client modules
|
13
|
+
include StartupStats::Configurable
|
14
|
+
include StartupStats::Requestable
|
15
|
+
|
16
|
+
# Countdb modules
|
17
|
+
include StartupStats::Countdb::Counts
|
18
|
+
|
19
|
+
def initialize( options = {} )
|
20
|
+
# raise StartupStats::Error::ParamsError unless options.has_key?(:db_id) && options[:db_id].match(/^\w+$/)
|
21
|
+
@db_id = ( options.has_key?(:db_id) ) ? options[:db_id] : nil
|
22
|
+
setup
|
23
|
+
@access_token_key = 'token'
|
24
|
+
StartupStats::Configurable.keys.each do |key|
|
25
|
+
instance_variable_set(:"@#{key}", options[key] || instance_variable_get(:"@#{key}"))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'startupstats/countdb/models/count'
|
2
|
+
require 'startupstats/response/api_result'
|
3
|
+
module StartupStats
|
4
|
+
module Countdb
|
5
|
+
module Counts
|
6
|
+
# Increments the value for a key
|
7
|
+
#
|
8
|
+
# @raise [StartupStats::Error::ParamsError] Error raised when inaccurate values
|
9
|
+
# @param key [String]
|
10
|
+
# @param count [Integer]
|
11
|
+
# @return [Boolean] Whether or not the request was successful
|
12
|
+
def increment_key( key , count )
|
13
|
+
raise StartupStats::Error::ParamsError unless key.to_s =~ /^[^\s]+$/ && count.to_s =~ /^\d+$/ && @db_id
|
14
|
+
res = send(:post , 'counts' , { 'key' => key , 'count' => count , 'db_id' => @db_id } )
|
15
|
+
( res[:status] == 200 )
|
16
|
+
end
|
17
|
+
|
18
|
+
# Increments the key for a specific date
|
19
|
+
#
|
20
|
+
# @raise [StartupStats::Error::ParamsError] Error raised when inaccurate values
|
21
|
+
# @param key [String]
|
22
|
+
# @param count [Integer]
|
23
|
+
# @param date [Integer]
|
24
|
+
# @return [Boolean] Whether or not the request was successful
|
25
|
+
def increment_key_for_date( key , count , date )
|
26
|
+
raise StartupStats::Error::ParamsError unless key.to_s =~ /^[^\s]+$/ && count.to_s =~ /^\d+$/ && date.to_s =~ /^\d+$/ && @db_id
|
27
|
+
res = send(:post , 'counts' , { 'key' => key , 'count' => count , 'db_id' => @db_id , 'date' => date } )
|
28
|
+
( res[:status] == 200 )
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns all the counts for a key
|
32
|
+
#
|
33
|
+
# @raise [StartupStats::Error::ParamsError]
|
34
|
+
# @param key [String]
|
35
|
+
# @return [StartupStats::ApiResult]
|
36
|
+
def counts_for_key( key )
|
37
|
+
res = send( :get , "counts/#{key}" , { 'db_id' => @db_id } )
|
38
|
+
# parse the counts
|
39
|
+
counts = []
|
40
|
+
res[:body][:counts].each{ |count|
|
41
|
+
c = StartupStats::Countdb::Count.new
|
42
|
+
c.key = key
|
43
|
+
c.db_id = @db_id
|
44
|
+
c.count = count[:count]
|
45
|
+
c.date = count[:date]
|
46
|
+
counts.push( c )
|
47
|
+
}
|
48
|
+
StartupStats::ApiResult.new( { 'total_count' => counts.length , 'start' => 0 , 'limit' => 0 , 'counts' => counts } )
|
49
|
+
end
|
50
|
+
|
51
|
+
# Returns all the counts for
|
52
|
+
#
|
53
|
+
# @raise [StartupStats::Error::ParamsError]
|
54
|
+
# @param date [Integer]
|
55
|
+
# @return [StartupStats::ApiResult]
|
56
|
+
def counts_for_day( date )
|
57
|
+
res = send( :get , "counts" , { 'date' => date , 'db_id' => @db_id } )
|
58
|
+
counts = []
|
59
|
+
res[:body][:counts].each{ |count|
|
60
|
+
c = StartupStats::Countdb::Count.new
|
61
|
+
c.key = count[:key]
|
62
|
+
c.db_id = @db_id
|
63
|
+
c.count = count[:count]
|
64
|
+
c.date = count[:date]
|
65
|
+
counts.push( c )
|
66
|
+
}
|
67
|
+
StartupStats::ApiResult.new( { 'total_count' => counts.length , 'start' => 0 , 'limit' => 0 , 'counts' => counts } )
|
68
|
+
end
|
69
|
+
|
70
|
+
# Deletes a count for a date
|
71
|
+
#
|
72
|
+
# @raise [StartupStats::Error::ParamsError]
|
73
|
+
# @param key [String]
|
74
|
+
# @param date [Integer]
|
75
|
+
# return [Boolean]
|
76
|
+
def delete_count( key , date )
|
77
|
+
res = send( :delete , "counts" , { 'key' => key , 'date' => date , 'db_id' => @db_id } )
|
78
|
+
( res[:status] == 200 )
|
79
|
+
end
|
80
|
+
|
81
|
+
# Deletes all counts for a key
|
82
|
+
#
|
83
|
+
# @raise [StartupStats::Error::ParamsError]
|
84
|
+
# @param key [String]
|
85
|
+
# return [Boolean]
|
86
|
+
def delete_counts( key )
|
87
|
+
res = send( :delete , "counts" , { 'key' => key , 'db_id' => @db_id } )
|
88
|
+
( res[:status] == 200 )
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -16,7 +16,7 @@ module StartupStats
|
|
16
16
|
def filings( start , limit , industry )
|
17
17
|
begin
|
18
18
|
result = parse_filings_from_response(:get , "filings", {start: start , limit: limit , industry: industry} )
|
19
|
-
result.
|
19
|
+
result.filings
|
20
20
|
rescue StartupStats::Error::Unauthorized => error
|
21
21
|
raise
|
22
22
|
end
|
@@ -69,7 +69,7 @@ module StartupStats
|
|
69
69
|
parsed_filings.push( StartupStats::Formd::Filing.new filing )
|
70
70
|
}
|
71
71
|
|
72
|
-
StartupStats::ApiResult.new( { :
|
72
|
+
StartupStats::ApiResult.new( { :filings => parsed_filings , :total_count => body[:total_count] , :start => body[:start] , :limit => body[:limit] } )
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -1,10 +1,47 @@
|
|
1
|
+
require 'startupstats/error/params_error'
|
1
2
|
module StartupStats
|
2
3
|
class ApiResult
|
3
|
-
attr_accessor :
|
4
|
+
attr_accessor :total_count , :start , :limit, :errors, :counts , :filings
|
5
|
+
|
6
|
+
# include Enumerable
|
7
|
+
|
4
8
|
def initialize args = {}
|
9
|
+
@counts = []
|
10
|
+
@filings = []
|
11
|
+
@errors = []
|
5
12
|
args.each do |k, v|
|
6
13
|
instance_variable_set("@#{k}",v) unless v.nil?
|
7
14
|
end
|
8
15
|
end
|
16
|
+
|
17
|
+
def success?
|
18
|
+
( @errors.length == 0 )
|
19
|
+
end
|
20
|
+
|
21
|
+
# TODO: Get method_missing working to define counts & filings in result_sets rather than standalone variables
|
22
|
+
|
23
|
+
# def method_missing( name , *args , &block )
|
24
|
+
# if name.to_s =~ /^(.+)s$/
|
25
|
+
# if name[-1] == "="
|
26
|
+
# base_name = name[0..2].to_sym
|
27
|
+
# define_singleton_method name , lambda{ |value| @result_sets[base_name] }
|
28
|
+
# define_method(name) do |value|
|
29
|
+
# @result_sets[base_name] = value
|
30
|
+
# end
|
31
|
+
# @result_sets[base_name] = args[0]
|
32
|
+
# else
|
33
|
+
# define_method(name) do
|
34
|
+
# @result_sets[name]
|
35
|
+
# end
|
36
|
+
# @result_sets[name]
|
37
|
+
# end
|
38
|
+
# else
|
39
|
+
# super
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
|
43
|
+
# def each
|
44
|
+
# @result_set.each
|
45
|
+
# end
|
9
46
|
end
|
10
47
|
end
|
data/lib/startupstats/version.rb
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "startupstats/response/api_result"
|
3
|
+
describe StartupStats::ApiResult do
|
4
|
+
context "instance methods" do
|
5
|
+
describe "#new" do
|
6
|
+
subject { build(:api_result) }
|
7
|
+
|
8
|
+
it { should respond_to(:start) }
|
9
|
+
it { should respond_to(:limit) }
|
10
|
+
it { should respond_to(:errors) }
|
11
|
+
it { should respond_to(:total_count) }
|
12
|
+
|
13
|
+
context "with counts" do
|
14
|
+
before do
|
15
|
+
@result = build(:result_with_counts)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has 1 count" do
|
19
|
+
@result.counts.length.should eq 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with filings" do
|
24
|
+
before do
|
25
|
+
@result = build(:result_with_filings)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "has 1 filing" do
|
29
|
+
@result.filings.length.should eq 1
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#success?" do
|
35
|
+
|
36
|
+
context "with errors" do
|
37
|
+
before do
|
38
|
+
@result = build(:result_with_errors)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns false" do
|
42
|
+
@result.success?.should eq false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "without errors" do
|
47
|
+
before do
|
48
|
+
@result = build(:api_result)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "returns true" do
|
52
|
+
@result.success?.should eq true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#message" do
|
58
|
+
before do
|
59
|
+
@result = build(:result_with_errors)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns a string representation of the errors"
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "custom result sets" do
|
66
|
+
it "sets counts"
|
67
|
+
|
68
|
+
it "sets filings"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module StartupStats
|
3
|
+
module Countdb
|
4
|
+
describe Client do
|
5
|
+
describe "#new" do
|
6
|
+
before do
|
7
|
+
@params = attributes_for(:countdb_client)
|
8
|
+
@client = StartupStats::Countdb::Client.new(@params)
|
9
|
+
end
|
10
|
+
it "initializes a new client" do
|
11
|
+
StartupStats::Countdb::Client.new(@params).should be_an_instance_of( StartupStats::Countdb::Client )
|
12
|
+
end
|
13
|
+
|
14
|
+
# it "requires a db_id to be set" do
|
15
|
+
# @params.delete(:db_id)
|
16
|
+
# expect {
|
17
|
+
# StartupStats::Countdb::Client.new(@params)
|
18
|
+
# }.to raise_error( StartupStats::Error::ParamsError )
|
19
|
+
# end
|
20
|
+
|
21
|
+
it "sets access_token_key to token" do
|
22
|
+
StartupStats::Countdb::Client.new(@params).access_token_key.should eq "token"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe StartupStats::Countdb::Count do
|
3
|
+
context "instance methods" do
|
4
|
+
describe "#new" do
|
5
|
+
subject { build( :count ) }
|
6
|
+
|
7
|
+
it { should respond_to(:db_id) }
|
8
|
+
it { should respond_to(:key) }
|
9
|
+
it { should respond_to(:count) }
|
10
|
+
it { should respond_to(:date) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vcr'
|
3
|
+
describe StartupStats::Countdb::Counts do
|
4
|
+
use_vcr_cassette 'counts' , :record => :new_episodes
|
5
|
+
|
6
|
+
context "with valid data" do
|
7
|
+
before(:all) do
|
8
|
+
# COUNTDB_ADMIN is the key necessary to create & destroy countdb databases
|
9
|
+
@db_client = StartupStats::Countdb::Client.new({
|
10
|
+
access_token: ENV['COUNTDB_ADMIN'] ,
|
11
|
+
access_token_key: "admin_key" ,
|
12
|
+
endpoint: ENV['COUNTDB_ENDPOINT'] })
|
13
|
+
VCR.use_cassette( 'counts' ) do
|
14
|
+
@db_token = @db_client.send( :post , "dbs" , { 'id' => 'rspec' , 'name' => 'rspec testing db' } )[:body][:db][:token]
|
15
|
+
end
|
16
|
+
|
17
|
+
@client = StartupStats::Countdb::Client.new({
|
18
|
+
db_id: 'rspec' ,
|
19
|
+
access_token: @db_token ,
|
20
|
+
access_token_key: "token" ,
|
21
|
+
endpoint: ENV['COUNTDB_ENDPOINT'] })
|
22
|
+
end
|
23
|
+
|
24
|
+
after(:all) do
|
25
|
+
# delete the test database
|
26
|
+
VCR.use_cassette( 'counts' ) do
|
27
|
+
@db_client.send( :delete , "dbs" , { 'id' => 'rspec' , 'token' => @db_token } )
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#increment_key" do
|
32
|
+
it "calls request with post to counts" do
|
33
|
+
@client.should_receive(:request).with( :post , 'counts' , anything ).and_return( { status: 200 } )
|
34
|
+
@client.increment_key( 'instagram.com' , 123 )
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns true or false based on a result" do
|
38
|
+
@client.increment_key( 'instagram.com' , 123 ).should == true
|
39
|
+
end
|
40
|
+
|
41
|
+
it "raises a ParamsError if key is empty" do
|
42
|
+
expect {
|
43
|
+
@client.increment_key( '' , 0 )
|
44
|
+
}.to raise_error( StartupStats::Error::ParamsError )
|
45
|
+
end
|
46
|
+
|
47
|
+
it "raises a ParamsError if count is not a number" do
|
48
|
+
expect {
|
49
|
+
@client.increment_key( 'i' , '' )
|
50
|
+
}.to raise_error( StartupStats::Error::ParamsError )
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#increment_key_for_date" do
|
55
|
+
it "calls request with post to counts" do
|
56
|
+
@client.should_receive(:request).with( :post , 'counts' , anything ).and_return( { status: 200 } )
|
57
|
+
@client.increment_key_for_date( 'instagram.com' , 123 , Date.today.jd )
|
58
|
+
end
|
59
|
+
|
60
|
+
it "returns true or false based on a result" do
|
61
|
+
@client.increment_key_for_date( 'instagram.com' , 123 , Date.today.jd - 1 ).should == true
|
62
|
+
end
|
63
|
+
|
64
|
+
it "raises a ParamsError if date is empty" do
|
65
|
+
expect {
|
66
|
+
@client.increment_key_for_date( '' , 0 , '' )
|
67
|
+
}.to raise_error( StartupStats::Error::ParamsError )
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#counts_for_key" do
|
72
|
+
|
73
|
+
it "calls request with get to counts/:key" do
|
74
|
+
@client.should_receive(:request).with( :get , 'counts/instagram.com' , anything ).and_return( { :body => { :counts => [] } } )
|
75
|
+
@client.counts_for_key( 'instagram.com' )
|
76
|
+
end
|
77
|
+
|
78
|
+
it "returns a StartupStats::ApiResult instance" do
|
79
|
+
@client.counts_for_key( 'instagram.com' ).should be_an_instance_of( StartupStats::ApiResult )
|
80
|
+
end
|
81
|
+
|
82
|
+
it "includes a count object in the result" do
|
83
|
+
@client.counts_for_key( 'instagram.com' ).counts[0].should be_an_instance_of( StartupStats::Countdb::Count )
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "#counts_for_day" do
|
88
|
+
it "calls request with get to counts" do
|
89
|
+
@client.should_receive(:request).with( :get , 'counts' , anything ).and_return( { :body => { :counts => [] } } )
|
90
|
+
@client.counts_for_day( Date.today.jd )
|
91
|
+
end
|
92
|
+
|
93
|
+
it "returns a StartupStats::ApiResult instance" do
|
94
|
+
@client.counts_for_day( Date.today.jd ).should be_an_instance_of( StartupStats::ApiResult )
|
95
|
+
end
|
96
|
+
|
97
|
+
it "includes a count object in the result" do
|
98
|
+
@client.counts_for_day( Date.today.jd ).counts[0].should be_an_instance_of( StartupStats::Countdb::Count )
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#delete_count" do
|
103
|
+
# two counts were created above with increment_key and increment_key_for_date
|
104
|
+
it "calls request with delete to counts" do
|
105
|
+
@client.should_receive(:request).with( :delete , 'counts' , anything ).and_return( { status: 200 } )
|
106
|
+
@client.delete_count( 'instagram.com' , Date.today.jd )
|
107
|
+
end
|
108
|
+
|
109
|
+
it "deletes a count" do
|
110
|
+
expect {
|
111
|
+
@client.delete_count( 'instagram.com' , Date.today.jd - 1 )
|
112
|
+
}.to change { @client.counts_for_key( 'instagram.com' ).counts.length }.from(2).to(1)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "returns true if successful" do
|
116
|
+
@client.delete_count( 'instagram.com' , Date.today.jd - 1 ).should eq true
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "#delete_counts" do
|
121
|
+
it "calls request with delete to counts" do
|
122
|
+
@client.should_receive(:request).with( :delete , 'counts' , anything ).and_return( { status: 200 } )
|
123
|
+
@client.delete_counts( 'instagram.com' )
|
124
|
+
end
|
125
|
+
it "deletes all counts for a key" do
|
126
|
+
expect {
|
127
|
+
@client.delete_counts( 'instagram.com' )
|
128
|
+
}.to change { @client.counts_for_key( 'instagram.com' ).counts.length }.from(1).to(0)
|
129
|
+
end
|
130
|
+
|
131
|
+
it "returns true" do
|
132
|
+
@client.delete_counts( 'instagram.com' ).should eq true
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
data/spec/factories.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
|
+
require 'startupstats/error/client_error'
|
1
2
|
FactoryGirl.define do
|
2
3
|
|
4
|
+
factory :countdb_client , class: StartupStats::Countdb::Client do
|
5
|
+
access_token "kjhk89yh98h98h87g76f6f76f76f76"
|
6
|
+
db_id "tb"
|
7
|
+
endpoint "http://localhost:4567/"
|
8
|
+
end
|
9
|
+
|
3
10
|
factory :filing , class: StartupStats::Formd::Filing do
|
4
11
|
filing_url_html "http://www.sec.gov/Archives/edgar/data/1525533/000152553312000003/xslFormDX01/primary_doc.xml"
|
5
12
|
filing_url_xml "http://www.sec.gov/Archives/edgar/data/1525533/000152553312000003/primary_doc.xml"
|
@@ -97,4 +104,30 @@ FactoryGirl.define do
|
|
97
104
|
factory :security do
|
98
105
|
name "Equity"
|
99
106
|
end
|
107
|
+
|
108
|
+
factory :count , class: StartupStats::Countdb::Count do
|
109
|
+
sequence(:key){ |n| "instagram#{n}.com" }
|
110
|
+
db_id "tb"
|
111
|
+
count 123
|
112
|
+
date { Date.today.jd }
|
113
|
+
end
|
114
|
+
|
115
|
+
factory :api_result , class: StartupStats::ApiResult do
|
116
|
+
# :result_set , :total_count , :start , :limit , :errors
|
117
|
+
|
118
|
+
start 0
|
119
|
+
limit 10
|
120
|
+
|
121
|
+
factory :result_with_errors do
|
122
|
+
errors [ StartupStats::Error::ClientError.new() ]
|
123
|
+
end
|
124
|
+
|
125
|
+
factory :result_with_counts do
|
126
|
+
counts [ FactoryGirl.build(:count) ]
|
127
|
+
end
|
128
|
+
|
129
|
+
factory :result_with_filings do
|
130
|
+
filings [ FactoryGirl.build(:filing) ]
|
131
|
+
end
|
132
|
+
end
|
100
133
|
end
|
data/spec/formd/filings_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -7,13 +7,18 @@ require 'factory_girl'
|
|
7
7
|
require 'factories'
|
8
8
|
require 'vcr'
|
9
9
|
|
10
|
-
Dir['./spec/support
|
10
|
+
Dir['./spec/support/*.rb'].each { |f| require f }
|
11
11
|
|
12
12
|
RSpec.configure do |config|
|
13
|
+
config.extend VCR::RSpec::Macros
|
13
14
|
config.include FactoryGirl::Syntax::Methods
|
14
15
|
|
15
16
|
config.mock_with :rspec
|
16
17
|
|
17
18
|
config.run_all_when_everything_filtered = true
|
18
19
|
config.color_enabled = true
|
20
|
+
|
21
|
+
# Add VCR to the StartupStats faraday middleware
|
22
|
+
StartupStats::Default::MIDDLEWARE.insert(4,VCR::Middleware::Faraday)
|
23
|
+
# StartupStats::Default::MIDDLEWARE.insert(4, Faraday::Response::Logger)
|
19
24
|
end
|
data/spec/support/vcr_support.rb
CHANGED
@@ -3,9 +3,6 @@ require 'vcr'
|
|
3
3
|
VCR.configure do |c|
|
4
4
|
c.cassette_library_dir = 'spec/vcr'
|
5
5
|
c.hook_into :faraday
|
6
|
-
#c.
|
7
|
-
|
8
|
-
|
9
|
-
RSpec.configure do |c|
|
10
|
-
c.extend VCR::RSpec::Macros
|
6
|
+
#c.debug_logger = $stdout
|
7
|
+
c.ignore_localhost = true
|
11
8
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: startupstats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -138,6 +138,9 @@ files:
|
|
138
138
|
- lib/startupstats.rb
|
139
139
|
- lib/startupstats/configurable.rb
|
140
140
|
- lib/startupstats/core_ext/hash.rb
|
141
|
+
- lib/startupstats/countdb/client.rb
|
142
|
+
- lib/startupstats/countdb/counts.rb
|
143
|
+
- lib/startupstats/countdb/models/count.rb
|
141
144
|
- lib/startupstats/default.rb
|
142
145
|
- lib/startupstats/error.rb
|
143
146
|
- lib/startupstats/error/bad_gateway.rb
|
@@ -149,6 +152,7 @@ files:
|
|
149
152
|
- lib/startupstats/error/internal_server_error.rb
|
150
153
|
- lib/startupstats/error/not_acceptable.rb
|
151
154
|
- lib/startupstats/error/not_found.rb
|
155
|
+
- lib/startupstats/error/params_error.rb
|
152
156
|
- lib/startupstats/error/server_error.rb
|
153
157
|
- lib/startupstats/error/unauthorized.rb
|
154
158
|
- lib/startupstats/formd/client.rb
|
@@ -160,6 +164,10 @@ files:
|
|
160
164
|
- lib/startupstats/response/parse_json.rb
|
161
165
|
- lib/startupstats/response/raise_error.rb
|
162
166
|
- lib/startupstats/version.rb
|
167
|
+
- spec/api_result_spec.rb
|
168
|
+
- spec/countdb/client_spec.rb
|
169
|
+
- spec/countdb/count_spec.rb
|
170
|
+
- spec/countdb/counts_spec.rb
|
163
171
|
- spec/factories.rb
|
164
172
|
- spec/formd/client_spec.rb
|
165
173
|
- spec/formd/company_spec.rb
|
@@ -191,11 +199,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
199
|
version: '0'
|
192
200
|
requirements: []
|
193
201
|
rubyforge_project:
|
194
|
-
rubygems_version: 1.8.
|
202
|
+
rubygems_version: 1.8.23
|
195
203
|
signing_key:
|
196
204
|
specification_version: 3
|
197
205
|
summary: A Ruby interface to the network of StartupStats APIs.
|
198
206
|
test_files:
|
207
|
+
- spec/api_result_spec.rb
|
208
|
+
- spec/countdb/client_spec.rb
|
209
|
+
- spec/countdb/count_spec.rb
|
210
|
+
- spec/countdb/counts_spec.rb
|
199
211
|
- spec/factories.rb
|
200
212
|
- spec/formd/client_spec.rb
|
201
213
|
- spec/formd/company_spec.rb
|