versionone_sdk 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e31a77bb8c908a4ceecef2fed819f89e21dc9ff6
4
- data.tar.gz: 97d3d7e6aa23cc1e50ab218b1088d58e89051c0f
3
+ metadata.gz: c9f526811b6a5f98ec420330a8427ab7274834db
4
+ data.tar.gz: d4df27978d440d828bc4b57ae492f5ea5fbda5b2
5
5
  SHA512:
6
- metadata.gz: 6425eae5af6a0bd94da2a685a51cf19abf07a7688de93a324211547e4af6501d714081a6bef3e98b66baf309458f4d0b3342eafb0d65a23fd9182661c83282cb
7
- data.tar.gz: 7c18b03697ca72c73c9d25fdedc24b434620ac051c9d8c26a236897727fe7af0583f4382635ca009e70ecab66bb563f76886ae0fc2418d13f50532345a805dc8
6
+ metadata.gz: f03fc89debd7eb1d9cf2d7c03c37994cec558368317d05228c851dc438271326a6608bf0250e86080d1993f4c8e7c5a94add42b96af3307878652048f988d1bc
7
+ data.tar.gz: 5204230875899a06d7c1866ef8053c64e05152984fde1259c511dc880d54e2d7f94993c8c1afecfb3dae2703e2985d35dc36c93a5de6a698b2aa43f148c544ed
data/CHANGELOG.md CHANGED
@@ -1,9 +1,11 @@
1
1
  CHANGELOG
2
2
  ---------
3
3
 
4
+ - **2014-03-24**: 0.1.0
5
+ - Update JSON representation to use Array for multiple values and String for single values for both Attribute and Relation tags. Previously Relation tags would be converted to arrays even if there was only a single element. This change is not backward compatible.
4
6
  - **2014-03-20**: 0.0.4
5
7
  - Fix for VersiononeSdk::Update::updateAsset
6
- - **2014-03-17**: 0.0.3
8
+ - **2014-03-20**: 0.0.3
7
9
  - Add ability to retrieve a single asset using an OID token or Number
8
10
  - Add VersiononeSdk::Update to support updating Assets
9
11
  - **2014-03-17**: 0.0.2
data/README.md CHANGED
@@ -10,7 +10,7 @@ VersionOne currently offers SDKs in Java, .NET, Python and JavaScript but not in
10
10
 
11
11
  It currently offers the following capabilities:
12
12
 
13
- 1. Ability to retrieve and parse all Assets of a certain type to JSON (via JsonDoc) seeking to match the JSON produced by the VersionOne JavaScript SDK.
13
+ 1. Ability to retrieve and parse all Assets of a certain type to JSON (via JsonDoc)
14
14
  2. Ability to query Assets transparently using Asset OID Tokens (e.g. "Story:1") or Asset Numbers (e.g. "B-1").
15
15
  3. Ability to update Assets using Ruby without needing to manually create XML.
16
16
 
@@ -105,6 +105,9 @@ Notes
105
105
  #Change Log
106
106
  -----------
107
107
 
108
+ - **2014-03-24**: 0.1.0
109
+ - Update JSON representation to use array for multiple values and string for single values for both attribute and relation XML tags. Previously relation tags would be converted to arrays even if there was only a single element. This change is not backward compatible.
110
+ - Update control properties format from __id__#{property} to _#{property}__id. This change is not backward compatible.
108
111
  - **2014-03-20**: 0.0.4
109
112
  - Fix for VersiononeSdk::Update::updateAsset
110
113
  - **2014-03-20**: 0.0.3
@@ -36,44 +36,31 @@ module VersiononeSdk
36
36
  end
37
37
  oAsset = VersiononeSdk::Asset.new
38
38
  oAsset.bIsStrict = false
39
+ sOidtokSrc = nil
40
+ sObjectType = nil
41
+ iObjectId = nil
39
42
  if oNodeAsset.attribute('id')
40
- sId = oNodeAsset.attribute('id').value
41
- if sId =~ /^(.+):([0-9]+)$/
42
- sObjectType = $1
43
- iObjectId = $2.to_i
44
- oAsset.setProp(:__id__sObjectDomain,'Versionone')
45
- oAsset.setProp(:__id__sObjectType,sObjectType)
46
- oAsset.setProp(:__id__iObjectId, iObjectId)
43
+ sOidtokSrc = oNodeAsset.attribute('id').value
44
+ if sOidtokSrc =~ /^(.+):([0-9]+)$/
45
+ sObjectType = $1
46
+ iObjectId = $2.to_i
47
+ oAsset.setProp(:_sObjectDomain__id,'Versionone')
48
+ oAsset.setProp(:_sObjectType__id,sObjectType)
49
+ oAsset.setProp(:_iObjectId__id, iObjectId)
47
50
  end
48
51
  end
49
52
  if oNodeAsset.attribute('href').value
50
53
  sUrl = @sUrl \
51
54
  ? @sUrl + oNodeAsset.attribute('href').value
52
55
  : oNodeAsset.attribute('href').value
53
- oAsset.setProp(:__id__sObjectUrl,sUrl)
56
+ oAsset.setProp(:_sObjectUrl__id,sUrl)
54
57
  end
55
58
  oNodeAsset.children.each do |oNodeChild|
56
- if oNodeChild.name == 'Attribute'
59
+ if oNodeChild.name == 'Attribute' || oNodeChild.name == 'Relation'
57
60
  if oNodeChild.attribute('name')
58
- yPropKey = oNodeChild.attribute('name').to_s.to_sym
59
- sPropVal = oNodeChild.text
60
- sPropVal = nil if sPropVal == ''
61
- oAsset.setProp(yPropKey,sPropVal)
62
- end
63
- elsif oNodeChild.name == 'Relation'
64
- yPropKey = oNodeChild.attribute('name').to_s.to_sym
65
- oNodeRelation = oNodeChild
66
- oNodeRelation.children.each do |oNodeRelationChild|
67
- if oNodeRelationChild.name == 'Asset'
68
- if oNodeRelationChild.attribute('idref').value
69
- oAsset.pushProp(yPropKey,oNodeRelationChild.attribute('idref').value)
70
- end
71
- else
72
- raise RuntimeError, "E_UNKNOWN_RELATION_CHILD_NAME #{oNodeRelationChild.name}"
73
- end
74
- end
75
- if oNodeRelation.children.count == 0
76
- oAsset.setProp(yPropKey,[])
61
+ yPropKey = oNodeChild.attribute('name').to_s.to_sym
62
+ xxPropVal = getAssetNodeChildPropVal( oNodeChild )
63
+ oAsset.setProp(yPropKey,xxPropVal)
77
64
  end
78
65
  else
79
66
  raise RuntimeError, "E_UNKNOWN_ASSET_NODE_NAME #{oNodeChild.name}"
@@ -82,5 +69,32 @@ module VersiononeSdk
82
69
  oAsset.inflate
83
70
  return oAsset
84
71
  end
72
+
73
+ def getAssetNodeChildPropVal(oNodeChild=nil)
74
+ xxPropVal = nil
75
+ aPropVals = []
76
+ if oNodeChild.children.length > 0
77
+ oNodeChild.children.each do |oNodeChildGrand|
78
+ dAttributes = oNodeChildGrand.attributes
79
+ xxPropVal = dAttributes.has_key?('idref') \
80
+ ? oNodeChildGrand.attribute('idref').value \
81
+ : oNodeChildGrand.text
82
+ xxPropVal = nil if xxPropVal == ''
83
+ aPropVals.push(xxPropVal)
84
+ end
85
+ if aPropVals.length > 1
86
+ xxPropVal = aPropVals
87
+ elsif aPropVals.length == 1
88
+ xxPropVal == aPropVals[0]
89
+ else
90
+ xxPropVal = nil
91
+ end
92
+ else
93
+ xxPropVal = oNodeChild.text
94
+ end
95
+ xxPropVal = nil if xxPropVal == ''
96
+ return xxPropVal
97
+ end
98
+
85
99
  end
86
100
  end
@@ -0,0 +1,5 @@
1
+ module VersiononeSdk
2
+
3
+ # The current version
4
+ VERSION = "0.1.0"
5
+ end
@@ -1,3 +1,5 @@
1
+ require 'versionone_sdk/version.rb'
2
+
1
3
  module VersiononeSdk
2
4
  autoload :Asset, 'versionone_sdk/asset'
3
5
  autoload :Client, 'versionone_sdk/client'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versionone_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-20 00:00:00.000000000 Z
11
+ date: 2014-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -86,6 +86,7 @@ files:
86
86
  - lib/versionone_sdk/client.rb
87
87
  - lib/versionone_sdk/parser_xml_assets.rb
88
88
  - lib/versionone_sdk/update.rb
89
+ - lib/versionone_sdk/version.rb
89
90
  - test/test_setup.rb
90
91
  homepage: http://johnwang.com/
91
92
  licenses: