undergrounder 0.1.0

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
+ require 'bundler/setup'
2
+ require 'padrino-core/cli/rake'
3
+
4
+ PadrinoTasks.use(:database)
5
+ PadrinoTasks.use(:activerecord)
6
+ PadrinoTasks.init
@@ -0,0 +1,10 @@
1
+ module WebFinder
2
+ class App < Padrino::Application
3
+ use ActiveRecord::ConnectionAdapters::ConnectionManagement
4
+ register Padrino::Rendering
5
+ register Padrino::Mailer
6
+ register Padrino::Helpers
7
+ enable :sessions
8
+
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ WebFinder::App.controllers :tube_planner do
2
+
3
+ get :index, :map => '/' do
4
+ render 'tube_planner/index'
5
+ end
6
+
7
+ post :index, :map => "/" do
8
+ @result = begin
9
+ Undergrounder.start!(params[:source], params[:destination], true)
10
+ rescue Exception => e
11
+ "Please insert a valid origin or destination ( origin was #{params[:origin]}, destination was #{params[:destination]})"
12
+ end
13
+
14
+ render 'tube_planner/index'
15
+ end
16
+
17
+ end
@@ -0,0 +1,9 @@
1
+ - form_tag ("/") do
2
+ Origin:
3
+ = text_field_tag :source
4
+ Destination:
5
+ = text_field_tag :destination
6
+ = submit_tag "Submit"
7
+
8
+ - if @result != nil
9
+ = @result
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env rackup
2
+ # encoding: utf-8
3
+
4
+ # This file can be used to start Padrino,
5
+ # just execute it from the command line.
6
+
7
+ require File.expand_path("../config/boot.rb", __FILE__)
8
+
9
+ run Padrino.application
@@ -0,0 +1,36 @@
1
+ ##
2
+ # This file mounts each app in the Padrino project to a specified sub-uri.
3
+ # You can mount additional applications using any of these commands below:
4
+ #
5
+ # Padrino.mount('blog').to('/blog')
6
+ # Padrino.mount('blog', :app_class => 'BlogApp').to('/blog')
7
+ # Padrino.mount('blog', :app_file => 'path/to/blog/app.rb').to('/blog')
8
+ #
9
+ # You can also map apps to a specified host:
10
+ #
11
+ # Padrino.mount('Admin').host('admin.example.org')
12
+ # Padrino.mount('WebSite').host(/.*\.?example.org/)
13
+ # Padrino.mount('Foo').to('/foo').host('bar.example.org')
14
+ #
15
+ # Note 1: Mounted apps (by default) should be placed into the project root at '/app_name'.
16
+ # Note 2: If you use the host matching remember to respect the order of the rules.
17
+ #
18
+ # By default, this file mounts the primary app which was generated with this project.
19
+ # However, the mounted app can be modified as needed:
20
+ #
21
+ # Padrino.mount('AppName', :app_file => 'path/to/file', :app_class => 'BlogApp').to('/')
22
+ #
23
+
24
+ ##
25
+ # Setup global project settings for your apps. These settings are inherited by every subapp. You can
26
+ # override these settings in the subapps as needed.
27
+ #
28
+ Padrino.configure_apps do
29
+ # enable :sessions
30
+ set :session_secret, '597406e07656b3e19e9794d314b7ec214add4f3fb0328222ca9485df27e96c76'
31
+ set :protection, true
32
+ set :protect_from_csrf, true
33
+ end
34
+
35
+ # Mounts the core application for this project
36
+ Padrino.mount('WebFinder::App', :app_file => Padrino.root('app/app.rb')).to('/')
@@ -0,0 +1,34 @@
1
+ # Defines our constants
2
+ PADRINO_ENV = ENV['PADRINO_ENV'] ||= ENV['RACK_ENV'] ||= 'development' unless defined?(PADRINO_ENV)
3
+ PADRINO_ROOT = File.expand_path('../..', __FILE__) unless defined?(PADRINO_ROOT)
4
+
5
+ # Load our dependencies
6
+ require 'rubygems' unless defined?(Gem)
7
+ require 'bundler/setup'
8
+ Bundler.require(:default, PADRINO_ENV)
9
+
10
+ ##
11
+ # ## Enable devel logging
12
+ #
13
+ # Padrino::Logger::Config[:development][:log_level] = :devel
14
+ # Padrino::Logger::Config[:development][:log_static] = true
15
+ #
16
+ # ## Configure your I18n
17
+ #
18
+ # I18n.default_locale = :en
19
+ #
20
+ # ## Configure your HTML5 data helpers
21
+ #
22
+ # Padrino::Helpers::TagHelpers::DATA_ATTRIBUTES.push(:dialog)
23
+ # text_field :foo, :dialog => true
24
+ # Generates: <input type="text" data-dialog="true" name="foo" />
25
+ #
26
+ # ## Add helpers to mailer
27
+ #
28
+ # Mail::Message.class_eval do
29
+ # include Padrino::Helpers::NumberHelpers
30
+ # include Padrino::Helpers::TranslationHelpers
31
+ # end
32
+
33
+
34
+ Padrino.load!
@@ -0,0 +1,58 @@
1
+ ##
2
+ # You can use other adapters like:
3
+ #
4
+ # ActiveRecord::Base.configurations[:development] = {
5
+ # :adapter => 'mysql2',
6
+ # :encoding => 'utf8',
7
+ # :reconnect => true,
8
+ # :database => 'your_database',
9
+ # :pool => 5,
10
+ # :username => 'root',
11
+ # :password => '',
12
+ # :host => 'localhost',
13
+ # :socket => '/tmp/mysql.sock'
14
+ # }
15
+ #
16
+ ActiveRecord::Base.configurations[:development] = {
17
+ :adapter => 'sqlite3',
18
+ :database => Padrino.root('db', 'web_finder_development.db')
19
+
20
+ }
21
+
22
+ ActiveRecord::Base.configurations[:production] = {
23
+ :adapter => 'sqlite3',
24
+ :database => Padrino.root('db', 'web_finder_production.db')
25
+
26
+ }
27
+
28
+ ActiveRecord::Base.configurations[:test] = {
29
+ :adapter => 'sqlite3',
30
+ :database => Padrino.root('db', 'web_finder_test.db')
31
+
32
+ }
33
+
34
+ # Setup our logger
35
+ ActiveRecord::Base.logger = logger
36
+
37
+ # Raise exception on mass assignment protection for Active Record models.
38
+ ActiveRecord::Base.mass_assignment_sanitizer = :strict
39
+
40
+ # Log the query plan for queries taking more than this (works
41
+ # with SQLite, MySQL, and PostgreSQL).
42
+ ActiveRecord::Base.auto_explain_threshold_in_seconds = 0.5
43
+
44
+ # Include Active Record class name as root for JSON serialized output.
45
+ ActiveRecord::Base.include_root_in_json = false
46
+
47
+ # Store the full class name (including module namespace) in STI type column.
48
+ ActiveRecord::Base.store_full_sti_class = true
49
+
50
+ # Use ISO 8601 format for JSON serialized times and dates.
51
+ ActiveSupport.use_standard_json_time_format = true
52
+
53
+ # Don't escape HTML entities in JSON, leave that for the #json_escape helper
54
+ # if you're including raw JSON in an HTML page.
55
+ ActiveSupport.escape_html_entities_in_json = false
56
+
57
+ # Now we can establish connection with our db.
58
+ ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[Padrino.env])
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: undergrounder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Enzo Rivello
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-10-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sinatra
16
+ requirement: !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: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: padrino
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: ruby-debug19
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Simple Implementation of a short path finder for the London Tube
79
+ email:
80
+ - vincenzo.rivello@gmail.com
81
+ executables:
82
+ - undergrounder
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - .gitignore
87
+ - .rspec
88
+ - Gemfile
89
+ - LICENSE.txt
90
+ - README.md
91
+ - Rakefile
92
+ - assets/test_assets.yml
93
+ - assets/tube_list.yml
94
+ - bin/undergrounder
95
+ - lib/undergrounder.rb
96
+ - lib/undergrounder/tube_scraper.rb
97
+ - lib/undergrounder/version.rb
98
+ - spec/spec_helper.rb
99
+ - spec/undergrounder_spec.rb
100
+ - undergrounder.gemspec
101
+ - vendor/web_finder/.components
102
+ - vendor/web_finder/.gitignore
103
+ - vendor/web_finder/Gemfile
104
+ - vendor/web_finder/Rakefile
105
+ - vendor/web_finder/app/app.rb
106
+ - vendor/web_finder/app/controllers/tube_planner.rb
107
+ - vendor/web_finder/app/views/tube_planner/index.haml
108
+ - vendor/web_finder/config.ru
109
+ - vendor/web_finder/config/apps.rb
110
+ - vendor/web_finder/config/boot.rb
111
+ - vendor/web_finder/config/database.rb
112
+ - vendor/web_finder/public/favicon.ico
113
+ homepage: https://github.com/enzor/undergrounder
114
+ licenses: []
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 1.8.24
134
+ signing_key:
135
+ specification_version: 3
136
+ summary: ''
137
+ test_files:
138
+ - spec/spec_helper.rb
139
+ - spec/undergrounder_spec.rb
140
+ has_rdoc: