timetrello 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d38c4826f46020f4c8a0d0ab696dabd913bf2ad2
4
- data.tar.gz: fefbbf22b394d766978f98b58e290e2490257754
3
+ metadata.gz: 9eb8a024baf17269e1034ddf6366a34d1e8c7f6e
4
+ data.tar.gz: aa906e7ada1ada537f36becaac9c6e7079fca65c
5
5
  SHA512:
6
- metadata.gz: d2b5036e27edb486e40051aafb91266708f1aa67ce187f16d3ce953a33549a22e80d48f71474cdbce879673b29f8680d1dc7d65af6b1fad84c30c5bfd335ed5e
7
- data.tar.gz: eb60c4efa997f3c1d47041554ce18b06a3d8a1fd86a046be0667c5a35bbbd372bbd2f17fd877821a6461b29037782f73daa22c92526b703ea2d7c31c1c9b2f67
6
+ metadata.gz: 270d966db6ef5a09c33d8c7d0f1d6e07b5fc945d4ddae229c48f95ea57f880d4521cd32d319ba59ca7d56c6f3a1cd823fc23349cb43f2eda58c31d39f0ca376f
7
+ data.tar.gz: e23e7339d760f98f74212364c015d56e5a1ecb078bcb711e5135e9433bfd53027bc273b3e2bd777f6c74eb222bef4ddc1672b4e9f51aea95fc8f44a5e53723ac
@@ -46,7 +46,7 @@ module TimeTrello
46
46
  # Private: Getter for a report instance. Guarantees only one single instance
47
47
  # available for caching optimization.
48
48
  def self.report(start_date, end_date, board_id)
49
- if @report == nil
49
+ if @report.nil?
50
50
  @report = Report.new(start_date, end_date, board_id, @prefix)
51
51
  else
52
52
  # Updates report parameters
@@ -29,6 +29,8 @@ module TimeTrello
29
29
  attr_accessor :start_date
30
30
  # Public: Task comment
31
31
  attr_accessor :task_description
32
+ # Public: Card Name
33
+ attr_accessor :card_name
32
34
 
33
35
  # Public: Initializes this class with proper information about a given task
34
36
  #
@@ -44,6 +46,7 @@ module TimeTrello
44
46
  @project = args[3]
45
47
  @start_date = args[4]
46
48
  @task_description = args[5]
49
+ @card_name = args[6]
47
50
  end
48
51
  end
49
52
 
@@ -28,7 +28,7 @@ module TimeTrello
28
28
  def initialize(*args)
29
29
  @internal_seconds = 0
30
30
  time_components = args
31
- if args.size == 1 && args[0].class.equal?(String)
31
+ if args.size == 1 && args[0].kind_of?(String)
32
32
  time_components = args[0].split(/[:.]/)
33
33
  end
34
34
  factor = 3600
@@ -40,24 +40,29 @@ module TimeTrello
40
40
 
41
41
  # Public: Getter. Returns the number of hours from a given duration
42
42
  def hours
43
- @internal_seconds.abs / 3600
43
+ @internal_seconds / 3600
44
44
  end
45
45
 
46
46
  # Public: Getter. Returns the number of minutes from the internal representation
47
47
  def minutes
48
- (@internal_seconds.abs / 60) % 60
48
+ (@internal_seconds / 60) % 60
49
49
  end
50
50
 
51
51
  # Public: Getter. Returns the number of seconds of a given duration
52
52
  def seconds
53
- @internal_seconds.abs % 60
53
+ @internal_seconds % 60
54
54
  end
55
55
 
56
56
  # Public: Getter. Returns the number of raw minutes of a given duration
57
57
  #
58
58
  # Important: This is a float value, since it is a raw value
59
59
  def raw_minutes
60
- @internal_seconds.abs.to_f / 60.0
60
+ @internal_seconds.to_f / 60.0
61
+ end
62
+
63
+ # Public: Getter. Returns the raw seconds for a given duration.
64
+ def raw_seconds
65
+ @internal_seconds
61
66
  end
62
67
 
63
68
  # Public: Operator overload. Sums up two different instances of Duration
@@ -80,7 +85,7 @@ module TimeTrello
80
85
  # integer division.
81
86
  def -(other)
82
87
  duration = Duration.new(0)
83
- duration.internal_seconds = @internal_seconds - other.internal_seconds
88
+ duration.internal_seconds = (@internal_seconds - other.internal_seconds).abs
84
89
 
85
90
  duration
86
91
  end
@@ -92,6 +97,11 @@ module TimeTrello
92
97
  def to_s
93
98
  "#{hours}:#{minutes}.#{seconds}"
94
99
  end
100
+
101
+ # Public: Let a developer to inspect this class instance
102
+ def inspect
103
+ self.to_s
104
+ end
95
105
  end
96
106
 
97
107
  end
@@ -70,16 +70,15 @@ module TimeTrello
70
70
  !activity.start_date.nil?
71
71
  end,
72
72
 
73
- # Parses the task comment
73
+ # Parses the task comment and card name
74
74
  lambda do |action_record, activity|
75
- txt_comment = action_record[:action].data["text"].scan(/"[a-zA-Z0-9]+"/)
75
+ txt_comment = action_record[:action].data["text"].scan(/"[\w\W\s]+"/)
76
76
  if txt_comment.size != 0
77
- activity.task_description = txt_comment[0]
78
- else
79
- activity.task_description = action_record[:action].card.name
77
+ activity.task_description = txt_comment.first.delete("\"")
80
78
  end
79
+ activity.card_name = action_record[:action].card.name
81
80
 
82
- !activity.task_description.nil?
81
+ !activity.card_name.nil? || !activity.task_description.nil?
83
82
  end,
84
83
 
85
84
  # Parses the task id
@@ -64,10 +64,13 @@ module TimeTrello
64
64
  result_set
65
65
  end
66
66
 
67
+ # Public: Setter. Overrides the board_id setter in order to re-initialize
68
+ # the driver properly with new settings.
67
69
  def board_id=(board_id)
68
70
  if board_id != @board_id
69
71
  @board_id = board_id
70
- self.driver.reset_cache
72
+ # Forces the driver reload with the new settings
73
+ @driver = nil
71
74
  end
72
75
  end
73
76
 
@@ -79,7 +79,7 @@ module TimeTrello
79
79
  @activities = []
80
80
  self.board.cards.each do |card|
81
81
  card.actions.each do |action|
82
- member = self.members.first
82
+ member = self.members.select { |member| member.id == action.member_creator_id }.first
83
83
  action_record = {action: action, member: member}
84
84
  activity = self.parser.parse(action_record)
85
85
  @activities.push(activity) unless activity.nil?
@@ -93,6 +93,7 @@ module TimeTrello
93
93
  def reset_cache
94
94
  @activities = nil
95
95
  @board = nil
96
+ @members = nil
96
97
  end
97
98
  end
98
99
  end
@@ -1,3 +1,3 @@
1
1
  module TimeTrello
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timetrello
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caio Tarifa
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-06 00:00:00.000000000 Z
12
+ date: 2016-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-trello