snogmetrics 0.1.9 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.rubocop.yml +1 -0
  4. data/.rubocop_todo.yml +203 -0
  5. data/Gemfile.lock +128 -25
  6. data/README.mdown +11 -6
  7. data/Rakefile +5 -12
  8. data/lib/snogmetrics.rb +18 -130
  9. data/lib/snogmetrics/kissmetrics_api.rb +112 -0
  10. data/lib/snogmetrics/railtie.rb +0 -1
  11. data/snogmetrics.gemspec +18 -12
  12. metadata +100 -130
  13. data/example/snoggy/.gitignore +0 -1
  14. data/example/snoggy/README.mdown +0 -7
  15. data/example/snoggy/Rakefile +0 -10
  16. data/example/snoggy/app/controllers/application_controller.rb +0 -2
  17. data/example/snoggy/app/controllers/snogs_controller.rb +0 -9
  18. data/example/snoggy/app/views/layouts/application.html.erb +0 -12
  19. data/example/snoggy/app/views/snogs/new.html.erb +0 -11
  20. data/example/snoggy/app/views/snogs/thank_you.html.erb +0 -1
  21. data/example/snoggy/config/boot.rb +0 -110
  22. data/example/snoggy/config/environment.rb +0 -13
  23. data/example/snoggy/config/environments/development.rb +0 -6
  24. data/example/snoggy/config/environments/production.rb +0 -4
  25. data/example/snoggy/config/environments/test.rb +0 -6
  26. data/example/snoggy/config/initializers/snogmetrics.rb +0 -14
  27. data/example/snoggy/config/routes.rb +0 -4
  28. data/example/snoggy/script/about +0 -4
  29. data/example/snoggy/script/console +0 -3
  30. data/example/snoggy/script/dbconsole +0 -3
  31. data/example/snoggy/script/destroy +0 -3
  32. data/example/snoggy/script/generate +0 -3
  33. data/example/snoggy/script/performance/benchmarker +0 -3
  34. data/example/snoggy/script/performance/profiler +0 -3
  35. data/example/snoggy/script/plugin +0 -3
  36. data/example/snoggy/script/runner +0 -3
  37. data/example/snoggy/script/server +0 -3
  38. data/example/snoggy/vendor/plugins/snogmetrics/init.rb +0 -4
  39. data/rails/init.rb +0 -4
  40. data/spec/snogmetrics_spec.rb +0 -224
  41. data/spec/spec.opts +0 -2
  42. data/spec/spec_helper.rb +0 -15
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3ef4ac9b437f568586dd8931fb452375dd6555d2
4
+ data.tar.gz: 91281360881e4dc56e41818fb818f5906d227642
5
+ SHA512:
6
+ metadata.gz: 5fb7598115f385aac4cb2955605dda79f634975fc2545722ea767207d6cee0672483625f1ecc9d81a97d30abac901938a3436824f10003d52666a9ad9036645e
7
+ data.tar.gz: 83b23d805726d468b34c087050338d629bf9ba45b8d2cad0e5fe7a34f8dd5af32939da6a0e71d4e3718ff967cc3a243b61e0dbc734a9366718e938685246935a
data/.gitignore CHANGED
@@ -22,3 +22,26 @@ tmtags
22
22
  /.yardoc
23
23
 
24
24
  ## PROJECT::SPECIFIC
25
+ *.gem
26
+ *.rbc
27
+ /.config
28
+ /coverage/
29
+ /InstalledFiles
30
+ /pkg/
31
+ /spec/reports/
32
+ /spec/examples.txt
33
+ /test/tmp/
34
+ /test/version_tmp/
35
+ /tmp/
36
+
37
+ ## Documentation cache and generated files:
38
+ /.yardoc/
39
+ /_yardoc/
40
+ /doc/
41
+ /rdoc/
42
+
43
+ ## Environment normalization:
44
+ /.bundle/
45
+ /vendor/bundle
46
+ /lib/bundler/man/
47
+
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,203 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-06-29 16:33:13 -0400 using RuboCop version 0.49.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Cop supports --auto-correct.
11
+ Layout/EmptyLinesAroundAccessModifier:
12
+ Exclude:
13
+ - 'example/snoggy/config/boot.rb'
14
+
15
+ # Offense count: 1
16
+ # Cop supports --auto-correct.
17
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
18
+ # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
19
+ Layout/EmptyLinesAroundClassBody:
20
+ Exclude:
21
+ - 'example/snoggy/app/controllers/snogs_controller.rb'
22
+
23
+ # Offense count: 1
24
+ # Cop supports --auto-correct.
25
+ Layout/EmptyLinesAroundExceptionHandlingKeywords:
26
+ Exclude:
27
+ - 'example/snoggy/config/boot.rb'
28
+
29
+ # Offense count: 10
30
+ # Cop supports --auto-correct.
31
+ # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
32
+ Layout/ExtraSpacing:
33
+ Exclude:
34
+ - 'example/snoggy/script/about'
35
+ - 'example/snoggy/script/console'
36
+ - 'example/snoggy/script/dbconsole'
37
+ - 'example/snoggy/script/destroy'
38
+ - 'example/snoggy/script/generate'
39
+ - 'example/snoggy/script/performance/benchmarker'
40
+ - 'example/snoggy/script/performance/profiler'
41
+ - 'example/snoggy/script/plugin'
42
+ - 'example/snoggy/script/runner'
43
+ - 'example/snoggy/script/server'
44
+
45
+ # Offense count: 1
46
+ # Cop supports --auto-correct.
47
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
48
+ # SupportedStyles: normal, rails
49
+ Layout/IndentationConsistency:
50
+ Exclude:
51
+ - 'example/snoggy/config/boot.rb'
52
+
53
+ # Offense count: 3
54
+ # Cop supports --auto-correct.
55
+ Layout/LeadingCommentSpace:
56
+ Exclude:
57
+ - 'example/snoggy/config/environment.rb'
58
+ - 'example/snoggy/config/initializers/snogmetrics.rb'
59
+
60
+ # Offense count: 4
61
+ # Cop supports --auto-correct.
62
+ # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces.
63
+ # SupportedStyles: space, no_space, compact
64
+ # SupportedStylesForEmptyBraces: space, no_space
65
+ Layout/SpaceInsideHashLiteralBraces:
66
+ Exclude:
67
+ - 'example/snoggy/config/environment.rb'
68
+ - 'example/snoggy/config/routes.rb'
69
+
70
+ # Offense count: 5
71
+ # Cop supports --auto-correct.
72
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
73
+ # SupportedStyles: final_newline, final_blank_line
74
+ Layout/TrailingBlankLines:
75
+ Exclude:
76
+ - 'example/snoggy/app/controllers/snogs_controller.rb'
77
+ - 'example/snoggy/config/environment.rb'
78
+ - 'example/snoggy/config/environments/development.rb'
79
+ - 'example/snoggy/config/environments/test.rb'
80
+ - 'example/snoggy/config/initializers/snogmetrics.rb'
81
+
82
+ # Offense count: 2
83
+ # Cop supports --auto-correct.
84
+ Layout/TrailingWhitespace:
85
+ Exclude:
86
+ - 'example/snoggy/app/controllers/snogs_controller.rb'
87
+ - 'example/snoggy/config/environment.rb'
88
+
89
+ # Offense count: 1
90
+ # Configuration parameters: AllowSafeAssignment.
91
+ Lint/AssignmentInCondition:
92
+ Exclude:
93
+ - 'example/snoggy/config/boot.rb'
94
+
95
+ # Offense count: 1
96
+ Lint/UselessAssignment:
97
+ Exclude:
98
+ - 'example/snoggy/config/boot.rb'
99
+
100
+ # Offense count: 3
101
+ # Configuration parameters: CountComments, ExcludedMethods.
102
+ Metrics/BlockLength:
103
+ Max: 176
104
+
105
+ # Offense count: 45
106
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
107
+ # URISchemes: http, https
108
+ Metrics/LineLength:
109
+ Max: 294
110
+
111
+ # Offense count: 1
112
+ # Configuration parameters: CountComments.
113
+ Metrics/MethodLength:
114
+ Max: 22
115
+
116
+ # Offense count: 2
117
+ # Cop supports --auto-correct.
118
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
119
+ # SupportedStyles: percent_q, bare_percent
120
+ Style/BarePercentLiterals:
121
+ Exclude:
122
+ - 'example/snoggy/config/boot.rb'
123
+
124
+ # Offense count: 7
125
+ Style/Documentation:
126
+ Exclude:
127
+ - 'spec/**/*'
128
+ - 'test/**/*'
129
+ - 'example/snoggy/app/controllers/snogs_controller.rb'
130
+ - 'example/snoggy/config/boot.rb'
131
+ - 'lib/snogmetrics/kissmetrics_api.rb'
132
+ - 'lib/snogmetrics/railtie.rb'
133
+
134
+ # Offense count: 2
135
+ # Configuration parameters: MinBodyLength.
136
+ Style/GuardClause:
137
+ Exclude:
138
+ - 'example/snoggy/config/boot.rb'
139
+ - 'lib/snogmetrics/kissmetrics_api.rb'
140
+
141
+ # Offense count: 8
142
+ # Cop supports --auto-correct.
143
+ # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
144
+ # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
145
+ Style/HashSyntax:
146
+ Exclude:
147
+ - 'example/snoggy/app/controllers/snogs_controller.rb'
148
+ - 'example/snoggy/config/environment.rb'
149
+ - 'example/snoggy/config/routes.rb'
150
+
151
+ # Offense count: 1
152
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
153
+ # SupportedStyles: snake_case, camelCase
154
+ Style/MethodName:
155
+ Exclude:
156
+ - 'lib/snogmetrics/kissmetrics_api.rb'
157
+
158
+ # Offense count: 2
159
+ # Cop supports --auto-correct.
160
+ Style/MutableConstant:
161
+ Exclude:
162
+ - 'example/snoggy/config/boot.rb'
163
+ - 'example/snoggy/config/environment.rb'
164
+
165
+ # Offense count: 1
166
+ # Cop supports --auto-correct.
167
+ # Configuration parameters: PreferredDelimiters.
168
+ Style/PercentLiteralDelimiters:
169
+ Exclude:
170
+ - 'example/snoggy/config/routes.rb'
171
+
172
+ # Offense count: 1
173
+ # Cop supports --auto-correct.
174
+ Style/PerlBackrefs:
175
+ Exclude:
176
+ - 'example/snoggy/config/boot.rb'
177
+
178
+ # Offense count: 1
179
+ # Cop supports --auto-correct.
180
+ # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
181
+ # SupportedStyles: slashes, percent_r, mixed
182
+ Style/RegexpLiteral:
183
+ Exclude:
184
+ - 'snogmetrics.gemspec'
185
+
186
+ # Offense count: 1
187
+ # Cop supports --auto-correct.
188
+ Style/RescueModifier:
189
+ Exclude:
190
+ - 'example/snoggy/config/boot.rb'
191
+
192
+ # Offense count: 1
193
+ # Cop supports --auto-correct.
194
+ # Configuration parameters: MinSize, SupportedStyles.
195
+ # SupportedStyles: percent, brackets
196
+ Style/SymbolArray:
197
+ EnforcedStyle: brackets
198
+
199
+ # Offense count: 2
200
+ # Cop supports --auto-correct.
201
+ Style/UnneededPercentQ:
202
+ Exclude:
203
+ - 'example/snoggy/config/boot.rb'
@@ -1,33 +1,133 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- snogmetrics (0.1.4)
4
+ snogmetrics (0.1.9)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
9
  BlueCloth (1.0.1)
10
- actionmailer (2.3.5)
11
- actionpack (= 2.3.5)
12
- actionpack (2.3.5)
13
- activesupport (= 2.3.5)
14
- rack (~> 1.0.0)
15
- activerecord (2.3.5)
16
- activesupport (= 2.3.5)
17
- activeresource (2.3.5)
18
- activesupport (= 2.3.5)
19
- activesupport (2.3.5)
20
- rack (1.0.1)
21
- rails (2.3.5)
22
- actionmailer (= 2.3.5)
23
- actionpack (= 2.3.5)
24
- activerecord (= 2.3.5)
25
- activeresource (= 2.3.5)
26
- activesupport (= 2.3.5)
27
- rake (>= 0.8.3)
10
+ actionmailer (4.2.8)
11
+ actionpack (= 4.2.8)
12
+ actionview (= 4.2.8)
13
+ activejob (= 4.2.8)
14
+ mail (~> 2.5, >= 2.5.4)
15
+ rails-dom-testing (~> 1.0, >= 1.0.5)
16
+ actionpack (4.2.8)
17
+ actionview (= 4.2.8)
18
+ activesupport (= 4.2.8)
19
+ rack (~> 1.6)
20
+ rack-test (~> 0.6.2)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
+ actionview (4.2.8)
24
+ activesupport (= 4.2.8)
25
+ builder (~> 3.1)
26
+ erubis (~> 2.7.0)
27
+ rails-dom-testing (~> 1.0, >= 1.0.5)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
29
+ activejob (4.2.8)
30
+ activesupport (= 4.2.8)
31
+ globalid (>= 0.3.0)
32
+ activemodel (4.2.8)
33
+ activesupport (= 4.2.8)
34
+ builder (~> 3.1)
35
+ activerecord (4.2.8)
36
+ activemodel (= 4.2.8)
37
+ activesupport (= 4.2.8)
38
+ arel (~> 6.0)
39
+ activesupport (4.2.8)
40
+ i18n (~> 0.7)
41
+ minitest (~> 5.1)
42
+ thread_safe (~> 0.3, >= 0.3.4)
43
+ tzinfo (~> 1.1)
44
+ arel (6.0.4)
45
+ ast (2.3.0)
46
+ builder (3.2.3)
47
+ concurrent-ruby (1.0.5)
48
+ diff-lcs (1.3)
49
+ erubis (2.7.0)
50
+ globalid (0.4.0)
51
+ activesupport (>= 4.2.0)
52
+ i18n (0.8.4)
53
+ loofah (2.0.3)
54
+ nokogiri (>= 1.5.9)
55
+ mail (2.6.5)
56
+ mime-types (>= 1.16, < 4)
57
+ mime-types (3.1)
58
+ mime-types-data (~> 3.2015)
59
+ mime-types-data (3.2016.0521)
60
+ mini_portile2 (2.2.0)
61
+ minitest (5.10.2)
62
+ nokogiri (1.8.0)
63
+ mini_portile2 (~> 2.2.0)
64
+ parallel (1.11.2)
65
+ parser (2.4.0.0)
66
+ ast (~> 2.2)
67
+ powerpack (0.1.1)
68
+ rack (1.6.8)
69
+ rack-test (0.6.3)
70
+ rack (>= 1.0)
71
+ rails (4.2.8)
72
+ actionmailer (= 4.2.8)
73
+ actionpack (= 4.2.8)
74
+ actionview (= 4.2.8)
75
+ activejob (= 4.2.8)
76
+ activemodel (= 4.2.8)
77
+ activerecord (= 4.2.8)
78
+ activesupport (= 4.2.8)
79
+ bundler (>= 1.3.0, < 2.0)
80
+ railties (= 4.2.8)
81
+ sprockets-rails
82
+ rails-deprecated_sanitizer (1.0.3)
83
+ activesupport (>= 4.2.0.alpha)
84
+ rails-dom-testing (1.0.8)
85
+ activesupport (>= 4.2.0.beta, < 5.0)
86
+ nokogiri (~> 1.6)
87
+ rails-deprecated_sanitizer (>= 1.0.1)
88
+ rails-html-sanitizer (1.0.3)
89
+ loofah (~> 2.0)
90
+ railties (4.2.8)
91
+ actionpack (= 4.2.8)
92
+ activesupport (= 4.2.8)
93
+ rake (>= 0.8.7)
94
+ thor (>= 0.18.1, < 2.0)
95
+ rainbow (2.2.2)
96
+ rake
28
97
  rake (0.8.7)
29
- rcov (0.9.8)
30
- rspec (1.3.0)
98
+ rspec (3.6.0)
99
+ rspec-core (~> 3.6.0)
100
+ rspec-expectations (~> 3.6.0)
101
+ rspec-mocks (~> 3.6.0)
102
+ rspec-core (3.6.0)
103
+ rspec-support (~> 3.6.0)
104
+ rspec-expectations (3.6.0)
105
+ diff-lcs (>= 1.2.0, < 2.0)
106
+ rspec-support (~> 3.6.0)
107
+ rspec-mocks (3.6.0)
108
+ diff-lcs (>= 1.2.0, < 2.0)
109
+ rspec-support (~> 3.6.0)
110
+ rspec-support (3.6.0)
111
+ rubocop (0.49.1)
112
+ parallel (~> 1.10)
113
+ parser (>= 2.3.3.1, < 3.0)
114
+ powerpack (~> 0.1)
115
+ rainbow (>= 1.99.1, < 3.0)
116
+ ruby-progressbar (~> 1.7)
117
+ unicode-display_width (~> 1.0, >= 1.0.1)
118
+ ruby-progressbar (1.8.1)
119
+ sprockets (3.7.1)
120
+ concurrent-ruby (~> 1.0)
121
+ rack (> 1, < 3)
122
+ sprockets-rails (3.2.0)
123
+ actionpack (>= 4.0)
124
+ activesupport (>= 4.0)
125
+ sprockets (>= 3.0.0)
126
+ thor (0.19.4)
127
+ thread_safe (0.3.6)
128
+ tzinfo (1.2.3)
129
+ thread_safe (~> 0.1)
130
+ unicode-display_width (1.3.0)
31
131
  yard (0.6.0)
32
132
 
33
133
  PLATFORMS
@@ -35,10 +135,13 @@ PLATFORMS
35
135
 
36
136
  DEPENDENCIES
37
137
  BlueCloth
38
- bundler (~> 1.0.0)
39
- rails
40
- rake (~> 0.8.7)
41
- rcov
138
+ bundler
139
+ rails (~> 4.2)
140
+ rake
42
141
  rspec
142
+ rubocop
43
143
  snogmetrics!
44
144
  yard
145
+
146
+ BUNDLED WITH
147
+ 1.14.6
@@ -12,11 +12,14 @@ It's true, but why settle for either or?
12
12
 
13
13
  SNOGmetrics works similarly to flash messages. Events are recorded and saved to the session, and are then sent when the next page is rendered. This way you get all of the benefits of the JavaScript API, but you can record events in your controllers. All you have to do is install this gem, configure it, and add a snipplet of code to your layout.
14
14
 
15
- ## How do I use it?
15
+ ## Rails 3+ How do I use it?
16
16
 
17
- 1. `gem install snogmetrics`
18
- 2. Edit `config/environment.rb` and add `config.gem 'snogmetrics'`
19
- 3. Edit your layout(s) and add `<%= km.js! %>` where you keep your JavaScript includes.
17
+ 1. Add `snogmetrics` in your gemfile and run the bundle command to install it
18
+ 2. Add an initializer file like the following under your config/initializers folder
19
+
20
+ Snogmetrics.kissmetrics_api_key = "your-api-key-here"
21
+
22
+ 3. Edit your layout(s) and add `<%= km.js! %>` in the body tag (this makes it work nicely with Turbolinks)
20
23
  4. Replace all your `KM.record(...)` and `KM.identify(...)` calls in JavaScript with calls to `km.record(...)` and `km.identify(...)`
21
24
 
22
25
  Have a look at the included example application to see it in action.
@@ -35,9 +38,11 @@ SNOGmetrics implements #set, which is equivalent to `_kmq.push(["set", ...])`, t
35
38
 
36
39
  ## Anything else I should know?
37
40
 
38
- Yes, SNOGmetrics will _not_ output the KISSmetrics API code unless `RAILS_ENV` is `production`. Instead it will output code that logs all calls to the console (if `console` is defined).
41
+ Yes, SNOGmetrics will _not_ output the KISSmetrics API code unless `RAILS_ENV` is `production` by default. Instead it will output code that logs all calls to the console (if `console` is defined).
42
+
43
+ If you'd like to change this behaviour, add the following to your initializer:
39
44
 
40
- In a future version this behaviour might be overrideable.
45
+ Snogmetrics.output_strategy = :live
41
46
 
42
47
  ## Note on Patches/Pull Requests
43
48
 
data/Rakefile CHANGED
@@ -1,21 +1,14 @@
1
1
  require 'bundler'
2
2
  require 'yard'
3
3
  require 'spec/rake/spectask'
4
-
5
-
6
- task :default => :spec
4
+ require 'rubocop/rake_task'
5
+ require 'rspec/core/rake_task'
6
+ task default: [:spec, :rubocop]
7
7
 
8
8
  Bundler::GemHelper.install_tasks
9
9
 
10
10
  YARD::Rake::YardocTask.new
11
11
 
12
- Spec::Rake::SpecTask.new(:spec) do |spec|
13
- spec.libs << 'lib' << 'spec'
14
- spec.spec_files = FileList['spec/**/*_spec.rb']
15
- end
12
+ RSpec::Core::RakeTask.new(:spec)
16
13
 
17
- Spec::Rake::SpecTask.new(:rcov) do |spec|
18
- spec.libs << 'lib' << 'spec'
19
- spec.pattern = 'spec/**/*_spec.rb'
20
- spec.rcov = true
21
- end
14
+ RuboCop::RakeTask.new(:rubocop)