talia_core 0.4.9 → 0.4.10

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/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 4
4
- :patch: 9
4
+ :patch: 10
5
5
  :build:
@@ -42,7 +42,7 @@ namespace :talia_core do
42
42
  end
43
43
 
44
44
  # Invoke the init after the setup
45
- Rake::Task["talia_core:init"].invoke
45
+ # Rake::Task["talia_core:init"].invoke
46
46
  end
47
47
 
48
48
  # Test task
@@ -1,10 +1,10 @@
1
1
  # Utility module for tests, rake tasks etc.
2
2
  module TaliaUtil
3
-
3
+
4
4
  # Main utility functions for Talia
5
5
  class Util
6
6
  class << self
7
-
7
+
8
8
  # Get the list of files from the "files" option
9
9
  def get_files
10
10
  puts "Files given: #{ENV['files']}"
@@ -13,7 +13,7 @@ module TaliaUtil
13
13
  print_options
14
14
  exit(1)
15
15
  end
16
-
16
+
17
17
  FileList.new(ENV['files'])
18
18
  end
19
19
 
@@ -44,37 +44,44 @@ module TaliaUtil
44
44
  # Init the talia core system
45
45
  def init_talia
46
46
  return if(TaliaCore::Initializer.initialized)
47
-
48
- # If options are not set, the initializer will fall back to the internal default
49
- TaliaCore::Initializer.talia_root = ENV['talia_root']
50
- TaliaCore::Initializer.environment = ENV['environment']
51
-
52
- config_file = ENV['config'] ? ENV['config'] : 'talia_core'
53
-
54
- # run the initializer
55
- TaliaCore::Initializer.run(config_file) do |config|
56
- unless(flag?('no_standalone'))
57
- puts "Always using standalone db from utilities."
58
- puts "Give the no_standalone option to override it."
59
- config['standalone_db'] = "true"
47
+
48
+ # If we have Rails installed, just call the Rails config
49
+ # instead of running the manual init
50
+ if(defined?(RAILS_ROOT) && File.exist?(File.join(RAILS_ROOT, 'config', 'environment.rb')))
51
+ puts "\nInitializing Talia through Rails"
52
+ load(File.join(RAILS_ROOT, 'config', 'environment.rb'))
53
+ else
54
+
55
+ # If options are not set, the initializer will fall back to the internal default
56
+ TaliaCore::Initializer.talia_root = ENV['talia_root']
57
+ TaliaCore::Initializer.environment = ENV['environment']
58
+
59
+ config_file = ENV['config'] ? ENV['config'] : 'talia_core'
60
+
61
+ # run the initializer
62
+ TaliaCore::Initializer.run(config_file) do |config|
63
+ unless(flag?('no_standalone'))
64
+ puts "Always using standalone db from utilities."
65
+ puts "Give the no_standalone option to override it."
66
+ config['standalone_db'] = "true"
67
+ end
60
68
  end
61
69
  end
62
-
63
70
  puts("\nTaliaCore initialized")
64
-
71
+
65
72
  # # Flush the database if requested
66
73
  if(flag?('reset_db'))
67
74
  flush_db
68
75
  puts "DB flushed"
69
76
  end
70
-
77
+
71
78
  # Flus the rdf if requested
72
79
  if(flag?('reset_rdf'))
73
80
  flush_rdf
74
81
  puts "RDF flushed"
75
82
  end
76
83
  end
77
-
84
+
78
85
  # Get info from the Talia configuraion
79
86
  def talia_config
80
87
  puts "Talia configuration"
@@ -85,25 +92,25 @@ module TaliaUtil
85
92
  puts "Data Directory: #{TaliaCore::CONFIG['data_directory_location']}"
86
93
  puts "Local Domain: #{N::LOCAL}"
87
94
  end
88
-
95
+
89
96
  # Put the title for Talia
90
97
  def title
91
98
  puts "\nTalia Digital Library system. Version: #{TaliaCore::Version::STRING}"
92
- puts "http://www.talia.discovery-project.eu/\n\n"
99
+ puts "http://www.muruca.org/\n\n"
93
100
  end
94
-
101
+
95
102
  # Flush the database. This only flushes the main data tables!
96
103
  def flush_db
97
104
  [ 'active_sources', 'data_records', 'semantic_properties', 'semantic_relations', 'workflows'].reverse.each { |f| ActiveRecord::Base.connection.execute "DELETE FROM #{f}" }
98
105
  # Also remove the "unsaved cache" for the wrappers (may be important during testing)
99
106
  TaliaCore::SemanticCollectionWrapper.instance_variable_set(:'@unsaved_source_cache', {})
100
107
  end
101
-
108
+
102
109
  # Flush the RDF store
103
110
  def flush_rdf
104
111
  ConnectionPool.write_adapter.clear
105
112
  end
106
-
113
+
107
114
  # Remove the data directories
108
115
  def clear_data
109
116
  data_dir = TaliaCore::CONFIG['data_directory_location']
@@ -111,8 +118,8 @@ module TaliaUtil
111
118
  FileUtils.rm_rf(data_dir) if(File.exist?(data_dir))
112
119
  FileUtils.rm_rf(iip_dir) if(File.exist?(iip_dir))
113
120
  end
114
-
115
-
121
+
122
+
116
123
  # Do a full reset of the data store
117
124
  def full_reset
118
125
  flush_db
@@ -129,7 +136,7 @@ module TaliaUtil
129
136
  flush_rdf
130
137
  # We'll get all data from single query.
131
138
  fat_rels = TaliaCore::SemanticRelation.find(:all, :joins => fat_record_joins,
132
- :select => fat_record_select)
139
+ :select => fat_record_select)
133
140
  fat_rels.each do |rec|
134
141
  subject = N::URI.new(rec.subject_uri)
135
142
  predicate = N::URI.new(rec.predicate_uri)
@@ -167,13 +174,13 @@ module TaliaUtil
167
174
  Fixtures.create_fixtures(File.join('test', 'fixtures'), File.basename(fixture_file, '.*'))
168
175
  end
169
176
  end
170
-
177
+
171
178
  # Do migrations
172
179
  def do_migrations
173
180
  migration_path = File.join("generators", "talia", "templates", "migrations")
174
181
  ActiveRecord::Migrator.migrate(migration_path, ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
175
182
  end
176
-
183
+
177
184
  # Check if the given flag is set on the command line
178
185
  def flag?(the_flag)
179
186
  assit_not_nil(the_flag)
@@ -220,7 +227,7 @@ module TaliaUtil
220
227
  puts "verbose={yes|no} - Show some additional info"
221
228
  puts ""
222
229
  end
223
-
230
+
224
231
  end
225
232
  end
226
233
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: talia_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danilo Giacomi
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2009-12-16 00:00:00 +01:00
16
+ date: 2009-12-17 00:00:00 +01:00
17
17
  default_executable: talia
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency