contineo 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b27caa0b0b677c00a74dfd928735ddf29de908be
4
+ data.tar.gz: 839cdc4bc7b9ee532594ea5637e9d6290f160a11
5
+ SHA512:
6
+ metadata.gz: fa2b3e2759a75370f02a42c49784abbe57faefc6fd8c4e9246b2cd8460d57599d5d555149a2f47d368cf96f0f7aa5beb2c3414a5f5264ad5b53806334550f030
7
+ data.tar.gz: 48baac207d5104901f2ffae1fd9148438549927edd002392ef9a5364f1720d3a52c10fa1c588c7eea24ae764667c658d9875eb1661c5e06d1b76099d1007cd13
@@ -0,0 +1,6 @@
1
+ build_steps_local
2
+ *.gem
3
+ .bundle
4
+ coverage
5
+ Gemfile.lock
6
+ db
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
4
+ - "2.0.0"
5
+ script:
6
+ - bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in timezonify.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Gemathon Warriors
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,69 @@
1
+ contineo
2
+ ========
3
+
4
+ Hold together all your databases in a rails application with ease!
5
+
6
+ ## Supports
7
+
8
+ Rails 2.3+
9
+
10
+ ## Installation
11
+
12
+ Add this line to your Rails application's `Gemfile`:
13
+
14
+ gem 'contineo'
15
+
16
+ And then run:
17
+
18
+ $ bundle install
19
+
20
+ ## Usage
21
+
22
+ Convention here is, simply you create configuration sections in database.yml, as:
23
+
24
+ <db_name_you_call_it>_<environment>
25
+
26
+ and you will get a connection class to this database as:
27
+
28
+ DbNameYouCallIt
29
+
30
+ Sample database.yml:
31
+
32
+ development:
33
+ adapter: sqlite3
34
+ database: db/development.sqlite3
35
+ pool: 5
36
+ timeout: 5000
37
+
38
+ # Look at the convention <db_name>_<environment>
39
+ other_development:
40
+ adapter: sqlite3
41
+ database: db/other_whatever_name_of_db.sqlite3
42
+ pool: 5
43
+ timeout: 5000
44
+
45
+ # Look at the convention <db_name>_<environment>
46
+ another_development:
47
+ adapter: sqlite3
48
+ database: db/another_db.sqlite3
49
+ pool: 5
50
+ timeout: 5000
51
+
52
+ Now Access db with ease
53
+
54
+ # Create your model as:
55
+ class Teacher < Other
56
+ end
57
+
58
+ class Doctor < Another
59
+ end
60
+
61
+ That's it!
62
+
63
+ ## Contributing
64
+
65
+ 1. Fork it
66
+ 2. Create your feature branch - `git checkout -b my-new-feature`
67
+ 3. Commit your changes - `git commit -m 'Add some feature'`
68
+ 4. Push to the branch - `git push origin my-new-feature`
69
+ 5. Create new Pull Request
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task :default => :spec
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'contineo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "contineo"
8
+ spec.version = Contineo::VERSION::STRING
9
+ spec.authors = ["Nikhil Nanjappa", "Ashish Upadhyay", "Ankur Gera", "Gourav Tiwari", "Hrishita Vaish"]
10
+ spec.email = ["nikhil.nanjappa@tcs.com", "ashish.upadhyaye@gmail.com", "ankurgera@gmail.com", "gouravtiwari21@gmail.com", "vaish.hrishita@tcs.com"]
11
+ spec.summary = %q{Connect rails app to multiple databases with ease}
12
+ spec.description = %q{Connect rails app to multiple databases with ease, includes sqlite, mysql, oracle etc}
13
+ spec.homepage = "https://github.com/gemathon-warriors/timezonify"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "activerecord",'>= 2.3.0'
24
+ spec.add_development_dependency "rails",'>= 2.3.0'
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'sqlite3'
27
+ spec.add_development_dependency 'coveralls'
28
+ end
@@ -0,0 +1,29 @@
1
+ require "contineo/version"
2
+ require 'active_record'
3
+ require 'rails'
4
+
5
+ module Contineo
6
+ CONFIG = begin
7
+ YAML.load_file(CONFIG_PATH)
8
+ rescue NameError => e
9
+ YAML.load_file("config/database.yml")
10
+ end
11
+
12
+ CONFIG.each do |db_env, connection_hash|
13
+ env = db_env.split('_').last
14
+
15
+ if db_env.split('_').size > 1 && ::Rails.env == env
16
+ db = db_env.split('_'+env).first
17
+
18
+ klass = Object.const_set(db.camelcase, Class.new(ActiveRecord::Base) {
19
+ self.abstract_class = true
20
+ def self.inherited(base)
21
+ contineo
22
+ end
23
+ })
24
+
25
+ klass.define_singleton_method(:contineo) { establish_connection db_env }
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,11 @@
1
+ module Contineo
2
+ # Returns the version of the currently loaded Contineo as a Gem::Version
3
+ def self.version
4
+ Gem::Version.new "0.0.1"
5
+ end
6
+
7
+ module VERSION #:nodoc:
8
+ MAJOR, MINOR, TINY = Contineo.version.segments
9
+ STRING = Contineo.version.to_s
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Contineo multiple databases' do
4
+ it "should return count for first database as zero" do
5
+ Doctor.count.should be_zero
6
+ end
7
+
8
+ it "should return count for second database as zero" do
9
+ Teacher.count.should be_zero
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/development.sqlite3
4
+ pool: 5
5
+ timeout: 5000
6
+
7
+ first_db_test:
8
+ adapter: sqlite3
9
+ database: db/first.sqlite3
10
+ pool: 5
11
+ timeout: 5000
12
+
13
+ second_db_test:
14
+ adapter: sqlite3
15
+ database: db/second.sqlite3
16
+ pool: 5
17
+ timeout: 5000
@@ -0,0 +1,2 @@
1
+ class Doctor < FirstDb
2
+ end
@@ -0,0 +1,2 @@
1
+ class Teacher < SecondDb
2
+ end
@@ -0,0 +1,45 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'coveralls'
5
+ Coveralls.wear!
6
+
7
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
8
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
9
+
10
+ require 'rspec'
11
+ ENV["RAILS_ENV"] ||= 'test'
12
+
13
+ require 'rspec/autorun'
14
+
15
+ require 'active_record'
16
+
17
+ Contineo::CONFIG_PATH = File.join("spec", "fixtures_setup", "config", "database.yml")
18
+
19
+ # FileUtils.mkdir_p "#{Dir.pwd}/tmp"
20
+ ActiveRecord::Base.logger = Logger.new(StringIO.new)
21
+ ActiveRecord::Base.configurations = YAML.load_file(File.join("spec", "fixtures_setup", "config", "database.yml"))
22
+ require 'contineo'
23
+
24
+ `cp -rf spec/fixtures_setup/db .`
25
+ require 'fixtures_setup/models/doctor'
26
+ require 'fixtures_setup/models/teacher'
27
+
28
+
29
+ # This file was generated by the `rspec --init` command. Conventionally, all
30
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
31
+ # Require this file using `require "spec_helper"` to ensure that it is only
32
+ # loaded once.
33
+ #
34
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
35
+ RSpec.configure do |config|
36
+ config.treat_symbols_as_metadata_keys_with_true_values = true
37
+ config.run_all_when_everything_filtered = true
38
+ # config.filter_run :focus
39
+
40
+ # Run specs in random order to surface order dependencies. If you find an
41
+ # order dependency and want to debug it, you can fix the order by providing
42
+ # the seed, which is printed after each run.
43
+ # --seed 1234
44
+ config.order = 'random'
45
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: contineo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nikhil Nanjappa
8
+ - Ashish Upadhyay
9
+ - Ankur Gera
10
+ - Gourav Tiwari
11
+ - Hrishita Vaish
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2014-02-21 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: bundler
19
+ requirement: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: '1.5'
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '1.5'
31
+ - !ruby/object:Gem::Dependency
32
+ name: rake
33
+ requirement: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ - !ruby/object:Gem::Dependency
46
+ name: activerecord
47
+ requirement: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - '>='
50
+ - !ruby/object:Gem::Version
51
+ version: 2.3.0
52
+ type: :development
53
+ prerelease: false
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - '>='
57
+ - !ruby/object:Gem::Version
58
+ version: 2.3.0
59
+ - !ruby/object:Gem::Dependency
60
+ name: rails
61
+ requirement: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - '>='
64
+ - !ruby/object:Gem::Version
65
+ version: 2.3.0
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: 2.3.0
73
+ - !ruby/object:Gem::Dependency
74
+ name: rspec
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ type: :development
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ - !ruby/object:Gem::Dependency
88
+ name: sqlite3
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ type: :development
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ - !ruby/object:Gem::Dependency
102
+ name: coveralls
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ type: :development
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ description: Connect rails app to multiple databases with ease, includes sqlite, mysql,
116
+ oracle etc
117
+ email:
118
+ - nikhil.nanjappa@tcs.com
119
+ - ashish.upadhyaye@gmail.com
120
+ - ankurgera@gmail.com
121
+ - gouravtiwari21@gmail.com
122
+ - vaish.hrishita@tcs.com
123
+ executables: []
124
+ extensions: []
125
+ extra_rdoc_files: []
126
+ files:
127
+ - .gitignore
128
+ - .rspec
129
+ - .travis.yml
130
+ - Gemfile
131
+ - LICENSE.txt
132
+ - README.md
133
+ - Rakefile
134
+ - contineo.gemspec
135
+ - lib/contineo.rb
136
+ - lib/contineo/version.rb
137
+ - spec/contineo_spec.rb
138
+ - spec/fixtures_setup/config/database.yml
139
+ - spec/fixtures_setup/models/doctor.rb
140
+ - spec/fixtures_setup/models/teacher.rb
141
+ - spec/spec_helper.rb
142
+ homepage: https://github.com/gemathon-warriors/timezonify
143
+ licenses:
144
+ - MIT
145
+ metadata: {}
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubyforge_project:
162
+ rubygems_version: 2.0.6
163
+ signing_key:
164
+ specification_version: 4
165
+ summary: Connect rails app to multiple databases with ease
166
+ test_files:
167
+ - spec/contineo_spec.rb
168
+ - spec/fixtures_setup/config/database.yml
169
+ - spec/fixtures_setup/models/doctor.rb
170
+ - spec/fixtures_setup/models/teacher.rb
171
+ - spec/spec_helper.rb