thirtysix 0.0.3 → 0.0.4

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: 0ebddafbe1045a12501e5df96fa6d2b15e6c5c72
4
- data.tar.gz: 711d3d9cea916f2c5ae650d3378d88767b176755
3
+ metadata.gz: 10701e01eef03ec1d4bc4a96b52f558e4699a1a8
4
+ data.tar.gz: 2385b6fa710f5c40ef25df28c5622c56826558cb
5
5
  SHA512:
6
- metadata.gz: d5573dab0362dbed7e830a8738ca0853cc3c41690a719e03df7890d883ab323aeb959ca3c2308a8b65d08c0ce08a83aeebdde12e8fd372a9784995a5c5bffed3
7
- data.tar.gz: 1fbdedda992ad6855922ea3cccec2bead0745d41175eaf98fbb6b4982c8ba04ba68bbbb6ebf92fbc8a38c5b3f6b55a717a6d3fd1b5ed69cb9e159e60261d6fb9
6
+ metadata.gz: 7dc0e20999be623a8a101c83029b64c1db25ff339e2d8f109e42d8545d9e82949fa12abcbfa2255c5cc9b09bb40420f97459864930abd3e1154fdf8726c5234e
7
+ data.tar.gz: c873f31704369a0bb40405777512e7bc923ed1ac82c5d591cb2085c7cc7dbf0e2322cba3fccb6e8058cafbbcdd624c69c1d4b7556e07bd632ed5103ebb9b7cd8
@@ -0,0 +1,54 @@
1
+ require 'json'
2
+
3
+ module Thirtysix
4
+ class AppRequest
5
+ attr_accessor :objects,
6
+ :classes,
7
+ :modules,
8
+ :floats,
9
+ :strings,
10
+ :regexps,
11
+ :arrays,
12
+ :hashes,
13
+ :files,
14
+ :request_time_in_milliseconds,
15
+ :controller,
16
+ :action,
17
+ :query_parameters,
18
+ :memory_in_mb
19
+
20
+ def build(start_objects, end_objects, env)
21
+ @objects = (end_objects[:T_OBJECT] || 0) - (start_objects[:T_OBJECT] || 0)
22
+ @classes = (end_objects[:T_CLASS] || 0) - (start_objects[:T_CLASS] || 0)
23
+ @modules = (end_objects[:T_MODULE] || 0) - (start_objects[:T_MODULE] || 0)
24
+ @floats = (end_objects[:T_FLOAT] || 0) - (start_objects[:T_FLOAT] || 0)
25
+ @strings = (end_objects[:T_STRING] || 0) - (start_objects[:T_STRING] || 0)
26
+ @regexps = (end_objects[:T_REGEXP] || 0) - (start_objects[:T_REGEXP] || 0)
27
+ @arrays = (end_objects[:T_ARRAY] || 0) - (start_objects[:T_ARRAY] || 0)
28
+ @hashes = (end_objects[:T_HASH] || 0) - (start_objects[:T_HASH] || 0)
29
+ @files = (end_objects[:T_FILE] || 0) - (start_objects[:T_FILE] || 0)
30
+ @controller = env.fetch("action_dispatch.request.path_parameters", {})[:controller]
31
+ @action = env.fetch("action_dispatch.request.path_parameters", {})[:action]
32
+ @query_parameters = env.fetch("action_dispatch.request.query_parameters", nil)
33
+ end
34
+
35
+ def to_json
36
+ {
37
+ objects: objects,
38
+ classes: classes,
39
+ modules: modules,
40
+ floats: floats,
41
+ strings: strings,
42
+ regexps: regexps,
43
+ arrays: arrays,
44
+ hashes: hashes,
45
+ files: files,
46
+ request_time_in_milliseconds: request_time_in_milliseconds,
47
+ controller: controller,
48
+ action: action,
49
+ query_parameters: query_parameters,
50
+ memory_in_mb: memory_in_mb
51
+ }.to_json
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,10 @@
1
+ module Thirtysix
2
+ module Rack
3
+ class Railtie < ::Rails::Railtie
4
+ initializer 'thirtysix.middleware' do |app|
5
+ puts "Thirtysix: Running Railtie"
6
+ app.middleware.use Thirtysix::Rack::Middleware
7
+ end
8
+ end
9
+ end
10
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thirtysix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary Moore
@@ -18,7 +18,9 @@ extra_rdoc_files: []
18
18
  files:
19
19
  - Gemfile
20
20
  - README.md
21
+ - lib/thirtysix/app_request.rb
21
22
  - lib/thirtysix/rack/middleware.rb
23
+ - lib/thirtysix/rack/railtie.rb
22
24
  homepage: http://github.com/gmoore/thirtysix
23
25
  licenses:
24
26
  - MIT