Floppy-amee 0.4.17 → 0.4.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,6 +46,7 @@ module AMEE
46
46
  return $cache[path] if @enable_caching and $cache[path]
47
47
  response = do_request Net::HTTP::Get.new(path)
48
48
  $cache[path] = response if @enable_caching
49
+ return response
49
50
  end
50
51
 
51
52
  def post(path, data = {})
@@ -3,15 +3,17 @@ module AMEE
3
3
  class Item < AMEE::Data::Object
4
4
 
5
5
  def initialize(data = {})
6
- @values = data ? data[:values] : []
7
- @choices = data ? data[:choices] : []
8
- @label = data ? data[:label] : []
6
+ @values = data[:values]
7
+ @choices = data[:choices]
8
+ @label = data[:label]
9
+ @item_definition = data[:item_definition]
9
10
  super
10
11
  end
11
12
 
12
13
  attr_reader :values
13
14
  attr_reader :choices
14
15
  attr_reader :label
16
+ attr_reader :item_definition
15
17
 
16
18
  def self.from_json(json)
17
19
  # Read JSON
@@ -23,6 +25,7 @@ module AMEE
23
25
  data[:name] = doc['dataItem']['name']
24
26
  data[:path] = doc['path']
25
27
  data[:label] = doc['dataItem']['label']
28
+ data[:item_definition] = doc['dataItem']['itemDefinition']['uid']
26
29
  # Get values
27
30
  data[:values] = []
28
31
  doc['dataItem']['itemValues'].each do |value|
@@ -57,6 +60,7 @@ module AMEE
57
60
  data[:name] = REXML::XPath.first(doc, '/Resources/DataItemResource/DataItem/Name').text
58
61
  data[:path] = REXML::XPath.first(doc, '/Resources/DataItemResource/Path').text
59
62
  data[:label] = REXML::XPath.first(doc, '/Resources/DataItemResource/DataItem/Label').text
63
+ data[:item_definition] = REXML::XPath.first(doc, '/Resources/DataItemResource/DataItem/ItemDefinition/@uid').to_s
60
64
  # Get values
61
65
  data[:values] = []
62
66
  REXML::XPath.each(doc, '/Resources/DataItemResource/DataItem/ItemValues/ItemValue') do |value|
@@ -99,6 +103,13 @@ module AMEE
99
103
  raise AMEE::BadData.new("Couldn't load DataItem. Check that your URL is correct.")
100
104
  end
101
105
 
106
+ def update(options = {})
107
+ connection.put(full_path, options)
108
+ rescue
109
+ raise AMEE::BadData.new("Couldn't update DataItem. Check that your information is correct.")
110
+ end
111
+
112
+
102
113
  end
103
114
  end
104
115
  end
data/lib/amee/version.rb CHANGED
@@ -3,7 +3,7 @@ module AMEE
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 0
5
5
  MINOR = 4
6
- TINY = 17
6
+ TINY = 18
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Floppy-amee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.17
4
+ version: 0.4.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-30 00:00:00 -07:00
12
+ date: 2008-11-03 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15