Class: HarvestReport::Runner
- Inherits:
-
Object
- Object
- HarvestReport::Runner
- Includes:
- Capybara::DSL
- Defined in:
- lib/harvest_report/runner.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ Runner
15 16 17 18 19 20 21 22 23 |
# File 'lib/harvest_report/runner.rb', line 15 def initialize(args) = { :download_dir => '/tmp/harvest_report', :download_timeout => 60 } (args) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
25 26 27 |
# File 'lib/harvest_report/runner.rb', line 25 def end |
Class Method Details
.run(*args) ⇒ Object
11 12 13 |
# File 'lib/harvest_report/runner.rb', line 11 def self.run(*args) new(ARGV).run end |
Instance Method Details
#run ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/harvest_report/runner.rb', line 27 def run .register_driver :chrome do |app| profile = ::Selenium::WebDriver::Chrome::Profile.new profile["download.default_directory"] = [:download_dir] ::Selenium::Driver.new(app, :browser => :chrome, :profile => profile) end .current_driver = :chrome .reset_sessions! page.visit "https://#{options[:domain]}.harvestapp.com/account/login" page.click_link "Or sign in with your Harvest account" page.fill_in "Email", :with => [:email] page.fill_in "Password", :with => [:password] page. "Sign In" element = page.find_link("My Profile") user_id = element[:href].scan(/\d+/).first export_url = "https://#{options[:domain]}.harvestapp.com/xlsx/export/user/#{user_id}" export_url << "?" export_url << "start_date=#{CGI.escape(options[:start_date])}&" export_url << "end_date=#{CGI.escape(options[:stop_date])}" page.visit export_url wait_for_download puts "Report downloaded to #{options[:download_dir]}" sleep 1 end |