perf_check 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/perf_check/server.rb +23 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52206bf5e430f664e8e993c4cbe3bd13d0d862df
4
- data.tar.gz: a201513878d7a50c3e467fa87a7a3e37527d3e5f
3
+ metadata.gz: 8364ffc19692621c05b33890106f93f7def8f61a
4
+ data.tar.gz: d5c7127cf7a61c842c95140984c0eabb6217da0c
5
5
  SHA512:
6
- metadata.gz: 8de9daf419d0d923f327638e8c7bd804c44d830e1c8e5dd50e9fff00cd671b247a278961e1fa08fc4b64f2061b94044c81c869907f4aeaeb831cbbd1c5669a1f
7
- data.tar.gz: 198873a5faba4c8870bfce9834f8d08b269685a74729e141257abcd8d4f763160b10a8e0278430d98eb554ab91da12cb30f07a868bf2dd017f3f283207cd1e13
6
+ metadata.gz: 1792332330ace057e55cfdf97e178bf10275d2c855b782814e21a8d8eb3f634dfdbde0d2e1295196c157f5d036c67cc8ede4ca89e9a85b0999bb4954ea7a3642
7
+ data.tar.gz: 4ffdc73593a60a3085a87b28e2003b72a398b8104e87af6fc504f372ab04a5053df508d5b91aebd6952be5a78bfd72fabe9219c019c5d55108b2075214a813ce
@@ -10,6 +10,29 @@ class PerfCheck
10
10
  define_method(:login, &block)
11
11
  end
12
12
 
13
+ def self.authorization_action(method, login_route, &block)
14
+ Rails.application.reload_routes!
15
+ p = Rails.application.routes.recognize_path(login_route, :method => method)
16
+ controller = "#{p[:controller]}_controller".classify.constantize
17
+ action = p[:action]
18
+
19
+ controller.send(:define_method, :get_perf_check_session, &block)
20
+ controller.send(:define_method, action) do
21
+ get_perf_check_session(params[:login], params[:route])
22
+ render :nothing => true
23
+ end
24
+
25
+ authorization do |login, route|
26
+ http = Net::HTTP.new(host, port)
27
+ if method == :post
28
+ response = http.post(login_route, "login=#{login}")
29
+ elsif method == :get
30
+ response = http.get(login_route+"?login=#{login}")
31
+ end
32
+ response['Set-Cookie']
33
+ end
34
+ end
35
+
13
36
  def self.sign_cookie_data(key, data, opts={})
14
37
  opts[:serializer] ||= Marshal
15
38
  secret = Rails.application.config.secret_token
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perf_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - rubytune