daengine 0.0.10.alpha → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/Gemfile +17 -17
  2. data/MIT-LICENSE +20 -20
  3. data/Rakefile +29 -29
  4. data/app/assets/javascripts/digital_assets.js +2 -2
  5. data/app/assets/stylesheets/digital_assets.css +4 -4
  6. data/app/controllers/digital_assets_controller.rb +76 -76
  7. data/app/helpers/digital_assets_helper.rb +2 -2
  8. data/app/views/digital_assets/_form.html.erb +17 -17
  9. data/app/views/digital_assets/edit.html.erb +6 -6
  10. data/app/views/digital_assets/index.html.erb +34 -34
  11. data/app/views/digital_assets/new.html.erb +5 -5
  12. data/app/views/digital_assets/search.html.erb +46 -46
  13. data/app/views/digital_assets/show.html.erb +58 -58
  14. data/config/routes.rb +8 -8
  15. data/lib/daengine.rb +43 -43
  16. data/lib/daengine/engine.rb +6 -6
  17. data/lib/daengine/version.rb +3 -3
  18. data/lib/tasks/daengine_tasks.rake +4 -4
  19. data/spec/controllers/digital_assets_controller_spec.rb +202 -202
  20. data/spec/dummy/README.rdoc +261 -261
  21. data/spec/dummy/Rakefile +7 -7
  22. data/spec/dummy/app/assets/javascripts/application.js +15 -15
  23. data/spec/dummy/app/assets/stylesheets/application.css +13 -13
  24. data/spec/dummy/app/controllers/application_controller.rb +3 -3
  25. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  26. data/spec/dummy/app/views/layouts/application.html.erb +14 -14
  27. data/spec/dummy/config.ru +4 -4
  28. data/spec/dummy/config/application.rb +70 -70
  29. data/spec/dummy/config/boot.rb +9 -9
  30. data/spec/dummy/config/environment.rb +5 -5
  31. data/spec/dummy/config/environments/development.rb +37 -37
  32. data/spec/dummy/config/environments/production.rb +67 -67
  33. data/spec/dummy/config/environments/test.rb +37 -37
  34. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  35. data/spec/dummy/config/initializers/inflections.rb +15 -15
  36. data/spec/dummy/config/initializers/mime_types.rb +5 -5
  37. data/spec/dummy/config/initializers/secret_token.rb +7 -7
  38. data/spec/dummy/config/initializers/session_store.rb +8 -8
  39. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  40. data/spec/dummy/config/locales/en.yml +5 -5
  41. data/spec/dummy/config/mongoid.yml +20 -20
  42. data/spec/dummy/config/routes.rb +58 -58
  43. data/spec/dummy/public/404.html +26 -26
  44. data/spec/dummy/public/422.html +26 -26
  45. data/spec/dummy/public/500.html +25 -25
  46. data/spec/dummy/script/rails +6 -6
  47. data/spec/lib/teamsite_metadata_parser_spec.rb +59 -59
  48. data/spec/spec_helper.rb +40 -40
  49. metadata +15 -20
  50. data/spec/dummy/log/development.log +0 -4
  51. data/spec/dummy/log/test.log +0 -435
data/Gemfile CHANGED
@@ -1,17 +1,17 @@
1
- source "http://rubygems.org"
2
-
3
- # Declare your gem's dependencies in daengine.gemspec.
4
- # Bundler will treat runtime dependencies like base dependencies, and
5
- # development dependencies will be added by default to the :development group.
6
- gemspec
7
-
8
- # jquery-rails is used by the dummy application
9
- # gem "jquery-rails"
10
-
11
- # Declare any dependencies that are still in development here instead of in
12
- # your gemspec. These might include edge Rails or gems from your path or
13
- # Git. Remember to move these dependencies to your gemspec before releasing
14
- # your gem to rubygems.org.
15
-
16
- # To use debugger
17
- # gem 'debugger'
1
+ source "http://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in daengine.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # jquery-rails is used by the dummy application
9
+ # gem "jquery-rails"
10
+
11
+ # Declare any dependencies that are still in development here instead of in
12
+ # your gemspec. These might include edge Rails or gems from your path or
13
+ # Git. Remember to move these dependencies to your gemspec before releasing
14
+ # your gem to rubygems.org.
15
+
16
+ # To use debugger
17
+ # gem 'debugger'
data/MIT-LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- Copyright 2012 YOURNAME
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,29 +1,29 @@
1
- #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
14
-
15
- RDoc::Task.new(:rdoc) do |rdoc|
16
- rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'Daengine'
18
- rdoc.options << '--line-numbers'
19
- rdoc.rdoc_files.include('README.rdoc')
20
- rdoc.rdoc_files.include('lib/**/*.rb')
21
- end
22
-
23
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
- load 'rails/tasks/engine.rake'
25
-
26
-
27
-
28
- Bundler::GemHelper.install_tasks
29
-
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Daengine'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
@@ -1,2 +1,2 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -1,4 +1,4 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -1,76 +1,76 @@
1
- class DigitalAssetsController < ApplicationController
2
-
3
- respond_to :json, :html, :only => [:index, :show, :search]
4
-
5
- CACHE_LAST_PARSE_TIME = 'last_parse_time'
6
- # GET /digital_assets
7
- # GET /digital_assets.json
8
- def index
9
- @digital_assets = DigitalAsset.all
10
- respond_with(@digital_assets)
11
- end
12
-
13
- # GET /digital_assets/1
14
- # GET /digital_assets/1.json
15
- def show
16
- @digital_asset = /\w{4,8}\.\d{0,3}/ =~ params[:id] ? DigitalAsset.sami_is(params[:id]).desc(:changed_at).first : DigitalAsset.find(params[:id])
17
- respond_with(@digital_asset)
18
- end
19
-
20
- #/digital_assets/search/sami_code=92023
21
- #/digital_assets/search/sami_code=NE00192&title=Fund%20Prospectus&fund_code=20293
22
- def search
23
- @digital_assets = []
24
- # loop thru each parameter that matches one of the method signatures
25
- @digital_assets = params.keys.select do |pk|
26
- DigitalAsset.respond_to?("#{pk}_is".to_sym) or DigitalAsset.respond_to?("#{pk}_in".to_sym)
27
- end.reduce(DigitalAsset) do |sum, key|
28
- # for each key, call the 'named query' method with the value given and chain...
29
- method = DigitalAsset.respond_to?("#{key}_in".to_sym) ? "#{key}_in".to_sym : "#{key}_is".to_sym
30
- sum.send(method, method.to_s.end_with?('in') ? params[key].to_a : params[key]) # should return result of the send call for chaining
31
- end
32
- respond_with(@digital_assets)
33
- end
34
-
35
- def sync_assets
36
- time0 = Rails.cache.read(CACHE_LAST_PARSE_TIME)
37
- if time0.nil?
38
- time0 = 2.days.ago
39
- end
40
- logger.info "Last time when ssc deploy files were read: #{time0.inspect}"
41
- time1 = Time.new
42
- logger.info "Current time: #{time1.inspect}"
43
-
44
- Rails.cache.write(CACHE_LAST_PARSE_TIME, time1)
45
- deploy_files= []
46
-
47
- start_directory = EDIST['digital_assets_directory']
48
- logger.info "Reading digital asset deployment files from #{start_directory}"
49
- if (File::directory?(start_directory))
50
- Dir.foreach(start_directory) do |entry|
51
- if (!File::directory?(entry))
52
- filename = start_directory + entry
53
- difference0 = File.mtime(filename)- time0 #To-Do - We should be looking at created time - ctime
54
- difference1 = File.mtime(filename) - time1
55
- if ((difference0 >= 0) & (difference1 < 0))
56
- if(/bulk-ssc_|selective-ssc_/ =~ filename)
57
- deploy_files << filename
58
- end
59
- end
60
- end
61
- end
62
- end
63
-
64
- deploy_files.each do |filename|
65
- #parse the file and add content to database.
66
- logger.info "Processing file #{filename} found."
67
- file = File.expand_path(filename, __FILE__)
68
- open_file = open(file, 'rb')
69
- Etl::TeamsiteMetadataParser.parse_tuple_file(open_file)
70
- logger.info "Finished parsing #{filename}."
71
- end
72
-
73
- head :accepted
74
- end
75
-
76
- end
1
+ class DigitalAssetsController < ApplicationController
2
+
3
+ respond_to :json, :html, :only => [:index, :show, :search]
4
+
5
+ CACHE_LAST_PARSE_TIME = 'last_parse_time'
6
+ # GET /digital_assets
7
+ # GET /digital_assets.json
8
+ def index
9
+ @digital_assets = DigitalAsset.all
10
+ respond_with(@digital_assets)
11
+ end
12
+
13
+ # GET /digital_assets/1
14
+ # GET /digital_assets/1.json
15
+ def show
16
+ @digital_asset = /\w{4,8}\.\d{0,3}/ =~ params[:id] ? DigitalAsset.sami_is(params[:id]).desc(:changed_at).first : DigitalAsset.find(params[:id])
17
+ respond_with(@digital_asset)
18
+ end
19
+
20
+ #/digital_assets/search/sami_code=92023
21
+ #/digital_assets/search/sami_code=NE00192&title=Fund%20Prospectus&fund_code=20293
22
+ def search
23
+ @digital_assets = []
24
+ # loop thru each parameter that matches one of the method signatures
25
+ @digital_assets = params.keys.select do |pk|
26
+ DigitalAsset.respond_to?("#{pk}_is".to_sym) or DigitalAsset.respond_to?("#{pk}_in".to_sym)
27
+ end.reduce(DigitalAsset) do |sum, key|
28
+ # for each key, call the 'named query' method with the value given and chain...
29
+ method = DigitalAsset.respond_to?("#{key}_in".to_sym) ? "#{key}_in".to_sym : "#{key}_is".to_sym
30
+ sum.send(method, method.to_s.end_with?('in') ? params[key].to_a : params[key]) # should return result of the send call for chaining
31
+ end
32
+ respond_with(@digital_assets)
33
+ end
34
+
35
+ def sync_assets
36
+ time0 = Rails.cache.read(CACHE_LAST_PARSE_TIME)
37
+ if time0.nil?
38
+ time0 = 2.days.ago
39
+ end
40
+ logger.info "Last time when ssc deploy files were read: #{time0.inspect}"
41
+ time1 = Time.new
42
+ logger.info "Current time: #{time1.inspect}"
43
+
44
+ Rails.cache.write(CACHE_LAST_PARSE_TIME, time1)
45
+ deploy_files= []
46
+
47
+ start_directory = EDIST['digital_assets_directory']
48
+ logger.info "Reading digital asset deployment files from #{start_directory}"
49
+ if (File::directory?(start_directory))
50
+ Dir.foreach(start_directory) do |entry|
51
+ if (!File::directory?(entry))
52
+ filename = start_directory + entry
53
+ difference0 = File.mtime(filename)- time0 #To-Do - We should be looking at created time - ctime
54
+ difference1 = File.mtime(filename) - time1
55
+ if ((difference0 >= 0) & (difference1 < 0))
56
+ if(/bulk-ssc_|selective-ssc_/ =~ filename)
57
+ deploy_files << filename
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ deploy_files.each do |filename|
65
+ #parse the file and add content to database.
66
+ logger.info "Processing file #{filename} found."
67
+ file = File.expand_path(filename, __FILE__)
68
+ open_file = open(file, 'rb')
69
+ Etl::TeamsiteMetadataParser.parse_tuple_file(open_file)
70
+ logger.info "Finished parsing #{filename}."
71
+ end
72
+
73
+ head :accepted
74
+ end
75
+
76
+ end
@@ -1,2 +1,2 @@
1
- module DigitalAssetsHelper
2
- end
1
+ module DigitalAssetsHelper
2
+ end
@@ -1,17 +1,17 @@
1
- <%= form_for(@digital_asset) do |f| %>
2
- <% if @digital_asset.errors.any? %>
3
- <div id="error_explanation">
4
- <h2><%= pluralize(@digital_asset.errors.count, "error") %> prohibited this digital_asset from being saved:</h2>
5
-
6
- <ul>
7
- <% @digital_asset.errors.full_messages.each do |msg| %>
8
- <li><%= msg %></li>
9
- <% end %>
10
- </ul>
11
- </div>
12
- <% end %>
13
-
14
- <div class="actions">
15
- <%= f.submit %>
16
- </div>
17
- <% end %>
1
+ <%= form_for(@digital_asset) do |f| %>
2
+ <% if @digital_asset.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@digital_asset.errors.count, "error") %> prohibited this digital_asset from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @digital_asset.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="actions">
15
+ <%= f.submit %>
16
+ </div>
17
+ <% end %>
@@ -1,6 +1,6 @@
1
- <h1>Editing digital_asset</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Show', @digital_asset %> |
6
- <%= link_to 'Back', digital_assets_path %>
1
+ <h1>Editing digital_asset</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @digital_asset %> |
6
+ <%= link_to 'Back', digital_assets_path %>
@@ -1,34 +1,34 @@
1
- <h1>Listing digital_assets</h1>
2
-
3
- <table>
4
- <tr>
5
- <th>Title</th>
6
- <th>Guid</th>
7
- <th>Updated at</th>
8
- <th>Audience</th>
9
- <th>Sami code</th>
10
- <th>Product</th>
11
- <th>Published at</th>
12
- <th>Expires at</th>
13
- <th></th>
14
- <th></th>
15
- <th></th>
16
- </tr>
17
-
18
- <% @digital_assets.each do |digital_asset| %>
19
- <tr>
20
- <td><%= digital_asset.title %></td>
21
- <td><%= digital_asset.guid %></td>
22
- <td><%= digital_asset.changed_at %></td>
23
- <td><%= digital_asset.audiences %></td>
24
- <td><%= digital_asset.sami_code %></td>
25
- <td><%= digital_asset.product_ids %></td>
26
- <td><%= digital_asset.published_at %></td>
27
- <td><%= digital_asset.expires_at %></td>
28
- <td><%= link_to 'Show', digital_asset %></td>
29
- </tr>
30
- <% end %>
31
- </table>
32
-
33
- <br/>
34
-
1
+ <h1>Listing digital_assets</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Title</th>
6
+ <th>Guid</th>
7
+ <th>Updated at</th>
8
+ <th>Audience</th>
9
+ <th>Sami code</th>
10
+ <th>Product</th>
11
+ <th>Published at</th>
12
+ <th>Expires at</th>
13
+ <th></th>
14
+ <th></th>
15
+ <th></th>
16
+ </tr>
17
+
18
+ <% @digital_assets.each do |digital_asset| %>
19
+ <tr>
20
+ <td><%= digital_asset.title %></td>
21
+ <td><%= digital_asset.guid %></td>
22
+ <td><%= digital_asset.changed_at %></td>
23
+ <td><%= digital_asset.audiences %></td>
24
+ <td><%= digital_asset.sami_code %></td>
25
+ <td><%= digital_asset.product_ids %></td>
26
+ <td><%= digital_asset.published_at %></td>
27
+ <td><%= digital_asset.expires_at %></td>
28
+ <td><%= link_to 'Show', digital_asset %></td>
29
+ </tr>
30
+ <% end %>
31
+ </table>
32
+
33
+ <br/>
34
+
@@ -1,5 +1,5 @@
1
- <h1>New digital_asset</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Back', digital_assets_path %>
1
+ <h1>New digital_asset</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', digital_assets_path %>
@@ -1,46 +1,46 @@
1
- <table>
2
- <tr>
3
- <th>Title</th>
4
- <th>Sami code</th>
5
- <th>Products</th>
6
- <th>Updated at</th>
7
- <th>Published at</th>
8
- <th>Expires at</th>
9
- <th>Guid</th>
10
- </tr>
11
-
12
- <% @digital_assets.each do |digital_asset| %>
13
- <tr>
14
- <td><%= digital_asset.title %></td>
15
- <td><%= digital_asset.sami_code %></td>
16
- <td><%= digital_asset.product_ids.join(", ") %></td>
17
- <td><%= digital_asset.changed_at %></td>
18
- <td><%= digital_asset.published_at %></td>
19
- <td><%= digital_asset.expires_at %></td>
20
- <td><%= digital_asset.guid %></td>
21
- <td><%= link_to 'Show', digital_asset %></td>
22
- </tr>
23
- <% end %>
24
- </table>
25
-
26
- <div>
27
- <h2>Current Documents</h2>
28
- <% @digital_assets.each do |digital_asset| %>
29
- <% if digital_asset.documents.size > 0 %>
30
- <table>
31
- <tr>
32
- <th>Content Type</th>
33
- <th>Path</th>
34
- </tr>
35
- <% for document in digital_asset.documents %>
36
- <tr>
37
- <td><%= document.content_type %></td>
38
- <td><%= document.path %></td>
39
- </tr>
40
- <% end %>
41
- </table>
42
- <% end %>
43
- <% end %>
44
-
45
- </div>
46
-
1
+ <table>
2
+ <tr>
3
+ <th>Title</th>
4
+ <th>Sami code</th>
5
+ <th>Products</th>
6
+ <th>Updated at</th>
7
+ <th>Published at</th>
8
+ <th>Expires at</th>
9
+ <th>Guid</th>
10
+ </tr>
11
+
12
+ <% @digital_assets.each do |digital_asset| %>
13
+ <tr>
14
+ <td><%= digital_asset.title %></td>
15
+ <td><%= digital_asset.sami_code %></td>
16
+ <td><%= digital_asset.product_ids.join(", ") %></td>
17
+ <td><%= digital_asset.changed_at %></td>
18
+ <td><%= digital_asset.published_at %></td>
19
+ <td><%= digital_asset.expires_at %></td>
20
+ <td><%= digital_asset.guid %></td>
21
+ <td><%= link_to 'Show', digital_asset %></td>
22
+ </tr>
23
+ <% end %>
24
+ </table>
25
+
26
+ <div>
27
+ <h2>Current Documents</h2>
28
+ <% @digital_assets.each do |digital_asset| %>
29
+ <% if digital_asset.documents.size > 0 %>
30
+ <table>
31
+ <tr>
32
+ <th>Content Type</th>
33
+ <th>Path</th>
34
+ </tr>
35
+ <% for document in digital_asset.documents %>
36
+ <tr>
37
+ <td><%= document.content_type %></td>
38
+ <td><%= document.path %></td>
39
+ </tr>
40
+ <% end %>
41
+ </table>
42
+ <% end %>
43
+ <% end %>
44
+
45
+ </div>
46
+