liquid-ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/.rspec +1 -0
- data/.rubocop.yml +270 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +71 -0
- data/README.md +47 -0
- data/Rakefile +11 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/liquid.rb +54 -0
- data/lib/liquid/configuration.rb +13 -0
- data/lib/liquid/errors.rb +23 -0
- data/lib/liquid/network.rb +63 -0
- data/lib/liquid/request_factory.rb +29 -0
- data/lib/liquid/version.rb +3 -0
- data/liquid.gemspec +33 -0
- metadata +171 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0e14a0a81084af83f470b35c7593880c4b3dd1b2
|
4
|
+
data.tar.gz: c6d750750969accc7bf78334352cdd2a1f399ce1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3196795df3b0347d6834bbc466304928119ca7022c97527be19945d72a880fa981624568377e386fd202c42c9fac803e188775d94da9926c77a029f08cc639a0
|
7
|
+
data.tar.gz: 02839eef2253792000532f80aad8925f6ad164faaf1ea2f9d3afc732e2fb7442ec14287ccb384dedafc20b9d40bb2c3c54dc034a61c76e029c7a69712b7cef2e
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,270 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
RunRailsCops: true
|
5
|
+
Exclude:
|
6
|
+
- 'db/**/*'
|
7
|
+
- 'config/**/*'
|
8
|
+
|
9
|
+
Rails/TimeZone:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
AccessorMethodName:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
ActionFilter:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Alias:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
ArrayJoin:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
AsciiComments:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
AsciiIdentifiers:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Attr:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
BlockNesting:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
CaseEquality:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
CharacterLiteral:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
ClassAndModuleChildren:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
ClassLength:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
ClassVars:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
CollectionMethods:
|
52
|
+
PreferredMethods:
|
53
|
+
find: detect
|
54
|
+
reduce: inject
|
55
|
+
collect: map
|
56
|
+
find_all: select
|
57
|
+
|
58
|
+
ColonMethodCall:
|
59
|
+
Enabled: false
|
60
|
+
|
61
|
+
CommentAnnotation:
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
CyclomaticComplexity:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
Delegate:
|
68
|
+
Enabled: false
|
69
|
+
|
70
|
+
DeprecatedHashMethods:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Documentation:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
DotPosition:
|
77
|
+
EnforcedStyle: trailing
|
78
|
+
|
79
|
+
DoubleNegation:
|
80
|
+
Enabled: false
|
81
|
+
|
82
|
+
EachWithObject:
|
83
|
+
Enabled: false
|
84
|
+
|
85
|
+
EmptyLiteral:
|
86
|
+
Enabled: false
|
87
|
+
|
88
|
+
Encoding:
|
89
|
+
Enabled: false
|
90
|
+
|
91
|
+
EvenOdd:
|
92
|
+
Enabled: false
|
93
|
+
|
94
|
+
FileName:
|
95
|
+
Enabled: false
|
96
|
+
|
97
|
+
FlipFlop:
|
98
|
+
Enabled: false
|
99
|
+
|
100
|
+
FormatString:
|
101
|
+
Enabled: false
|
102
|
+
|
103
|
+
GlobalVars:
|
104
|
+
Enabled: false
|
105
|
+
|
106
|
+
GuardClause:
|
107
|
+
Enabled: false
|
108
|
+
|
109
|
+
IfUnlessModifier:
|
110
|
+
Enabled: false
|
111
|
+
|
112
|
+
IfWithSemicolon:
|
113
|
+
Enabled: false
|
114
|
+
|
115
|
+
InlineComment:
|
116
|
+
Enabled: false
|
117
|
+
|
118
|
+
Lambda:
|
119
|
+
Enabled: false
|
120
|
+
|
121
|
+
LambdaCall:
|
122
|
+
Enabled: false
|
123
|
+
|
124
|
+
LineEndConcatenation:
|
125
|
+
Enabled: false
|
126
|
+
|
127
|
+
LineLength:
|
128
|
+
Max: 85
|
129
|
+
|
130
|
+
MethodLength:
|
131
|
+
Enabled: false
|
132
|
+
|
133
|
+
ModuleFunction:
|
134
|
+
Enabled: false
|
135
|
+
|
136
|
+
NegatedIf:
|
137
|
+
Enabled: false
|
138
|
+
|
139
|
+
NegatedWhile:
|
140
|
+
Enabled: false
|
141
|
+
|
142
|
+
BlockDelimiters:
|
143
|
+
Exclude:
|
144
|
+
- spec/**/*
|
145
|
+
|
146
|
+
Next:
|
147
|
+
Enabled: false
|
148
|
+
|
149
|
+
NilComparison:
|
150
|
+
Enabled: false
|
151
|
+
|
152
|
+
Not:
|
153
|
+
Enabled: false
|
154
|
+
|
155
|
+
NumericLiterals:
|
156
|
+
Enabled: false
|
157
|
+
|
158
|
+
OneLineConditional:
|
159
|
+
Enabled: false
|
160
|
+
|
161
|
+
OpMethod:
|
162
|
+
Enabled: false
|
163
|
+
|
164
|
+
ParameterLists:
|
165
|
+
Enabled: false
|
166
|
+
|
167
|
+
PercentLiteralDelimiters:
|
168
|
+
Enabled: false
|
169
|
+
|
170
|
+
PerlBackrefs:
|
171
|
+
Enabled: false
|
172
|
+
|
173
|
+
PredicateName:
|
174
|
+
NamePrefixBlacklist:
|
175
|
+
- is_
|
176
|
+
|
177
|
+
Proc:
|
178
|
+
Enabled: false
|
179
|
+
|
180
|
+
RaiseArgs:
|
181
|
+
Enabled: false
|
182
|
+
|
183
|
+
RegexpLiteral:
|
184
|
+
Enabled: false
|
185
|
+
|
186
|
+
SelfAssignment:
|
187
|
+
Enabled: false
|
188
|
+
|
189
|
+
SingleLineBlockParams:
|
190
|
+
Enabled: false
|
191
|
+
|
192
|
+
SingleLineMethods:
|
193
|
+
Enabled: false
|
194
|
+
|
195
|
+
SignalException:
|
196
|
+
Enabled: false
|
197
|
+
|
198
|
+
SpecialGlobalVars:
|
199
|
+
Enabled: false
|
200
|
+
|
201
|
+
StringLiterals:
|
202
|
+
EnforcedStyle: single_quotes
|
203
|
+
|
204
|
+
VariableInterpolation:
|
205
|
+
Enabled: false
|
206
|
+
|
207
|
+
TrailingComma:
|
208
|
+
Enabled: false
|
209
|
+
|
210
|
+
TrivialAccessors:
|
211
|
+
Enabled: false
|
212
|
+
|
213
|
+
VariableInterpolation:
|
214
|
+
Enabled: false
|
215
|
+
|
216
|
+
WhenThen:
|
217
|
+
Enabled: false
|
218
|
+
|
219
|
+
WhileUntilModifier:
|
220
|
+
Enabled: false
|
221
|
+
|
222
|
+
WordArray:
|
223
|
+
Enabled: false
|
224
|
+
|
225
|
+
# Lint
|
226
|
+
|
227
|
+
AmbiguousOperator:
|
228
|
+
Enabled: false
|
229
|
+
|
230
|
+
AmbiguousRegexpLiteral:
|
231
|
+
Enabled: false
|
232
|
+
|
233
|
+
AssignmentInCondition:
|
234
|
+
Enabled: false
|
235
|
+
|
236
|
+
ConditionPosition:
|
237
|
+
Enabled: false
|
238
|
+
|
239
|
+
DeprecatedClassMethods:
|
240
|
+
Enabled: false
|
241
|
+
|
242
|
+
ElseLayout:
|
243
|
+
Enabled: false
|
244
|
+
|
245
|
+
HandleExceptions:
|
246
|
+
Enabled: false
|
247
|
+
|
248
|
+
InvalidCharacterLiteral:
|
249
|
+
Enabled: false
|
250
|
+
|
251
|
+
LiteralInCondition:
|
252
|
+
Enabled: false
|
253
|
+
|
254
|
+
LiteralInInterpolation:
|
255
|
+
Enabled: false
|
256
|
+
|
257
|
+
Loop:
|
258
|
+
Enabled: false
|
259
|
+
|
260
|
+
ParenthesesAsGroupedExpression:
|
261
|
+
Enabled: false
|
262
|
+
|
263
|
+
RequireParentheses:
|
264
|
+
Enabled: false
|
265
|
+
|
266
|
+
UnderscorePrefixedVariableName:
|
267
|
+
Enabled: false
|
268
|
+
|
269
|
+
Void:
|
270
|
+
Enabled: false
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
liquid-ruby (0.1.0)
|
5
|
+
json
|
6
|
+
rest-client (~> 1.8.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.3.8)
|
12
|
+
coderay (1.1.0)
|
13
|
+
crack (0.4.2)
|
14
|
+
safe_yaml (~> 1.0.0)
|
15
|
+
diff-lcs (1.2.5)
|
16
|
+
domain_name (0.5.25)
|
17
|
+
unf (>= 0.0.5, < 1.0.0)
|
18
|
+
hashdiff (0.2.3)
|
19
|
+
http-cookie (1.0.2)
|
20
|
+
domain_name (~> 0.5)
|
21
|
+
json (1.8.3)
|
22
|
+
method_source (0.8.2)
|
23
|
+
mime-types (2.99)
|
24
|
+
netrc (0.11.0)
|
25
|
+
pry (0.10.1)
|
26
|
+
coderay (~> 1.1.0)
|
27
|
+
method_source (~> 0.8.1)
|
28
|
+
slop (~> 3.4)
|
29
|
+
rake (10.4.2)
|
30
|
+
rest-client (1.8.0)
|
31
|
+
http-cookie (>= 1.0.2, < 2.0)
|
32
|
+
mime-types (>= 1.16, < 3.0)
|
33
|
+
netrc (~> 0.7)
|
34
|
+
rspec (3.4.0)
|
35
|
+
rspec-core (~> 3.4.0)
|
36
|
+
rspec-expectations (~> 3.4.0)
|
37
|
+
rspec-mocks (~> 3.4.0)
|
38
|
+
rspec-core (3.4.1)
|
39
|
+
rspec-support (~> 3.4.0)
|
40
|
+
rspec-expectations (3.4.0)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.4.0)
|
43
|
+
rspec-mocks (3.4.0)
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
+
rspec-support (~> 3.4.0)
|
46
|
+
rspec-support (3.4.0)
|
47
|
+
safe_yaml (1.0.4)
|
48
|
+
slop (3.6.0)
|
49
|
+
unf (0.1.4)
|
50
|
+
unf_ext
|
51
|
+
unf_ext (0.0.7.1)
|
52
|
+
vcr (3.0.0)
|
53
|
+
webmock (1.22.3)
|
54
|
+
addressable (>= 2.3.6)
|
55
|
+
crack (>= 0.3.2)
|
56
|
+
hashdiff
|
57
|
+
|
58
|
+
PLATFORMS
|
59
|
+
ruby
|
60
|
+
|
61
|
+
DEPENDENCIES
|
62
|
+
bundler (~> 1.10)
|
63
|
+
liquid-ruby!
|
64
|
+
pry
|
65
|
+
rake (~> 10.0)
|
66
|
+
rspec
|
67
|
+
vcr
|
68
|
+
webmock
|
69
|
+
|
70
|
+
BUNDLED WITH
|
71
|
+
1.10.6
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Liquid
|
2
|
+
|
3
|
+
Ruby wrapper for the Liquid API (analyze and collect)
|
4
|
+
|
5
|
+
This gem is currently in development, it might break something :grimacing:
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'liquid-ruby'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install liquid-ruby
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
#### Setup authentication
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
Liquid.configure do |config|
|
29
|
+
config.analyze_api = 'your_analyze_token'
|
30
|
+
config.collect_api = 'your_collect_token'
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
#### Track event
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
user_attrs = { unique_id: 'your_unique_id', age: 25, premium: true }
|
38
|
+
event_attrs = { name: 'buy' }
|
39
|
+
|
40
|
+
Liquid.track(user_attrs, event_attrs)
|
41
|
+
```
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
Bug reports and pull requests are welcome on GitHub at:
|
46
|
+
|
47
|
+
https://github.com/lqd-io/liquid-ruby
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'liquid'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/liquid.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'cgi'
|
3
|
+
require 'uri'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
require 'liquid/version'
|
7
|
+
require 'liquid/network'
|
8
|
+
require 'liquid/request_factory'
|
9
|
+
require 'liquid/configuration'
|
10
|
+
require 'liquid/errors'
|
11
|
+
|
12
|
+
module Liquid
|
13
|
+
@configuration = Liquid::Configuration.new
|
14
|
+
@network = Liquid::RequestFactory.new
|
15
|
+
|
16
|
+
def self.configure
|
17
|
+
if block_given?
|
18
|
+
yield @configuration
|
19
|
+
@Liquid
|
20
|
+
@network.configure @configuration
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Track an event
|
25
|
+
# @param [Hash] user attributes (mandatory fields [unique_id])
|
26
|
+
# @param [Hash] event attributes (mandatory fields [date])
|
27
|
+
# @param [Hash] device attributes
|
28
|
+
def self.track(user, event, device = {})
|
29
|
+
date = DateTime.now
|
30
|
+
event[:date] = date
|
31
|
+
device[:unique_id] ||= "Ruby::#{user[:unique_id]}"
|
32
|
+
device[:platform] ||= 'Ruby'
|
33
|
+
dp = { user: user, device: device, event: event, timestamp: date }
|
34
|
+
@network.create_data_point dp
|
35
|
+
true
|
36
|
+
end
|
37
|
+
|
38
|
+
# Make alias (merge 2 users)
|
39
|
+
# @param [String] old_unique_id of user
|
40
|
+
# @param [String] new unique_id of user
|
41
|
+
def self.alias(old_unique_id, new_unique_id)
|
42
|
+
@network.make_alias old_unique_id, new_unique_id
|
43
|
+
true
|
44
|
+
end
|
45
|
+
|
46
|
+
# ---------------
|
47
|
+
# ANALYZE API
|
48
|
+
# ---------------
|
49
|
+
|
50
|
+
# Get User info
|
51
|
+
def self.user(unique_id)
|
52
|
+
@network.user unique_id
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Liquid::Configuration
|
2
|
+
CONFIGURABLE_ATTRIBUTES = %i(collect_api analyze_api)
|
3
|
+
|
4
|
+
attr_accessor *CONFIGURABLE_ATTRIBUTES
|
5
|
+
|
6
|
+
def initialize(attrs = {})
|
7
|
+
self.attributes = attrs
|
8
|
+
end
|
9
|
+
|
10
|
+
def attributes=(attrs = {})
|
11
|
+
attrs.each { |key, value| instance_variable_set("@#{key}", value) }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Liquid
|
2
|
+
class LiquidError < StandardError
|
3
|
+
end
|
4
|
+
|
5
|
+
class LiquidUnauthorizedError < LiquidError
|
6
|
+
end
|
7
|
+
|
8
|
+
class LiquidInvalidDataPointError < LiquidError
|
9
|
+
end
|
10
|
+
|
11
|
+
class ErrorHandler
|
12
|
+
def self.fail(error_code, message = nil)
|
13
|
+
case error_code
|
14
|
+
when 401
|
15
|
+
raise LiquidUnauthorizedError.new "#{error_code}: #{message}"
|
16
|
+
when 422
|
17
|
+
raise LiquidInvalidDataPointError.new "#{error_code}: #{message}"
|
18
|
+
else
|
19
|
+
raise LiquidError.new "#{error_code}: #{message}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class Liquid::Network
|
2
|
+
require 'rest_client'
|
3
|
+
|
4
|
+
USER_AGENT = "Liquid/#{Liquid::VERSION} (Ruby ;)"
|
5
|
+
|
6
|
+
def initialize(end_point = nil, token = nil)
|
7
|
+
@headers = default_headers
|
8
|
+
@end_point = end_point
|
9
|
+
change_token token unless token.nil?
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(path)
|
13
|
+
parse(generic_request(path).get(&handle_error))
|
14
|
+
end
|
15
|
+
|
16
|
+
def post(path, params = {})
|
17
|
+
parse(generic_request(path).post params, &handle_error)
|
18
|
+
end
|
19
|
+
|
20
|
+
def put(path, params = {})
|
21
|
+
parse(generic_request(path).put params, &handle_error)
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete(path, params = {})
|
25
|
+
parse(generic_request(path).delete params, &handle_error)
|
26
|
+
end
|
27
|
+
|
28
|
+
def generic_request(path)
|
29
|
+
RestClient::Resource.new("#{@end_point}#{path}", headers: @headers)
|
30
|
+
end
|
31
|
+
|
32
|
+
def change_token(token)
|
33
|
+
@headers['Authorization'] = "Token #{token}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def default_headers
|
37
|
+
{
|
38
|
+
'User-Agent' => USER_AGENT,
|
39
|
+
'Accept' => 'application/vnd.lqd.v1+json',
|
40
|
+
'Content-Type' => 'application/json',
|
41
|
+
'Accept-Encoding' => 'gzip',
|
42
|
+
'Authorization' => 'Token '
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def parse(response)
|
49
|
+
JSON.parse(response)
|
50
|
+
rescue JSON::ParserError
|
51
|
+
true
|
52
|
+
end
|
53
|
+
|
54
|
+
def handle_error
|
55
|
+
proc do |response, request, result, &block|
|
56
|
+
if response.code >= 400 && response.code <= 500
|
57
|
+
Liquid::ErrorHandler.fail response.code, response
|
58
|
+
else
|
59
|
+
response.return!(request, result, &block)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Requests router between analyze and collect
|
2
|
+
class Liquid::RequestFactory
|
3
|
+
COLLECT_ENDPOINT = 'https://api.lqd.io/collect/'
|
4
|
+
ANALYZE_ENDPOINT = 'https://analyze.onliquid.com/'
|
5
|
+
|
6
|
+
def initialize(configuration = nil)
|
7
|
+
configure configuration unless configuration.nil?
|
8
|
+
end
|
9
|
+
|
10
|
+
def configure(configuration)
|
11
|
+
@collect_token = configuration.collect_api
|
12
|
+
@analyze_token = configuration.analyze_api
|
13
|
+
@collect = Liquid::Network.new COLLECT_ENDPOINT, @collect_token
|
14
|
+
@analyze = Liquid::Network.new ANALYZE_ENDPOINT, @analyze_token
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_data_point(data_point)
|
18
|
+
@collect.post 'data_points', data_point
|
19
|
+
end
|
20
|
+
|
21
|
+
def make_alias(old_unique_id, new_unique_id)
|
22
|
+
payload = { unique_id: new_unique_id, unique_id_alias: old_unique_id }
|
23
|
+
@collect.post 'aliases', payload
|
24
|
+
end
|
25
|
+
|
26
|
+
def user(unique_id)
|
27
|
+
@analyze.get "users/#{unique_id}"
|
28
|
+
end
|
29
|
+
end
|
data/liquid.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'liquid/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'liquid-ruby'
|
8
|
+
spec.version = Liquid::VERSION
|
9
|
+
spec.authors = ['Ricardo Leitao']
|
10
|
+
spec.email = ['rleitao@onliquid.com']
|
11
|
+
|
12
|
+
spec.summary = 'Ruby wrapper for the Liquid API'
|
13
|
+
spec.description = 'Ruby wrapper for the Liquid API (https://onliquid.com)'
|
14
|
+
spec.homepage = 'https://github.com/lqd-io/liquid-ruby'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rspec'
|
27
|
+
spec.add_development_dependency 'webmock'
|
28
|
+
spec.add_development_dependency 'vcr'
|
29
|
+
spec.add_development_dependency 'pry'
|
30
|
+
|
31
|
+
spec.add_dependency 'rest-client', '~> 1.8.0'
|
32
|
+
spec.add_dependency 'json'
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: liquid-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ricardo Leitao
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
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: webmock
|
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
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: vcr
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rest-client
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.8.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.8.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: json
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Ruby wrapper for the Liquid API (https://onliquid.com)
|
126
|
+
email:
|
127
|
+
- rleitao@onliquid.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- ".rubocop.yml"
|
135
|
+
- Gemfile
|
136
|
+
- Gemfile.lock
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- bin/console
|
140
|
+
- bin/setup
|
141
|
+
- lib/liquid.rb
|
142
|
+
- lib/liquid/configuration.rb
|
143
|
+
- lib/liquid/errors.rb
|
144
|
+
- lib/liquid/network.rb
|
145
|
+
- lib/liquid/request_factory.rb
|
146
|
+
- lib/liquid/version.rb
|
147
|
+
- liquid.gemspec
|
148
|
+
homepage: https://github.com/lqd-io/liquid-ruby
|
149
|
+
licenses: []
|
150
|
+
metadata: {}
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 2.5.0
|
168
|
+
signing_key:
|
169
|
+
specification_version: 4
|
170
|
+
summary: Ruby wrapper for the Liquid API
|
171
|
+
test_files: []
|