Class: Adva::Static::Import

Inherits:
Object
  • Object
show all
Defined in:
lib/adva/static/import.rb,
lib/adva/static/import/model.rb,
lib/adva/static/import/format.rb,
lib/adva/static/import/source.rb,
lib/adva/static/import/request.rb,
lib/adva/static/import/model/base.rb,
lib/adva/static/import/model/blog.rb,
lib/adva/static/import/model/page.rb,
lib/adva/static/import/model/post.rb,
lib/adva/static/import/model/site.rb,
lib/adva/static/import/source/base.rb,
lib/adva/static/import/source/blog.rb,
lib/adva/static/import/source/page.rb,
lib/adva/static/import/source/path.rb,
lib/adva/static/import/source/post.rb,
lib/adva/static/import/source/site.rb,
lib/adva/static/import/model/section.rb,
lib/adva/static/import/source/section.rb

Defined Under Namespace

Modules: Format, Model, Source Classes: Request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Import

Returns a new instance of Import.



11
12
13
# File 'lib/adva/static/import.rb', line 11

def initialize(options = {})
  @root = Source::Path.new(File.expand_path(options[:source] || 'import'))
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



9
10
11
# File 'lib/adva/static/import.rb', line 9

def root
  @root
end

Instance Method Details

#import(path) ⇒ Object



22
23
24
25
# File 'lib/adva/static/import.rb', line 22

def import(path)
  model = recognize(path)
  model.update! if model
end

#request_for(path) ⇒ Object



27
28
29
30
# File 'lib/adva/static/import.rb', line 27

def request_for(path)
  model = recognize(path)
  Request.new(model.source, model.record, model.attributes)
end

#runObject



15
16
17
18
19
20
# File 'lib/adva/static/import.rb', line 15

def run
  Adva.out.puts "importing from #{root}"
  Account.all.each(&:destroy)
  Category.delete_all
  Model::Site.new(root).update!
end