class Guard::Blogger
Attributes
blog[R]
email[R]
password[R]
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
# File lib/guard/blogger.rb, line 13 def initialize(options = {}) super Capybara.default_driver = :selenium Capybara.app_host = "https://www.blogger.com" @email = options[:email] @password = options[:password] @blog = options[:blog] end
Public Instance Methods
run_on_changes(paths)
click to toggle source
# File lib/guard/blogger.rb, line 28 def run_on_changes(paths) update_template(paths.first) end
start()
click to toggle source
# File lib/guard/blogger.rb, line 24 def start sign_in end
Private Instance Methods
resize()
click to toggle source
# File lib/guard/blogger.rb, line 60 def resize width = page.execute_script('return window.screen.width') height = page.execute_script('return window.screen.height') page.driver.browser.manage.window.resize_to width, height end
sign_in()
click to toggle source
# File lib/guard/blogger.rb, line 34 def sign_in visit '/' resize fill_in 'Email', with: email fill_in 'Password', with: password click_on 'Sign in' click_on blog click_on 'Template' click_on 'Edit HTML' end
template(path)
click to toggle source
# File lib/guard/blogger.rb, line 55 def template(path) t = File.read(path) escape_template(t.nil? || t.empty? ? default_template : t) end
update_template(path)
click to toggle source
# File lib/guard/blogger.rb, line 45 def update_template(path) UI.info "Updating Blogger template..." page.execute_script "document.getElementsByClassName('CodeMirror')[0].CodeMirror.doc.setValue('#{template(path)}')" click_on 'Save template' if page.has_selector? '.GFPUSQ2NMB' throw :task_has_failed UI.error 'Could not update Blogger template' end end