amee 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,9 @@
1
1
  = Changelog
2
2
 
3
+ == 2.3.0
4
+ * Remove misleading ItemValueDefinition#type function. Use profile?, data? and
5
+ drill? separately instead.
6
+
3
7
  == 2.2.0
4
8
 
5
9
  * Add SSL support. SSL connections are now used by default.
@@ -38,4 +38,8 @@ module AMEE
38
38
 
39
39
  class NotSupported < Exception
40
40
  end
41
+
42
+ class Deprecated < Exception
43
+ end
44
+
41
45
  end
@@ -30,8 +30,10 @@ module AMEE
30
30
  data[:unit] = p['unit']
31
31
  data[:perunit] = p['perunit']
32
32
  data[:valuetype] = p['valueDefinition']['valueType']
33
- data=ItemValueDefinition.parsetype(data,p['drillDown'],p['fromProfile'],p['fromData'])
34
-
33
+ data[:drill]=p['drillDown']
34
+ data[:from_profile]=p['fromProfile']
35
+ data[:from_data]=p['fromData']
36
+ data
35
37
  end
36
38
  def parse_xml(p)
37
39
  data = {}
@@ -42,11 +44,10 @@ module AMEE
42
44
  data[:unit] = x 'Unit',:doc => p
43
45
  data[:perunit] = x 'PerUnit',:doc => p
44
46
  data[:valuetype] =x 'ValueDefinition/ValueType',:doc => p
45
- drill=(x('DrillDown',:doc => p)=='true')
46
- profile=(x('FromProfile',:doc => p)=='true')
47
- ldata=(x('FromData',:doc => p)=='true')
48
- data=ItemValueDefinition.parsetype(data,drill,profile,ldata)
49
-
47
+ data[:drill]=(x('DrillDown',:doc => p)=='true')
48
+ data[:from_profile]=(x('FromProfile',:doc => p)=='true')
49
+ data[:from_data]=(x('FromData',:doc => p)=='true')
50
+ data
50
51
  end
51
52
  end
52
53
 
@@ -57,28 +58,35 @@ module AMEE
57
58
  @name = data[:name]
58
59
  @uid = data[:uid]
59
60
  @path = data[:path]
60
- @type = data[:type]
61
61
  @unit = data[:unit]
62
62
  @perunit = data[:perunit]
63
63
  @valuetype = data[:valuetype]
64
64
  @default = data[:default] == "" ? nil : data[:default]
65
65
  @choices = data[:choices] || []
66
66
  @versions = data[:versions] || []
67
+ @drill = data[:drill]
68
+ @from_data = @drill ? false : data[:from_data] # Drills are also data, but we don't want them to show as such for clarity
69
+ @from_profile = data[:from_profile]
67
70
  super
68
71
  end
69
72
 
70
- attr_reader :name,:uid,:path,:itemdefuid, :type, :valuetype, :unit, :perunit, :type, :default, :choices, :versions
73
+ attr_reader :name,:uid,:path,:itemdefuid, :type, :valuetype, :unit, :perunit, :default, :choices, :versions
74
+
75
+ # This function has bee deprecated in favour of the separate profile? data? and drill? functions
76
+ def type
77
+ raise AMEE::Deprecated
78
+ end
71
79
 
72
80
  def profile?
73
- type=='profile'
81
+ @from_profile
74
82
  end
75
83
 
76
84
  def data?
77
- type=='data'
85
+ @from_data
78
86
  end
79
87
 
80
88
  def drill?
81
- type=='drill'
89
+ @drill
82
90
  end
83
91
 
84
92
  def self.list(connection)
@@ -115,19 +123,17 @@ module AMEE
115
123
  data[:default] = p['value']
116
124
  data[:choices] = p['choices'].split(',')
117
125
  data[:versions] = p['apiVersions'].map{|v| v['apiVersion']}
118
- data=ItemValueDefinition.parsetype(data,p['drillDown'],p['fromProfile'],p['fromData'])
126
+ data[:drill]=p['drillDown']
127
+ data[:from_profile]=p['fromProfile']
128
+ data[:from_data]=p['fromData']
119
129
  # Create object
120
130
  ItemValueDefinition.new(data)
121
131
  rescue
122
132
  raise AMEE::BadData.new("Couldn't load ItemValueDefinition from JSON. Check that your URL is correct.\n#{json}")
123
133
  end
124
134
 
125
- def self.parsetype(data,drill,profile,ldata)
126
- ( (profile && !(drill||ldata) ) || ldata) or raise 'inconsistent type'
127
- data[:type]='profile' if profile
128
- data[:type]='data' if ldata
129
- data[:type]='drill' if drill
130
- data
135
+ def self.xmlpathpreamble
136
+ "/Resources//ItemValueDefinition/"
131
137
  end
132
138
 
133
139
  def self.from_xml(xml, is_list = true)
@@ -149,10 +155,9 @@ module AMEE
149
155
  data[:default] = REXML::XPath.first(doc, prefix + "ItemValueDefinition/Value").text
150
156
  data[:choices] = REXML::XPath.first(doc, prefix + "ItemValueDefinition/Choices").text.split(',') rescue nil
151
157
  data[:versions] = REXML::XPath.each(doc, prefix + "ItemValueDefinition/APIVersions/APIVersion").map{|v| v.text}
152
- drill=(REXML::XPath.first(doc, prefix + "ItemValueDefinition/DrillDown").text=='true')
153
- profile=(REXML::XPath.first(doc, prefix + "ItemValueDefinition/FromProfile").text=='true')
154
- ldata=(REXML::XPath.first(doc, prefix + "ItemValueDefinition/FromData").text=='true')
155
- data=parsetype(data,drill,profile,ldata)
158
+ data[:drill]=(x('DrillDown',:doc => doc)=='true')
159
+ data[:from_profile]=(x('FromProfile',:doc => doc)=='true')
160
+ data[:from_data]=(x('FromData',:doc => doc)=='true')
156
161
  # Create object
157
162
  ItemValueDefinition.new(data)
158
163
  rescue
data/lib/amee/version.rb CHANGED
@@ -2,8 +2,8 @@ module AMEE
2
2
 
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 2
5
- MINOR = 2
6
- TINY = 1
5
+ MINOR = 3
6
+ TINY = 0
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
9
9
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amee
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
- - 2
9
- - 1
10
- version: 2.2.1
8
+ - 3
9
+ - 0
10
+ version: 2.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Smith
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-24 00:00:00 +01:00
18
+ date: 2010-09-23 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency