mpxj 13.5.1 → 13.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mpxj/calendar.rb +112 -0
- data/lib/mpxj/calendar_day.rb +26 -0
- data/lib/mpxj/calendar_exception.rb +47 -0
- data/lib/mpxj/calendar_hours.rb +19 -0
- data/lib/mpxj/calendar_week.rb +38 -0
- data/lib/mpxj/container.rb +8 -0
- data/lib/mpxj/mpxj.jar +0 -0
- data/lib/mpxj/project.rb +23 -1
- data/lib/mpxj/properties.rb +7 -0
- data/lib/mpxj/relation.rb +16 -1
- data/lib/mpxj/resource.rb +8 -0
- data/lib/mpxj/task.rb +8 -0
- data/lib/mpxj/task_methods.rb +16 -0
- data/lib/mpxj/version.rb +1 -1
- data/lib/mpxj.rb +5 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6db16fa074527bf24f66fc3489f80b74e8d3b57f66c16a1ec08fb1caff9549f9
|
4
|
+
data.tar.gz: 828539843889b0dc81b6af42895d40002aafa3f21333ee746f2f51402d0fb9e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b797948446ff205f52ad52442308923c89b571c6f74b5d9524dad595a50fc04ca3b3f82db67a2ae15e948fd90bc29c61e7df10adbbafe0dc2e5fff7014ac014
|
7
|
+
data.tar.gz: 2f5e9809446502455952c062e2a848bc06031d29d3fa293a7c755b077263e199540bb0f1191013ed562e6aa6404f2a3b96b817ac5977f900d3fbc5f217faec30
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module MPXJ
|
2
|
+
# Represents a calendar
|
3
|
+
class Calendar < Container
|
4
|
+
attr_reader :days
|
5
|
+
attr_reader :weeks
|
6
|
+
attr_reader :exceptions
|
7
|
+
|
8
|
+
def initialize(parent_project, attribute_values)
|
9
|
+
super(parent_project, attribute_values.slice('unique_id', 'guid', 'parent_unique_id', 'name', 'type', 'personal', 'minutes_per_day', 'minutes_per_week', 'minutes_per_month', 'minutes_per_year'))
|
10
|
+
process_days(attribute_values)
|
11
|
+
process_weeks(attribute_values)
|
12
|
+
process_exceptions(attribute_values)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Retrieve the calendar unique ID
|
16
|
+
#
|
17
|
+
# @return [Integer] the calendar unique ID
|
18
|
+
def unique_id
|
19
|
+
get_integer_value(attribute_values['unique_id'])
|
20
|
+
end
|
21
|
+
|
22
|
+
# Retrieve the calendar GUID
|
23
|
+
#
|
24
|
+
# @return [String] the calendar GUID
|
25
|
+
def guid
|
26
|
+
attribute_values['guid']
|
27
|
+
end
|
28
|
+
|
29
|
+
# Retrieve the parent calendar unique ID
|
30
|
+
#
|
31
|
+
# @return [Integer] the parent calendar unique ID
|
32
|
+
# @return [nil] if the calendar does not have a parent
|
33
|
+
def parent_unique_id
|
34
|
+
get_nillable_integer_value(attribute_values['parent_unique_id'])
|
35
|
+
end
|
36
|
+
|
37
|
+
# Retrieve the parent calendar of this calendar
|
38
|
+
#
|
39
|
+
# @return [Calendar] if this calendar is the child of another calendar
|
40
|
+
# @return [nil] if this is a base calendar
|
41
|
+
def parent_calendar
|
42
|
+
parent_project.get_calendar_by_unique_id(attribute_values['parent_unique_id']&.to_i)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Retrieve the calendar name
|
46
|
+
#
|
47
|
+
# @return [String] the calendar name
|
48
|
+
def name
|
49
|
+
attribute_values['name']
|
50
|
+
end
|
51
|
+
|
52
|
+
# Retrieve the calendar type
|
53
|
+
#
|
54
|
+
# @return [String] the calendar type
|
55
|
+
def type
|
56
|
+
attribute_values['type']
|
57
|
+
end
|
58
|
+
|
59
|
+
# Retrieve the personal flag
|
60
|
+
#
|
61
|
+
# @return [Boolean] true if this is a personal calendar
|
62
|
+
def personal
|
63
|
+
get_boolean_value(attribute_values['personal'])
|
64
|
+
end
|
65
|
+
|
66
|
+
# Retrieve the number of minutes per day
|
67
|
+
#
|
68
|
+
# @return [Integer] the number of minutes per day
|
69
|
+
# @return [nil] if this calendar does not provide a value for minutes per day
|
70
|
+
def minutes_per_day
|
71
|
+
get_nillable_integer_value(attribute_values['minutes_per_day'])
|
72
|
+
end
|
73
|
+
|
74
|
+
# Retrieve the number of minutes per week
|
75
|
+
#
|
76
|
+
# @return [Integer] the number of minutes per week
|
77
|
+
# @return [nil] if this calendar does not provide a value for minutes per week
|
78
|
+
def minutes_per_week
|
79
|
+
get_nillable_integer_value(attribute_values['minutes_per_week'])
|
80
|
+
end
|
81
|
+
|
82
|
+
# Retrieve the number of minutes per month
|
83
|
+
#
|
84
|
+
# @return [Integer] the number of minutes per month
|
85
|
+
# @return [nil] if this calendar does not provide a value for minutes per month
|
86
|
+
def minutes_per_month
|
87
|
+
get_nillable_integer_value(attribute_values['minutes_per_month'])
|
88
|
+
end
|
89
|
+
|
90
|
+
# Retrieve the number of minutes per year
|
91
|
+
#
|
92
|
+
# @return [Integer] the number of minutes per year
|
93
|
+
# @return [nil] if this calendar does not provide a value for minutes per year
|
94
|
+
def minutes_per_year
|
95
|
+
get_nillable_integer_value(attribute_values['minutes_per_year'])
|
96
|
+
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
def process_days(attribute_values)
|
101
|
+
@days = attribute_values.slice('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday').map {|name, day| [name, CalendarDay.new(parent_project, day)]}.to_h
|
102
|
+
end
|
103
|
+
|
104
|
+
def process_weeks(attribute_values)
|
105
|
+
@weeks = (attribute_values['working_weeks'] || []).map {|week| CalendarWeek.new(parent_project, week)}
|
106
|
+
end
|
107
|
+
|
108
|
+
def process_exceptions(attribute_values)
|
109
|
+
@exceptions = (attribute_values['exceptions'] || []).map {|exception| CalendarException.new(parent_project, exception)}
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module MPXJ
|
2
|
+
# Represents a calendar day
|
3
|
+
class CalendarDay < Container
|
4
|
+
attr_reader :hours
|
5
|
+
|
6
|
+
def initialize(parent_project, attribute_values)
|
7
|
+
super(parent_project, attribute_values.slice('type'))
|
8
|
+
process_hours(attribute_values)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Retrieve the day type
|
12
|
+
#
|
13
|
+
# @return [String] the calendar day type
|
14
|
+
def type
|
15
|
+
attribute_values['type']
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def process_hours(attribute_values)
|
21
|
+
@hours = (attribute_values['hours'] || {}).map do |hours|
|
22
|
+
CalendarHours.new(parent_project, hours)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module MPXJ
|
2
|
+
# Represents a calendar exception
|
3
|
+
class CalendarException < Container
|
4
|
+
attr_reader :hours
|
5
|
+
|
6
|
+
def initialize(parent_project, attribute_values)
|
7
|
+
super(parent_project, attribute_values.slice('name', 'from', 'to', 'type'))
|
8
|
+
process_hours(attribute_values)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Retrieve the exception name
|
12
|
+
#
|
13
|
+
# @return [String] the exception name
|
14
|
+
def name
|
15
|
+
attribute_values['name']
|
16
|
+
end
|
17
|
+
|
18
|
+
# Retrieve the date on which this exception starts
|
19
|
+
#
|
20
|
+
# @return [Time] the exception from date
|
21
|
+
def from
|
22
|
+
get_date_value(attribute_values['from'])
|
23
|
+
end
|
24
|
+
|
25
|
+
# Retrieve the date on which this exception ends
|
26
|
+
#
|
27
|
+
# @return [Time] the exception to date
|
28
|
+
def to
|
29
|
+
get_date_value(attribute_values['to'])
|
30
|
+
end
|
31
|
+
|
32
|
+
# Retrieve the exception type
|
33
|
+
#
|
34
|
+
# @return [String] the exception type
|
35
|
+
def type
|
36
|
+
attribute_values['type']
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def process_hours(attribute_values)
|
42
|
+
@hours = (attribute_values['hours'] || {}).map do |hours|
|
43
|
+
CalendarHours.new(parent_project, hours)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module MPXJ
|
2
|
+
# Represents a range of hours
|
3
|
+
class CalendarHours < Container
|
4
|
+
|
5
|
+
# Retrieve the the start hour
|
6
|
+
#
|
7
|
+
# @return [Time] start hour
|
8
|
+
def from
|
9
|
+
get_date_value(attribute_values['from'])
|
10
|
+
end
|
11
|
+
|
12
|
+
# Retrieve the the finish hour
|
13
|
+
#
|
14
|
+
# @return [Time] finish hour
|
15
|
+
def to
|
16
|
+
get_date_value(attribute_values['to'])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module MPXJ
|
2
|
+
# Represents a working week
|
3
|
+
class CalendarWeek < Container
|
4
|
+
attr_reader :days
|
5
|
+
|
6
|
+
def initialize(parent_project, attribute_values)
|
7
|
+
super(parent_project, attribute_values.slice('name', 'effective_from', 'effective_to'))
|
8
|
+
process_days(attribute_values)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Retrieve the exception name
|
12
|
+
#
|
13
|
+
# @return [String] the exception name
|
14
|
+
def name
|
15
|
+
attribute_values['name']
|
16
|
+
end
|
17
|
+
|
18
|
+
# Retrieve the date from which this working week is in effect
|
19
|
+
#
|
20
|
+
# @return [Time] effective from date
|
21
|
+
def effective_from
|
22
|
+
get_date_value(attribute_values['effective_from'])
|
23
|
+
end
|
24
|
+
|
25
|
+
# Retrieve the date to which this working week is in effect
|
26
|
+
#
|
27
|
+
# @return [Time] effective to date
|
28
|
+
def effective_to
|
29
|
+
get_date_value(attribute_values['effective_to'])
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def process_days(attribute_values)
|
35
|
+
@days = attribute_values.slice('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday').map {|name, day| [name, CalendarDay.new(parent_project, day)]}.to_h
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/mpxj/container.rb
CHANGED
data/lib/mpxj/mpxj.jar
CHANGED
Binary file
|
data/lib/mpxj/project.rb
CHANGED
@@ -4,6 +4,7 @@ module MPXJ
|
|
4
4
|
# Represents a project plan
|
5
5
|
class Project
|
6
6
|
attr_reader :properties
|
7
|
+
attr_reader :all_calendars
|
7
8
|
attr_reader :all_resources
|
8
9
|
attr_reader :all_tasks
|
9
10
|
attr_reader :child_tasks
|
@@ -11,12 +12,14 @@ module MPXJ
|
|
11
12
|
attr_reader :zone
|
12
13
|
|
13
14
|
def initialize(file_name, zone)
|
15
|
+
@calendars_by_unique_id = {}
|
14
16
|
@resources_by_unique_id = {}
|
15
17
|
@tasks_by_unique_id = {}
|
16
18
|
|
17
|
-
@resources_by_id = {}
|
19
|
+
@resources_by_id = {}
|
18
20
|
@tasks_by_id = {}
|
19
21
|
|
22
|
+
@all_calendars = []
|
20
23
|
@all_resources = []
|
21
24
|
@all_tasks = []
|
22
25
|
@all_assignments = []
|
@@ -29,6 +32,7 @@ module MPXJ
|
|
29
32
|
|
30
33
|
file = File.read(file_name)
|
31
34
|
json_data = JSON.parse(file)
|
35
|
+
process_calendars(json_data)
|
32
36
|
process_custom_fields(json_data)
|
33
37
|
process_properties(json_data)
|
34
38
|
process_resources(json_data)
|
@@ -36,6 +40,15 @@ module MPXJ
|
|
36
40
|
process_assignments(json_data)
|
37
41
|
end
|
38
42
|
|
43
|
+
# Retrieves the calendar with the matching unique_id attribute
|
44
|
+
#
|
45
|
+
# @param unique_id [Integer] calendar unique ID
|
46
|
+
# @return [Calendar] if the requested calendar is found
|
47
|
+
# @return [nil] if the requested calendar is not found
|
48
|
+
def get_calendar_by_unique_id(unique_id)
|
49
|
+
@calendars_by_unique_id[unique_id]
|
50
|
+
end
|
51
|
+
|
39
52
|
# Retrieves the resource with the matching unique_id attribute
|
40
53
|
#
|
41
54
|
# @param unique_id [Integer] resource unique ID
|
@@ -104,6 +117,15 @@ module MPXJ
|
|
104
117
|
|
105
118
|
private
|
106
119
|
|
120
|
+
def process_calendars(json_data)
|
121
|
+
calendars = json_data["calendars"]
|
122
|
+
calendars.each do |attribute_values|
|
123
|
+
calendar = Calendar.new(self, attribute_values)
|
124
|
+
@all_calendars << calendar
|
125
|
+
@calendars_by_unique_id[calendar.unique_id] = calendar
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
107
129
|
def process_custom_fields(json_data)
|
108
130
|
custom_fields = json_data["custom_fields"] || []
|
109
131
|
custom_fields.each do |field|
|
data/lib/mpxj/properties.rb
CHANGED
@@ -2,5 +2,12 @@ module MPXJ
|
|
2
2
|
# Represents the properties of a project
|
3
3
|
class Properties < Container
|
4
4
|
include MPXJ::PropertyMethods
|
5
|
+
|
6
|
+
# Retrieve the default calendar for this project
|
7
|
+
#
|
8
|
+
# @return [Calendar] default calendar
|
9
|
+
def default_calendar
|
10
|
+
parent_project.get_calendar_by_unique_id(attribute_values['default_calendar_unique_id']&.to_i)
|
11
|
+
end
|
5
12
|
end
|
6
13
|
end
|
data/lib/mpxj/relation.rb
CHANGED
@@ -2,12 +2,27 @@ module MPXJ
|
|
2
2
|
# Represents a relationship between two tasks in a project plan
|
3
3
|
class Relation < Container
|
4
4
|
# Retrieve the Task Unique ID value
|
5
|
-
#
|
5
|
+
# <b>DEPRECATED:</b> Please use <tt>predecessor_task_unique_id</tt> or <tt>successor_task_unique_id</tt>instead.
|
6
|
+
#
|
6
7
|
# @return Task Unique ID value
|
7
8
|
def task_unique_id
|
8
9
|
get_integer_value(attribute_values['task_unique_id'])
|
9
10
|
end
|
10
11
|
|
12
|
+
# Retrieve the Predecessor Task Unique ID value
|
13
|
+
#
|
14
|
+
# @return Predecessor Task Unique ID value
|
15
|
+
def predecessor_task_unique_id
|
16
|
+
get_integer_value(attribute_values['predecessor_task_unique_id'])
|
17
|
+
end
|
18
|
+
|
19
|
+
# Retrieve the Successor Task Unique ID value
|
20
|
+
#
|
21
|
+
# @return Successor Task Unique ID value
|
22
|
+
def successor_task_unique_id
|
23
|
+
get_integer_value(attribute_values['successor_task_unique_id'])
|
24
|
+
end
|
25
|
+
|
11
26
|
# Retrieve the Lag value
|
12
27
|
#
|
13
28
|
# @return Lag value
|
data/lib/mpxj/resource.rb
CHANGED
@@ -8,5 +8,13 @@ module MPXJ
|
|
8
8
|
super(parent_project, attribute_values)
|
9
9
|
@assignments = []
|
10
10
|
end
|
11
|
+
|
12
|
+
# Retrieve the calendar used by this resource
|
13
|
+
#
|
14
|
+
# @return [Calendar] resource calendar
|
15
|
+
# @return [nil] if this resource does not have a calendar
|
16
|
+
def calendar
|
17
|
+
parent_project.get_calendar_by_unique_id(attribute_values['calendar_unique_id']&.to_i)
|
18
|
+
end
|
11
19
|
end
|
12
20
|
end
|
data/lib/mpxj/task.rb
CHANGED
@@ -24,6 +24,14 @@ module MPXJ
|
|
24
24
|
parent_project.get_task_by_unique_id(attribute_values['parent_task_unique_id']&.to_i)
|
25
25
|
end
|
26
26
|
|
27
|
+
# Retrieve the calendar used by this task
|
28
|
+
#
|
29
|
+
# @return [Calendar] task calendar
|
30
|
+
# @return [nil] if this task does not have a calendar assigned
|
31
|
+
def calendar
|
32
|
+
parent_project.get_calendar_by_unique_id(attribute_values['calendar_unique_id']&.to_i)
|
33
|
+
end
|
34
|
+
|
27
35
|
private
|
28
36
|
|
29
37
|
def process_relations
|
data/lib/mpxj/task_methods.rb
CHANGED
@@ -18,6 +18,13 @@ module MPXJ
|
|
18
18
|
attribute_values['activity_codes']
|
19
19
|
end
|
20
20
|
|
21
|
+
# Retrieve the Activity Code Values value
|
22
|
+
#
|
23
|
+
# @return Activity Code Values value
|
24
|
+
def activity_code_values
|
25
|
+
attribute_values['activity_code_values']
|
26
|
+
end
|
27
|
+
|
21
28
|
# Retrieve the Activity ID value
|
22
29
|
#
|
23
30
|
# @return Activity ID value
|
@@ -25,6 +32,13 @@ module MPXJ
|
|
25
32
|
attribute_values['activity_id']
|
26
33
|
end
|
27
34
|
|
35
|
+
# Retrieve the Activity Percent Complete value
|
36
|
+
#
|
37
|
+
# @return Activity Percent Complete value
|
38
|
+
def activity_percent_complete
|
39
|
+
get_float_value(attribute_values['activity_percent_complete'])
|
40
|
+
end
|
41
|
+
|
28
42
|
# Retrieve the Activity Status value
|
29
43
|
#
|
30
44
|
# @return Activity Status value
|
@@ -6902,7 +6916,9 @@ module MPXJ
|
|
6902
6916
|
ATTRIBUTE_TYPES = {
|
6903
6917
|
'active' => :boolean,
|
6904
6918
|
'activity_codes' => :activity_code_list,
|
6919
|
+
'activity_code_values' => :activity_code_values,
|
6905
6920
|
'activity_id' => :string,
|
6921
|
+
'activity_percent_complete' => :percentage,
|
6906
6922
|
'activity_status' => :activity_status,
|
6907
6923
|
'activity_type' => :activity_type,
|
6908
6924
|
'actual_cost' => :currency,
|
data/lib/mpxj/version.rb
CHANGED
data/lib/mpxj.rb
CHANGED
@@ -3,6 +3,11 @@ require "mpxj/container"
|
|
3
3
|
require "mpxj/project"
|
4
4
|
require "mpxj/property_methods"
|
5
5
|
require "mpxj/properties"
|
6
|
+
require "mpxj/calendar"
|
7
|
+
require "mpxj/calendar_day"
|
8
|
+
require "mpxj/calendar_week"
|
9
|
+
require "mpxj/calendar_hours"
|
10
|
+
require "mpxj/calendar_exception"
|
6
11
|
require "mpxj/resource_methods"
|
7
12
|
require "mpxj/resource"
|
8
13
|
require "mpxj/task_methods"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mpxj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 13.
|
4
|
+
version: 13.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Iles
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -118,6 +118,11 @@ files:
|
|
118
118
|
- lib/mpxj/argument_error.rb
|
119
119
|
- lib/mpxj/assignment.rb
|
120
120
|
- lib/mpxj/assignment_methods.rb
|
121
|
+
- lib/mpxj/calendar.rb
|
122
|
+
- lib/mpxj/calendar_day.rb
|
123
|
+
- lib/mpxj/calendar_exception.rb
|
124
|
+
- lib/mpxj/calendar_hours.rb
|
125
|
+
- lib/mpxj/calendar_week.rb
|
121
126
|
- lib/mpxj/commons-codec-1.17.0.jar
|
122
127
|
- lib/mpxj/commons-collections4-4.4.jar
|
123
128
|
- lib/mpxj/commons-io-2.16.1.jar
|