sampl 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ee012d5de21a89e26498868eda7e3ed1105ff11
4
- data.tar.gz: 107d2c7b71d030753545f24d515665255d752b7e
3
+ metadata.gz: 37d47b8f365653696513b4a6cb807bd5a0ed8e81
4
+ data.tar.gz: 01237550258a62bd04d4bdfd1e749c81d41e3ef8
5
5
  SHA512:
6
- metadata.gz: d2f5167fcc3f7bcd1f92a4e14c732f34371662f37837245a50db715918e4f52aa19cdfe856bcb044ea3cf6f016319b23b2b1b578792a35c625c1dc96789ef9d9
7
- data.tar.gz: 2745625b79102609d700cfd875f91dac4234f39f77123f2d087fd513cedc5a5ecbc2cbb30057a135c8656d182ea8f9b4302f79f8356ff04a47b687a98064f408
6
+ metadata.gz: 5bb5d062a4d21449232026bde897499372ae40d570707c818f55289c778d749daaa3f2a043fffe6a2218ba3d89f6cf41330b837ca81910fd7053d4f6625e095d
7
+ data.tar.gz: 43ce9aa54bb3b8f65b45414fa9d1f949ea8a7b408f9891d0b7a1e2345f7be1d03426bdfa2acf11bc189e8dbfb0fed4082b7fb99a8a32c6c2895a66d026ed6966
@@ -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/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'rake'
5
+ gem 'httparty', '~> 0.13'
6
+
7
+ group :development do
8
+ end
@@ -0,0 +1,23 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sampl (0.0.1)
5
+ httparty (~> 0.13)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ httparty (0.13.1)
11
+ json (~> 1.8)
12
+ multi_xml (>= 0.5.2)
13
+ json (1.8.1)
14
+ multi_xml (0.5.5)
15
+ rake (10.3.2)
16
+
17
+ PLATFORMS
18
+ ruby
19
+
20
+ DEPENDENCIES
21
+ httparty (~> 0.13)
22
+ rake
23
+ sampl!
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 5D Lab GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ Sampl.rb
2
+ =========
3
+
4
+ Report tracking events from a Ruby on Rails server.
5
+
6
+ Sampl.rb is a thin wrapper around HTTParty that implements PSIORI's REST API. It tries to adapt and rely on the same concepts and principles that HTTParty uses, so users already familiar with HTTParty will have an easy start with Sampl.rb.
7
+
8
+
9
+ Usage
10
+ -----
11
+
12
+ Sampl's usage is very similar to that of HTTParty, you might already be familiar with. There are two options:
13
+
14
+ A) calling the static methods of the Sampl module:
15
+
16
+ ```
17
+ Sampl.track('rb_test_event', 'test', { app_token: 'your-unique-app-token', debug: true })
18
+ ```
19
+
20
+ B) inheriting the module (recommended) in a custom class and implementing instance methods
21
+
@@ -1,3 +1,121 @@
1
- class Sampl
1
+ require 'httparty'
2
2
 
3
+ require 'sampl/version'
4
+
5
+ module Sampl
6
+
7
+ def self.included(base)
8
+ base.extend ClassMethods
9
+ # the following inheritance pattern was explained in this block post by John Nunemaker:
10
+ # http://www.railstips.org/blog/archives/2006/11/18/class-and-instance-variables-in-ruby/
11
+ # We borrow its implementation from HTTParty so usage is as close to HTTParty as possible.
12
+ base.send :include, HTTParty::ModuleInheritableAttributes
13
+ base.send(:mattr_inheritable, :default_arguments)
14
+ base.send(:mattr_inheritable, :default_endpoint)
15
+ base.instance_variable_set("@default_arguments", {
16
+ sdk: "Sampl.rb",
17
+ sdk_version: Sampl::VERSION,
18
+ event_category: "custom",
19
+ server_side: true
20
+ })
21
+ base.instance_variable_set("@default_endpoint", "http://events.neurometry.com/sample/v01/event")
22
+ end
23
+
24
+ module ClassMethods
25
+
26
+ def version
27
+ Sampl::VERSION
28
+ end
29
+
30
+ def default_arguments #:nodoc:
31
+ @default_arguments
32
+ end
33
+
34
+ def endpoint(endpoint=nil)
35
+ if endpoint.nil?
36
+ @default_endpoint
37
+ else
38
+ @default_endpoint = endpoint
39
+ end
40
+ end
41
+
42
+ def app_token(app_token=nil)
43
+ if app_token.nil?
44
+ default_arguments[:app_token]
45
+ else
46
+ default_arguments[:app_token] = app_token
47
+ end
48
+ end
49
+
50
+ def server_side(flag=nil)
51
+ if flag.nil?
52
+ default_arguments[:server_side]
53
+ else
54
+ default_arguments[:server_side] = flag
55
+ end
56
+ end
57
+
58
+ def track(event_name, event_category="custom", arguments={}, &block)
59
+ perform_tracking event_name, event_category, arguments, &block
60
+ end
61
+
62
+ private
63
+
64
+ def my_blank?(value)
65
+ value.nil? || (value.respond_to?(:empty?) ? !!value.empty? : false)
66
+ end
67
+
68
+ def perform_tracking(event_name, event_category, arguments, &block) # :nodoc:
69
+ # this is the central method that actually performs the tracking call
70
+ # with the help of HTTParty.
71
+
72
+ arguments = arguments.merge({
73
+ event_name: event_name,
74
+ event_category: event_category # will overwrite default value, iff provided and not blank?
75
+ }).select { |key, value| !my_blank?(value) }
76
+
77
+ arguments = HTTParty::ModuleInheritableAttributes.hash_deep_dup(default_arguments).merge({
78
+ timestamp: DateTime.now # will be overwritten by (optional) user-provided timestamp
79
+ }).merge(arguments)
80
+
81
+ HTTParty.post(endpoint,
82
+ body: { p: arguments },
83
+ headers: { 'Accept' => 'application/json'},
84
+ &block)
85
+ end
86
+
87
+ end
88
+
89
+
90
+ class Basement #:nodoc:
91
+ include Sampl # because of the included-method this will pull the ClassMethods into Basement.
92
+ end
93
+
94
+ # change the URI where to send the events. Please note this
95
+ # that chaging this on the static inteface of Sampl directly
96
+ # (Sampl.endpoint="http://my.url.com") will affect the whole
97
+ # app and all tracking calls to Sampl. Thus, all workers
98
+ # in a Rails app will send events to the same endpoint when
99
+ # working with the static interface. Use custom classes
100
+ # when in need for different endpoints.
101
+ def self.endpoint(endpoint=nil)
102
+ Basement.endpoint(endpoint)
103
+ end
104
+
105
+ def self.app_token(app_token=nil)
106
+ Basement.app_token(app_token)
107
+ end
108
+
109
+ def self.server_side(flag=nil)
110
+ Basement.server_side(flag)
111
+ end
112
+
113
+ def self.track(*args, &block)
114
+ Basement.track(*args, &block)
115
+ end
116
+
117
+ def self.version(*args, &block)
118
+ Basement.version(*args, &block)
119
+ end
120
+
3
121
  end
@@ -0,0 +1,3 @@
1
+ module Sampl
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ require "sampl/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'sampl'
8
+ s.version = Sampl::VERSION
9
+ s.date = '2014-08-11'
10
+ s.summary = %q{Report tracking events from a Ruby on Rails server.}
11
+ s.description = %q{Report tracking events from a Ruby on Rails server.}
12
+ s.authors = ["Sascha Lange"]
13
+ s.email = 'sascha@5dlab.com'
14
+ s.homepage = 'https://github.com/wackadoo/sampl.rb'
15
+ s.license = 'MIT'
16
+
17
+ s.add_dependency 'httparty', "~> 0.13"
18
+
19
+ s.post_install_message = 'Sampl on!'
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,65 @@
1
+ #!/bin/sh
2
+ #/ Usage: release
3
+ #/
4
+ #/ Tag the version in the repo and push the gem.
5
+ #/
6
+
7
+ # This is a slightly modified version of httparty's release script.
8
+ #
9
+ # Copyright (c) 2008 John Nunemaker
10
+ #
11
+ # Permission is hereby granted, free of charge, to any person obtaining
12
+ # a copy of this software and associated documentation files (the
13
+ # "Software"), to deal in the Software without restriction, including
14
+ # without limitation the rights to use, copy, modify, merge, publish,
15
+ # distribute, sublicense, and/or sell copies of the Software, and to
16
+ # permit persons to whom the Software is furnished to do so, subject to
17
+ # the following conditions:
18
+ #
19
+ # The above copyright notice and this permission notice shall be
20
+ # included in all copies or substantial portions of the Software.
21
+ #
22
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
+
30
+ set -e
31
+ cd $(dirname "$0")/..
32
+
33
+ [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "help" ] && {
34
+ grep '^#/' <"$0"| cut -c4-
35
+ exit 0
36
+ }
37
+
38
+ gem_name=sampl
39
+
40
+ # Build a new gem archive.
41
+ rm -rf $gem_name-*.gem
42
+ gem build -q $gem_name.gemspec
43
+
44
+ # Make sure we're on the master branch.
45
+ (git branch | grep -q '* master') || {
46
+ echo "Only release from the master branch."
47
+ exit 1
48
+ }
49
+
50
+ # Figure out what version we're releasing.
51
+ tag=v`ls $gem_name-*.gem | sed "s/^$gem_name-\(.*\)\.gem$/\1/"`
52
+
53
+ echo "Releasing $tag"
54
+
55
+ # Make sure we haven't released this version before.
56
+ git fetch -t origin
57
+
58
+ (git tag -l | grep -q "$tag") && {
59
+ echo "Whoops, there's already a '${tag}' tag."
60
+ exit 1
61
+ }
62
+
63
+ # Tag it and bag it.
64
+ gem push $gem_name-*.gem && git tag "$tag" &&
65
+ git push origin master && git push origin "$tag"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sampl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sascha Lange
@@ -9,20 +9,41 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-08-11 00:00:00.000000000 Z
12
- dependencies: []
13
- description: SDK that helps sending tracking events to PSIORI's REST API. To be used
14
- to send events from a Rails backend or any other Ruby program.
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0.13'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '0.13'
27
+ description: Report tracking events from a Ruby on Rails server.
15
28
  email: sascha@5dlab.com
16
29
  executables: []
17
30
  extensions: []
18
31
  extra_rdoc_files: []
19
32
  files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - Gemfile.lock
36
+ - LICENSE
37
+ - README.md
20
38
  - lib/sampl.rb
21
- homepage: https://github.com/wackadoo/analytics-sample.rb
39
+ - lib/sampl/version.rb
40
+ - sampl.gemspec
41
+ - script/release
42
+ homepage: https://github.com/wackadoo/sampl.rb
22
43
  licenses:
23
44
  - MIT
24
45
  metadata: {}
25
- post_install_message:
46
+ post_install_message: Sampl on!
26
47
  rdoc_options: []
27
48
  require_paths:
28
49
  - lib