xteam_schedule 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +11 -3
- data/lib/xteam_schedule/facilitation/{db.rb → base.rb} +1 -1
- data/lib/xteam_schedule/facilitation/parser.rb +8 -4
- data/lib/xteam_schedule/models/assignment.rb +9 -3
- data/lib/xteam_schedule/models/schedule.rb +20 -4
- data/lib/xteam_schedule/models/weekly_working_schedule.rb +6 -1
- data/lib/xteam_schedule.rb +3 -3
- metadata +13 -9
data/README.md
CHANGED
@@ -21,6 +21,8 @@ I am in no way associated with adnX. I work for an agile development company tha
|
|
21
21
|
|
22
22
|
It is not required that you have [xTeam](http://www.adnx.com/i/apps/xteam4mac) installed. However, you will not be able to visualise your schedules otherwise.
|
23
23
|
|
24
|
+
At present, the gem is incompatible with existing database connections (rails, for example). This will change soon.
|
25
|
+
|
24
26
|
**Install the gem:**
|
25
27
|
|
26
28
|
```ruby
|
@@ -53,7 +55,7 @@ XTeamSchedule.new('path/to/file.xtps')
|
|
53
55
|
=> #<XTeamSchedule resoruce_groups(9), resources(42), assignment_groups(14), assignments(118), working_times(79)>
|
54
56
|
```
|
55
57
|
|
56
|
-
A schedule has many resource groups and assignment groups. It also has many resources and assignments through resource groups and assignment groups respectively. Finally, a schedule has many working times through either resource groups then resources or assignment groups then assignments.
|
58
|
+
A schedule has many resource groups and assignment groups. It also has many resources and assignments through resource groups and assignment groups respectively. Finally, a schedule has many working times through either resource groups then resources or assignment groups then assignments. Wherever possible, naming has been chosen to match xTeam, i.e. 'resource' instead of 'employee'.
|
57
59
|
|
58
60
|
```ruby
|
59
61
|
schedule = XTeamSchedule.new('path/to/file.xtps')
|
@@ -65,7 +67,13 @@ assignments = schedule.assignments
|
|
65
67
|
working_times = schedule.working_times
|
66
68
|
```
|
67
69
|
|
68
|
-
There are numerous other models, for example a schedule has one 'interface' which contains various display settings. These are explained in detail below.
|
70
|
+
There are numerous other models, for example a schedule has one 'interface' which contains various display settings. These are explained in detail below. To output a schedule that can be read by xTeam, use the 'write' method:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
schedule.write('path/to/file.xtps')
|
74
|
+
```
|
75
|
+
|
76
|
+
It is also possible to convert a schedule to/from a hash. After serialisation, this could easily be written to a database.
|
69
77
|
|
70
78
|
```ruby
|
71
79
|
hash = schedule.hash
|
@@ -295,7 +303,7 @@ wednesday.update_attribute(:break_begin, nil)
|
|
295
303
|
```
|
296
304
|
|
297
305
|
**Defaults:**
|
298
|
-
The default weekly working schedule is identical to the same as the one set up above. i.e. 9am-5pm Mon-Fri, with lunch from 12pm-1pm.
|
306
|
+
The default weekly working schedule is identical to the same as the one set up above (except wednesday lunch). i.e. 9am-5pm Mon-Fri, with lunch from 12pm-1pm.
|
299
307
|
|
300
308
|
## Under Development
|
301
309
|
|
@@ -26,16 +26,17 @@ class XTeamSchedule::Parser
|
|
26
26
|
private
|
27
27
|
|
28
28
|
def parse_resource_groups!
|
29
|
-
hash['resource groups'].
|
29
|
+
hash['resource groups'].each do |rg|
|
30
30
|
schedule.resource_groups.create!(
|
31
31
|
:name => rg['name'],
|
32
32
|
:expanded_in_library => rg['expanded in library']
|
33
33
|
)
|
34
34
|
end
|
35
|
+
rescue
|
35
36
|
end
|
36
37
|
|
37
38
|
def parse_resources!
|
38
|
-
hash['resources'].
|
39
|
+
hash['resources'].each do |r|
|
39
40
|
resource_group = schedule.resource_groups.find_by_name(r['group'])
|
40
41
|
if resource_group
|
41
42
|
image = r['image'].class == StringIO ? r['image'].read : ''
|
@@ -49,19 +50,21 @@ private
|
|
49
50
|
)
|
50
51
|
end
|
51
52
|
end
|
53
|
+
rescue
|
52
54
|
end
|
53
55
|
|
54
56
|
def parse_assignment_groups!
|
55
|
-
hash['task categories'].
|
57
|
+
hash['task categories'].each do |ag|
|
56
58
|
schedule.assignment_groups.create!(
|
57
59
|
:name => ag['name'],
|
58
60
|
:expanded_in_library => ag['expanded in library']
|
59
61
|
)
|
60
62
|
end
|
63
|
+
rescue
|
61
64
|
end
|
62
65
|
|
63
66
|
def parse_assignments!
|
64
|
-
hash['tasks'].
|
67
|
+
hash['tasks'].each do |a|
|
65
68
|
assignment_group = schedule.assignment_groups.find_by_name(a['category'])
|
66
69
|
if assignment_group
|
67
70
|
assignment_group.assignments.create!(
|
@@ -70,6 +73,7 @@ private
|
|
70
73
|
)
|
71
74
|
end
|
72
75
|
end
|
76
|
+
rescue
|
73
77
|
end
|
74
78
|
|
75
79
|
def parse_working_times!
|
@@ -8,8 +8,14 @@ class XTeamSchedule::Assignment < ActiveRecord::Base
|
|
8
8
|
validates_presence_of :colour
|
9
9
|
validate :rgb_colour
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
ActiveSupport::Deprecation.silence do
|
12
|
+
after_initialize :set_default_colour
|
13
|
+
def after_initialize
|
14
|
+
set_default_colour
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
serialize :colour
|
13
19
|
before_save :symbolize_colour!
|
14
20
|
after_validation :float_colour_values!
|
15
21
|
|
@@ -29,7 +35,7 @@ private
|
|
29
35
|
end
|
30
36
|
|
31
37
|
def set_default_colour
|
32
|
-
self.colour = { :red => 0.5, :green => 0.5, :blue => 0.5 }
|
38
|
+
self.colour = { :red => 0.5, :green => 0.5, :blue => 0.5 } unless colour.present?
|
33
39
|
end
|
34
40
|
|
35
41
|
def symbolize_colour!
|
@@ -3,14 +3,30 @@ class XTeamSchedule::Schedule < ActiveRecord::Base
|
|
3
3
|
has_many :resources, :through => :resource_groups
|
4
4
|
has_many :assignment_groups, :dependent => :destroy
|
5
5
|
has_many :assignments, :through => :assignment_groups
|
6
|
-
has_many :working_times, :through => :resources
|
7
6
|
has_many :working_days, :through => :weekly_working_schedule
|
8
7
|
|
9
8
|
has_one :interface
|
10
|
-
after_initialize :set_default_interface
|
11
|
-
|
12
9
|
has_one :weekly_working_schedule
|
13
|
-
|
10
|
+
|
11
|
+
ActiveSupport::Deprecation.silence do
|
12
|
+
after_initialize :set_default_interface
|
13
|
+
after_initialize :set_default_weekly_working_schedule
|
14
|
+
def after_initialize
|
15
|
+
set_default_interface
|
16
|
+
set_default_weekly_working_schedule
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def working_times
|
21
|
+
ids = XTeamSchedule::WorkingTime.find_by_sql([
|
22
|
+
"select distinct * from working_times as wt
|
23
|
+
join resources r on wt.resource_id = r.id
|
24
|
+
join resource_groups rg on r.resource_group_id = rg.id
|
25
|
+
where rg.schedule_id = ?", id
|
26
|
+
]).map(&:id)
|
27
|
+
|
28
|
+
XTeamSchedule::WorkingTime.scoped(:conditions => { :id => ids })
|
29
|
+
end
|
14
30
|
|
15
31
|
private
|
16
32
|
|
@@ -2,7 +2,12 @@ class XTeamSchedule::WeeklyWorkingSchedule < ActiveRecord::Base
|
|
2
2
|
belongs_to :schedule
|
3
3
|
has_many :working_days, :dependent => :destroy
|
4
4
|
|
5
|
-
|
5
|
+
ActiveSupport::Deprecation.silence do
|
6
|
+
after_initialize :set_default_working_days
|
7
|
+
def after_initialize
|
8
|
+
set_default_working_days
|
9
|
+
end
|
10
|
+
end
|
6
11
|
|
7
12
|
private
|
8
13
|
|
data/lib/xteam_schedule.rb
CHANGED
@@ -14,9 +14,9 @@ require 'xteam_schedule/models/working_day'
|
|
14
14
|
require 'xteam_schedule/models/working_time'
|
15
15
|
|
16
16
|
require 'xteam_schedule/facilitation/composer'
|
17
|
-
require 'xteam_schedule/facilitation/
|
17
|
+
require 'xteam_schedule/facilitation/base'
|
18
18
|
require 'xteam_schedule/facilitation/io'
|
19
19
|
require 'xteam_schedule/facilitation/parser'
|
20
20
|
|
21
|
-
XTeamSchedule::
|
22
|
-
XTeamSchedule::
|
21
|
+
XTeamSchedule::Base.connect
|
22
|
+
XTeamSchedule::Base.build_schema
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xteam_schedule
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christopher Patuzzo
|
@@ -41,8 +41,10 @@ dependencies:
|
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
hash: 3
|
43
43
|
segments:
|
44
|
-
-
|
45
|
-
|
44
|
+
- 2
|
45
|
+
- 2
|
46
|
+
- 2
|
47
|
+
version: 2.2.2
|
46
48
|
type: :runtime
|
47
49
|
version_requirements: *id002
|
48
50
|
- !ruby/object:Gem::Dependency
|
@@ -79,12 +81,14 @@ dependencies:
|
|
79
81
|
requirement: &id005 !ruby/object:Gem::Requirement
|
80
82
|
none: false
|
81
83
|
requirements:
|
82
|
-
- - "
|
84
|
+
- - "="
|
83
85
|
- !ruby/object:Gem::Version
|
84
|
-
hash:
|
86
|
+
hash: 7
|
85
87
|
segments:
|
88
|
+
- 2
|
89
|
+
- 2
|
86
90
|
- 0
|
87
|
-
version:
|
91
|
+
version: 2.2.0
|
88
92
|
type: :development
|
89
93
|
version_requirements: *id005
|
90
94
|
- !ruby/object:Gem::Dependency
|
@@ -112,8 +116,8 @@ extra_rdoc_files: []
|
|
112
116
|
files:
|
113
117
|
- README.md
|
114
118
|
- lib/xteam_schedule/core.rb
|
119
|
+
- lib/xteam_schedule/facilitation/base.rb
|
115
120
|
- lib/xteam_schedule/facilitation/composer.rb
|
116
|
-
- lib/xteam_schedule/facilitation/db.rb
|
117
121
|
- lib/xteam_schedule/facilitation/io.rb
|
118
122
|
- lib/xteam_schedule/facilitation/parser.rb
|
119
123
|
- lib/xteam_schedule/models/assignment.rb
|