mpxj 5.1.6 → 5.1.7
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/container.rb +89 -89
- data/lib/mpxj/mpxj.jar +0 -0
- data/lib/mpxj/reader.rb +48 -48
- data/lib/mpxj/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 229d1bbbaf65e22830abe15ffbe4d756aeeb7910
|
4
|
+
data.tar.gz: 02227b372cfd1475d659b1c305140713c08d4903
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb6df8217441cb630c3f101e47d87f073c5fbddbcfac96f9f4df0f3ec7ce57d8baec6ebe3bdf7701975b1ff11ebcd7dd62a995082b245dad8281ef81208b9bb1
|
7
|
+
data.tar.gz: df627367722da6c14aa8f3c703684b81fef5478deaf0775f311c38faab06e35bdb0bb2915ae26a26d595a5c63ad3e293fff363aa17724cbf64c189d02d2bfa8d
|
data/lib/mpxj/container.rb
CHANGED
@@ -1,89 +1,89 @@
|
|
1
|
-
require 'duration'
|
2
|
-
require 'time'
|
3
|
-
|
4
|
-
module MPXJ
|
5
|
-
# Base class from which all project entities are derived
|
6
|
-
class Container
|
7
|
-
attr_reader :parent_project
|
8
|
-
def initialize(parent_project, attribute_types, attribute_values)
|
9
|
-
@parent_project = parent_project
|
10
|
-
@attribute_types = attribute_types
|
11
|
-
@attribute_values = attribute_values
|
12
|
-
end
|
13
|
-
|
14
|
-
def method_missing(name, *args, &block)
|
15
|
-
# We can probably do this more efficiently with dynamic methods... but let's get some feedback first!
|
16
|
-
attribute_name = name.to_s
|
17
|
-
attribute_type = @attribute_types[attribute_name]
|
18
|
-
attribute_value = @attribute_values[attribute_name]
|
19
|
-
|
20
|
-
if attribute_type.nil? && attribute_value.nil?
|
21
|
-
super
|
22
|
-
else
|
23
|
-
if attribute_type.nil?
|
24
|
-
attribute_type = 1
|
25
|
-
end
|
26
|
-
get_attribute_value(attribute_type, attribute_value)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
protected
|
31
|
-
|
32
|
-
attr_reader :attribute_values
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def get_attribute_value(attribute_type, attribute_value)
|
37
|
-
case attribute_type.to_i
|
38
|
-
when 12, 17, 19
|
39
|
-
get_integer_value(attribute_value)
|
40
|
-
when 8, 3, 5, 7
|
41
|
-
get_float_value(attribute_value)
|
42
|
-
when 2
|
43
|
-
get_date_value(attribute_value)
|
44
|
-
when 6, 16
|
45
|
-
get_duration_value(attribute_value)
|
46
|
-
when 4
|
47
|
-
get_boolean_value(attribute_value)
|
48
|
-
else
|
49
|
-
attribute_value
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def get_duration_value(attribute_value)
|
54
|
-
if attribute_value.nil?
|
55
|
-
Duration.new(0)
|
56
|
-
else
|
57
|
-
Duration.new(attribute_value.to_i)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def get_date_value(attribute_value)
|
62
|
-
if attribute_value.nil?
|
63
|
-
nil
|
64
|
-
else
|
65
|
-
@parent_project.zone.parse(attribute_value)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def get_float_value(attribute_value)
|
70
|
-
if attribute_value.nil?
|
71
|
-
0.0
|
72
|
-
else
|
73
|
-
attribute_value.to_f
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def get_integer_value(attribute_value)
|
78
|
-
if attribute_value.nil?
|
79
|
-
0
|
80
|
-
else
|
81
|
-
attribute_value.to_i
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def get_boolean_value(attribute_value)
|
86
|
-
attribute_value == true
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
1
|
+
require 'duration'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
module MPXJ
|
5
|
+
# Base class from which all project entities are derived
|
6
|
+
class Container
|
7
|
+
attr_reader :parent_project
|
8
|
+
def initialize(parent_project, attribute_types, attribute_values)
|
9
|
+
@parent_project = parent_project
|
10
|
+
@attribute_types = attribute_types
|
11
|
+
@attribute_values = attribute_values
|
12
|
+
end
|
13
|
+
|
14
|
+
def method_missing(name, *args, &block)
|
15
|
+
# We can probably do this more efficiently with dynamic methods... but let's get some feedback first!
|
16
|
+
attribute_name = name.to_s
|
17
|
+
attribute_type = @attribute_types[attribute_name]
|
18
|
+
attribute_value = @attribute_values[attribute_name]
|
19
|
+
|
20
|
+
if attribute_type.nil? && attribute_value.nil?
|
21
|
+
super
|
22
|
+
else
|
23
|
+
if attribute_type.nil?
|
24
|
+
attribute_type = 1
|
25
|
+
end
|
26
|
+
get_attribute_value(attribute_type, attribute_value)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
|
32
|
+
attr_reader :attribute_values
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def get_attribute_value(attribute_type, attribute_value)
|
37
|
+
case attribute_type.to_i
|
38
|
+
when 12, 17, 19
|
39
|
+
get_integer_value(attribute_value)
|
40
|
+
when 8, 3, 5, 7
|
41
|
+
get_float_value(attribute_value)
|
42
|
+
when 2
|
43
|
+
get_date_value(attribute_value)
|
44
|
+
when 6, 16
|
45
|
+
get_duration_value(attribute_value)
|
46
|
+
when 4
|
47
|
+
get_boolean_value(attribute_value)
|
48
|
+
else
|
49
|
+
attribute_value
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_duration_value(attribute_value)
|
54
|
+
if attribute_value.nil?
|
55
|
+
Duration.new(0)
|
56
|
+
else
|
57
|
+
Duration.new(attribute_value.to_i)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_date_value(attribute_value)
|
62
|
+
if attribute_value.nil?
|
63
|
+
nil
|
64
|
+
else
|
65
|
+
@parent_project.zone.parse(attribute_value)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def get_float_value(attribute_value)
|
70
|
+
if attribute_value.nil?
|
71
|
+
0.0
|
72
|
+
else
|
73
|
+
attribute_value.to_f
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_integer_value(attribute_value)
|
78
|
+
if attribute_value.nil?
|
79
|
+
0
|
80
|
+
else
|
81
|
+
attribute_value.to_i
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_boolean_value(attribute_value)
|
86
|
+
attribute_value == true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/mpxj/mpxj.jar
CHANGED
Binary file
|
data/lib/mpxj/reader.rb
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
require 'tempfile'
|
2
|
-
require 'active_support/core_ext/time/calculations'
|
3
|
-
|
4
|
-
module MPXJ
|
5
|
-
# Used to read a project plan from a file
|
6
|
-
class Reader
|
7
|
-
# Reads a project plan from a file, and returns a Project instance
|
8
|
-
# which provides access to the structure and attributes of the project data.
|
9
|
-
# Note that an optional timezone can be supplied to ensue that all date-time
|
10
|
-
# values returned are in the specified timezone.
|
11
|
-
#
|
12
|
-
# @param file_name [String] the name of the file to read
|
13
|
-
# @param zone [ActiveSupport::TimeZone] an optional timezone
|
14
|
-
# @return [Project] new Project instance
|
15
|
-
def self.read(file_name, zone = nil)
|
16
|
-
project = nil
|
17
|
-
json_file = Tempfile.new([File.basename(file_name, ".*"), '.json'])
|
18
|
-
tz = zone || Time.zone || ActiveSupport::TimeZone["UTC"]
|
19
|
-
|
20
|
-
begin
|
21
|
-
classpath = Dir["#{File.dirname(__FILE__)}/*.jar"].join(path_separator)
|
22
|
-
java_output = `java -cp \"#{classpath}\" net.sf.mpxj.sample.MpxjConvert \"#{file_name}\" \"#{json_file.path}\"`
|
23
|
-
if $?.exitstatus != 0
|
24
|
-
raise "Failed to read file: #{java_output}"
|
25
|
-
end
|
26
|
-
project = Project.new(json_file, tz)
|
27
|
-
ensure
|
28
|
-
json_file.close
|
29
|
-
json_file.unlink
|
30
|
-
end
|
31
|
-
project
|
32
|
-
end
|
33
|
-
|
34
|
-
# @private
|
35
|
-
def self.path_separator
|
36
|
-
if windows?
|
37
|
-
";"
|
38
|
-
else
|
39
|
-
":"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# @private
|
44
|
-
def self.windows?
|
45
|
-
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
1
|
+
require 'tempfile'
|
2
|
+
require 'active_support/core_ext/time/calculations'
|
3
|
+
|
4
|
+
module MPXJ
|
5
|
+
# Used to read a project plan from a file
|
6
|
+
class Reader
|
7
|
+
# Reads a project plan from a file, and returns a Project instance
|
8
|
+
# which provides access to the structure and attributes of the project data.
|
9
|
+
# Note that an optional timezone can be supplied to ensue that all date-time
|
10
|
+
# values returned are in the specified timezone.
|
11
|
+
#
|
12
|
+
# @param file_name [String] the name of the file to read
|
13
|
+
# @param zone [ActiveSupport::TimeZone] an optional timezone
|
14
|
+
# @return [Project] new Project instance
|
15
|
+
def self.read(file_name, zone = nil)
|
16
|
+
project = nil
|
17
|
+
json_file = Tempfile.new([File.basename(file_name, ".*"), '.json'])
|
18
|
+
tz = zone || Time.zone || ActiveSupport::TimeZone["UTC"]
|
19
|
+
|
20
|
+
begin
|
21
|
+
classpath = Dir["#{File.dirname(__FILE__)}/*.jar"].join(path_separator)
|
22
|
+
java_output = `java -cp \"#{classpath}\" net.sf.mpxj.sample.MpxjConvert \"#{file_name}\" \"#{json_file.path}\"`
|
23
|
+
if $?.exitstatus != 0
|
24
|
+
raise "Failed to read file: #{java_output}"
|
25
|
+
end
|
26
|
+
project = Project.new(json_file, tz)
|
27
|
+
ensure
|
28
|
+
json_file.close
|
29
|
+
json_file.unlink
|
30
|
+
end
|
31
|
+
project
|
32
|
+
end
|
33
|
+
|
34
|
+
# @private
|
35
|
+
def self.path_separator
|
36
|
+
if windows?
|
37
|
+
";"
|
38
|
+
else
|
39
|
+
":"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# @private
|
44
|
+
def self.windows?
|
45
|
+
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/mpxj/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mpxj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.1.
|
4
|
+
version: 5.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Iles
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: activesupport
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: tzinfo-data
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|