ruian 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +25 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/example/.gitignore +15 -0
- data/example/Gemfile +28 -0
- data/example/README.md +23 -0
- data/example/Rakefile +7 -0
- data/example/app/assets/images/rails.png +0 -0
- data/example/app/assets/javascripts/application.js +13 -0
- data/example/app/assets/stylesheets/application.css +13 -0
- data/example/app/controllers/application_controller.rb +3 -0
- data/example/app/helpers/application_helper.rb +2 -0
- data/example/app/mailers/.gitkeep +0 -0
- data/example/app/models/.gitkeep +0 -0
- data/example/app/models/address.rb +5 -0
- data/example/app/models/address/city.rb +7 -0
- data/example/app/models/address/city_part.rb +7 -0
- data/example/app/models/address/county.rb +3 -0
- data/example/app/models/address/county_name_count.rb +7 -0
- data/example/app/models/address/momc_name.rb +5 -0
- data/example/app/models/address/mop_name.rb +5 -0
- data/example/app/models/address/name.rb +18 -0
- data/example/app/models/address/name_type.rb +6 -0
- data/example/app/models/address/place.rb +13 -0
- data/example/app/models/address/region.rb +3 -0
- data/example/app/models/address/region_name_count.rb +7 -0
- data/example/app/models/address/street_name.rb +5 -0
- data/example/app/views/layouts/application.html.erb +14 -0
- data/example/config.ru +4 -0
- data/example/config/application.rb +63 -0
- data/example/config/boot.rb +6 -0
- data/example/config/database.yml +25 -0
- data/example/config/environment.rb +5 -0
- data/example/config/environments/development.rb +32 -0
- data/example/config/environments/production.rb +54 -0
- data/example/config/environments/test.rb +37 -0
- data/example/config/initializers/backtrace_silencers.rb +7 -0
- data/example/config/initializers/inflections.rb +15 -0
- data/example/config/initializers/mime_types.rb +5 -0
- data/example/config/initializers/secret_token.rb +7 -0
- data/example/config/initializers/session_store.rb +8 -0
- data/example/config/initializers/wrap_parameters.rb +14 -0
- data/example/config/locales/en.yml +5 -0
- data/example/config/routes.rb +58 -0
- data/example/db/migrate/20140418190407_create_tables.rb +170 -0
- data/example/db/schema.rb +182 -0
- data/example/db/seeds.rb +7 -0
- data/example/lib/assets/.gitkeep +0 -0
- data/example/lib/importer.rb +163 -0
- data/example/lib/tasks/.gitkeep +0 -0
- data/example/lib/tasks/ruian.rake +4 -0
- data/example/log/.gitkeep +0 -0
- data/example/public/404.html +26 -0
- data/example/public/422.html +26 -0
- data/example/public/500.html +25 -0
- data/example/public/favicon.ico +0 -0
- data/example/public/index.html +241 -0
- data/example/public/robots.txt +5 -0
- data/example/script/rails +6 -0
- data/example/vendor/assets/javascripts/.gitkeep +0 -0
- data/example/vendor/assets/stylesheets/.gitkeep +0 -0
- data/example/vendor/plugins/.gitkeep +0 -0
- data/fixtures/counties.csv +92 -0
- data/fixtures/vazby-cr.csv +15072 -0
- data/fixtures/vazby-okresy-cr.csv +15072 -0
- data/lib/ruian.rb +86 -0
- data/lib/ruian/enum_updater.rb +59 -0
- data/lib/ruian/fetcher.rb +71 -0
- data/lib/ruian/files_updater.rb +54 -0
- data/lib/ruian/importer.rb +21 -0
- data/lib/ruian/model.rb +10 -0
- data/lib/ruian/model/county.rb +6 -0
- data/lib/ruian/model/county_integration.rb +6 -0
- data/lib/ruian/model/region.rb +6 -0
- data/lib/ruian/model/region_integration.rb +6 -0
- data/lib/ruian/model/row.rb +9 -0
- data/lib/ruian/parser.rb +12 -0
- data/lib/ruian/queue.rb +24 -0
- data/lib/ruian/railtie.rb +9 -0
- data/lib/ruian/tasks/ruian.rake +18 -0
- data/lib/ruian/version.rb +3 -0
- data/ruian.gemspec +26 -0
- metadata +198 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7d0d41e4ce58585d4ebd8ada6e6e1f921bbebf2d
|
4
|
+
data.tar.gz: e15fcd0ab484ce45fbbb3519556aa320ca294d68
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5f3dfcff52eaf83c942715e2ec2dd348639c2c7bef051a0d3997864f77ccc651a44e5841e4d5a8fa7f4477792bea5b96fb47b594ef3b53ccff441f282a6ffe0d
|
7
|
+
data.tar.gz: a3ff4e3a3b6396b8e456e8dd9a645616bcb3946c408118e36deee0c75f5ab8733b75d3083e1a5d75727707b5bcbb3e7b48efd3ac068472cb7f36e964a46772da
|
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
fixtures/CSV
|
24
|
+
fixtures counties.csv
|
25
|
+
fixtures/regions.csv
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Josef Šimánek
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Ruian
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'ruian'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install ruian
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
See example directory.
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/simi/ruian/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/example/.gitignore
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
+
|
7
|
+
# Ignore bundler config
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
|
13
|
+
# Ignore all logfiles and tempfiles.
|
14
|
+
/log/*.log
|
15
|
+
/tmp
|
data/example/Gemfile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '3.2.16'
|
4
|
+
|
5
|
+
# Bundle edge Rails instead:
|
6
|
+
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
7
|
+
|
8
|
+
gem 'sqlite3'
|
9
|
+
|
10
|
+
gem 'ruian', path: '../'
|
11
|
+
gem 'jtsk', '0.0.2'
|
12
|
+
|
13
|
+
gem 'activerecord-import', '~> 0.3.0'
|
14
|
+
|
15
|
+
# To use ActiveModel has_secure_password
|
16
|
+
# gem 'bcrypt-ruby', '~> 3.0.0'
|
17
|
+
|
18
|
+
# To use Jbuilder templates for JSON
|
19
|
+
# gem 'jbuilder'
|
20
|
+
|
21
|
+
# Use unicorn as the app server
|
22
|
+
# gem 'unicorn'
|
23
|
+
|
24
|
+
# Deploy with Capistrano
|
25
|
+
# gem 'capistrano'
|
26
|
+
|
27
|
+
# To use debugger
|
28
|
+
# gem 'debugger'
|
data/example/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# RUIAN Rails importer example
|
2
|
+
|
3
|
+
## Install
|
4
|
+
|
5
|
+
```
|
6
|
+
bundle install
|
7
|
+
bundle exec rake db:setup
|
8
|
+
```
|
9
|
+
|
10
|
+
## Start import
|
11
|
+
|
12
|
+
```
|
13
|
+
bundle rake ruian:update_all
|
14
|
+
bundle rake ruian:import
|
15
|
+
```
|
16
|
+
|
17
|
+
## How it works
|
18
|
+
|
19
|
+
See example lib/tasks/ruian.rake for details about ruian:import task. Mainly example/lib/importer.rb is used for importing.
|
20
|
+
|
21
|
+
'Interface' is defined in lib/ruian/importer.rb.
|
22
|
+
|
23
|
+
Update tasks are defined in lib/tasks/ruian.rake.
|
data/example/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Example::Application.load_tasks
|
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
File without changes
|
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Address::Name < ActiveRecord::Base
|
2
|
+
attr_accessible :name, :type
|
3
|
+
self.inheritance_column = :sti_type
|
4
|
+
|
5
|
+
has_many :county_name_counts, :dependent => :delete_all
|
6
|
+
has_many :region_name_counts, :dependent => :delete_all
|
7
|
+
|
8
|
+
has_enum :type, :class_name => 'Address::NameType'
|
9
|
+
|
10
|
+
def self.find_and_touch(name, type)
|
11
|
+
if n = where(:type => type, :name => name).first
|
12
|
+
n.touch
|
13
|
+
else
|
14
|
+
n = create!(:type => type, :name => name)
|
15
|
+
end
|
16
|
+
n
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Address::Place < ActiveRecord::Base
|
2
|
+
belongs_to :street_name
|
3
|
+
belongs_to :mop_name
|
4
|
+
belongs_to :momc_name
|
5
|
+
belongs_to :city
|
6
|
+
belongs_to :city_part
|
7
|
+
|
8
|
+
attr_accessible :e, :p, :o, :zip, :code, :street_name, :street_name_id, :mop_name, :mop_name_id,
|
9
|
+
:momc_name, :momc_name_id, :city, :city_id, :city_part, :city_part_id, :latitude, :longitude
|
10
|
+
|
11
|
+
validates_presence_of :code, :city_id
|
12
|
+
validates_format_of :zip, :with => %r(\A\d{5}\z), :allow_blank => true
|
13
|
+
end
|
data/example/config.ru
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_mailer/railtie"
|
7
|
+
require "active_resource/railtie"
|
8
|
+
# require "sprockets/railtie"
|
9
|
+
# require "rails/test_unit/railtie"
|
10
|
+
|
11
|
+
if defined?(Bundler)
|
12
|
+
# If you precompile assets before deploying to production, use this line
|
13
|
+
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
14
|
+
# If you want your assets lazily compiled in production, use this line
|
15
|
+
# Bundler.require(:default, :assets, Rails.env)
|
16
|
+
end
|
17
|
+
|
18
|
+
module Example
|
19
|
+
class Application < Rails::Application
|
20
|
+
# Settings in config/environments/* take precedence over those specified here.
|
21
|
+
# Application configuration should go into files in config/initializers
|
22
|
+
# -- all .rb files in that directory are automatically loaded.
|
23
|
+
|
24
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
25
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
26
|
+
|
27
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
28
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
29
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
30
|
+
|
31
|
+
# Activate observers that should always be running.
|
32
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
33
|
+
|
34
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
35
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
36
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
37
|
+
|
38
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
39
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
40
|
+
# config.i18n.default_locale = :de
|
41
|
+
|
42
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
43
|
+
config.encoding = "utf-8"
|
44
|
+
|
45
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
46
|
+
config.filter_parameters += [:password]
|
47
|
+
|
48
|
+
# Enable escaping HTML in JSON.
|
49
|
+
config.active_support.escape_html_entities_in_json = true
|
50
|
+
|
51
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
52
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
53
|
+
# like if you have constraints or database-specific column types
|
54
|
+
# config.active_record.schema_format = :sql
|
55
|
+
|
56
|
+
# Enforce whitelist mode for mass assignment.
|
57
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
58
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
59
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
60
|
+
config.active_record.whitelist_attributes = true
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
development:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: db/development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
13
|
+
# re-generated from your development database when you run "rake".
|
14
|
+
# Do not set this db to the same as development or production.
|
15
|
+
test:
|
16
|
+
adapter: sqlite3
|
17
|
+
database: db/test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
20
|
+
|
21
|
+
production:
|
22
|
+
adapter: sqlite3
|
23
|
+
database: db/production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|