Class: Chouette::FileValidator
- Inherits:
-
Object
- Object
- Chouette::FileValidator
- Includes:
- CommandLineSupport
- Defined in:
- app/models/chouette/file_validator.rb
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #chouette_command ⇒ Object
-
#initialize(schema) ⇒ FileValidator
constructor
A new instance of FileValidator.
- #validate(file, options = {}) ⇒ Object
Methods included from CommandLineSupport
#available_loggers, #execute!, #logger, #max_output_length
Constructor Details
#initialize(schema) ⇒ FileValidator
Returns a new instance of FileValidator.
5 6 7 8 9 10 11 12 13 14 |
# File 'app/models/chouette/file_validator.rb', line 5 def initialize(schema) @schema = schema Chouette::ActiveRecord.connection_pool.spec.config.tap do |config| @database = config[:database] @user = config[:username] @password = config[:password] @host = (config[:host] or "localhost") end end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
3 4 5 |
# File 'app/models/chouette/file_validator.rb', line 3 def database @database end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
3 4 5 |
# File 'app/models/chouette/file_validator.rb', line 3 def host @host end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
3 4 5 |
# File 'app/models/chouette/file_validator.rb', line 3 def password @password end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
3 4 5 |
# File 'app/models/chouette/file_validator.rb', line 3 def schema @schema end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'app/models/chouette/file_validator.rb', line 3 def user @user end |
Class Method Details
Instance Method Details
#chouette_command ⇒ Object
24 25 26 |
# File 'app/models/chouette/file_validator.rb', line 24 def chouette_command @chouette_command ||= Chouette::Command.new(:schema => schema) end |
#validate(file, options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/chouette/file_validator.rb', line 28 def validate(file, = {}) = { :format => :neptune }.merge() = { :c => "validate", :o => "line", :input_file => File.(file), :optimize_memory => true }.merge() logger.info "Validate #{file}" chouette_command.run! end |