Class: RedmineActivity::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/redmine_activity/fetcher.rb

Overview

Class to fetch and parse activity page

Constant Summary collapse

ACTIVITY_ATOM_PARAMS =
{ show_issues: 1 }.freeze
TIME_FORMAT =
'%Y-%m-%d %H:%M:%S'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Fetcher

Initialize a new Fetcher object

Parameters:

  • options (Hash) (defaults to: {})

    Initialize options

Options Hash (options):

  • :url (String)

    Redmine URL

  • :login_id (String)

    Login ID

  • :password (String)

    Password

  • :user_id (Fixnum)

    User ID

  • :project (String)

    Project identifier

  • :date (String)

    Date



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/redmine_activity/fetcher.rb', line 19

def initialize(options = {})
  @url      = ENV['REDMINE_ACTIVITY_URL']
  @login_id = ENV['REDMINE_ACTIVITY_LOGIN_ID']
  @password = ENV['REDMINE_ACTIVITY_PASSWORD']

  options.each do |key, value|
    instance_variable_set(:"@#{key}", value)
  end

  @agent = Mechanize.new
end

Instance Method Details

#getObject

Fetch and print activities



32
33
34
35
36
37
# File 'lib/redmine_activity/fetcher.rb', line 32

def get
  
  parse(activities)
rescue Mechanize::ResponseCodeError => e
  puts Rainbow('404 Not Found.').red if e.response_code == '404'
end