km 1.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.
Files changed (71) hide show
  1. data/.gitignore +4 -0
  2. data/CHANGELOG +4 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +33 -0
  5. data/README.rdoc +10 -0
  6. data/Rakefile +5 -0
  7. data/bin/km_send +26 -0
  8. data/doc/Accept.html +546 -0
  9. data/doc/Gemfile.html +110 -0
  10. data/doc/Hash.html +283 -0
  11. data/doc/Helper.html +318 -0
  12. data/doc/KM/IdentError.html +159 -0
  13. data/doc/KM/InitError.html +159 -0
  14. data/doc/KM/SaaS.html +451 -0
  15. data/doc/KM.html +493 -0
  16. data/doc/KMError.html +159 -0
  17. data/doc/Object.html +211 -0
  18. data/doc/README_rdoc.html +122 -0
  19. data/doc/Rakefile.html +111 -0
  20. data/doc/String.html +244 -0
  21. data/doc/bin/km_send.html +54 -0
  22. data/doc/created.rid +15 -0
  23. data/doc/images/brick.png +0 -0
  24. data/doc/images/brick_link.png +0 -0
  25. data/doc/images/bug.png +0 -0
  26. data/doc/images/bullet_black.png +0 -0
  27. data/doc/images/bullet_toggle_minus.png +0 -0
  28. data/doc/images/bullet_toggle_plus.png +0 -0
  29. data/doc/images/date.png +0 -0
  30. data/doc/images/find.png +0 -0
  31. data/doc/images/loadingAnimation.gif +0 -0
  32. data/doc/images/macFFBgHack.png +0 -0
  33. data/doc/images/package.png +0 -0
  34. data/doc/images/page_green.png +0 -0
  35. data/doc/images/page_white_text.png +0 -0
  36. data/doc/images/page_white_width.png +0 -0
  37. data/doc/images/plugin.png +0 -0
  38. data/doc/images/ruby.png +0 -0
  39. data/doc/images/tag_green.png +0 -0
  40. data/doc/images/wrench.png +0 -0
  41. data/doc/images/wrench_orange.png +0 -0
  42. data/doc/images/zoom.png +0 -0
  43. data/doc/index.html +142 -0
  44. data/doc/js/darkfish.js +116 -0
  45. data/doc/js/jquery.js +32 -0
  46. data/doc/js/quicksearch.js +114 -0
  47. data/doc/js/thickbox-compressed.js +10 -0
  48. data/doc/lib/km/saas_rb.html +54 -0
  49. data/doc/lib/km/version_rb.html +52 -0
  50. data/doc/lib/km_rb.html +60 -0
  51. data/doc/rdoc.css +730 -0
  52. data/doc/spec/accept_rb.html +62 -0
  53. data/doc/spec/km_old_rb.html +54 -0
  54. data/doc/spec/km_saas_spec_rb.html +56 -0
  55. data/doc/spec/km_send_spec_rb.html +54 -0
  56. data/doc/spec/km_spec_rb.html +54 -0
  57. data/doc/spec/setup_rb.html +60 -0
  58. data/doc/spec/watchr_rb.html +52 -0
  59. data/km.gemspec +28 -0
  60. data/lib/km/saas.rb +39 -0
  61. data/lib/km/version.rb +3 -0
  62. data/lib/km.rb +263 -0
  63. data/spec/accept.rb +90 -0
  64. data/spec/km_old.rb +105 -0
  65. data/spec/km_saas_spec.rb +121 -0
  66. data/spec/km_send_spec.rb +82 -0
  67. data/spec/km_spec.rb +186 -0
  68. data/spec/log/.hold +0 -0
  69. data/spec/setup.rb +78 -0
  70. data/spec/watchr.rb +3 -0
  71. metadata +224 -0
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ spec/log/*
data/CHANGELOG ADDED
@@ -0,0 +1,4 @@
1
+ 1.1.0
2
+ - Add support for hoptoad notifier if defined
3
+ - change log names to use rails environment if rails is defined
4
+ - add SaaS API calls
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :gemcutter
2
+
3
+ # Specify your gem's dependencies in km.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,33 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ km (1.1.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ awesome_print (0.3.1)
10
+ diff-lcs (1.1.2)
11
+ json (1.5.1)
12
+ rake (0.8.7)
13
+ rspec (2.4.0)
14
+ rspec-core (~> 2.4.0)
15
+ rspec-expectations (~> 2.4.0)
16
+ rspec-mocks (~> 2.4.0)
17
+ rspec-core (2.4.0)
18
+ rspec-expectations (2.4.0)
19
+ diff-lcs (~> 1.1.2)
20
+ rspec-mocks (2.4.0)
21
+ watchr (0.7)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ awesome_print
28
+ bundler (>= 1.0.0)
29
+ json
30
+ km!
31
+ rake
32
+ rspec (~> 2.4.0)
33
+ watchr
data/README.rdoc ADDED
@@ -0,0 +1,10 @@
1
+ = Documentation
2
+
3
+ We are hosting our documentation for our Ruby API here: http://support.kissmetrics.com/apis/ruby
4
+
5
+ = SaaS
6
+
7
+ This gem includes SaaS calls. For more information please refer to:
8
+ http://support.kissmetrics.com/getting-started/saas_basics
9
+
10
+ For the methods used, see the {rdoc for SaaS}[link:KM/SaaS.html]
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
data/bin/km_send ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ require 'km'
3
+
4
+ env = 'production'
5
+ begin
6
+ parser = OptionParser.new()
7
+ parser.banner = "#{File.basename($0)} [<log_dir>]\n\n"
8
+ parser.on("-e", "--env ENVIRONMENT", "The environment to run in. Default: production") do |e|
9
+ puts "Note, only production will actually send queries to the kissmetrics servers."
10
+ env = e
11
+ end
12
+
13
+ parser.on_tail("-h", "--help", "This help.") do
14
+ puts parser
15
+ exit
16
+ end
17
+
18
+ opts = parser.parse(ARGV)
19
+ rescue => e
20
+ $stderr.puts "\nERROR: #{e.message}\n\n"
21
+ $stderr.puts parser.help
22
+ exit(-1)
23
+ end
24
+
25
+ KM.init('', :log_dir => opts[0] || KM.log_dir, :host => opts[1] || KM.host, :env => env)
26
+ KM.send_logged_queries
data/doc/Accept.html ADDED
@@ -0,0 +1,546 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
7
+
8
+ <title>Class: Accept</title>
9
+
10
+ <link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="./js/jquery.js" type="text/javascript"
13
+ charset="utf-8"></script>
14
+ <script src="./js/thickbox-compressed.js" type="text/javascript"
15
+ charset="utf-8"></script>
16
+ <script src="./js/quicksearch.js" type="text/javascript"
17
+ charset="utf-8"></script>
18
+ <script src="./js/darkfish.js" type="text/javascript"
19
+ charset="utf-8"></script>
20
+
21
+ </head>
22
+ <body class="class">
23
+
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="./index.html">Home</a>
29
+ <a href="./index.html#classes">Classes</a>
30
+ <a href="./index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="file-metadata">
36
+ <div id="file-list-section" class="section">
37
+ <h3 class="section-header">In Files</h3>
38
+ <div class="section-body">
39
+ <ul>
40
+
41
+ <li><a href="./spec/accept_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
+ class="thickbox" title="spec/accept.rb">spec/accept.rb</a></li>
43
+
44
+ </ul>
45
+ </div>
46
+ </div>
47
+
48
+
49
+ </div>
50
+
51
+ <div id="class-metadata">
52
+
53
+ <!-- Parent Class -->
54
+
55
+ <div id="parent-class-section" class="section">
56
+ <h3 class="section-header">Parent</h3>
57
+
58
+ <p class="link"><a href="Object.html">Object</a></p>
59
+
60
+ </div>
61
+
62
+
63
+ <!-- Namespace Contents -->
64
+
65
+
66
+ <!-- Method Quickref -->
67
+
68
+ <div id="method-list-section" class="section">
69
+ <h3 class="section-header">Methods</h3>
70
+ <ul class="link-list">
71
+
72
+ <li><a href="#method-c-new">::new</a></li>
73
+
74
+ <li><a href="#method-i-clear">#clear</a></li>
75
+
76
+ <li><a href="#method-i-close">#close</a></li>
77
+
78
+ <li><a href="#method-i-handle_input">#handle_input</a></li>
79
+
80
+ <li><a href="#method-i-input_history">#input_history</a></li>
81
+
82
+ <li><a href="#method-i-parse_input">#parse_input</a></li>
83
+
84
+ <li><a href="#method-i-wait">#wait</a></li>
85
+
86
+ </ul>
87
+ </div>
88
+
89
+
90
+ <!-- Included Modules -->
91
+
92
+ </div>
93
+
94
+ <div id="project-metadata">
95
+
96
+
97
+ <div id="fileindex-section" class="section project-section">
98
+ <h3 class="section-header">Files</h3>
99
+ <ul>
100
+
101
+ <li class="file"><a href="./Gemfile.html">Gemfile</a></li>
102
+
103
+ <li class="file"><a href="./README_rdoc.html">README.rdoc</a></li>
104
+
105
+ <li class="file"><a href="./Rakefile.html">Rakefile</a></li>
106
+
107
+ </ul>
108
+ </div>
109
+
110
+
111
+ <div id="classindex-section" class="section project-section">
112
+ <h3 class="section-header">Class/Module Index
113
+ <span class="search-toggle"><img src="./images/find.png"
114
+ height="16" width="16" alt="[+]"
115
+ title="show/hide quicksearch" /></span></h3>
116
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
117
+ <fieldset>
118
+ <legend>Quicksearch</legend>
119
+ <input type="text" name="quicksearch" value=""
120
+ class="quicksearch-field" />
121
+ </fieldset>
122
+ </form>
123
+
124
+ <ul class="link-list">
125
+
126
+ <li><a href="./KM.html">KM</a></li>
127
+
128
+ <li><a href="./KM/IdentError.html">KM::IdentError</a></li>
129
+
130
+ <li><a href="./KM/InitError.html">KM::InitError</a></li>
131
+
132
+ <li><a href="./KM/SaaS.html">KM::SaaS</a></li>
133
+
134
+ <li><a href="./Accept.html">Accept</a></li>
135
+
136
+ <li><a href="./Hash.html">Hash</a></li>
137
+
138
+ <li><a href="./Helper.html">Helper</a></li>
139
+
140
+ <li><a href="./KMError.html">KMError</a></li>
141
+
142
+ <li><a href="./Object.html">Object</a></li>
143
+
144
+ <li><a href="./String.html">String</a></li>
145
+
146
+ </ul>
147
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
148
+ </div>
149
+
150
+
151
+ </div>
152
+ </div>
153
+
154
+ <div id="documentation">
155
+ <h1 class="class">Accept</h1>
156
+
157
+ <div id="description">
158
+
159
+ <p>a library to accept connections as a server, and send back what it received
160
+ on request.</p>
161
+
162
+ </div>
163
+
164
+ <!-- Constants -->
165
+
166
+ <div id="constants-list" class="section">
167
+ <h3 class="section-header">Constants</h3>
168
+ <dl>
169
+
170
+ <dt><a name="URI_REXEGP">URI_REXEGP</a></dt>
171
+
172
+ <dd class="description"></dd>
173
+
174
+
175
+ </dl>
176
+ </div>
177
+
178
+
179
+ <!-- Attributes -->
180
+
181
+ <div id="attribute-method-details" class="method-section section">
182
+ <h3 class="section-header">Attributes</h3>
183
+
184
+
185
+ <div id="server-attribute-method" class="method-detail">
186
+ <a name="server"></a>
187
+
188
+ <a name="server="></a>
189
+
190
+ <div class="method-heading attribute-method-heading">
191
+ <span class="method-name">server</span><span
192
+ class="attribute-access-type">[RW]</span>
193
+ </div>
194
+
195
+ <div class="method-description">
196
+
197
+
198
+
199
+ </div>
200
+ </div>
201
+
202
+ <div id="session-attribute-method" class="method-detail">
203
+ <a name="session"></a>
204
+
205
+ <a name="session="></a>
206
+
207
+ <div class="method-heading attribute-method-heading">
208
+ <span class="method-name">session</span><span
209
+ class="attribute-access-type">[RW]</span>
210
+ </div>
211
+
212
+ <div class="method-description">
213
+
214
+
215
+
216
+ </div>
217
+ </div>
218
+
219
+ <div id="opts-attribute-method" class="method-detail">
220
+ <a name="opts"></a>
221
+
222
+ <div class="method-heading attribute-method-heading">
223
+ <span class="method-name">opts</span><span
224
+ class="attribute-access-type">[R]</span>
225
+ </div>
226
+
227
+ <div class="method-description">
228
+
229
+
230
+
231
+ </div>
232
+ </div>
233
+
234
+ </div>
235
+
236
+
237
+ <!-- Methods -->
238
+
239
+ <div id="public-class-method-details" class="method-section section">
240
+ <h3 class="section-header">Public Class Methods</h3>
241
+
242
+
243
+ <div id="new-method" class="method-detail ">
244
+ <a name="method-c-new"></a>
245
+
246
+
247
+ <div class="method-heading">
248
+ <span class="method-name">new</span><span
249
+ class="method-args">(args = {})</span>
250
+ <span class="method-click-advice">click to toggle source</span>
251
+ </div>
252
+
253
+
254
+ <div class="method-description">
255
+
256
+
257
+
258
+
259
+
260
+ <div class="method-source-code"
261
+ id="new-source">
262
+ <pre>
263
+ <span class="ruby-comment"># File spec/accept.rb, line 14</span>
264
+ def initialize(args = {})
265
+ opts = { :port =&gt; 9292, :debug =&gt; false }
266
+ opts.update(args)
267
+
268
+ puts &quot;Starting up server on port #{opts[:port]} ...&quot;
269
+ <span class="ruby-ivar">@opts</span> = opts
270
+ <span class="ruby-ivar">@server</span> = <span class="ruby-constant">TCPServer</span>.new(opts[:port])
271
+ @@input_history = []
272
+ <span class="ruby-ivar">@handle</span> = <span class="ruby-constant">Thread</span>.start do
273
+ while (<span class="ruby-ivar">@session</span> = server.accept)
274
+ <span class="ruby-constant">Thread</span>.start do
275
+ <span class="ruby-comment"># puts &quot;log: Connection from #{session.peeraddr[2]} at #{session.peeraddr[3]}&quot;</span>
276
+ <span class="ruby-comment"># session.puts &quot;Server: Connection from #{session.peeraddr[2]}\n&quot;</span>
277
+ handle_input
278
+ session.close
279
+ end
280
+ end
281
+ end
282
+ end</pre>
283
+ </div>
284
+
285
+ </div>
286
+
287
+
288
+
289
+
290
+ </div>
291
+
292
+
293
+ </div>
294
+
295
+ <div id="public-instance-method-details" class="method-section section">
296
+ <h3 class="section-header">Public Instance Methods</h3>
297
+
298
+
299
+ <div id="clear-method" class="method-detail ">
300
+ <a name="method-i-clear"></a>
301
+
302
+
303
+ <div class="method-heading">
304
+ <span class="method-name">clear</span><span
305
+ class="method-args">()</span>
306
+ <span class="method-click-advice">click to toggle source</span>
307
+ </div>
308
+
309
+
310
+ <div class="method-description">
311
+
312
+ <p>clear history</p>
313
+
314
+
315
+
316
+ <div class="method-source-code"
317
+ id="clear-source">
318
+ <pre>
319
+ <span class="ruby-comment"># File spec/accept.rb, line 80</span>
320
+ def clear
321
+ @@input_history.clear
322
+ end</pre>
323
+ </div>
324
+
325
+ </div>
326
+
327
+
328
+
329
+
330
+ </div>
331
+
332
+
333
+ <div id="close-method" class="method-detail ">
334
+ <a name="method-i-close"></a>
335
+
336
+
337
+ <div class="method-heading">
338
+ <span class="method-name">close</span><span
339
+ class="method-args">()</span>
340
+ <span class="method-click-advice">click to toggle source</span>
341
+ </div>
342
+
343
+
344
+ <div class="method-description">
345
+
346
+
347
+
348
+
349
+
350
+ <div class="method-source-code"
351
+ id="close-source">
352
+ <pre>
353
+ <span class="ruby-comment"># File spec/accept.rb, line 75</span>
354
+ def close
355
+ session = nil
356
+ server.close
357
+ end</pre>
358
+ </div>
359
+
360
+ </div>
361
+
362
+
363
+
364
+
365
+ </div>
366
+
367
+
368
+ <div id="handle_input-method" class="method-detail ">
369
+ <a name="method-i-handle_input"></a>
370
+
371
+
372
+ <div class="method-heading">
373
+ <span class="method-name">handle_input</span><span
374
+ class="method-args">()</span>
375
+ <span class="method-click-advice">click to toggle source</span>
376
+ </div>
377
+
378
+
379
+ <div class="method-description">
380
+
381
+
382
+
383
+
384
+
385
+ <div class="method-source-code"
386
+ id="handle_input-source">
387
+ <pre>
388
+ <span class="ruby-comment"># File spec/accept.rb, line 40</span>
389
+ def handle_input
390
+ input = session.gets
391
+ if input
392
+ puts &quot;received: #{input.inspect}&quot; if opts[:debug]
393
+ case input
394
+ when <span class="ruby-regexp">/clear/</span>
395
+ clear
396
+ when <span class="ruby-regexp">/history/</span>
397
+ session.puts input_history.to_json
398
+ when <span class="ruby-regexp">/exit/</span>
399
+ begin
400
+ close
401
+ rescue <span class="ruby-constant">Exception</span>
402
+ end
403
+ return
404
+ when <span class="ruby-regexp">/^\s*(GET|POST|PUT|DELETE)\s+([^ ]*)\s+(.*)$/</span>
405
+ @@input_history &lt;&lt; parse_input(input)
406
+ else
407
+ @@input_history &lt;&lt; input.chomp
408
+ end
409
+ end
410
+ end</pre>
411
+ </div>
412
+
413
+ </div>
414
+
415
+
416
+
417
+
418
+ </div>
419
+
420
+
421
+ <div id="input_history-method" class="method-detail ">
422
+ <a name="method-i-input_history"></a>
423
+
424
+
425
+ <div class="method-heading">
426
+ <span class="method-name">input_history</span><span
427
+ class="method-args">()</span>
428
+ <span class="method-click-advice">click to toggle source</span>
429
+ </div>
430
+
431
+
432
+ <div class="method-description">
433
+
434
+
435
+
436
+
437
+
438
+ <div class="method-source-code"
439
+ id="input_history-source">
440
+ <pre>
441
+ <span class="ruby-comment"># File spec/accept.rb, line 33</span>
442
+ def input_history
443
+ @@input_history
444
+ end</pre>
445
+ </div>
446
+
447
+ </div>
448
+
449
+
450
+
451
+
452
+ </div>
453
+
454
+
455
+ <div id="parse_input-method" class="method-detail ">
456
+ <a name="method-i-parse_input"></a>
457
+
458
+
459
+ <div class="method-heading">
460
+ <span class="method-name">parse_input</span><span
461
+ class="method-args">(input)</span>
462
+ <span class="method-click-advice">click to toggle source</span>
463
+ </div>
464
+
465
+
466
+ <div class="method-description">
467
+
468
+
469
+
470
+
471
+
472
+ <div class="method-source-code"
473
+ id="parse_input-source">
474
+ <pre>
475
+ <span class="ruby-comment"># File spec/accept.rb, line 62</span>
476
+ def parse_input(input)
477
+ data = {}
478
+ data[:raw] = input.chomp
479
+ (method,uri,http) = input.scan(<span class="ruby-regexp">/^\s*(\w+)\s+([^ ]*)\s+(.*)$/</span>).flatten
480
+
481
+ data[:method] = method
482
+ data[:http] = http.chomp
483
+ data[:uri] = uri
484
+ u = <span class="ruby-constant">URI</span>(uri)
485
+ data[:path] = u.path
486
+ data[:query] = <span class="ruby-constant">CGI</span>.parse(u.query)
487
+ return data
488
+ end</pre>
489
+ </div>
490
+
491
+ </div>
492
+
493
+
494
+
495
+
496
+ </div>
497
+
498
+
499
+ <div id="wait-method" class="method-detail ">
500
+ <a name="method-i-wait"></a>
501
+
502
+
503
+ <div class="method-heading">
504
+ <span class="method-name">wait</span><span
505
+ class="method-args">()</span>
506
+ <span class="method-click-advice">click to toggle source</span>
507
+ </div>
508
+
509
+
510
+ <div class="method-description">
511
+
512
+
513
+
514
+
515
+
516
+ <div class="method-source-code"
517
+ id="wait-source">
518
+ <pre>
519
+ <span class="ruby-comment"># File spec/accept.rb, line 36</span>
520
+ def wait
521
+ <span class="ruby-ivar">@handle</span>.join
522
+ end</pre>
523
+ </div>
524
+
525
+ </div>
526
+
527
+
528
+
529
+
530
+ </div>
531
+
532
+
533
+ </div>
534
+
535
+
536
+ </div>
537
+
538
+ <div id="validator-badges">
539
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
540
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
541
+ Rdoc Generator</a> 2</small>.</p>
542
+ </div>
543
+
544
+ </body>
545
+ </html>
546
+