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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38217b1232f14ba426af17430291a18dfe965dc2
4
- data.tar.gz: 06643f9305150a8159f0ff439d0002e72d1db5ff
3
+ metadata.gz: 6363fe9476f202a228b63d1311d75c5fe11e222d
4
+ data.tar.gz: 2787ea9671187ea9e3e6104fa337fba26d3be521
5
5
  SHA512:
6
- metadata.gz: b945f4fa95813e44890184688833cc23f72f0c6924847c19d282f1fdffb7f86d4aeb7c9758618dfca248a5f4d8866e94fcfc88cf8a475bb59a237c2034366ed1
7
- data.tar.gz: 6005339d5fd4a283d61f8e68c352cf6264fc5c56d018bfbc58ecab5e9644b441b58d877c4392baaff76bec30297e15cb90c399207210a7d057a7ed99a77651a6
6
+ metadata.gz: 874cdb9476f9fafef6081eed9b3a41379cb33ba0ec82ab017f287f68b15b66d44cc23d1dc67f6f8469df138737be582e4c81167b6a7dd5255e2abf63c18806c0
7
+ data.tar.gz: 0e56816bcbf1ffc4337d02c965e7248248e40c6c3d6183b702c212bda2a9dd9815936d607747818337d6c51b8a07219239359c2564888e1eb2c88cacc6e01301
@@ -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.10'
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"
@@ -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
@@ -59,5 +59,10 @@ module Crowdskout
59
59
  def delete_attribute(attribute_id)
60
60
  Services::AttributeService.delete_attribute(attribute_id)
61
61
  end
62
+
63
+ # Quartermaster Service Methods
64
+ def tracking_code
65
+ Services::QuartermasterService.tracking_code
66
+ end
62
67
  end
63
68
  end
@@ -30,7 +30,7 @@ module Crowdskout
30
30
  # Hash override to generate the correct hash
31
31
  def to_hash
32
32
  {
33
- key_name => (value.is_a?(Hash) ? value.to_hash : value)
33
+ key_name => (value.to_hash rescue value)
34
34
  }
35
35
  end
36
36
  end
@@ -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
@@ -23,7 +23,9 @@ module Crowdskout
23
23
 
24
24
  :attributes => 'attributes',
25
25
  :attribute => 'attribute',
26
- :crud_attribute => 'attribute/%s'
26
+ :crud_attribute => 'attribute/%s',
27
+
28
+ :tracking => 'tracking'
27
29
  },
28
30
 
29
31
  # OAuth2 Authorization related configuration options
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Crowdskout
22
- VERSION = '0.0.10'
22
+ VERSION = '0.0.12'
23
23
  end
@@ -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.10
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-05-18 00:00:00.000000000 Z
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.2.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