versionone_sdk 0.0.1 → 0.0.2

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: b929a84fe8986422cdc95404986d18e2a0eec9e5
4
- data.tar.gz: fa773d457e79500251f754a7a317e7c26bf03c9e
3
+ metadata.gz: 1daac7c4e87ce3126bb13a34fb2f4a592f70d6de
4
+ data.tar.gz: 85d4ff86d26a6c8d4bdff3d9174ac51ead75ec7e
5
5
  SHA512:
6
- metadata.gz: 762acd0b035a50e2e1b8b080c91d00ebcf2d6033e6d7c6bdc9198a3f37b7772adebcf2ea01d65a79efebd0e4ad9257ed56fc064796f9e5463c8e09beb677dbfc
7
- data.tar.gz: e419b27a5ef24b59672482fd1197ddb15f9ab307ffac0dab98298a00f64ee4eed71ad8bf61e544ca6c40bdaeebb52f7d62c245f839af3cbebce34892786d7416
6
+ metadata.gz: 88a38a47a9ed0f1258ace70aa5d6da504e93fe86d22c3c8e5d912ae7de8067716dbe3c13c789515a4b06e03d9690ef3500d9cfe79cb5c48701ade8d711d917f5
7
+ data.tar.gz: 65cdf7a3fd33460abb4d62e055afd240739c19a4a49393ba94f10e76afd54827dde9c05cb79b6c52db0c9b179924a5694d1f11c69db7bc88a08d87a37600bff7
data/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
1
  CHANGELOG
2
2
  ---------
3
+ - **2014-03-17**: 0.0.2
4
+ - Add VersiononeSdk::Asset object to support value inflation, starting with AssetState.Name
3
5
  - **2014-03-16**: 0.0.1
4
6
  - Initial release
data/README.md CHANGED
@@ -33,9 +33,9 @@ Download and install versionone_sdk with the following:
33
33
 
34
34
  v1client = VersiononeSdk::Client.new(dParams)
35
35
 
36
- # Retrieve an array of JsonDoc::Document objects
36
+ # Retrieve an array of VersiononeSdk::Asset objects
37
37
 
38
- assets = oClient.getAssets('Scope')
38
+ assets = v1client.getAssets('Scope')
39
39
 
40
40
  assets.each do |asset|
41
41
  assetHash = asset.asHash
@@ -52,17 +52,27 @@ This gem is 100% documented with YARD, an exceptional documentation library. To
52
52
  Notes
53
53
  -----
54
54
 
55
- 1. Nil/Null Values and Empty Strings
55
+ 1. Integer Values
56
+
57
+ Integer values for Order and AssetState are converted from strings to integers.
58
+
59
+ 2. Nil/Null Values and Empty Strings
56
60
 
57
61
  The VersionOne JavaScript API provides empty strings when no value is present. This SDK uses Ruby nil values and JSON null values for empty strings. The primary reason for this is to support easy indexing using Elasticsearch.
58
62
 
59
- 2. Tracking Properties
63
+ 3. Inflation
64
+
65
+ Some values are inflated. Currently, AssetState is used to derive AssetState.Name as defined here: https://community.versionone.com/Developers/Developer-Library/Concepts/Asset_State
66
+
67
+ 4. Tracking Properties
60
68
 
61
69
  In addition to the standard VersionOne properties, this modules adds the following generic properties for tracking: :__id__sObjectDomain, :__id__sObjectType, :__id__iObjectId, :__id__sObjectUrl. The object domain is set to 'Versionone', while object type and object id correspond to VersionOne Asset types and ids. The URL is the full URL for the resource including protocol, host and port.
62
70
 
63
71
  #Change Log
64
72
  -----------
65
73
 
74
+ - **2014-03-17**: 0.0.2
75
+ - Add VersiononeSdk::Asset object to support value inflation, starting with AssetState.Name
66
76
  - **2014-03-16**: 0.0.1
67
77
  - Initial release
68
78
 
data/Rakefile CHANGED
@@ -16,4 +16,4 @@ task :gendoc do
16
16
  #puts 'yard doc generation disabled until JRuby build native extensions for redcarpet or yard removes the dependency.'
17
17
  system "yardoc"
18
18
  system "yard stats --list-undoc"
19
- end
19
+ end
@@ -1,4 +1,5 @@
1
1
  module VersiononeSdk
2
+ autoload :Asset, 'versionone_sdk/asset'
2
3
  autoload :Client, 'versionone_sdk/client'
3
4
  autoload :ParserXmlAssets, 'versionone_sdk/parser_xml_assets'
4
5
  end
@@ -0,0 +1,61 @@
1
+ require 'jsondoc'
2
+
3
+ module VersiononeSdk
4
+
5
+ # VersiononeSdk::Asset class is a JsonDoc::Document subclass that includes
6
+ # the #inflateNames method to add AssetState.Name based on the VersionOne
7
+ # classifications avaiable at: https://community.versionone.com/Developers/Developer-Library/Concepts/Asset_State
8
+
9
+ class Asset < JsonDoc::Document
10
+ attr_accessor :dSchema
11
+ def initialize(dValues=nil,dSchema=nil,bDefaultifyDoc=false,bIsStrict=false)
12
+ @dSchema = dSchema || self.getDefaultSchema()
13
+ @bDefaultifyDoc = bDefaultifyDoc ? true : false
14
+ @bIsStrict = bIsStrict ? true : false
15
+ @dDocument = self.getDefaultDocument()
16
+ self.loadInitialValues(dValues)
17
+ end
18
+
19
+ def getDefaultSchema()
20
+ dSchema = {}
21
+ return dSchema
22
+ end
23
+
24
+ def inflate()
25
+ self.inflateNames
26
+ self.convertIntegers
27
+ end
28
+
29
+ def convertIntegers()
30
+ [:Order,:AssetState].each do |yKey|
31
+ xxVal = self.getProp(yKey)
32
+ if xxVal.is_a?(String) && xxVal =~ /^-?[0-9]+$/
33
+ xxVal = xxVal.to_i
34
+ self.setProp(yKey,xxVal)
35
+ end
36
+ end
37
+ end
38
+
39
+ def inflateNames()
40
+ dAssetState = {
41
+ 0 => 'Future',
42
+ 64 => 'Active',
43
+ 128 => 'Closed',
44
+ 200 => 'Template (Dead)',
45
+ 208 => 'Broken Down (Dead)',
46
+ 255 => 'Deleted (Dead)'
47
+ }
48
+ if @dDocument.has_key?(:AssetState)
49
+ sAssetState = @dDocument[:AssetState]
50
+ if sAssetState.is_a?(String) && sAssetState =~ /^[0-9]+$/
51
+ iAssetState = sAssetState.to_i
52
+ if dAssetState.has_key?(iAssetState)
53
+ sAssetStateName = dAssetState[iAssetState]
54
+ self.setProp(:'AssetState.Name',sAssetStateName)
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ end
61
+ end
@@ -1,5 +1,6 @@
1
1
  require 'jsondoc'
2
2
  require 'nokogiri'
3
+ require 'versionone_sdk/asset'
3
4
 
4
5
  module VersiononeSdk
5
6
  class ParserXmlAssets
@@ -28,7 +29,7 @@ module VersiononeSdk
28
29
  if oNodeAsset.nil?
29
30
  raise RuntimeError, 'E_NIL_NODE'
30
31
  end
31
- oJsondoc = JsonDoc::Document.new
32
+ oJsondoc = VersiononeSdk::Asset.new
32
33
  oJsondoc.bIsStrict = false
33
34
  if oNodeAsset.attribute('id')
34
35
  sId = oNodeAsset.attribute('id').value
@@ -73,6 +74,7 @@ module VersiononeSdk
73
74
  raise RuntimeError, "E_UNKNOWN_ASSET_NODE_NAME #{oNodeChild.name}"
74
75
  end
75
76
  end
77
+ oJsondoc.inflate
76
78
  return oJsondoc
77
79
  end
78
80
  end
data/test/test_setup.rb CHANGED
@@ -4,8 +4,13 @@ require 'versionone_sdk'
4
4
  class VersiononeSdkTest < Test::Unit::TestCase
5
5
  def testSetup
6
6
 
7
+ oAsset = VersiononeSdk::Asset.new
7
8
  oClient = VersiononeSdk::Client.new
8
9
  oParser = VersiononeSdk::ParserXmlAssets.new
9
10
 
11
+ assert_equal 'VersiononeSdk::Asset', oAsset.class.name
12
+ assert_equal 'VersiononeSdk::Client', oClient.class.name
13
+ assert_equal 'VersiononeSdk::ParserXmlAssets', oParser.class.name
14
+
10
15
  end
11
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versionone_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wang
@@ -56,20 +56,20 @@ dependencies:
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '0'
59
+ version: '1.5'
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: '0'
62
+ version: 1.5.0
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '0'
69
+ version: '1.5'
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: '0'
72
+ version: 1.5.0
73
73
  description: A Ruby SDK for the VersionOne REST API
74
74
  email: john@johnwang.com
75
75
  executables: []
@@ -82,6 +82,7 @@ files:
82
82
  - Rakefile
83
83
  - VERSION
84
84
  - lib/versionone_sdk.rb
85
+ - lib/versionone_sdk/asset.rb
85
86
  - lib/versionone_sdk/client.rb
86
87
  - lib/versionone_sdk/parser_xml_assets.rb
87
88
  - test/test_setup.rb