daengine 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -62,3 +62,31 @@ Query via the REST API...
62
62
  get 'http://localhost:3000/digital_assets/search?sami=FOOBAR.001'
63
63
  get 'http://localhost:3000/digital_assets/search?funds=12345'
64
64
 
65
+
66
+ To test the app locally as a project from irb console
67
+ ------------------------------------------------------
68
+ Update your #{RAILS_ROOT}/client/config.yml
69
+
70
+ 1. Ensure mongo is running locally
71
+ 2. Provide a database name. Asset metadata records will be stored in edist database in mongo.
72
+ 3. Ensure mongo port is correct in config.yml
73
+ 4. Ensure assets_path info is correct. [Sample deploy files provided under #{RAILS_ROOT}/client/digital-assets/*.xml]
74
+ 5. Set paths for daengine.yml, daengine.log in config.yml
75
+
76
+ %%% Sample config.yml %%%
77
+ host: localhost
78
+ database: edist
79
+ port: 27017
80
+ assets_path: c:/tmp/daengine/digital_assets
81
+ daengine_yml_file: c:/tmp/daengine/daengine.yml
82
+ logfile_location: c:/tmp/daengine.log
83
+
84
+ Start the irb using the command from your project root directory:
85
+ C:\dev\daengine> irb -Ilib -rdaengine
86
+ irb(main): config = YAML.load_file('#{RAILS_ROOT}\client\config.yml')
87
+ irb(main): Daengine.execute(config)
88
+
89
+ At the end of this, "digital_assets" collection will be created with all asset metadata records in "edist" database.
90
+
91
+
92
+
@@ -12,6 +12,4 @@ config = YAML.load_file(ARGV[0])
12
12
 
13
13
  t = Daengine.execute(config)
14
14
 
15
- puts t
16
-
17
- t.join
15
+ puts t
@@ -22,7 +22,7 @@ module Daengine::TeamsiteMetadataParser
22
22
  "TeamSite/Metadata/enterprise_content_type_id" => 'content_type'
23
23
  }
24
24
  @@validations = {
25
- "TeamSite/Metadata/display_on_website" => lambda { |val| /Y|1/ =~ val },
25
+ "TeamSite/Metadata/display_on_website" => lambda { |val| /Y|1|true/ =~ val },
26
26
  "TeamSite/Metadata/enterprise_expiration_date" => lambda {|val| !val.blank? },
27
27
  # "TeamSite/Metadata/enterprise_unpublish_date" => lambda {|val| val.blank? },
28
28
  "path" => lambda {|val| !(/\/manifest\// =~ val) }
@@ -40,43 +40,43 @@ module Daengine::TeamsiteMetadataParser
40
40
  end
41
41
 
42
42
  def self.parse_tuple_file(file)
43
- time do
43
+ time do
44
44
  asset = nil
45
45
  assets = {}
46
46
  docpath = {}
47
47
  valid = true
48
48
  while (line = file.gets)
49
49
  case line
50
- when /<\/?data-tuple>/
51
- if (asset.blank?)
52
- asset = DigitalAsset.new
53
- elsif(valid)
54
- assets[asset.guid] ||= asset.attributes # first tuple metadata wins
55
- assets[asset.guid]['documents_attributes'] ||= []
56
- assets[asset.guid]['documents_attributes'] << docpath
57
- # assets[asset.guid]['_id'] = asset.guid
58
- asset = nil; docpath = {}; valid = true;
59
- else
60
- asset = nil; docpath = {}; valid = true;
61
- end
62
- when /<tuple-field name="([^"]+)">([^<]+)<\/tuple-field>/
63
- if (valid)
64
- if @@validations[$1]
65
- valid = @@validations[$1].call($2)
50
+ when /<\/?data-tuple>/
51
+ if (asset.blank?)
52
+ asset = DigitalAsset.new
53
+ elsif (valid)
54
+ assets[asset.guid] ||= asset.attributes # first tuple metadata wins
55
+ assets[asset.guid]['documents_attributes'] ||= []
56
+ assets[asset.guid]['documents_attributes'] << docpath
57
+ # assets[asset.guid]['_id'] = asset.guid
58
+ asset = nil; docpath = {}; valid = true;
59
+ else
60
+ asset = nil; docpath = {}; valid = true;
66
61
  end
67
- if @@path_tuples[$1]
68
- docpath[@@path_tuples[$1]] = $2 # if this is one of our keys, 'send' to the method
69
- elsif (@@translation[$1])
70
- val = asset.send("#{@@translation[$1]}").respond_to?(:[]) ? $2.split(',') : $2
71
- asset.send("#{@@translation[$1]}=", val)
62
+ when /<tuple-field name="([^"]+)">([^<]+)<\/tuple-field>/
63
+ if (valid)
64
+ if @@validations[$1]
65
+ valid = @@validations[$1].call($2)
66
+ end
67
+ if @@path_tuples[$1]
68
+ docpath[@@path_tuples[$1]] = $2 # if this is one of our keys, 'send' to the method
69
+ elsif (@@translation[$1])
70
+ val = asset.send("#{@@translation[$1]}").respond_to?(:[]) ? $2.split(',') : $2
71
+ asset.send("#{@@translation[$1]}=", val)
72
+ end
72
73
  end
73
- end
74
74
  end
75
75
  end
76
76
  # loop thru each doc in the collection, either replace or delete it
77
77
  error_files = []
78
78
  update_count = 0; delete_count = 0; added_count = 0;
79
- assets.keys.each do |key|
79
+ assets.keys.each do |key|
80
80
  da = nil
81
81
  begin
82
82
  if (!assets[key]['unpublished_at'].nil?)
@@ -90,7 +90,7 @@ module Daengine::TeamsiteMetadataParser
90
90
  creating = da.new?
91
91
  da.documents = []
92
92
  da.update_attributes!(assets[key])
93
- if(creating)
93
+ if (creating)
94
94
  added_count += 1
95
95
  else
96
96
  update_count += 1
@@ -99,14 +99,14 @@ module Daengine::TeamsiteMetadataParser
99
99
  rescue Exception => e
100
100
  #puts "--**Exception**--- #{e}"
101
101
  error_files << "#{da.try(:guid)}, #{da.try(:errors).try(:full_messages)}"
102
- end
102
+ end
103
103
  end
104
104
  log_txt = "TeamsiteMetadataParser: Failed to save/update following DigitalAssets in database:\n"
105
105
  error_files.each do |asset_file|
106
106
  log_txt = log_txt + "> #{asset_file}\n"
107
107
  end
108
108
  Daengine.log(log_txt, "warn") if !error_files.empty?
109
- DigitalAsset.purge! # if the purge criteria is met, purge anything not updated
109
+ DigitalAsset.purge! # if the purge criteria is met, purge anything not updated
110
110
  Daengine.log("TeamsiteMetadataParser: #{added_count} records added, #{update_count} updated, #{delete_count} removed", "info")
111
111
  end
112
112
  end
@@ -1,3 +1,3 @@
1
1
  module Daengine
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: daengine
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.8
5
+ version: 0.1.9
6
6
  platform: ruby
7
7
  authors:
8
8
  - sbhatia