jaeheegeo 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.
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ tmp
6
+ log
data/.rvmrc ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
+ environment_id="ruby-1.9.3-p0@jaeheegeo"
8
+
9
+ #
10
+ # Uncomment following line if you want options to be set only for given project.
11
+ #
12
+ # PROJECT_JRUBY_OPTS=( --1.9 )
13
+ #
14
+ # The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
15
+ #
16
+ # chmod +x ${rvm_path}/hooks/after_use_jruby_opts
17
+ #
18
+
19
+ #
20
+ # First we attempt to load the desired environment directly from the environment
21
+ # file. This is very fast and efficient compared to running through the entire
22
+ # CLI and selector. If you want feedback on which environment was used then
23
+ # insert the word 'use' after --create as this triggers verbose mode.
24
+ #
25
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
26
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
27
+ then
28
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
29
+
30
+ if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
31
+ then
32
+ . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
33
+ fi
34
+ else
35
+ # If the environment file has not yet been created, use the RVM CLI to select.
36
+ if ! rvm --create use "$environment_id"
37
+ then
38
+ echo "Failed to create RVM environment '${environment_id}'."
39
+ return 1
40
+ fi
41
+ fi
42
+
43
+ #
44
+ # If you use an RVM gemset file to install a list of gems (*.gems), you can have
45
+ # it be automatically loaded. Uncomment the following and adjust the filename if
46
+ # necessary.
47
+ #
48
+ # filename=".gems"
49
+ # if [[ -s "$filename" ]]
50
+ # then
51
+ # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
52
+ # fi
53
+
54
+ # If you use bundler, this might be useful to you:
55
+ # if [[ -s Gemfile ]] && ! command -v bundle >/dev/null
56
+ # then
57
+ # printf "The rubygem 'bundler' is not installed. Installing it now.\n"
58
+ # gem install bundler
59
+ # fi
60
+ # if [[ -s Gemfile ]] && command -v bundle
61
+ # then
62
+ # bundle install
63
+ # fi
64
+
65
+ if [[ $- == *i* ]] # check for interactive shells
66
+ then
67
+ echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
68
+ else
69
+ echo "Using: $GEM_HOME" # don't use colors in interactive shells
70
+ fi
71
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in jaeheegeo.gemspec
4
+ gemspec
@@ -0,0 +1,35 @@
1
+ # JaeheeGeo
2
+
3
+ This gem contains a simple sinatra-based web application for MaxMind's
4
+ GeoIP service lookup.
5
+
6
+ ## Installation
7
+
8
+ First, install jaeheego.
9
+
10
+ $ gem install jaeheegeo
11
+
12
+ Then run the command below to install geoip data:
13
+
14
+ $ sudo install_geoip
15
+
16
+ ## Usage
17
+
18
+ To run the application, just run:
19
+
20
+ $ jaeheegeo start
21
+
22
+ It will run the sinatra application on thin. So you can provide
23
+ additional parameters like `-p` or `-d`. Default port is 4009.
24
+
25
+ While the application is running, try these:
26
+
27
+ $ curl http://localhost:4009/geoip/220.93.126.147
28
+ $ curl http://localhost:4009/geoip/klassmate.com
29
+
30
+ The output is like this:
31
+
32
+ {"country":"US","county":"CA","city":"San Francisco","lat":37.769699,"lng":-122.393303,"version":"GeoIP City Edition"}
33
+
34
+ JSONP is also supported for cross domain request. Just pass `callback`
35
+ parameter additionally.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thin'
4
+
5
+ rackup_file = "#{File.dirname(__FILE__)}/../config.ru"
6
+
7
+ argv = ARGV
8
+ argv << ["-R", rackup_file] unless ARGV.include?("-R")
9
+ argv << ["-p", "4009"] unless ARGV.include?("-p")
10
+ argv << ["-e", "production"] unless ARGV.include?("-e")
11
+ Thin::Runner.new(argv.flatten).run!
@@ -0,0 +1,3 @@
1
+ $:.unshift(File.join('lib', File.dirname(__FILE__)))
2
+ require 'jaeheegeo'
3
+ run JaeheeGeo::App
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "jaeheegeo/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "jaeheegeo"
7
+ s.version = Jaeheegeo::VERSION
8
+ s.authors = ["Hoseong Hwang"]
9
+ s.email = ["thefron@wafflestudio.com"]
10
+ s.homepage = "http://thefron.me"
11
+ s.summary = %q{Simple web application for geoip}
12
+ s.description = %q{Simple web application for geoip}
13
+
14
+ s.rubyforge_project = "jaeheegeo"
15
+
16
+ s.add_dependency "activesupport"
17
+ s.add_dependency "sinatra"
18
+ s.add_dependency "thin"
19
+ s.add_dependency "autometal-geoip"
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = ["jaeheegeo"]
24
+ s.require_paths = ["lib"]
25
+
26
+ # specify any dependencies here; for example:
27
+ # s.add_development_dependency "rspec"
28
+ # s.add_runtime_dependency "rest-client"
29
+ end
@@ -0,0 +1,5 @@
1
+ require 'jaeheegeo/app'
2
+ require 'jaeheegeo/geoip'
3
+
4
+ module JaeheeGeo
5
+ end
@@ -0,0 +1,24 @@
1
+ require 'active_support/core_ext'
2
+ require 'sinatra/base'
3
+
4
+ module JaeheeGeo
5
+ class App < ::Sinatra::Base
6
+ get '/' do
7
+ "Running\n"
8
+ end
9
+
10
+ get '/geoip/:host' do
11
+ callback = params.delete('callback')
12
+ json = JaeheeGeo::Geoip.new(params[:host]).to_json
13
+ if callback
14
+ content_type :js
15
+ response = "#{callback}(#{json})"
16
+ else
17
+ content_type :json
18
+ response = json
19
+ end
20
+
21
+ response
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,14 @@
1
+ require 'geoip'
2
+
3
+ class JaeheeGeo::Geoip < ::Autometal::Geoip
4
+ def as_json(options = {})
5
+ {
6
+ :country => self.country,
7
+ :county => self.county,
8
+ :city => self.city,
9
+ :lat => self.lat,
10
+ :lng => self.lng,
11
+ :version => self.version
12
+ }.as_json(options)
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module Jaeheegeo
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jaeheegeo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Hoseong Hwang
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: &70094675988020 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70094675988020
25
+ - !ruby/object:Gem::Dependency
26
+ name: sinatra
27
+ requirement: &70094675987420 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70094675987420
36
+ - !ruby/object:Gem::Dependency
37
+ name: thin
38
+ requirement: &70094676141440 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70094676141440
47
+ - !ruby/object:Gem::Dependency
48
+ name: autometal-geoip
49
+ requirement: &70094676140920 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70094676140920
58
+ description: Simple web application for geoip
59
+ email:
60
+ - thefron@wafflestudio.com
61
+ executables:
62
+ - jaeheegeo
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - .gitignore
67
+ - .rvmrc
68
+ - Gemfile
69
+ - README.md
70
+ - Rakefile
71
+ - bin/jaeheegeo
72
+ - config.ru
73
+ - jaeheegeo.gemspec
74
+ - lib/jaeheegeo.rb
75
+ - lib/jaeheegeo/app.rb
76
+ - lib/jaeheegeo/geoip.rb
77
+ - lib/jaeheegeo/version.rb
78
+ homepage: http://thefron.me
79
+ licenses: []
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project: jaeheegeo
98
+ rubygems_version: 1.8.10
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Simple web application for geoip
102
+ test_files: []