itly-plugin-testing 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e8abdb87423a7837ed4c440182e4942d59c3b575a5a66b236b80e692c8a941f5
4
+ data.tar.gz: 22dff78de21efb4e434d8dcc5b0bcac92307c401978fce7457410e102ffc6652
5
+ SHA512:
6
+ metadata.gz: 72e0a57e668dad74226a7357fe86e215742093c3ef60b9d8bbe8dba2cc565923d948fd1bf4028713b179e0d526221fcaaa9b28fd018766c13e6d9c0b91705560
7
+ data.tar.gz: c8d4c76591439746abf764f9ea444699bb6dd29ffaf8494a26d9e6591d54a89a33355f1eddb4efdb9875cb09169450ebdf5da40e6ba9c5b5757fa4ac83242ef6
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in itly-plugin-testing.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+
10
+ if ENV['LOCAL_ITLY_GEM']
11
+ # TODO: before publication to RubyGems, switch to version 1
12
+ gem 'itly-sdk', '~> 0.1', path: '../sdk'
13
+ end
14
+
15
+ gem 'rbs', '~> 1.0'
16
+ gem 'rspec'
17
+ gem 'steep', '~> 0.41'
data/Steepfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ target :lib do
4
+ signature 'sig'
5
+
6
+ check 'lib'
7
+
8
+ library 'logger', 'set', 'itly-sdk'
9
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'itly/plugin-testing'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/rspec ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Configure and load RBS
5
+ unless ENV['DISABLE_TYPE_CHECKING']
6
+ ENV['RBS_TEST_TARGET'] = 'Itly::*'
7
+ ENV['RBS_TEST_LOGLEVEL'] = 'warn'
8
+ ENV['RBS_TEST_DOUBLE_SUITE'] = 'rspec'
9
+ ENV['RBS_TEST_OPT'] = '-I./sig -I./spec/sig -I../sdk/sig'
10
+
11
+ require 'rbs/test/setup'
12
+ end
13
+
14
+ # Start RSpec
15
+ require 'rspec/core'
16
+
17
+ ENV['RSPEC_RUN_FROM_SCRIPT'] = 'true'
18
+ RSpec::Core::Runner.invoke
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/itly/plugin/testing/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'itly-plugin-testing'
7
+ spec.version = Itly::Plugin::Testing::VERSION
8
+ spec.authors = ['Iteratively', 'Benjamin Bouchet', 'Justin Fiedler', 'Andrey Sokolov']
9
+ spec.email = ['support@iterative.ly']
10
+
11
+ spec.summary = 'Testing plugin for Iteratively SDK for Ruby'
12
+ spec.description = 'Track and validate analytics with a unified, extensible interface ' \
13
+ 'that works with all your 3rd party analytics providers.'
14
+ spec.homepage = 'https://github.com/iterativelyhq/itly-sdk-ruby'
15
+ spec.license = 'MIT'
16
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
17
+
18
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
19
+
20
+ spec.metadata['homepage_uri'] = spec.homepage
21
+ spec.metadata['source_code_uri'] = 'https://github.com/iterativelyhq/itly-sdk-ruby/plugin-testing'
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
+ end
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.add_dependency 'concurrent-ruby', '~> 1.1'
31
+ spec.add_dependency 'itly-sdk', '~> 0.1'
32
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ if ENV['LOCAL_ITLY_GEM']
4
+ lib = File.expand_path('../../../sdk/lib', File.dirname(__FILE__))
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+ end
7
+
8
+ require_relative 'plugin/testing/testing'
9
+ require_relative 'plugin/testing/call_options'
10
+ require_relative 'plugin/testing/version'
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Itly
4
+ class Plugin
5
+ # Testing plugin class for Itly SDK
6
+ class Testing
7
+ ##
8
+ # Testing specific plugin options class
9
+ #
10
+ class CallOptions < Itly::PluginCallOptions
11
+ end
12
+
13
+ ##
14
+ # Testing specific plugin options class for calls to plugin methods
15
+ #
16
+ %w[Identify Group Page Track Alias].each do |name|
17
+ class_eval(
18
+ <<-EVAL, __FILE__, __LINE__ + 1
19
+ class #{name}Options < CallOptions # class IdentifyOptions < CallOptions
20
+ end # end
21
+ EVAL
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,118 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'concurrent'
4
+ require 'itly-sdk'
5
+
6
+ class Itly
7
+ class Plugin
8
+ ##
9
+ # Testing plugin class for Itly SDK
10
+ #
11
+ class Testing < Plugin
12
+ attr_reader :logger, :disabled
13
+
14
+ ##
15
+ # Instantiate a new Plugin::Testing
16
+ #
17
+ # @param [TrueClass/FalseClass] disabled: set to true to disable the plugin. Default to false
18
+ #
19
+ def initialize(disabled: false)
20
+ super()
21
+ @calls = Concurrent::Hash.new
22
+ @disabled = disabled
23
+ end
24
+
25
+ ##
26
+ # Initialize TestingApi client
27
+ #
28
+ # @param [Itly::PluginOptions] options: plugins options
29
+ #
30
+ def load(options:)
31
+ super
32
+ # Get options
33
+ @logger = options.logger
34
+
35
+ # Log
36
+ logger&.info "#{id}: load()"
37
+
38
+ logger&.info "#{id}: plugin is disabled!" if @disabled
39
+ end
40
+
41
+ ##
42
+ # Empty the cache
43
+ #
44
+ def reset
45
+ @calls.clear
46
+ end
47
+
48
+ ##
49
+ # Get all events that was sent to the +track+ method
50
+ #
51
+ # @param [String] user_id: (optional) filter the events returned by the method by the user_id.
52
+ # Leave it +nil+ to get all events
53
+ # @return [Array] array of EvItly::Event objects that was sent to the +track+ method
54
+ #
55
+ def all(user_id: nil)
56
+ calls = @calls['track'].dup
57
+ calls = calls.select { |call| call[:user_id] == user_id } unless user_id.nil?
58
+ calls.collect { |call| call[:event] }
59
+ end
60
+
61
+ ##
62
+ # Get events that was sent to the +track+ method of the specified class name
63
+ #
64
+ # @param [Event] class_name: the method return only events of the specified class name
65
+ # @param [String] user_id: (optional) filter the events returned by the method by the user_id.
66
+ # Leave it +nil+ to get all events
67
+ # @return [Array] array of Itly::Event objects that was sent to the +track+ method
68
+ #
69
+ def of_type(class_name:, user_id: nil)
70
+ calls = all user_id: user_id
71
+ calls.select { |call| call.is_a? class_name }
72
+ end
73
+
74
+ ##
75
+ # Get the first event that was sent to the +track+ method of the specified class name
76
+ #
77
+ # @param [Event] class_name: the method return only an event of the specified class name
78
+ # @param [String] user_id: (optional) filter the events returned by the method by the user_id.
79
+ # Leave it +nil+ to get all events
80
+ # @return [Itly::Event] object that was sent to the +track+ method. +nil+ if none was found
81
+ #
82
+ def first_of_type(class_name:, user_id: nil)
83
+ of_type(class_name: class_name, user_id: user_id).first
84
+ end
85
+
86
+ ##
87
+ # Tracking methods
88
+ #
89
+ # Accept any params, store them in the @calls instance variable
90
+ #
91
+ %i[alias identify group track].each do |method_name|
92
+ define_method method_name do |args|
93
+ track_calls method_name.to_s, args
94
+ end
95
+ end
96
+
97
+ ##
98
+ # Get the plugin ID
99
+ #
100
+ # @return [String] plugin id
101
+ #
102
+ def id
103
+ 'testing'
104
+ end
105
+
106
+ private
107
+
108
+ def enabled?
109
+ !@disabled
110
+ end
111
+
112
+ def track_calls(method_name, args)
113
+ @calls[method_name] ||= []
114
+ @calls[method_name] << args
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Itly
4
+ class Plugin
5
+ class Testing < Plugin
6
+ VERSION = '0.1.0'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ class Itly
2
+ class Plugin
3
+ class Testing
4
+ class CallOptions < Itly::PluginCallOptions
5
+ end
6
+
7
+ class IdentifyOptions < CallOptions
8
+ end
9
+
10
+ class GroupOptions < CallOptions
11
+ end
12
+
13
+ class PageOptions < CallOptions
14
+ end
15
+
16
+ class TrackOptions < CallOptions
17
+ end
18
+
19
+ class AliasOptions < CallOptions
20
+ end
21
+ end
22
+ end
23
+ end
data/sig/testing.rbs ADDED
@@ -0,0 +1,28 @@
1
+ class Itly
2
+ class Plugin
3
+ class Testing < Plugin
4
+ VERSION: String
5
+
6
+ attr_reader logger: Logger?
7
+ attr_reader disabled: bool
8
+
9
+ def load: (options: Itly::PluginOptions options) -> void
10
+ def reset: () -> void
11
+ def all: (?user_id: String? user_id) -> Array[Itly::Event]
12
+ def of_type: (class_name: Class class_name, ?user_id: String? user_id) -> Array[Itly::Event]
13
+ def first_of_type: (class_name: Class class_name, ?user_id: String? user_id) -> Itly::Event?
14
+
15
+ def alias: (user_id: String user_id, previous_id: String previous_id, ?options: Itly::PluginCallOptions? options) -> void
16
+ def identify: (user_id: String user_id, ?properties: propertiesHash? properties, ?options: Itly::PluginCallOptions? options) -> void
17
+ def group: (user_id: String user_id, group_id: String group_id, ?properties: propertiesHash? properties, ?options: Itly::PluginCallOptions? options) -> void
18
+ def track: (user_id: String user_id, event: Itly::Event event, ?options: Itly::PluginCallOptions? options) -> void
19
+ def id: () -> String
20
+
21
+ private
22
+
23
+ def initialize: (?disabled: bool disabled) -> void
24
+ def enabled?: () -> bool
25
+ def track_calls: (String method_name, Hash[Symbol, untyped] args) -> void
26
+ end
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itly-plugin-testing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Iteratively
8
+ - Benjamin Bouchet
9
+ - Justin Fiedler
10
+ - Andrey Sokolov
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2021-06-15 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: concurrent-ruby
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.1'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: itly-sdk
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: '0.1'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.1'
44
+ description: Track and validate analytics with a unified, extensible interface that
45
+ works with all your 3rd party analytics providers.
46
+ email:
47
+ - support@iterative.ly
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - ".rspec"
53
+ - Gemfile
54
+ - Steepfile
55
+ - bin/console
56
+ - bin/rspec
57
+ - bin/setup
58
+ - itly-plugin-testing.gemspec
59
+ - lib/itly/plugin-testing.rb
60
+ - lib/itly/plugin/testing/call_options.rb
61
+ - lib/itly/plugin/testing/testing.rb
62
+ - lib/itly/plugin/testing/version.rb
63
+ - sig/call_options.rbs
64
+ - sig/testing.rbs
65
+ homepage: https://github.com/iterativelyhq/itly-sdk-ruby
66
+ licenses:
67
+ - MIT
68
+ metadata:
69
+ allowed_push_host: https://rubygems.org/
70
+ homepage_uri: https://github.com/iterativelyhq/itly-sdk-ruby
71
+ source_code_uri: https://github.com/iterativelyhq/itly-sdk-ruby/plugin-testing
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 2.6.0
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubygems_version: 3.0.3.1
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Testing plugin for Iteratively SDK for Ruby
91
+ test_files: []