Class: NeocitiesRed::Services::SiteExporter
- Inherits:
-
Object
- Object
- NeocitiesRed::Services::SiteExporter
- Defined in:
- lib/neocities_red/services/site_exporter.rb
Instance Attribute Summary collapse
-
#app_config_path ⇒ Object
Returns the value of attribute app_config_path.
-
#client ⇒ Object
Returns the value of attribute client.
-
#data ⇒ Object
Returns the value of attribute data.
-
#sitename ⇒ Object
Returns the value of attribute sitename.
Instance Method Summary collapse
- #export(quiet: false, last_pull_time: nil, last_pull_loc: nil) ⇒ Object
-
#initialize(client, sitename, data, app_config_path) ⇒ SiteExporter
constructor
A new instance of SiteExporter.
Constructor Details
#initialize(client, sitename, data, app_config_path) ⇒ SiteExporter
Returns a new instance of SiteExporter.
11 12 13 14 15 16 17 |
# File 'lib/neocities_red/services/site_exporter.rb', line 11 def initialize(client, sitename, data, app_config_path) @client = client @sitename = sitename @data = data @app_config_path = app_config_path @pastel = Pastel.new(eachline: "\n") end |
Instance Attribute Details
#app_config_path ⇒ Object
Returns the value of attribute app_config_path.
9 10 11 |
# File 'lib/neocities_red/services/site_exporter.rb', line 9 def app_config_path @app_config_path end |
#client ⇒ Object
Returns the value of attribute client.
9 10 11 |
# File 'lib/neocities_red/services/site_exporter.rb', line 9 def client @client end |
#data ⇒ Object
Returns the value of attribute data.
9 10 11 |
# File 'lib/neocities_red/services/site_exporter.rb', line 9 def data @data end |
#sitename ⇒ Object
Returns the value of attribute sitename.
9 10 11 |
# File 'lib/neocities_red/services/site_exporter.rb', line 9 def sitename @sitename end |
Instance Method Details
#export(quiet: false, last_pull_time: nil, last_pull_loc: nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/neocities_red/services/site_exporter.rb', line 19 def export(quiet: false, last_pull_time: nil, last_pull_loc: nil) if quiet Whirly.start spinner: ["😺", "😸", "😹", "😻", "😼", "😽", "🙀", "😿", "😾"], status: "Retrieving files for #{@pastel.bold @sitename}" end @client.pull(@sitename, last_pull_time, last_pull_loc, quiet: quiet) # write last pull data to file (not necessarily the best way to do this, but better than cloning every time) data["LAST_PULL"] = { time: Time.now, loc: Dir.pwd } File.write(app_config_path, data.to_json) rescue StandardError => e e ensure Whirly.stop if quiet end |