Class: Timetrap::Formatters::Redmine
- Inherits:
-
Object
- Object
- Timetrap::Formatters::Redmine
- Defined in:
- lib/timetrap-redmine.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Instance Method Summary collapse
-
#initialize(entries) ⇒ Redmine
constructor
A new instance of Redmine.
- #output ⇒ Object
Constructor Details
#initialize(entries) ⇒ Redmine
Returns a new instance of Redmine.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/timetrap-redmine.rb', line 8 def initialize(entries) TimetrapRedmine::API::Resource.site = Timetrap::Config['redmine']['url'] TimetrapRedmine::API::Resource.user = Timetrap::Config['redmine']['user'] TimetrapRedmine::API::Resource.password = Timetrap::Config['redmine']['password'] @entries = entries threads = [] threads << Thread.new do @issues = {} TimetrapRedmine::API::Issue.find(:all, :params => { :f => ['status'], :op => [:status => '*'], :sort => 'id:desc', :limit => 100, }).each do |i| @issues[i.id] = i end end threads << Thread.new do @rm_entries = TimetrapRedmine::API::TimeEntry.find(:all, :params => { :f => ['comments', 'user_id'], :op => {:comments => '~', 'user_id' => '='}, :v => {:comments => ['[tt '], 'user_id' => ['me']}, :sort => 'id:desc', :limit => 100, }) end threads.each(&:join) end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
6 7 8 |
# File 'lib/timetrap-redmine.rb', line 6 def entries @entries end |
Instance Method Details
#output ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/timetrap-redmine.rb', line 42 def output status = Hash.new(0) entries.each {|e| status[process(e)] += 1} STDERR.puts "" if status.length STDERR.puts "error unchanged created updated" STDERR.puts "%5d %9d %7d %7d" % [status[:error], status[:unchanged], status[:created], status[:updated]] if status[:error] > 0 exit 1 else exit end end |