exist 0.1.0.beta.3 → 0.1.0.beta.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 +4 -4
- data/lib/exist/api.rb +36 -30
- data/lib/exist/version.rb +1 -1
- data/spec/spec_helper.rb +0 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21dab1306f76bac038b16bfc2d7c6e5ccb43ea23
|
4
|
+
data.tar.gz: 5217e66cc73f48eceb15e6baa470f9304c41fa5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 306e8f7e13843f67f036ace37e9329fbb113a43593e9a0cee432e58b5bf44eb1da7c4827d8710ab03dc3d9d17aa7127e4fa5faf8121d6d906d85fe06bc3ee534
|
7
|
+
data.tar.gz: c2ccf39403583e638823aaa0a803a60dc3ed9cada21bfa77afe902ec11b634a837670d6e02ff2682608ec8907d9dae4e95f3e3989f583d84103b2512771c4c7e
|
data/lib/exist/api.rb
CHANGED
@@ -21,7 +21,7 @@ module Exist
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def me
|
24
|
-
User.new(
|
24
|
+
User.new(user_resource(nil))
|
25
25
|
end
|
26
26
|
|
27
27
|
def overview(username = '$self')
|
@@ -29,65 +29,57 @@ module Exist
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def attributes(limit: 31)
|
32
|
-
response =
|
33
|
-
|
32
|
+
response = user_resource('attributes', limit: limit)
|
34
33
|
AttributeList.new(attributes: response)
|
35
34
|
end
|
36
35
|
|
37
36
|
# Date format is YYYY-mm-dd
|
38
37
|
def attribute(attribute, limit: 31, page: 1, oldest_date: nil, newest_date: nil)
|
39
|
-
response =
|
40
|
-
"
|
41
|
-
|
42
|
-
).body
|
38
|
+
response = paginated_user_resource(
|
39
|
+
"attributes/#{attribute}", page, limit, oldest_date, newest_date
|
40
|
+
)
|
43
41
|
AttributeList.new(
|
44
|
-
attributes: response['results'],
|
45
|
-
total: response['count'],
|
42
|
+
attributes: response['results'], total: response['count']
|
46
43
|
)
|
47
44
|
end
|
48
45
|
|
49
46
|
def insights(limit: 31, page: 1, oldest_date: nil, newest_date: nil)
|
50
|
-
response =
|
51
|
-
|
52
|
-
page: page, limit: limit, date_min: oldest_date, date_max: newest_date
|
47
|
+
response = paginated_user_resource(
|
48
|
+
'insights', page, limit, oldest_date, newest_date
|
53
49
|
)
|
54
50
|
|
55
|
-
InsightList.new(
|
56
|
-
insights: response.body['results'],
|
57
|
-
total: response.body['count'],
|
58
|
-
)
|
51
|
+
InsightList.new(insights: response['results'], total: response['count'])
|
59
52
|
end
|
60
53
|
|
61
54
|
def insights_for_attribute(attribute, limit: 31, page: 1, oldest_date: nil, newest_date: nil)
|
62
|
-
response =
|
63
|
-
"
|
64
|
-
page
|
55
|
+
response = paginated_user_resource(
|
56
|
+
"insights/attribute/#{attribute}",
|
57
|
+
page, limit, oldest_date, newest_date
|
65
58
|
)
|
66
59
|
InsightList.new(
|
67
|
-
insights: response
|
68
|
-
total: response
|
60
|
+
insights: response['results'],
|
61
|
+
total: response['count'],
|
69
62
|
)
|
70
63
|
end
|
71
64
|
|
72
65
|
def averages
|
73
|
-
response =
|
74
|
-
AverageList.new(averages: response
|
66
|
+
response = user_resource('averages')
|
67
|
+
AverageList.new(averages: response)
|
75
68
|
end
|
76
69
|
|
77
70
|
def average_for_attribute(attribute, limit: 31, page: 1, oldest_date: nil, newest_date: nil)
|
78
|
-
response =
|
79
|
-
"
|
80
|
-
|
81
|
-
).body
|
71
|
+
response = paginated_user_resource(
|
72
|
+
"averages/attribute/#{attribute}", page, limit, oldest_date, newest_date
|
73
|
+
)
|
82
74
|
|
83
75
|
AverageList.new(averages: response['results'], total: response['count'])
|
84
76
|
end
|
85
77
|
|
86
|
-
def correlations(username, attribute,
|
87
|
-
|
88
|
-
latest_only: false)
|
78
|
+
def correlations(username, attribute, limit: 31, page: 1, oldest_date: nil,
|
79
|
+
newest_date: nil, latest_only: false)
|
89
80
|
|
90
81
|
params = { page: page, limit: limit }
|
82
|
+
|
91
83
|
if !latest_only
|
92
84
|
params.merge!(date_min: oldest_date, date_max: newest_date)
|
93
85
|
else
|
@@ -115,6 +107,20 @@ module Exist
|
|
115
107
|
end
|
116
108
|
end
|
117
109
|
|
110
|
+
def user_resource(resource, params = {})
|
111
|
+
url = base_url + "users/$self/#{resource}"
|
112
|
+
url += "/" unless url.end_with?('/')
|
113
|
+
|
114
|
+
client.get(url, params).body
|
115
|
+
end
|
116
|
+
|
117
|
+
def paginated_user_resource(resource, page, limit, newest_date, oldest_date)
|
118
|
+
user_resource(resource, {
|
119
|
+
page: page, limit: limit, date_min: oldest_date,
|
120
|
+
date_max: newest_date
|
121
|
+
})
|
122
|
+
end
|
123
|
+
|
118
124
|
def base_url
|
119
125
|
'https://exist.io/api/1/'
|
120
126
|
end
|
data/lib/exist/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -28,15 +28,6 @@ RSpec.configure do |config|
|
|
28
28
|
config.order = :random
|
29
29
|
|
30
30
|
Kernel.srand config.seed
|
31
|
-
|
32
|
-
config.expect_with :rspec do |expectations|
|
33
|
-
expectations.syntax = :expect
|
34
|
-
end
|
35
|
-
|
36
|
-
config.mock_with :rspec do |mocks|
|
37
|
-
mocks.syntax = :expect
|
38
|
-
mocks.verify_partial_doubles = true
|
39
|
-
end
|
40
31
|
end
|
41
32
|
|
42
33
|
require 'exist'
|