Class: Adva::Static::Setup
- Inherits:
-
Object
- Object
- Adva::Static::Setup
- Defined in:
- lib/adva/static/setup.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #initial_import_and_export ⇒ Object
-
#initialize(options) ⇒ Setup
constructor
A new instance of Setup.
- #run ⇒ Object
- #setup_directories ⇒ Object
- #setup_export_repository ⇒ Object
- #setup_source_repository ⇒ Object
Constructor Details
#initialize(options) ⇒ Setup
Returns a new instance of Setup.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/adva/static/setup.rb', line 8 def initialize() @app = [:app] || Rails.application @root = Pathname.new([:root] || Dir.pwd) @source = root.join([:source] || 'import') @target = root.join([:target] || 'export') @remote = [:remote] @host = [:host] || 'example.org' @title = [:title] || host Adva.out = StringIO.new('') end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
6 7 8 |
# File 'lib/adva/static/setup.rb', line 6 def app @app end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
6 7 8 |
# File 'lib/adva/static/setup.rb', line 6 def host @host end |
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
6 7 8 |
# File 'lib/adva/static/setup.rb', line 6 def remote @remote end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
6 7 8 |
# File 'lib/adva/static/setup.rb', line 6 def root @root end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
6 7 8 |
# File 'lib/adva/static/setup.rb', line 6 def source @source end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
6 7 8 |
# File 'lib/adva/static/setup.rb', line 6 def target @target end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/adva/static/setup.rb', line 6 def title @title end |
Instance Method Details
#initial_import_and_export ⇒ Object
34 35 36 37 |
# File 'lib/adva/static/setup.rb', line 34 def initial_import_and_export Import.new(:source => source).run Export.new(app, :target => target).run end |
#run ⇒ Object
20 21 22 23 24 25 |
# File 'lib/adva/static/setup.rb', line 20 def run setup_directories initial_import_and_export setup_source_repository setup_export_repository end |
#setup_directories ⇒ Object
27 28 29 30 31 32 |
# File 'lib/adva/static/setup.rb', line 27 def setup_directories source.mkdir rescue Errno::EEXIST target.mkdir rescue Errno::EEXIST site = source.join('site.yml') File.open(site, 'w+') { |f| f.write(YAML.dump(:host => host, :title => title)) } unless site.exist? end |
#setup_export_repository ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/adva/static/setup.rb', line 54 def setup_export_repository root.join('export/.git').rmtree rescue Errno::ENOENT Dir.chdir(target) do init_repository commit("#{host} export") add_remote('master') if remote end end |
#setup_source_repository ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/adva/static/setup.rb', line 39 def setup_source_repository root.join('.gitignore').rmtree rescue Errno::ENOENT root.join('.git').rmtree rescue Errno::ENOENT File.open(root.join('.gitignore'), 'w+') { |f| f.write('export') } Dir.chdir(root) do init_repository commit("#{host} source") checkout_branch('source') delete_branch('master') add_remote('source') if remote end end |