unimedia_ip_checker 0.0.1

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 (3) hide show
  1. checksums.yaml +15 -0
  2. data/lib/ip_checker.rb +28 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MzI3NWRmZTE5MGI5MzVmZjg3MmZiNmUzNmY4NGE1MjUxYmIwMWY4Yw==
5
+ data.tar.gz: !binary |-
6
+ ZGM3NjA3MDBkYTQ0NDlhNjVlMWVhZGZiYzg1M2I0N2NiY2U1MDUzZQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ODNkYjU0NzFmOTMzMGE4ZmIyYjQyZDMyZjA5YWNkMTUwNmY0ODlmOTI5MmZh
10
+ YjliNjFlYWVkYWQ0ZWFiMTZjM2Q1ZjM4MGUyZTgzNWUxMzExZjMwMGVjZGU4
11
+ N2VmMTIxY2E0MWY0NWY1ZWZjZjBhMTE2ZjIyMDBmM2FiMjU1NjE=
12
+ data.tar.gz: !binary |-
13
+ YWMzNThlMDFkMWJhMWE1NTJlNzdiOWEwNDE5Y2QzOTkxYTk5NWI0NjhlNjMx
14
+ YzgxZjI5ZmI5ZDY3MGQyOTIwMmY2NTljNDViZjAwZmM2M2E1YTNlNjBhNjMz
15
+ ZTRmMTVmNjQ0NzhkNDFhYWQ0YmE1OGYyNGQyZmQ3NWM3ZjU3OWI=
data/lib/ip_checker.rb ADDED
@@ -0,0 +1,28 @@
1
+ class IpChecker
2
+ def initialize(project_name)
3
+ @project_name = project_name
4
+ end
5
+
6
+
7
+ def letme_in(request)
8
+ ip ||= request.remote_ip
9
+ # :auth_type = 1 block
10
+ # :auth_type = 0 allow
11
+
12
+ any_ip = Base::DtbIpAddressBlock.where(:ip_address => 'all', :auth_type => 1, :project => @project_name).first
13
+
14
+ white_list_ip = any_ip && any_ip.auth_type.to_s == '1' ? true : false
15
+
16
+ ip_address = Base::DtbIpAddressBlock.where(:ip_address => ip, :project => @project_name).first
17
+
18
+ if white_list_ip
19
+ # black list
20
+ return false if ip_address
21
+ else
22
+ # white list
23
+ return false unless ip_address
24
+ end
25
+ return true
26
+
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unimedia_ip_checker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Zulnemekh Bekhbat
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2010-04-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple hello world gem
14
+ email:
15
+ - zulnemeh@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/ip_checker.rb
21
+ homepage: http://rubygems.org/gems/unimedia_ip_checker
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.6.13
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: unimedia_ip_checker!
45
+ test_files: []