infopark_cloud_connector 6.8.0.beta.200.681.7c84f4a → 6.8.0.beta.200.713.e5c3150

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,51 @@
1
+ module RailsConnector
2
+
3
+ class DictStorage #:nodoc: all
4
+
5
+ class << self
6
+
7
+ def configure(config)
8
+ @config = config.present? ? config.symbolize_keys : {}
9
+ end
10
+
11
+ def get(spec)
12
+ storage.get(spec)
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :config
18
+
19
+ def storage
20
+ @storage ||=
21
+ case config[:type]
22
+ when "s3"
23
+ s3_storage(config)
24
+ when "file"
25
+ file_storage(config)
26
+ else
27
+ raise "Unsupported dict storage type #{config[:type]}"
28
+ end
29
+ end
30
+
31
+ def s3_storage(config)
32
+ bucket = AWS::S3.new(config).buckets[config[:bucket_name]]
33
+ Kvom::Storage::S3Storage.new({
34
+ :bucket => bucket,
35
+ :bucket_prefix => "dict",
36
+ :cache => s3_storage_cache,
37
+ :cache_prefix => "dict.",
38
+ })
39
+ end
40
+
41
+ def s3_storage_cache
42
+ Rails.cache
43
+ end
44
+
45
+ def file_storage(config)
46
+ Kvom::Storage::FileSystemStorage.new(config)
47
+ end
48
+
49
+ end
50
+ end
51
+ end
@@ -520,29 +520,35 @@ module RailsConnector
520
520
  private
521
521
 
522
522
  def update_data(values = {}, meta = {})
523
- @values = values
523
+ @values = values || {}
524
+ meta ||= {}
524
525
  @attributes = meta["attributes"] || {}
526
+ @ext_ref = meta["ext_ref"]
525
527
  @attr_cache = {}
526
528
  end
527
529
 
528
530
  def read_attribute(name)
529
531
  name = name.to_s
532
+ @attr_cache[name] ||= attribute_value_from_raw_attribute_value(name)
533
+ end
534
+
535
+ def attribute_value_from_raw_attribute_value(name)
530
536
  raw = read_raw_attribute_value(name)
531
- @attr_cache[name] ||= case type_of(name)
532
- when :markdown
533
- StringTagging.tag_as_markdown(raw, self)
534
- when :html
535
- StringTagging.tag_as_html(raw, self)
536
- when :date
537
- DateAttribute.parse raw if raw
538
- when :linklist
539
- if name == "_text_links"
540
- LinkList.new(raw.values)
541
- else
542
- LinkList.new(raw)
543
- end
537
+ case type_of(name)
538
+ when :markdown
539
+ StringTagging.tag_as_markdown(raw, self)
540
+ when :html
541
+ StringTagging.tag_as_html(raw, self)
542
+ when :date
543
+ DateAttribute.parse raw if raw
544
+ when :linklist
545
+ if name == "_text_links"
546
+ LinkList.new(raw && raw.values)
544
547
  else
545
- raw
548
+ LinkList.new(raw)
549
+ end
550
+ else
551
+ raw
546
552
  end
547
553
  end
548
554
 
@@ -618,9 +624,21 @@ module RailsConnector
618
624
  end
619
625
 
620
626
  def read_raw_attribute_value(attribute_name)
627
+ return @values[attribute_name] if @values.key?(attribute_name)
628
+ if @ext_ref && (attribute_name == "_text_links" || ?_ != attribute_name[0])
629
+ extend_values_with_dict_storage_values
630
+ end
621
631
  @values[attribute_name]
622
632
  end
623
633
 
634
+ def extend_values_with_dict_storage_values
635
+ # may raise Kvom::Storage::NotFound
636
+ values = DictStorage.get(@ext_ref)
637
+ @values.reverse_merge!(values)
638
+ @ext_ref = nil
639
+ @values
640
+ end
641
+
624
642
  class << self
625
643
  private
626
644
 
@@ -3,7 +3,11 @@ module RailsConnector
3
3
  module PathConversion #:nodoc: all
4
4
 
5
5
  def self.path_from_list(components)
6
- "/#{components.join("/")}"
6
+ if components
7
+ "/#{components.join("/")}"
8
+ else
9
+ "/"
10
+ end
7
11
  end
8
12
 
9
13
  private
@@ -137,7 +137,8 @@ module RailsConnector
137
137
  "_obj_type" => data["obj_type"],
138
138
  "_obj_class" => data["obj_class"]["name"]
139
139
  ),
140
- "attributes" => data["attributes"]
140
+ "attributes" => data["attributes"],
141
+ "ext_ref" => data["ext_ref"],
141
142
  }
142
143
  end
143
144
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_cloud_connector
3
3
  version: !ruby/object:Gem::Version
4
- hash: -177875434235
4
+ hash: 2363298151
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 6
@@ -9,14 +9,12 @@ version: !ruby/object:Gem::Version
9
9
  - 0
10
10
  - beta
11
11
  - 200
12
- - 681
13
- - 7
12
+ - 713
13
+ - e
14
+ - 5
14
15
  - c
15
- - 84
16
- - f
17
- - 4
18
- - a
19
- version: 6.8.0.beta.200.681.7c84f4a
16
+ - 3150
17
+ version: 6.8.0.beta.200.713.e5c3150
20
18
  platform: ruby
21
19
  authors:
22
20
  - Infopark AG
@@ -24,7 +22,7 @@ autorequire:
24
22
  bindir: bin
25
23
  cert_chain: []
26
24
 
27
- date: 2012-06-26 00:00:00 +02:00
25
+ date: 2012-06-29 00:00:00 +02:00
28
26
  default_executable:
29
27
  dependencies:
30
28
  - !ruby/object:Gem::Dependency
@@ -65,21 +63,19 @@ dependencies:
65
63
  requirements:
66
64
  - - "="
67
65
  - !ruby/object:Gem::Version
68
- hash: -177875434235
66
+ hash: 2363298151
69
67
  segments:
70
68
  - 6
71
69
  - 8
72
70
  - 0
73
71
  - beta
74
72
  - 200
75
- - 681
76
- - 7
73
+ - 713
74
+ - e
75
+ - 5
77
76
  - c
78
- - 84
79
- - f
80
- - 4
81
- - a
82
- version: 6.8.0.beta.200.681.7c84f4a
77
+ - 3150
78
+ version: 6.8.0.beta.200.713.e5c3150
83
79
  version_requirements: *id003
84
80
  name: kvom
85
81
  prerelease: false
@@ -106,6 +102,7 @@ files:
106
102
  - lib/rails_connector/couchdb_views_source_path.rb
107
103
  - lib/rails_connector/date_attribute.rb
108
104
  - lib/rails_connector/default_search_request.rb
105
+ - lib/rails_connector/dict_storage.rb
109
106
  - lib/rails_connector/elasticsearch_request.rb
110
107
  - lib/rails_connector/errors.rb
111
108
  - lib/rails_connector/link.rb