artk 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -38,17 +38,46 @@ And then add the engine to your application
38
38
 
39
39
  mount Artk::Engine => '/artk'
40
40
 
41
- Configure the gem to connect to your database by adding a `config/initializers/at_connect.rb` file:
42
-
43
- ActiveRecord::Base.establish_connection(
44
- :adapter => 'mysql2',
45
- :encoding => 'utf8',
46
- :database => 'at_database_name',
47
- :host => 'host_of_the_at_database',
48
- :username => 'username',
49
- :password => 'password'
50
- )
51
-
41
+ Configure the gem to connect to your Archivists' Toolkit database by editing `config/database.yml` and adding these lines:
42
+
43
+ artk_development:
44
+ adapter: mysql2
45
+ encoding: utf8
46
+ reconnect: false
47
+ database: atk
48
+ pool: 5
49
+ username: root
50
+ password: password
51
+ host: localhost
52
+
53
+ artk_test:
54
+ adapter: mysql2
55
+ encoding: utf8
56
+ reconnect: false
57
+ database: bl_test
58
+ pool: 5
59
+ username: root
60
+ password: password
61
+ host: localhost
62
+
63
+ artk_production:
64
+ adapter: mysql2
65
+ encoding: utf8
66
+ reconnect: false
67
+ database: bl_prod
68
+ pool: 5
69
+ username: root
70
+ password: password
71
+ host: localhost
72
+
73
+ The above configuration is for Mysql, so your adapater may vary, and you'll need to change these username,
74
+ password, and host values to match your environment. Using this configuration allows you to keep your databases
75
+ separate. For example, the Rails database for your application would be defined by the `developement` yaml
76
+ value, while the Archivists' Toolkit database by the `artk_development` yaml value, and so forth with the other
77
+ environments.
78
+
79
+ To be safe, you might want to use a username for the Toolkit connection that has only SELECT rights,
80
+ and avoid any possibility of the Rails application trying to make changes to the wrong database.
52
81
 
53
82
  ## Contributing
54
83
 
@@ -1,4 +1,5 @@
1
- class Artk::Accession < ActiveRecord::Base
1
+ module Artk
2
+ class Accession < Artk::Base
2
3
 
3
4
  def self.table_name
4
5
  "Accessions"
@@ -8,4 +9,5 @@ class Artk::Accession < ActiveRecord::Base
8
9
  "accessionId"
9
10
  end
10
11
 
12
+ end
11
13
  end
@@ -0,0 +1,6 @@
1
+ module Artk
2
+ class Base < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ establish_connection "artk_#{Rails.env}"
5
+ end
6
+ end
@@ -1,5 +1,5 @@
1
1
  module Artk
2
- class Component < ActiveRecord::Base
2
+ class Component < Artk::Base
3
3
 
4
4
  belongs_to :resource, :foreign_key => "resourceId"
5
5
  has_many :sub_components, :class_name => "Component", :foreign_key => "parentResourceComponentId"
@@ -1,5 +1,5 @@
1
1
  module Artk
2
- class Resource < ActiveRecord::Base
2
+ class Resource < Artk::Base
3
3
 
4
4
  has_many :components, :foreign_key => "resourceId"
5
5
 
@@ -1,3 +1,3 @@
1
1
  module Artk
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-08 00:00:00.000000000 Z
12
+ date: 2013-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -44,7 +44,7 @@ dependencies:
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
- name: rspec-rails
47
+ name: mysql2
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
@@ -60,7 +60,7 @@ dependencies:
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
- name: mysql2
63
+ name: rspec-rails
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
@@ -106,10 +106,10 @@ files:
106
106
  - app/controllers/artk/resources_controller.rb
107
107
  - app/helpers/artk/application_helper.rb
108
108
  - app/models/artk/accession.rb
109
+ - app/models/artk/base.rb
109
110
  - app/models/artk/component.rb
110
111
  - app/models/artk/resource.rb
111
112
  - app/views/layouts/artk/application.html.erb
112
- - config/initializers/at_connect.rb
113
113
  - config/routes.rb
114
114
  - lib/artk/engine.rb
115
115
  - lib/artk/version.rb
@@ -133,7 +133,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  segments:
135
135
  - 0
136
- hash: -2761099062751207607
136
+ hash: 4392052325810986348
137
137
  required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  segments:
144
144
  - 0
145
- hash: -2761099062751207607
145
+ hash: 4392052325810986348
146
146
  requirements: []
147
147
  rubyforge_project:
148
148
  rubygems_version: 1.8.23
@@ -1,11 +0,0 @@
1
- # sample connection configuration. Rename to at_connect.rb
2
- #
3
- # We override ActiveRecord to connect to our AT Database
4
- ActiveRecord::Base.establish_connection(
5
- :adapter => 'mysql2',
6
- :encoding => 'utf8',
7
- :database => 'atk',
8
- :host => 'localhost',
9
- :username => 'root',
10
- :password => 'password'
11
- )