ardekantur-gantty 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/gantty.rb +9 -15
  2. data/spec/gantty_spec.rb +1 -0
  3. metadata +2 -2
@@ -323,7 +323,6 @@ module Gantty
323
323
  #
324
324
  class Task
325
325
 
326
- attr_accessor :start, :duration, :end
327
326
  attr_accessor :percent_complete, :coordinators, :priority, :color
328
327
 
329
328
  # The dependency arrays of the task. Dependencies are defined at Task.
@@ -349,6 +348,7 @@ module Gantty
349
348
  raise ArgumentError, "name cannot be blank" if t.length == 0
350
349
  @name = t
351
350
  else
351
+ # This is when we're probably getting a Nokogiri object, so attempt to parse that.
352
352
  @name = t.attributes["name"]
353
353
  @start = Date.strptime(t.attributes["start"])
354
354
  @duration = t.attributes["duration"].to_i
@@ -444,20 +444,14 @@ module Gantty
444
444
  end
445
445
 
446
446
  # Attributes
447
- def name set = nil
448
- return @name unless set
449
- @name = set
450
- end
451
-
452
- def start set = nil
453
- return @start unless set
454
- self.start = set
455
- end
456
-
457
- def duration set = nil
458
- return @duration unless set
459
- self.duration = set
460
- end
447
+ %w/ name start duration end /.each do |attribute|
448
+ define_method(attribute.to_sym) do |*args|
449
+ set = *args
450
+ set ||= nil
451
+ return self.instance_variable_get("@" + attribute) unless set
452
+ self.send("#{attribute}=".to_sym, set)
453
+ end
454
+ end
461
455
 
462
456
  end
463
457
 
@@ -68,6 +68,7 @@ describe "Gantty" do
68
68
  @gantt.details.should == "This is the description of the project."
69
69
 
70
70
  @gantt.all_tasks.size.should == 1
71
+ @gantt.all_tasks.first.name.should == "Complete this task"
71
72
 
72
73
  end
73
74
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ardekantur-gantty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - ardekantur
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-23 00:00:00 -08:00
12
+ date: 2008-11-26 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency