crowdskout 0.0.10 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/crowdskout.gemspec +1 -1
- data/lib/crowdskout.rb +2 -0
- data/lib/crowdskout/api.rb +5 -0
- data/lib/crowdskout/components/profiles/field.rb +1 -1
- data/lib/crowdskout/components/quartermaster/tracking_code.rb +49 -0
- data/lib/crowdskout/services/quartermaster_service.rb +23 -0
- data/lib/crowdskout/util/config.rb +3 -1
- data/lib/crowdskout/version.rb +1 -1
- data/spec/crowdskout/components/quartermaster/tracking_code_spec.rb +39 -0
- data/spec/crowdskout/services/quartermaster_service_spec.rb +40 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6363fe9476f202a228b63d1311d75c5fe11e222d
|
4
|
+
data.tar.gz: 2787ea9671187ea9e3e6104fa337fba26d3be521
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 874cdb9476f9fafef6081eed9b3a41379cb33ba0ec82ab017f287f68b15b66d44cc23d1dc67f6f8469df138737be582e4c81167b6a7dd5255e2abf63c18806c0
|
7
|
+
data.tar.gz: 0e56816bcbf1ffc4337d02c965e7248248e40c6c3d6183b702c212bda2a9dd9815936d607747818337d6c51b8a07219239359c2564888e1eb2c88cacc6e01301
|
data/crowdskout.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "crowdskout"
|
8
|
-
s.version = '0.0.
|
8
|
+
s.version = '0.0.13'
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.authors = ["Crowdskout", "Revv","Kyle Schutt"]
|
11
11
|
s.homepage = "https://github.com/revvco/crowdskout"
|
data/lib/crowdskout.rb
CHANGED
@@ -40,6 +40,7 @@ module Crowdskout
|
|
40
40
|
autoload :ProfileService, 'crowdskout/services/profile_service'
|
41
41
|
autoload :FieldService, 'crowdskout/services/field_service'
|
42
42
|
autoload :AttributeService, 'crowdskout/services/attribute_service'
|
43
|
+
autoload :QuartermasterService, 'crowdskout/services/quartermaster_service'
|
43
44
|
end
|
44
45
|
|
45
46
|
module Components
|
@@ -53,6 +54,7 @@ module Crowdskout
|
|
53
54
|
autoload :Field, 'crowdskout/components/profiles/field'
|
54
55
|
autoload :Value, 'crowdskout/components/profiles/value'
|
55
56
|
autoload :FieldOptions, 'crowdskout/components/fields/field_options'
|
57
|
+
autoload :TrackingCode, 'crowdskout/components/quartermaster/tracking_code'
|
56
58
|
end
|
57
59
|
|
58
60
|
module Exceptions
|
data/lib/crowdskout/api.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
#
|
2
|
+
# tracking_code.rb
|
3
|
+
# Crowdskout
|
4
|
+
#
|
5
|
+
# Copyright (c) 2016 Kyle Schutt. All rights reserved.
|
6
|
+
|
7
|
+
module Crowdskout
|
8
|
+
module Components
|
9
|
+
class TrackingCode < Component
|
10
|
+
attr_accessor :source, :organization, :client
|
11
|
+
|
12
|
+
# Factory method to create a TrackingCode object from a json string
|
13
|
+
# @param [Hash] props - properties to create object from
|
14
|
+
# @return [TrackingCode]
|
15
|
+
def self.create(props)
|
16
|
+
obj = TrackingCode.new
|
17
|
+
if props
|
18
|
+
props.each do |key, value|
|
19
|
+
obj.send("#{key}=", value.to_i) if obj.respond_to? key
|
20
|
+
end
|
21
|
+
end
|
22
|
+
obj
|
23
|
+
end
|
24
|
+
|
25
|
+
# Generate the crowdskout tracking source based on the codes
|
26
|
+
# @return [String] javascript function with the tracking information
|
27
|
+
def tracking_code_source
|
28
|
+
if !source.nil? && !organization.nil? && !client.nil?
|
29
|
+
%{<!-- Crowdskout -->
|
30
|
+
<script>
|
31
|
+
(function(l,o,v,e,d) {
|
32
|
+
l.cs=l.cs || function() {cs.q.push(arguments);};
|
33
|
+
cs.q=cs.q||[];cs.apiUrl=d;cs('pageView');
|
34
|
+
l.sourceId = #{source};l.clientId = #{client};l.organizationId = #{organization};
|
35
|
+
var a=o.getElementsByTagName(v)[0];var b=o.createElement(v);b.src=e+'/analytics.js';a.parentNode.insertBefore(b,a);
|
36
|
+
})(window, document, 'script', '//s.crowdskout.com','https://a.crowdskout.com');
|
37
|
+
</script>}
|
38
|
+
else
|
39
|
+
%{
|
40
|
+
Tracking Codes Error
|
41
|
+
Source: #{source}
|
42
|
+
Organization: #{organization}
|
43
|
+
Client: #{client}
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# quartermaster_service.rb
|
3
|
+
# Crowdskout
|
4
|
+
#
|
5
|
+
# Copyright (c) 2016 Kyle Schutt. All rights reserved.
|
6
|
+
|
7
|
+
module Crowdskout
|
8
|
+
module Services
|
9
|
+
class QuartermasterService < BaseService
|
10
|
+
class << self
|
11
|
+
|
12
|
+
# More info - to get the tracking codes for CrowdSkout
|
13
|
+
# @return [Components::TrackingCode] Components::TrackingCode
|
14
|
+
def tracking_code
|
15
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.tracking')
|
16
|
+
|
17
|
+
response = RestClient.get(url, get_headers())
|
18
|
+
Components::TrackingCode.create(JSON.parse(response.body)["data"])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/crowdskout/version.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
#
|
2
|
+
# tracking_code_spec.rb
|
3
|
+
# Crowdskout
|
4
|
+
#
|
5
|
+
# Copyright (c) 2016 Kyle Schutt. All rights reserved.require 'spec_helper'
|
6
|
+
|
7
|
+
require 'spec_helper'
|
8
|
+
|
9
|
+
describe Crowdskout::Components::TrackingCode do
|
10
|
+
before do
|
11
|
+
@json_string = %[{
|
12
|
+
"source": 1,
|
13
|
+
"organization": 2,
|
14
|
+
"client": 3
|
15
|
+
}]
|
16
|
+
@hash = JSON.parse(@json_string)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "creates a component" do
|
20
|
+
component = Crowdskout::Components::TrackingCode.create(@hash)
|
21
|
+
expect(component.source).to eq 1
|
22
|
+
expect(component.organization).to eq 2
|
23
|
+
expect(component.client).to eq 3
|
24
|
+
|
25
|
+
expect(component.tracking_code_source.gsub(/\s+/, " ")).to eq %{<!-- Crowdskout -->
|
26
|
+
<script>
|
27
|
+
(function(l,o,v,e,d) {
|
28
|
+
l.cs=l.cs || function() {cs.q.push(arguments);};
|
29
|
+
cs.q=cs.q||[];cs.apiUrl=d;cs('pageView');
|
30
|
+
l.sourceId = #{component.source};l.clientId = #{component.client};l.organizationId = #{component.organization};
|
31
|
+
var a=o.getElementsByTagName(v)[0];var b=o.createElement(v);b.src=e+'/analytics.js';a.parentNode.insertBefore(b,a);
|
32
|
+
})(window, document, 'script', '//s.crowdskout.com','https://a.crowdskout.com');
|
33
|
+
</script>}.gsub(/\s+/, " ")
|
34
|
+
end
|
35
|
+
it "generates the correct json object" do
|
36
|
+
component = Crowdskout::Components::TrackingCode.create(@hash)
|
37
|
+
expect(JSON.parse(component.to_json)).to eq @hash
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#
|
2
|
+
# quartermaster_service_spec.rb
|
3
|
+
# Crowdskout
|
4
|
+
#
|
5
|
+
# Copyright (c) 2016 Kyle Schutt. All rights reserved.require 'spec_helper'
|
6
|
+
|
7
|
+
require 'spec_helper'
|
8
|
+
|
9
|
+
describe Crowdskout::Services::QuartermasterService do
|
10
|
+
before(:each) do
|
11
|
+
@request = double('http request', :user => nil, :password => nil, :url => 'http://example.com', :redirection_history => nil)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#tracking_code" do
|
15
|
+
it "returns a tracking code" do
|
16
|
+
json = load_file('tracking_code_response.json')
|
17
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
18
|
+
|
19
|
+
response = RestClient::Response.create(json, net_http_resp, {}, @request)
|
20
|
+
RestClient.stub(:get).and_return(response)
|
21
|
+
tracking_code = Crowdskout::Services::QuartermasterService.tracking_code
|
22
|
+
|
23
|
+
tracking_code.should be_kind_of(Crowdskout::Components::TrackingCode)
|
24
|
+
|
25
|
+
expect(tracking_code.source).to eq 1
|
26
|
+
expect(tracking_code.organization).to eq 2
|
27
|
+
expect(tracking_code.client).to eq 3
|
28
|
+
|
29
|
+
expect(tracking_code.tracking_code_source.gsub(/\s+/, " ")).to eq %{<!-- Crowdskout -->
|
30
|
+
<script>
|
31
|
+
(function(l,o,v,e,d) {
|
32
|
+
l.cs=l.cs || function() {cs.q.push(arguments);};
|
33
|
+
cs.q=cs.q||[];cs.apiUrl=d;cs('pageView');
|
34
|
+
l.sourceId = #{tracking_code.source};l.clientId = #{tracking_code.client};l.organizationId = #{tracking_code.organization};
|
35
|
+
var a=o.getElementsByTagName(v)[0];var b=o.createElement(v);b.src=e+'/analytics.js';a.parentNode.insertBefore(b,a);
|
36
|
+
})(window, document, 'script', '//s.crowdskout.com','https://a.crowdskout.com');
|
37
|
+
</script>}.gsub(/\s+/, " ")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crowdskout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Crowdskout
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-07-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/crowdskout/components/profiles/item.rb
|
108
108
|
- lib/crowdskout/components/profiles/profile.rb
|
109
109
|
- lib/crowdskout/components/profiles/value.rb
|
110
|
+
- lib/crowdskout/components/quartermaster/tracking_code.rb
|
110
111
|
- lib/crowdskout/components/result_set.rb
|
111
112
|
- lib/crowdskout/exceptions/oauth2_exception.rb
|
112
113
|
- lib/crowdskout/exceptions/service_exception.rb
|
@@ -114,6 +115,7 @@ files:
|
|
114
115
|
- lib/crowdskout/services/base_service.rb
|
115
116
|
- lib/crowdskout/services/field_service.rb
|
116
117
|
- lib/crowdskout/services/profile_service.rb
|
118
|
+
- lib/crowdskout/services/quartermaster_service.rb
|
117
119
|
- lib/crowdskout/util/config.rb
|
118
120
|
- lib/crowdskout/util/helpers.rb
|
119
121
|
- lib/crowdskout/version.rb
|
@@ -125,9 +127,11 @@ files:
|
|
125
127
|
- spec/crowdskout/components/profiles/item_spec.rb
|
126
128
|
- spec/crowdskout/components/profiles/profile_spec.rb
|
127
129
|
- spec/crowdskout/components/profiles/value_spec.rb
|
130
|
+
- spec/crowdskout/components/quartermaster/tracking_code_spec.rb
|
128
131
|
- spec/crowdskout/services/attribute_service_spec.rb
|
129
132
|
- spec/crowdskout/services/field_service_spec.rb
|
130
133
|
- spec/crowdskout/services/profile_service_spec.rb
|
134
|
+
- spec/crowdskout/services/quartermaster_service_spec.rb
|
131
135
|
homepage: https://github.com/revvco/crowdskout
|
132
136
|
licenses:
|
133
137
|
- MIT
|
@@ -148,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
152
|
version: '0'
|
149
153
|
requirements: []
|
150
154
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.
|
155
|
+
rubygems_version: 2.4.8
|
152
156
|
signing_key:
|
153
157
|
specification_version: 4
|
154
158
|
summary: Crowdskout SDK for Ruby
|
@@ -161,6 +165,8 @@ test_files:
|
|
161
165
|
- spec/crowdskout/components/profiles/item_spec.rb
|
162
166
|
- spec/crowdskout/components/profiles/profile_spec.rb
|
163
167
|
- spec/crowdskout/components/profiles/value_spec.rb
|
168
|
+
- spec/crowdskout/components/quartermaster/tracking_code_spec.rb
|
164
169
|
- spec/crowdskout/services/attribute_service_spec.rb
|
165
170
|
- spec/crowdskout/services/field_service_spec.rb
|
166
171
|
- spec/crowdskout/services/profile_service_spec.rb
|
172
|
+
- spec/crowdskout/services/quartermaster_service_spec.rb
|