Class: Rack::Dedos::Executables::Geoipget
- Inherits:
-
Object
- Object
- Rack::Dedos::Executables::Geoipget
- Defined in:
- lib/rack/dedos/executables/geoipget.rb
Defined Under Namespace
Classes: Maxmind
Instance Attribute Summary collapse
-
#arch ⇒ Object
readonly
Returns the value of attribute arch.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**options) ⇒ Geoipget
constructor
A new instance of Geoipget.
- #run ⇒ Object
Constructor Details
#initialize(**options) ⇒ Geoipget
Returns a new instance of Geoipget.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rack/dedos/executables/geoipget.rb', line 15 def initialize(**) @arch, @dir = 'linux_amd64', '.' OptionParser.new do |o| o. = " Download the geoip database from Maxmind.\n Usage: \#{::File.basename($0)} CONFIG_FILE\n END\n o.on('-a', '--arch ARCH', String, \"architecture (default: \#{arch})\") { @arch = _1 }\n o.on('-d', '--dir DIR', String, \"destination directory (default: \#{dir})\") { @dir = _1 }\n o.on('-A', '--about', 'show author/license information and exit') { self.class.about }\n o.on('-V', '--version', 'show version and exit') { self.class.version }\n end.parse!\n @config = ARGV.first\nend\n" |
Instance Attribute Details
#arch ⇒ Object (readonly)
Returns the value of attribute arch.
13 14 15 |
# File 'lib/rack/dedos/executables/geoipget.rb', line 13 def arch @arch end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/rack/dedos/executables/geoipget.rb', line 13 def config @config end |
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
13 14 15 |
# File 'lib/rack/dedos/executables/geoipget.rb', line 13 def dir @dir end |
Class Method Details
.about ⇒ Object
35 36 37 38 |
# File 'lib/rack/dedos/executables/geoipget.rb', line 35 def self.about puts 'Written by Sven Schwyn (bitcetera.com) and distributed under MIT license.' exit end |
.version ⇒ Object
40 41 42 43 |
# File 'lib/rack/dedos/executables/geoipget.rb', line 40 def self.version puts Rack::Dedos::VERSION exit end |
Instance Method Details
#run ⇒ Object
30 31 32 33 |
# File 'lib/rack/dedos/executables/geoipget.rb', line 30 def run fail "cannot read config file #{config}" unless config && ::File.readable?(config) Maxmind.new(::File.realpath(config), ::File.realpath(dir), arch).get end |