trend 0.1.1 → 0.1.2
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +5 -5
- data/lib/trend/client.rb +3 -3
- data/lib/trend/version.rb +1 -1
- metadata +6 -13
- data/.gitignore +0 -9
- data/.travis.yml +0 -11
- data/Gemfile +0 -4
- data/Rakefile +0 -29
- data/trend.gemspec +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 127d317059995d6c5ef713438f3c3ccbd61cac529a74fd9481a34f5429ecc59a
|
4
|
+
data.tar.gz: ee6f4c72cb63f2582f41ec5efb82920fae6158ec87b31c84bc09fd83f1170de0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b081882f557cfa7a9e27b55764d74afc9cb8c4692eb1e5aac45f7b86cf879d820f9585a9d31150087e443b7a4cd6455c358ae6200947352e9720b698396334a6
|
7
|
+
data.tar.gz: 26e63588c546ef8fe71c6959ac63feaeb57989309e5f4f0b003ed40c12c535b8bbc832cc9f072e430cd38a2a920bce0c7b965890be73a54f3e49d11989679d94
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Ruby client for [Trend](https://trendapi.org), the anomaly detection and forecas
|
|
4
4
|
|
5
5
|
[](https://travis-ci.org/ankane/trend)
|
6
6
|
|
7
|
-
##
|
7
|
+
## Installation
|
8
8
|
|
9
9
|
Add this line to your application’s Gemfile:
|
10
10
|
|
@@ -12,7 +12,7 @@ Add this line to your application’s Gemfile:
|
|
12
12
|
gem 'trend'
|
13
13
|
```
|
14
14
|
|
15
|
-
|
15
|
+
## Anomaly Detection
|
16
16
|
|
17
17
|
Detect anomalies in a time series
|
18
18
|
|
@@ -38,7 +38,7 @@ series = User.group_by_day(:created_at).count
|
|
38
38
|
Trend.anomalies(series)
|
39
39
|
```
|
40
40
|
|
41
|
-
|
41
|
+
## Forecasting
|
42
42
|
|
43
43
|
Get future predictions for a time series
|
44
44
|
|
@@ -66,7 +66,7 @@ Specify the number of predictions to return
|
|
66
66
|
Trend.forecast(series, count: 3)
|
67
67
|
```
|
68
68
|
|
69
|
-
|
69
|
+
## Correlation [experimental]
|
70
70
|
|
71
71
|
Get the correlation between two time series
|
72
72
|
|
@@ -76,7 +76,7 @@ Trend.correlation(series, series2)
|
|
76
76
|
|
77
77
|
## Authentication
|
78
78
|
|
79
|
-
An API key is needed for more than
|
79
|
+
An API key is needed for more than 1,000 requests per day per IP. [Email us](mailto:hi@trendapi.org) to get one.
|
80
80
|
|
81
81
|
If you have one, set `ENV["TREND_API_KEY"]` or use:
|
82
82
|
|
data/lib/trend/client.rb
CHANGED
@@ -8,13 +8,13 @@ module Trend
|
|
8
8
|
"User-Agent" => "trend-ruby/#{Trend::VERSION}"
|
9
9
|
}
|
10
10
|
|
11
|
-
def initialize(url: nil, api_key: nil)
|
11
|
+
def initialize(url: nil, api_key: nil, timeout: 30)
|
12
12
|
@api_key = api_key || Trend.api_key
|
13
13
|
@uri = URI.parse(url || Trend.url)
|
14
14
|
@http = Net::HTTP.new(@uri.host, @uri.port)
|
15
15
|
@http.use_ssl = true if @uri.scheme == "https"
|
16
|
-
@http.open_timeout =
|
17
|
-
@http.read_timeout =
|
16
|
+
@http.open_timeout = timeout
|
17
|
+
@http.read_timeout = timeout
|
18
18
|
end
|
19
19
|
|
20
20
|
def anomalies(series, params = {})
|
data/lib/trend/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -67,23 +67,17 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description:
|
70
|
-
email:
|
71
|
-
- andrew@chartkick.com
|
70
|
+
email: andrew@chartkick.com
|
72
71
|
executables: []
|
73
72
|
extensions: []
|
74
73
|
extra_rdoc_files: []
|
75
74
|
files:
|
76
|
-
- ".gitignore"
|
77
|
-
- ".travis.yml"
|
78
75
|
- CHANGELOG.md
|
79
|
-
- Gemfile
|
80
76
|
- LICENSE.txt
|
81
77
|
- README.md
|
82
|
-
- Rakefile
|
83
78
|
- lib/trend.rb
|
84
79
|
- lib/trend/client.rb
|
85
80
|
- lib/trend/version.rb
|
86
|
-
- trend.gemspec
|
87
81
|
homepage: https://github.com/ankane/trend
|
88
82
|
licenses:
|
89
83
|
- MIT
|
@@ -96,15 +90,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
90
|
requirements:
|
97
91
|
- - ">="
|
98
92
|
- !ruby/object:Gem::Version
|
99
|
-
version: '
|
93
|
+
version: '2.2'
|
100
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
95
|
requirements:
|
102
96
|
- - ">="
|
103
97
|
- !ruby/object:Gem::Version
|
104
98
|
version: '0'
|
105
99
|
requirements: []
|
106
|
-
|
107
|
-
rubygems_version: 2.7.7
|
100
|
+
rubygems_version: 3.0.3
|
108
101
|
signing_key:
|
109
102
|
specification_version: 4
|
110
103
|
summary: Ruby client for Trend, the time series API
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rake/testtask"
|
3
|
-
|
4
|
-
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs << "test"
|
6
|
-
t.libs << "lib"
|
7
|
-
t.test_files = FileList["test/**/*_test.rb"]
|
8
|
-
end
|
9
|
-
|
10
|
-
task :default => :test
|
11
|
-
|
12
|
-
task :benchmark do
|
13
|
-
require "benchmark/ips"
|
14
|
-
require "trend"
|
15
|
-
|
16
|
-
series = {}
|
17
|
-
date = Date.parse("2018-01-01")
|
18
|
-
1000.times do
|
19
|
-
series[date] = rand(100)
|
20
|
-
date += 1
|
21
|
-
end
|
22
|
-
|
23
|
-
Trend.url = "http://localhost:8000"
|
24
|
-
|
25
|
-
Benchmark.ips do |x|
|
26
|
-
x.report("anomalies") { Trend.anomalies(series) }
|
27
|
-
x.report("forecast") { Trend.forecast(series) }
|
28
|
-
end
|
29
|
-
end
|
data/trend.gemspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "trend/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "trend"
|
8
|
-
spec.version = Trend::VERSION
|
9
|
-
spec.authors = ["Andrew Kane"]
|
10
|
-
spec.email = ["andrew@chartkick.com"]
|
11
|
-
|
12
|
-
spec.summary = "Ruby client for Trend, the time series API"
|
13
|
-
spec.homepage = "https://github.com/ankane/trend"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
# Specify which files should be added to the gem when it is released.
|
17
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
-
end
|
21
|
-
spec.bindir = "exe"
|
22
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
-
spec.require_paths = ["lib"]
|
24
|
-
|
25
|
-
spec.add_development_dependency "benchmark-ips"
|
26
|
-
spec.add_development_dependency "bundler"
|
27
|
-
spec.add_development_dependency "rake"
|
28
|
-
spec.add_development_dependency "minitest"
|
29
|
-
end
|