Skip to content
Browse files

Extract ipaddresses to external repository

Signed-off-by: Shin-ichiro OGAWA <rust.stnard+git@gmail.com>
  • Loading branch information...
1 parent 69bcc1a commit c18d66a45d6a39d82ba0a758bccc3366c637f13f @rust rust committed Sep 3, 2010
View
1 .gitignore
@@ -4,3 +4,4 @@ pkg
.bundle
Gemfile
Gemfile.lock
+vendor
View
11 lib/jpmobile.rb
@@ -28,17 +28,6 @@ module Mobile
autoload :Display, 'jpmobile/mobile/display'
- module IpAddresses
- autoload :AbstractIpAddresses, 'jpmobile/mobile/ip_addresses/abstract_ip_addresses'
- autoload :Docomo, 'jpmobile/mobile/ip_addresses/docomo'
- autoload :Au, 'jpmobile/mobile/ip_addresses/au'
- autoload :Softbank, 'jpmobile/mobile/ip_addresses/softbank'
- autoload :Vodafone, 'jpmobile/mobile/ip_addresses/softbank'
- autoload :Willcom, 'jpmobile/mobile/ip_addresses/willcom'
- autoload :Ddipocket, 'jpmobile/mobile/ip_addresses/willcom'
- autoload :Emobile, 'jpmobile/mobile/ip_addresses/emobile'
- end
-
DEFAULT_CARRIERS = %w(Docomo Au Softbank Vodafone Emobile Willcom Ddipocket Iphone Android WindowsPhone)
def self.carriers
View
23 lib/jpmobile/mobile/ip_addresses/abstract_ip_addresses.rb
@@ -1,23 +0,0 @@
-module Jpmobile
- module Mobile
- module IpAddresses
- class AbstractIpAddresses
- def valid_ip?(remote_ip_str)
- begin
- remote_ip = IPAddr.new(remote_ip_str)
- rescue
- return false
- end
-
- self.class.ip_address_list.any? {|ip| ip.include?(remote_ip)}
- end
-
- class << self
- def ip_address_list
- []
- end
- end
- end
- end
- end
-end
View
40 lib/jpmobile/mobile/ip_addresses/au.rb
@@ -1,40 +0,0 @@
-module Jpmobile
- module Mobile
- module IpAddresses
- class Au < AbstractIpAddresses
- class << self
- def ip_address_list
- @@ip_address_list ||= [
- "210.230.128.224/28",
- "121.111.227.160/27",
- "61.117.1.0/28",
- "219.108.158.0/27",
- "219.125.146.0/28",
- "61.117.2.32/29",
- "61.117.2.40/29",
- "219.108.158.40/29",
- "219.125.148.0/25",
- "222.5.63.0/25",
- "222.5.63.128/25",
- "222.5.62.128/25",
- "59.135.38.128/25",
- "219.108.157.0/25",
- "219.125.145.0/25",
- "121.111.231.0/25",
- "121.111.227.0/25",
- "118.152.214.192/26",
- "118.159.131.0/25",
- "118.159.133.0/25",
- "118.159.132.160/27",
- "111.86.142.0/26",
- "111.86.141.64/26",
- "111.86.141.128/26",
- "111.86.141.192/26",
- "118.159.133.192/26"
- ].map {|ip| IPAddr.new(ip) }
- end
- end
- end
- end
- end
-end
View
22 lib/jpmobile/mobile/ip_addresses/docomo.rb
@@ -1,22 +0,0 @@
-module Jpmobile
- module Mobile
- module IpAddresses
- class Docomo < AbstractIpAddresses
- class << self
- def ip_address_list
- @@ip_address_list ||= [
- "210.153.84.0/24",
- "210.136.161.0/24",
- "210.153.86.0/24",
- "124.146.174.0/24",
- "124.146.175.0/24",
- "202.229.176.0/24",
- "202.229.177.0/24",
- "202.229.178.0/24"
- ].map {|ip| IPAddr.new(ip)}
- end
- end
- end
- end
- end
-end
View
15 lib/jpmobile/mobile/ip_addresses/emobile.rb
@@ -1,15 +0,0 @@
-module Jpmobile
- module Mobile
- module IpAddresses
- class Emobile < AbstractIpAddresses
- class << self
- def ip_address_list
- @@ip_address_list ||= [
- "117.55.1.224/27"
- ].map {|ip| IPAddr.new(ip) }
- end
- end
- end
- end
- end
-end
View
20 lib/jpmobile/mobile/ip_addresses/softbank.rb
@@ -1,20 +0,0 @@
-module Jpmobile
- module Mobile
- module IpAddresses
- class Softbank < AbstractIpAddresses
- class << self
- def ip_address_list
- @@ip_address_list ||= [
- "123.108.237.0/27",
- "202.253.96.224/27",
- "210.146.7.192/26",
- "210.175.1.128/25"
- ].map {|ip| IPAddr.new(ip) }
- end
- end
- end
- class Vodafone < Softbank
- end
- end
- end
-end
View
158 lib/jpmobile/mobile/ip_addresses/willcom.rb
@@ -1,158 +0,0 @@
-module Jpmobile
- module Mobile
- module IpAddresses
- class Willcom < AbstractIpAddresses
- class << self
- def ip_address_list
- @@ip_address_list ||= [
- "61.198.128.0/24",
- "61.198.129.0/24",
- "61.198.130.0/24",
- "61.198.131.0/24",
- "61.198.132.0/24",
- "61.198.133.0/24",
- "61.198.134.0/24",
- "61.198.135.0/24",
- "61.198.136.0/24",
- "61.198.137.0/24",
- "61.198.138.100/32",
- "61.198.138.101/32",
- "61.198.138.102/32",
- "61.198.138.103/32",
- "61.198.139.0/29",
- "61.198.139.128/27",
- "61.198.139.160/28",
- "61.198.140.0/24",
- "61.198.141.0/24",
- "61.198.142.0/24",
- "61.198.143.0/24",
- "61.198.160.0/24",
- "61.198.161.0/24",
- "61.198.162.0/24",
- "61.198.163.0/24",
- "61.198.164.0/24",
- "61.198.165.0/24",
- "61.198.166.0/24",
- "61.198.168.0/24",
- "61.198.169.0/24",
- "61.198.170.0/24",
- "61.198.171.0/24",
- "61.198.172.0/24",
- "61.198.173.0/24",
- "61.198.174.0/24",
- "61.198.175.0/24",
- "61.198.248.0/24",
- "61.198.249.0/24",
- "61.198.250.0/24",
- "61.198.251.0/24",
- "61.198.252.0/24",
- "61.198.253.0/24",
- "61.198.254.0/24",
- "61.198.255.0/24",
- "61.204.0.0/24",
- "61.204.2.0/24",
- "61.204.3.0/25",
- "61.204.3.128/25",
- "61.204.4.0/24",
- "61.204.5.0/24",
- "61.204.6.0/25",
- "61.204.6.128/25",
- "61.204.7.0/25",
- "61.204.92.0/24",
- "61.204.93.0/24",
- "61.204.94.0/24",
- "61.204.95.0/24",
- "114.20.49.0/24",
- "114.20.50.0/24",
- "114.20.51.0/24",
- "114.20.52.0/24",
- "114.20.53.0/24",
- "114.20.54.0/24",
- "114.20.55.0/24",
- "114.20.56.0/24",
- "114.20.57.0/24",
- "114.20.58.0/24",
- "114.20.59.0/24",
- "114.20.60.0/24",
- "114.20.61.0/24",
- "114.20.62.0/24",
- "114.20.63.0/24",
- "114.20.64.0/24",
- "114.20.65.0/24",
- "114.20.66.0/24",
- "114.20.67.0/24",
- "114.21.255.0/27",
- "125.28.0.0/24",
- "125.28.1.0/24",
- "125.28.15.0/24",
- "125.28.16.0/24",
- "125.28.17.0/24",
- "125.28.2.0/24",
- "125.28.3.0/24",
- "125.28.4.0/24",
- "125.28.5.0/24",
- "125.28.8.0/24",
- "210.168.246.0/24",
- "210.168.247.0/24",
- "210.169.92.0/24",
- "210.169.93.0/24",
- "210.169.94.0/24",
- "210.169.95.0/24",
- "210.169.96.0/24",
- "210.169.97.0/24",
- "210.169.98.0/24",
- "210.169.99.0/24",
- "211.126.192.128/25",
- "211.18.232.0/24",
- "211.18.233.0/24",
- "211.18.234.0/24",
- "211.18.235.0/24",
- "211.18.236.0/24",
- "211.18.237.0/24",
- "219.108.10.0/24",
- "219.108.11.0/24",
- "219.108.12.0/24",
- "219.108.13.0/24",
- "219.108.14.0/24",
- "219.108.15.0/24",
- "219.108.7.0/24",
- "219.108.8.0/24",
- "219.108.9.0/24",
- "221.119.0.0/24",
- "221.119.1.0/24",
- "221.119.2.0/24",
- "221.119.3.0/24",
- "221.119.4.0/24",
- "221.119.6.0/24",
- "221.119.7.0/24",
- "221.119.8.0/24",
- "221.119.9.0/24",
- "114.20.49.0/24",
- "114.20.50.0/24",
- "114.20.51.0/24",
- "114.20.52.0/24",
- "114.20.53.0/24",
- "114.20.54.0/24",
- "114.20.55.0/24",
- "114.20.56.0/24",
- "114.20.57.0/24",
- "114.20.58.0/24",
- "114.20.59.0/24",
- "114.20.60.0/24",
- "114.20.61.0/24",
- "114.20.62.0/24",
- "114.20.63.0/24",
- "114.20.64.0/24",
- "114.20.65.0/24",
- "114.20.66.0/24",
- "114.20.67.0/24",
- "114.21.255.0/27"
- ].map {|ip| IPAddr.new(ip) }
- end
- end
- end
- class Ddipocket < Willcom
- end
- end
- end
-end
View
20 lib/tasks/jpmobile_tasks.rake
@@ -4,6 +4,15 @@
# # Task goes here
# end
+def check_ip_addresses
+ ip_address_dir = File.join(File.dirname(__FILE__), "../../vendor/jpmobile-ipaddresses/")
+
+ unless File.exists?(File.join(ip_address_dir, "lib/jpmobile/mobile/ip_addresses/abstract_ip_addresses.rb"))
+ FileUtils.mkdir_p(ip_address_dir)
+ system "git clone git://github.com/jpmobile/jpmobile-ipaddresses.git #{ip_address_dir}"
+ end
+end
+
begin
require 'rspec/core/rake_task'
@@ -57,6 +66,17 @@ namespace :test do
FileUtils.cp_r(file, plugin_path)
end
+ # setup jpmobile-ipaddresses
+ begin
+ plugin_path = File.join(rails_root, 'vendor', 'plugins', 'jpmobile-ipaddresses')
+ FileUtils.mkdir_p(plugin_path)
+ FileList["vendor/jpmobile-ipaddresses/*"].exclude("test").each do |file|
+ FileUtils.cp_r(file, plugin_path)
+ end
+ rescue LoadError
+ puts "IP Address test requires jpmobile-ipaddresses module"
+ end
+
# setup tests
FileList["test/rails/overrides/*"].each do |file|
FileUtils.cp_r(file, rails_root)
View
5 spec/rack_helper.rb
@@ -5,6 +5,11 @@
require 'jpmobile'
require 'jpmobile/rack'
require 'pp' # for debug
+begin
+ require File.dirname(__FILE__)+'/../vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses'
+rescue LoadError
+ puts "IP Address test requires jpmobile-ipaddresses module"
+end
RSpec.configure do |config|
config.include Rack::Test::Methods
View
5 spec/spec_helper.rb
@@ -8,6 +8,11 @@
require 'action_mailer'
require 'initializer'
require dir+'/../lib/jpmobile'
+ # begin
+ require dir+'/../vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses'
+ # rescue LoadError
+ # puts "IP Address test requires jpmobile-ipaddresses module"
+ # end
# set (dummy) RAILS_ROOT
RAILS_ROOT=dir+"/.."
View
5 spec/unit/spec_helper.rb
@@ -2,3 +2,8 @@
require 'rspec'
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib')))
require 'jpmobile'
+begin
+ require File.dirname(__FILE__)+'/../../vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses'
+rescue LoadError
+ puts "[NOTICE] IP Address test requires jpmobile-ipaddresses module"
+end

0 comments on commit c18d66a

Please sign in to comment.
Something went wrong with that request. Please try again.