Class: JekyllDeployShosetsu::Deployers::Narou
- Inherits:
-
Object
- Object
- JekyllDeployShosetsu::Deployers::Narou
- Defined in:
- lib/jekyll-deploy-shosetsu/deployers/narou.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
Instance Method Summary collapse
- #deploy(site) ⇒ Object
-
#initialize(agent: NarouAgent.new) ⇒ Narou
constructor
A new instance of Narou.
Constructor Details
#initialize(agent: NarouAgent.new) ⇒ Narou
Returns a new instance of Narou.
6 7 8 |
# File 'lib/jekyll-deploy-shosetsu/deployers/narou.rb', line 6 def initialize(agent: NarouAgent.new) @agent = agent end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
4 5 6 |
# File 'lib/jekyll-deploy-shosetsu/deployers/narou.rb', line 4 def agent @agent end |
Instance Method Details
#deploy(site) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/jekyll-deploy-shosetsu/deployers/narou.rb', line 10 def deploy(site) id = site.config['narou']['id'] password = site.config['narou']['password'] agent.login!(id: id, password: password) ncode = site.config['narou']['ncode'] site.posts.docs.each do |post| narou_config = post['narou'] || {} next if narou_config['ignore'] post.output = Jekyll::Renderer.new(site, post).run if narou_config['url'] part_id = NarouAgent::UrlHelper.extract_part_id(narou_config['url']) url = agent.update_part(ncode: ncode, part_id: part_id, subtitle: post['title'], body: post.output, date: post.date) Jekyll.logger.info 'Updated:', "#{post.basename} #{url}" else url = agent.create_part(ncode: ncode, subtitle: post['title'], body: post.output, date: post.date) Jekyll.logger.info 'Created:', "#{post.basename} #{url}" Util.append_yaml_front_matter post.path, <<~YAML narou: url: #{url} YAML end end end |