datum 0.9.2 → 4.0.0

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.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +25 -1
  3. data/README.md +2 -130
  4. data/Rakefile +3 -9
  5. data/lib/datum/container.rb +64 -0
  6. data/lib/datum/datum.rb +51 -0
  7. data/lib/datum/helpers.rb +58 -0
  8. data/lib/datum/version.rb +8 -27
  9. data/lib/datum.rb +21 -93
  10. data/lib/plan9/structures.rb +71 -0
  11. data/lib/support/scenario.rb +14 -0
  12. data/lib/support/test.rb +27 -0
  13. metadata +29 -124
  14. data/lib/datum/context.rb +0 -55
  15. data/lib/datum/db_tasks.rb +0 -108
  16. data/lib/datum/driver_helper.rb +0 -109
  17. data/lib/datum/enable_notification.rb +0 -27
  18. data/lib/datum/enable_task.rb +0 -148
  19. data/lib/datum/railtie.rb +0 -14
  20. data/lib/datum/verification_task.rb +0 -154
  21. data/lib/datum/verify_helpers/20120726105125_create_datum_versions.rb +0 -18
  22. data/lib/datum/verify_helpers/datum_version.rb +0 -8
  23. data/lib/datum/verify_helpers/datum_version_test.rb +0 -11
  24. data/lib/generators/datum/USAGE +0 -0
  25. data/lib/generators/datum/datum_generator.rb +0 -104
  26. data/lib/generators/datum/templates/datum_migration.rb +0 -21
  27. data/lib/generators/datum/templates/datum_model.rb +0 -6
  28. data/lib/tasks/datum.rake +0 -49
  29. data/test/datum_test.rb +0 -17
  30. data/test/dummy/README.rdoc +0 -261
  31. data/test/dummy/Rakefile +0 -7
  32. data/test/dummy/app/assets/javascripts/application.js +0 -15
  33. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  34. data/test/dummy/app/controllers/application_controller.rb +0 -3
  35. data/test/dummy/app/helpers/application_helper.rb +0 -2
  36. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  37. data/test/dummy/config/application.rb +0 -61
  38. data/test/dummy/config/boot.rb +0 -10
  39. data/test/dummy/config/database.example +0 -42
  40. data/test/dummy/config/database.sqlite +0 -25
  41. data/test/dummy/config/database.yml +0 -55
  42. data/test/dummy/config/environment.rb +0 -5
  43. data/test/dummy/config/environments/development.rb +0 -37
  44. data/test/dummy/config/environments/production.rb +0 -67
  45. data/test/dummy/config/environments/test.rb +0 -37
  46. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  47. data/test/dummy/config/initializers/inflections.rb +0 -15
  48. data/test/dummy/config/initializers/mime_types.rb +0 -5
  49. data/test/dummy/config/initializers/secret_token.rb +0 -7
  50. data/test/dummy/config/initializers/session_store.rb +0 -8
  51. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  52. data/test/dummy/config/locales/en.yml +0 -5
  53. data/test/dummy/config/routes.rb +0 -58
  54. data/test/dummy/config.ru +0 -4
  55. data/test/dummy/db/schema.rb +0 -16
  56. data/test/dummy/public/404.html +0 -26
  57. data/test/dummy/public/422.html +0 -26
  58. data/test/dummy/public/500.html +0 -25
  59. data/test/dummy/public/favicon.ico +0 -0
  60. data/test/dummy/script/rails +0 -6
  61. data/test/dummy/test/lib/datum/utils/application.rb +0 -57
  62. data/test/dummy/test/lib/datum/utils/database.yml +0 -42
  63. data/test/dummy/test/test_helper.rb +0 -13
  64. data/test/dummy/test/unit/enable_task_test.rb +0 -70
  65. data/test/test_helper.rb +0 -10
metadata CHANGED
@@ -1,49 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
5
- prerelease:
4
+ version: 4.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tyemill
9
- - Gabriel Marius
10
8
  autorequire:
11
9
  bindir: bin
12
10
  cert_chain: []
13
- date: 2013-01-18 00:00:00.000000000 Z
11
+ date: 2015-02-15 00:00:00.000000000 Z
14
12
  dependencies:
15
13
  - !ruby/object:Gem::Dependency
16
14
  name: rails
17
15
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
16
  requirements:
20
- - - ! '>='
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: 3.2.1
19
+ version: 4.1.7
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
23
  requirements:
28
- - - ! '>='
24
+ - - "~>"
29
25
  - !ruby/object:Gem::Version
30
- version: 3.2.1
26
+ version: 4.1.7
31
27
  - !ruby/object:Gem::Dependency
32
- name: mysql2
28
+ name: pg
33
29
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
30
  requirements:
36
- - - ! '>='
31
+ - - ">="
37
32
  - !ruby/object:Gem::Version
38
- version: 0.3.11
39
- type: :runtime
33
+ version: '0'
34
+ type: :development
40
35
  prerelease: false
41
36
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
37
  requirements:
44
- - - ! '>='
38
+ - - ">="
45
39
  - !ruby/object:Gem::Version
46
- version: 0.3.11
40
+ version: '0'
47
41
  description: Flexible data-driven test solution for Rails
48
42
  email:
49
43
  - datum@tyemill.com
@@ -51,128 +45,39 @@ executables: []
51
45
  extensions: []
52
46
  extra_rdoc_files: []
53
47
  files:
54
- - lib/datum/context.rb
55
- - lib/datum/db_tasks.rb
56
- - lib/datum/driver_helper.rb
57
- - lib/datum/enable_notification.rb
58
- - lib/datum/enable_task.rb
59
- - lib/datum/railtie.rb
60
- - lib/datum/verification_task.rb
61
- - lib/datum/verify_helpers/20120726105125_create_datum_versions.rb
62
- - lib/datum/verify_helpers/datum_version.rb
63
- - lib/datum/verify_helpers/datum_version_test.rb
64
- - lib/datum/version.rb
65
- - lib/datum.rb
66
- - lib/generators/datum/datum_generator.rb
67
- - lib/generators/datum/templates/datum_migration.rb
68
- - lib/generators/datum/templates/datum_model.rb
69
- - lib/generators/datum/USAGE
70
- - lib/tasks/datum.rake
71
48
  - MIT-LICENSE
72
- - Rakefile
73
49
  - README.md
74
- - test/datum_test.rb
75
- - test/dummy/app/assets/javascripts/application.js
76
- - test/dummy/app/assets/stylesheets/application.css
77
- - test/dummy/app/controllers/application_controller.rb
78
- - test/dummy/app/helpers/application_helper.rb
79
- - test/dummy/app/views/layouts/application.html.erb
80
- - test/dummy/config/application.rb
81
- - test/dummy/config/boot.rb
82
- - test/dummy/config/database.example
83
- - test/dummy/config/database.sqlite
84
- - test/dummy/config/database.yml
85
- - test/dummy/config/environment.rb
86
- - test/dummy/config/environments/development.rb
87
- - test/dummy/config/environments/production.rb
88
- - test/dummy/config/environments/test.rb
89
- - test/dummy/config/initializers/backtrace_silencers.rb
90
- - test/dummy/config/initializers/inflections.rb
91
- - test/dummy/config/initializers/mime_types.rb
92
- - test/dummy/config/initializers/secret_token.rb
93
- - test/dummy/config/initializers/session_store.rb
94
- - test/dummy/config/initializers/wrap_parameters.rb
95
- - test/dummy/config/locales/en.yml
96
- - test/dummy/config/routes.rb
97
- - test/dummy/config.ru
98
- - test/dummy/db/schema.rb
99
- - test/dummy/public/404.html
100
- - test/dummy/public/422.html
101
- - test/dummy/public/500.html
102
- - test/dummy/public/favicon.ico
103
- - test/dummy/Rakefile
104
- - test/dummy/README.rdoc
105
- - test/dummy/script/rails
106
- - test/dummy/test/lib/datum/utils/application.rb
107
- - test/dummy/test/lib/datum/utils/database.yml
108
- - test/dummy/test/test_helper.rb
109
- - test/dummy/test/unit/enable_task_test.rb
110
- - test/test_helper.rb
50
+ - Rakefile
51
+ - lib/datum.rb
52
+ - lib/datum/container.rb
53
+ - lib/datum/datum.rb
54
+ - lib/datum/helpers.rb
55
+ - lib/datum/version.rb
56
+ - lib/plan9/structures.rb
57
+ - lib/support/scenario.rb
58
+ - lib/support/test.rb
111
59
  homepage: https://github.com/tyemill/datum
112
- licenses: []
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
113
63
  post_install_message:
114
64
  rdoc_options: []
115
65
  require_paths:
116
66
  - lib
117
67
  required_ruby_version: !ruby/object:Gem::Requirement
118
- none: false
119
68
  requirements:
120
- - - ! '>='
69
+ - - ">="
121
70
  - !ruby/object:Gem::Version
122
71
  version: '0'
123
- segments:
124
- - 0
125
- hash: 4179343628097419980
126
72
  required_rubygems_version: !ruby/object:Gem::Requirement
127
- none: false
128
73
  requirements:
129
- - - ! '>='
74
+ - - ">="
130
75
  - !ruby/object:Gem::Version
131
76
  version: '0'
132
- segments:
133
- - 0
134
- hash: 4179343628097419980
135
77
  requirements: []
136
78
  rubyforge_project:
137
- rubygems_version: 1.8.24
79
+ rubygems_version: 2.2.2
138
80
  signing_key:
139
- specification_version: 3
81
+ specification_version: 4
140
82
  summary: Flexible data-driven test solution for Rails
141
- test_files:
142
- - test/datum_test.rb
143
- - test/dummy/app/assets/javascripts/application.js
144
- - test/dummy/app/assets/stylesheets/application.css
145
- - test/dummy/app/controllers/application_controller.rb
146
- - test/dummy/app/helpers/application_helper.rb
147
- - test/dummy/app/views/layouts/application.html.erb
148
- - test/dummy/config/application.rb
149
- - test/dummy/config/boot.rb
150
- - test/dummy/config/database.example
151
- - test/dummy/config/database.sqlite
152
- - test/dummy/config/database.yml
153
- - test/dummy/config/environment.rb
154
- - test/dummy/config/environments/development.rb
155
- - test/dummy/config/environments/production.rb
156
- - test/dummy/config/environments/test.rb
157
- - test/dummy/config/initializers/backtrace_silencers.rb
158
- - test/dummy/config/initializers/inflections.rb
159
- - test/dummy/config/initializers/mime_types.rb
160
- - test/dummy/config/initializers/secret_token.rb
161
- - test/dummy/config/initializers/session_store.rb
162
- - test/dummy/config/initializers/wrap_parameters.rb
163
- - test/dummy/config/locales/en.yml
164
- - test/dummy/config/routes.rb
165
- - test/dummy/config.ru
166
- - test/dummy/db/schema.rb
167
- - test/dummy/public/404.html
168
- - test/dummy/public/422.html
169
- - test/dummy/public/500.html
170
- - test/dummy/public/favicon.ico
171
- - test/dummy/Rakefile
172
- - test/dummy/README.rdoc
173
- - test/dummy/script/rails
174
- - test/dummy/test/lib/datum/utils/application.rb
175
- - test/dummy/test/lib/datum/utils/database.yml
176
- - test/dummy/test/test_helper.rb
177
- - test/dummy/test/unit/enable_task_test.rb
178
- - test/test_helper.rb
83
+ test_files: []
data/lib/datum/context.rb DELETED
@@ -1,55 +0,0 @@
1
-
2
- module Datum
3
-
4
- class Context
5
-
6
- def self.initialized?
7
- return @@initialized
8
- end
9
-
10
- def self.continue?
11
- @@table_data.nil? ? false : (@@table_data.count != 0 ? true : false)
12
- end
13
-
14
- protected
15
-
16
- def self.next_row
17
- result = nil if @@table_data.nil?
18
- result = @@table_data.delete_at(0) unless @@table_data.nil?
19
- @@initialized = false if !result.nil? && @@table_data.count == 0
20
-
21
- log "next row table_data: #{@@table_data}"
22
- #log "next row result: #{result.attributes}" unless result.nil?
23
- log "next row initialized: #{@@initialized}"
24
- return result
25
- end
26
-
27
- def self.datum_directory
28
- return @@directory
29
- end
30
-
31
- def self.table_data
32
- return @@table_data
33
- end
34
-
35
- def self.table_data= data
36
- @@table_data = data
37
- @@initialized = true if !@@table_data.nil?
38
- end
39
-
40
- def self.log msg
41
- Datum::DriverHelper.log msg
42
- end
43
-
44
- @@directory = "#{Rails.env}/lib/datum"
45
- @@test_directory = "#{Rails.env}/test/lib/datum"
46
- @@table_data = nil
47
- @@initialized = false
48
-
49
- private
50
-
51
-
52
-
53
- end
54
-
55
- end
@@ -1,108 +0,0 @@
1
-
2
- module Datum
3
-
4
- class DbTasks
5
- def initialize
6
- Rails.env = @@datum_environment
7
- end
8
-
9
- def prepare
10
- create
11
- migrate
12
- load_when_empty
13
- end
14
-
15
- def create
16
- Rake::Task['db:create'].invoke()
17
- end
18
-
19
- def migrate
20
- ActiveRecord::Base.establish_connection(Rails.env)
21
- ActiveRecord::Migrator.migrate "#{@@local_path}/migrate"
22
- end
23
-
24
- def drop
25
- config = Rails.configuration.database_configuration
26
- database = config[Rails.env]["database"]
27
-
28
- #Rake::Task['db:drop'].invoke()
29
- ActiveRecord::Base.connection.drop_database database rescue nil
30
- end
31
-
32
- def load_when_empty
33
- load_fixtures true
34
- end
35
-
36
- # get into the datum fixtures directory, walk the yml, load into db
37
- def load
38
- load_fixtures false
39
- end
40
-
41
- # get into datum db, get relevant tables, produce ymls (for sharing)
42
- # tonyamoyal.com/2009/12/09/
43
- # converting-table-data-to-yaml-for-testing-in-ruby-on-rails/
44
- def dump
45
- sql = "SELECT * FROM %s"
46
- skip_tables = ["schema_info", "schema_migrations"]
47
- ActiveRecord::Base.establish_connection(Rails.env)
48
- tables = (ActiveRecord::Base.connection.tables - skip_tables)
49
- tables.each do |table_name|
50
- i = "000"
51
- File.open("#{@@local_path}/fixtures/#{table_name}.yml", 'w') do |file|
52
- data = ActiveRecord::Base.connection.select_all(sql % table_name)
53
- file.write data.inject({}) { |hash, record|
54
- hash["#{table_name}_#{i.succ!}"] = record
55
- hash}.to_yaml
56
- end
57
- end
58
- end
59
-
60
- # take Models data, produce a file for use without db
61
- def localize args
62
- tasked_model = args[:table].classify.constantize
63
- data = tasked_model.all
64
- file_name = args[:table]
65
- File.open("#{@@local_path}/locals/#{file_name}.rb", 'w') do |f1|
66
- f1.puts "\n\n#\n# data dump for code access of table #{file_name}"
67
- f1.puts "#\nmodule #{tasked_model.to_s.pluralize}"
68
- f1.puts "def self.data\nd = ["
69
- data.each_with_index {|e, i|
70
- hash = e.attributes
71
- hash.each_pair {|key, value|
72
- new_value = value.to_s
73
- hash[key] = new_value
74
- }
75
- f1.puts "#{hash.to_s},"
76
- }
77
- f1.puts "]\nend\nend"
78
- end
79
- end
80
-
81
- private
82
-
83
- @@local_path = "#{Rails.root}/test/lib/datum"
84
-
85
- @@datum_environment = "datum"
86
-
87
- def load_fixtures skip_with_data
88
- Dir.glob("#{@@local_path}/fixtures/*.yml").entries.each do |entry|
89
- file_name = entry.to_s.split('/').last.to_s.split('.')[0]
90
- target_model = file_name.classify.constantize
91
- if(!skip_with_data || target_model.count == 0)
92
- data_hash = YAML.load(File.read(entry))
93
- data_hash.each_value {|value|
94
- value.delete "id"
95
- value.delete "created_at"
96
- value.delete "updated_at"
97
- target_model.create value
98
- }
99
- end
100
- end
101
- end
102
-
103
- def context
104
- return Datum::Context
105
- end
106
-
107
- end
108
- end
@@ -1,109 +0,0 @@
1
-
2
- module Datum
3
-
4
- class DriverHelper
5
-
6
- def self.load_data table
7
- context.table_data = load_file_data(table) || load_model_data(table)
8
- end
9
-
10
- def self.add_datum_exec_ext init_before_exec, result
11
- return result if !init_before_exec && !context.initialized?
12
-
13
- first = !init_before_exec && context.initialized?
14
- last = init_before_exec && !context.initialized?
15
-
16
- base = "," if result == "."
17
- base = "," + result unless base == ","
18
- base = "[" + base if first
19
- base += "]" if last
20
- return base
21
- end
22
-
23
- def self.enable_logger
24
- @@logger = true
25
- end
26
-
27
- def self.disable_logger
28
- @@logger = false
29
- end
30
-
31
- protected
32
- @@logger = false
33
-
34
- def self.log msg
35
- Rails.logger.debug "$$ " + msg unless !@@logger
36
- end
37
-
38
- def self.load_model_data table
39
- data = nil
40
- begin
41
- log "load_model_data attempting to constantize"
42
- driver_method = table.to_s.singularize
43
- data = driver_method.classify.constantize.all.reverse
44
- log "load_model_data data loaded"
45
- rescue Exception => exc
46
- log "load_model_data: could not get data from model #{driver_method}"
47
- log exc
48
- raise
49
- "Accessing datum database with table / model #{driver_method} failed."
50
- end
51
-
52
- return data
53
- end
54
-
55
- def self.load_file_data table
56
- data = nil
57
- begin
58
- driver_method = table.to_s.singularize
59
- log "load_file_data: attempting require..."
60
- file = "lib/datum/locals/#{table}"
61
- klas = driver_method.classify.pluralize
62
- require file
63
- log "load_file_data: require was successful"
64
- cls = klas.constantize
65
- log "load_file_data: classify pluralize constantize was successful"
66
- data = cls::data.reverse
67
- log "load_file_data: data reading was successful"
68
- data = mock_data data
69
- log "load_file_data: mocking was successful"
70
- rescue Exception => exc
71
- ## database-driven
72
- log "load_file_data: file load failed for: #{file}"
73
- log "load_file_data: driver_method: #{driver_method}"
74
- log "load_file_data: class: #{klas}"
75
- log "... attempting database connection."
76
- end
77
-
78
- return data
79
- end
80
-
81
- def self.mock_data data
82
- modified_data = []
83
- data.each_with_index {|e, i|
84
- o = Object.new
85
- e.each_pair {|key, value|
86
- addMockExtension key, value, o
87
- }
88
- modified_data.push o
89
- }
90
- return modified_data
91
- end
92
-
93
- def self.addMockExtension(ext, instance, obj)
94
- method_name = ext.to_sym
95
- obj.class.send :define_method, method_name do
96
- return instance unless instance.to_i.to_s == instance || instance == ""
97
- return nil if instance == ""
98
- return instance.to_i
99
- end
100
- end
101
-
102
- private
103
-
104
- def self.context
105
- return Datum::Context
106
- end
107
-
108
- end
109
- end
@@ -1,27 +0,0 @@
1
-
2
- module Datum
3
- NOTIFICATION =
4
- "
5
- ### !!!ADDITIONAL UPDATES REQUIRED!!!
6
-
7
- Datum requires:
8
- + application.rb to reference testcase specific models
9
- + database.yml to contain a datum environment
10
-
11
- - application.rb should contain:
12
- config.autoload_paths += %W(\#{Rails.root}/test/lib/datum/models)
13
-
14
- - database.yml should contain something like:
15
-
16
- datum:
17
- adapter: mysql2
18
- encoding: utf8
19
- reconnect: false
20
- database: yourapp_datum
21
- pool: 5
22
- username: root
23
- password:
24
- socket: /tmp/mysql.sock
25
-
26
- "
27
- end
@@ -1,148 +0,0 @@
1
-
2
- module Datum
3
- class EnableTask
4
-
5
- def disable_user_questions
6
- @@ask_user = false
7
- end
8
-
9
- def disable_verification
10
- @@use_verification = false
11
- end
12
-
13
- def datum_directories
14
- return @@directories
15
- end
16
-
17
- def rock
18
- puts "\n Enabling Datum Data-Driven Testing Tools."
19
- create_directories
20
- notify_check
21
- update_yml if @@update_yml
22
- update_app if @@update_app
23
-
24
- if @@use_verification
25
- verifier = Datum::VerificationTask.new
26
- verifier.disable_user_questions if !@@ask_user
27
- verifier.rock
28
- end
29
-
30
- puts " Datum enabled.\n "
31
- end
32
-
33
- def create_directories
34
- @@directories = ["#{@@datum_drop_path}/fixtures",
35
- "#{@@datum_drop_path}/locals", "#{@@datum_drop_path}/migrate",
36
- "#{@@datum_drop_path}/models"]
37
-
38
- @@directories.each {
39
- |path| FileUtils.mkdir_p(path) if !File::directory?(path)
40
- }
41
-
42
- puts " Datum directories created."
43
- end
44
-
45
- private
46
- @@use_verification = @@ask_user = true
47
- @@directories = @@application_path = @@info = nil
48
- @@update_app = @@update_yml = false
49
- @@datum_drop_path = "test/lib/datum"
50
- @@datum_model_path = 'config.autoload_paths += %W(#{Rails.root}/' +
51
- "#{@@datum_drop_path}" + '/models)'
52
- @@datum_app_scan = "config.autoload_paths.*#{@@datum_drop_path}/models"
53
- #@@datum_app_scan = "config.autoload_paths.*test\/lib\/datum\/models"
54
- #@@datum_drop_path.gsub(Regexp.new("\\/"), "\\/")
55
- #"config.autoload_paths.*#{encoded_path}\/models"
56
-
57
-
58
-
59
- def notify_check
60
- @@update_yml = need_yml?
61
- @@update_app = need_app?
62
-
63
- notify unless !@@update_yml && !@@update_app
64
- end
65
-
66
- def notify
67
- require "datum/enable_notification"
68
- puts "#{Datum::NOTIFICATION}"
69
- puts " Files that may need updates: "
70
- puts " database.yml" if @@update_yml
71
- puts " application.rb" if @@update_app
72
-
73
- if @@ask_user
74
- puts "\n>>>>>>>>>>>>>>>> Attempt updates for you? y/n"
75
- continue = STDIN.gets.chomp
76
- unless continue == 'y' || continue == 'yes'
77
- puts "\n Files must be updated manually to fully enable Datum"
78
- puts " Run rake task 'datum:db:verify' after manual update.\n "
79
- exit!
80
- end
81
- end
82
- end
83
-
84
- def update_yml
85
- app_name = Rails.root.to_s.split("/").last
86
- target_hash = @@info["test"] ? @@info["test"] : @@info["development"]
87
-
88
- if target_hash.nil?
89
- puts " Can't update database.yml without a pre-existing"
90
- puts " test or development segment."
91
- puts "###### !!!! Please update database.yml manually !!!! ######\n "
92
- return
93
- end
94
-
95
- File.open(Rails.root.join("config/database.yml"), 'a') do |f1|
96
- f1.puts "\n\n#\n# database entry for data-driven testing.\n#"
97
- f1.puts "datum:"
98
- target_hash.each_pair {|key, value|
99
- f1.puts " #{key}: #{value}" unless key == "database"
100
- f1.puts " database: #{app_name}_datum" if key == "database"
101
- }
102
- end
103
-
104
- puts " database.yml updated with datum entry"
105
- end
106
-
107
- def update_app
108
- FileUtils.mkdir_p("tmp")
109
- tmp_path = "tmp/app.tmp"
110
- tempfile = File.open(tmp_path, 'w')
111
- readfile = open_app_file
112
-
113
- readfile.each do |line|
114
- tempfile << line
115
- if line.strip == "class Application < Rails::Application"
116
- tempfile << "\n # Added as part of datum install, enables access to datum specific models\n"
117
- tempfile << " #{@@datum_model_path}\n\n"
118
- end
119
- end
120
-
121
- readfile.close
122
- tempfile.close
123
- FileUtils.mv(tmp_path, @@application_path)
124
-
125
- puts " application.rb updated with datum model reference"
126
- end
127
-
128
- def need_yml?
129
- @@info = YAML::load(IO.read(Rails.root.join("config/database.yml")))
130
- return true unless @@info["datum"]
131
- return false
132
- end
133
-
134
- def need_app?
135
- pattern = Regexp.new "#{@@datum_app_scan}"
136
- readfile = open_app_file
137
- readfile.each do |line|
138
- return false if line.scan(pattern).length != 0
139
- end
140
- return true
141
- end
142
-
143
- def open_app_file
144
- @@application_path = Rails.root.join("config/application.rb")
145
- return File.new(@@application_path)
146
- end
147
- end
148
- end
data/lib/datum/railtie.rb DELETED
@@ -1,14 +0,0 @@
1
-
2
- module Datum
3
- require 'rails'
4
- # require 'active_support'
5
-
6
- class Railtie < Rails::Railtie
7
- rake_tasks do
8
- load "tasks/datum.rake"
9
- end
10
- # initializer 'Rails logger' do
11
- # Datum.logger = Rails.logger
12
- # end
13
- end
14
- end