trend 0.1.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -3
- data/LICENSE.txt +1 -1
- data/README.md +22 -24
- data/lib/trend/version.rb +1 -1
- data/lib/trend.rb +11 -3
- metadata +11 -67
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c45555f23668c7c5b0c4b6852d117feb7ceadc27ef14bf036fb9e3d71ab8ead4
|
4
|
+
data.tar.gz: edcd7f8e0aead518dcb4e159c0fd3a0b0aa7037aaeca74791f922e321182b3d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 860677a520c3ae9a6c997f3c046f94f798c42aac76cfe3e6d688eb0a8b32f25c0d54765d92d78f46fa81f2d34e452b5412dc78743ee555931bcde7c1b7b89f2c
|
7
|
+
data.tar.gz: 1636b2b82f27332f93eeaccaad3dcdcf62abd363e753390af1c822efbd35db9927ee215885cbbc2147fc8d167829ab099b7d2473e8053e00500507e1b5fa24ba
|
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,21 @@
|
|
1
|
-
## 0.1
|
1
|
+
## 0.2.1 (2023-10-08)
|
2
|
+
|
3
|
+
- Added warning about hosted version shutdown
|
4
|
+
|
5
|
+
## 0.2.0 (2023-05-03)
|
6
|
+
|
7
|
+
- Dropped support for Ruby < 3
|
8
|
+
|
9
|
+
## 0.1.2 (2019-04-10)
|
2
10
|
|
3
11
|
- Extended timeout
|
4
12
|
- Added `timeout` option
|
5
13
|
|
6
|
-
## 0.1.1
|
14
|
+
## 0.1.1 (2018-10-28)
|
7
15
|
|
8
16
|
- Added support for API keys
|
9
17
|
- Added experimental `correlation` method
|
10
18
|
|
11
|
-
## 0.1.0
|
19
|
+
## 0.1.0 (2018-05-23)
|
12
20
|
|
13
21
|
- First release
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,23 @@
|
|
1
|
-
# Trend
|
1
|
+
# Trend Ruby
|
2
2
|
|
3
|
-
Ruby client for [Trend](https://
|
3
|
+
Ruby client for [Trend](https://github.com/ankane/trend-api), the anomaly detection and forecasting API
|
4
4
|
|
5
|
-
[
|
5
|
+
**Note: The [hosted version](https://trendapi.org/) is shutting down on May 1, 2024. [See how to run the API on your own infrastructure.](https://github.com/ankane/trend-api)**
|
6
|
+
|
7
|
+
[![Build Status](https://github.com/ankane/trend-ruby/workflows/build/badge.svg?branch=master)](https://github.com/ankane/trend-ruby/actions)
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
9
11
|
Add this line to your application’s Gemfile:
|
10
12
|
|
11
13
|
```ruby
|
12
|
-
gem
|
14
|
+
gem "trend"
|
15
|
+
```
|
16
|
+
|
17
|
+
And set the URL to the API:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
Trend.url = "http://localhost:8000"
|
13
21
|
```
|
14
22
|
|
15
23
|
## Anomaly Detection
|
@@ -19,7 +27,7 @@ Detect anomalies in a time series
|
|
19
27
|
```ruby
|
20
28
|
# generate series
|
21
29
|
series = {}
|
22
|
-
date = Date.parse("
|
30
|
+
date = Date.parse("2023-04-01")
|
23
31
|
28.times do
|
24
32
|
series[date] = rand(100)
|
25
33
|
date += 1
|
@@ -31,7 +39,7 @@ series[date - 8] = 999
|
|
31
39
|
Trend.anomalies(series)
|
32
40
|
```
|
33
41
|
|
34
|
-
Works great with
|
42
|
+
Works great with [Groupdate](https://github.com/ankane/groupdate)
|
35
43
|
|
36
44
|
```ruby
|
37
45
|
series = User.group_by_day(:created_at).count
|
@@ -44,7 +52,7 @@ Get future predictions for a time series
|
|
44
52
|
|
45
53
|
```ruby
|
46
54
|
series = {}
|
47
|
-
date = Date.parse("
|
55
|
+
date = Date.parse("2023-04-01")
|
48
56
|
28.times do
|
49
57
|
series[date] = date.wday
|
50
58
|
date += 1
|
@@ -74,34 +82,24 @@ Get the correlation between two time series
|
|
74
82
|
Trend.correlation(series, series2)
|
75
83
|
```
|
76
84
|
|
77
|
-
## Authentication
|
78
|
-
|
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
|
-
|
81
|
-
If you have one, set `ENV["TREND_API_KEY"]` or use:
|
82
|
-
|
83
|
-
```ruby
|
84
|
-
Trend.api_key = "secret"
|
85
|
-
```
|
86
|
-
|
87
85
|
## History
|
88
86
|
|
89
|
-
View the [changelog](https://github.com/ankane/trend/blob/master/CHANGELOG.md)
|
87
|
+
View the [changelog](https://github.com/ankane/trend-ruby/blob/master/CHANGELOG.md)
|
90
88
|
|
91
89
|
## Contributing
|
92
90
|
|
93
91
|
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
94
92
|
|
95
|
-
- [Report bugs](https://github.com/ankane/trend/issues)
|
96
|
-
- Fix bugs and [submit pull requests](https://github.com/ankane/trend/pulls)
|
93
|
+
- [Report bugs](https://github.com/ankane/trend-ruby/issues)
|
94
|
+
- Fix bugs and [submit pull requests](https://github.com/ankane/trend-ruby/pulls)
|
97
95
|
- Write, clarify, or fix documentation
|
98
96
|
- Suggest or add new features
|
99
97
|
|
100
|
-
To get started with development
|
98
|
+
To get started with development:
|
101
99
|
|
102
100
|
```sh
|
103
|
-
git clone https://github.com/ankane/trend.git
|
104
|
-
cd trend
|
101
|
+
git clone https://github.com/ankane/trend-ruby.git
|
102
|
+
cd trend-ruby
|
105
103
|
bundle install
|
106
|
-
rake test
|
104
|
+
bundle exec rake test
|
107
105
|
```
|
data/lib/trend/version.rb
CHANGED
data/lib/trend.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# stdlib
|
1
2
|
require "date"
|
2
3
|
require "json"
|
3
4
|
require "net/http"
|
4
5
|
require "time"
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
# modules
|
8
|
+
require_relative "trend/client"
|
9
|
+
require_relative "trend/version"
|
8
10
|
|
9
11
|
module Trend
|
10
12
|
class Error < StandardError; end
|
@@ -22,7 +24,7 @@ module Trend
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def self.url
|
25
|
-
@url ||= ENV["TREND_URL"] ||
|
27
|
+
@url ||= ENV["TREND_URL"] || hosted_url
|
26
28
|
end
|
27
29
|
|
28
30
|
def self.url=(url)
|
@@ -43,4 +45,10 @@ module Trend
|
|
43
45
|
def self.client
|
44
46
|
@client ||= Client.new
|
45
47
|
end
|
48
|
+
|
49
|
+
# private
|
50
|
+
def self.hosted_url
|
51
|
+
warn "[trend] WARNING: The hosted version is shutting down on May 1, 2024. See https://github.com/ankane/trend-api for how to run the API on your own infrastructure."
|
52
|
+
"https://trendapi.org"
|
53
|
+
end
|
46
54
|
end
|
metadata
CHANGED
@@ -1,73 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
description:
|
70
|
-
email: andrew@chartkick.com
|
11
|
+
date: 2023-10-08 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: andrew@ankane.org
|
71
15
|
executables: []
|
72
16
|
extensions: []
|
73
17
|
extra_rdoc_files: []
|
@@ -78,11 +22,11 @@ files:
|
|
78
22
|
- lib/trend.rb
|
79
23
|
- lib/trend/client.rb
|
80
24
|
- lib/trend/version.rb
|
81
|
-
homepage: https://github.com/ankane/trend
|
25
|
+
homepage: https://github.com/ankane/trend-ruby
|
82
26
|
licenses:
|
83
27
|
- MIT
|
84
28
|
metadata: {}
|
85
|
-
post_install_message:
|
29
|
+
post_install_message:
|
86
30
|
rdoc_options: []
|
87
31
|
require_paths:
|
88
32
|
- lib
|
@@ -90,15 +34,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
34
|
requirements:
|
91
35
|
- - ">="
|
92
36
|
- !ruby/object:Gem::Version
|
93
|
-
version: '
|
37
|
+
version: '3'
|
94
38
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
39
|
requirements:
|
96
40
|
- - ">="
|
97
41
|
- !ruby/object:Gem::Version
|
98
42
|
version: '0'
|
99
43
|
requirements: []
|
100
|
-
rubygems_version: 3.
|
101
|
-
signing_key:
|
44
|
+
rubygems_version: 3.4.10
|
45
|
+
signing_key:
|
102
46
|
specification_version: 4
|
103
47
|
summary: Ruby client for Trend, the time series API
|
104
48
|
test_files: []
|