Class: PointmdComments::Aggregators::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/pointmd_comments/aggregators/main.rb

Constant Summary collapse

CHROME_ARGS =
%w[disable-dev-shm-usage disable-software-rasterizer no-sandbox].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Main

Returns a new instance of Main.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pointmd_comments/aggregators/main.rb', line 8

def initialize(options)
  # Currently 'path' is not supported
  @path                = nil
  @output              = options[:output] || default_output_path
  @source              = options[:source] || Aggregators::Posts::DEFAULT_SOURCE
  @posts_aggregator    = Aggregators::Posts.new(source: source, path: path)
  @comments_aggregator = Aggregators::Comments.new

  client = Selenium::WebDriver::Remote::Http::Default.new
  # NOTE: #timeout= is deprecated, use #read_timeout= and #open_timeout= instead
  client.timeout = 600 # instead of the default 60 (seconds)

  @browser             = ::Watir::Browser.new :chrome, http_client: client, headless: true, args: CHROME_ARGS
  @all_comments        = []
end

Instance Attribute Details

#all_commentsObject (readonly)

Returns the value of attribute all_comments.



6
7
8
# File 'lib/pointmd_comments/aggregators/main.rb', line 6

def all_comments
  @all_comments
end

#browserObject (readonly)

Returns the value of attribute browser.



6
7
8
# File 'lib/pointmd_comments/aggregators/main.rb', line 6

def browser
  @browser
end

#comments_aggregatorObject (readonly)

Returns the value of attribute comments_aggregator.



6
7
8
# File 'lib/pointmd_comments/aggregators/main.rb', line 6

def comments_aggregator
  @comments_aggregator
end

#outputObject (readonly)

Returns the value of attribute output.



6
7
8
# File 'lib/pointmd_comments/aggregators/main.rb', line 6

def output
  @output
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/pointmd_comments/aggregators/main.rb', line 6

def path
  @path
end

#postsObject (readonly)

Returns the value of attribute posts.



6
7
8
# File 'lib/pointmd_comments/aggregators/main.rb', line 6

def posts
  @posts
end

#posts_aggregatorObject (readonly)

Returns the value of attribute posts_aggregator.



6
7
8
# File 'lib/pointmd_comments/aggregators/main.rb', line 6

def posts_aggregator
  @posts_aggregator
end

#sourceObject (readonly)

Returns the value of attribute source.



6
7
8
# File 'lib/pointmd_comments/aggregators/main.rb', line 6

def source
  @source
end

Instance Method Details

#callObject



24
25
26
27
28
29
30
# File 'lib/pointmd_comments/aggregators/main.rb', line 24

def call
  @posts = posts_aggregator.call

  collect_all_comments

  write_to_csv
end