Class: JekyllSort::Reorder
- Inherits:
-
Object
- Object
- JekyllSort::Reorder
- Defined in:
- lib/jekyll_sort/reorder.rb
Instance Method Summary collapse
- #check_in_docs_folder! ⇒ Object
-
#initialize(options) ⇒ Reorder
constructor
A new instance of Reorder.
- #run ⇒ Object
Constructor Details
#initialize(options) ⇒ Reorder
Returns a new instance of Reorder.
6 7 8 |
# File 'lib/jekyll_sort/reorder.rb', line 6 def initialize() @options = end |
Instance Method Details
#check_in_docs_folder! ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/jekyll_sort/reorder.rb', line 33 def check_in_docs_folder! parent_folder = File.basename(Dir.pwd) if parent_folder != "docs" puts "Please run this command within the docs folder" exit 1 end end |
#run ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jekyll_sort/reorder.rb', line 10 def run check_in_docs_folder! uri = URI('http://localhost:4000/docs/') begin body = Net::HTTP.get(uri) # => String rescue Errno::ECONNREFUSED => e puts e puts "ERROR: Please make sure the jekyll server is running and server docs. You can use:" puts " bin/web" end PrevNext.new.create Page.reset_all doc = Nokogiri::HTML(body) links = doc.search('.content-nav a') links.each_with_index do |link, i| page = Page.new(link[:href], i+1) page.update end end |