track-plugins 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +0 -0
- data/LICENSE +20 -0
- data/README.md +45 -0
- data/lib/track/active_record.rb +37 -0
- data/lib/track/sequel.rb +32 -0
- metadata +73 -0
data/CHANGELOG.md
ADDED
File without changes
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
MIT License
|
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/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Track Plugins
|
2
|
+
|
3
|
+
Plugin collection for the rack based nano framework [Track](http://github.com/larskuhnt/track).
|
4
|
+
|
5
|
+
## List of available plugins
|
6
|
+
|
7
|
+
### ORM
|
8
|
+
|
9
|
+
* ActiveRecord
|
10
|
+
* Sequel
|
11
|
+
|
12
|
+
## Install
|
13
|
+
|
14
|
+
Add the following line to your Gemfile
|
15
|
+
|
16
|
+
gem 'track-plugins'
|
17
|
+
|
18
|
+
or install it with rubygems
|
19
|
+
|
20
|
+
gem install track-plugins
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
require the plugin you want to use and call `Track#use` _before_ you boot Track, i.e.:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
require 'track'
|
28
|
+
require 'track/sequel'
|
29
|
+
|
30
|
+
Track.use Track::Sequel
|
31
|
+
Track.boot! File.expand_path('..', __FILE__)
|
32
|
+
|
33
|
+
DB = Track::Sequel.db
|
34
|
+
DB << "SET CLIENT_ENCODING TO 'UTF8';"
|
35
|
+
```
|
36
|
+
## Author
|
37
|
+
|
38
|
+
[Lars Kuhnt](http://www.github.com/larskuhnt)
|
39
|
+
Copyright (c) 2011
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
Published under the MIT License.
|
44
|
+
|
45
|
+
See [LICENSE](LICENSE) for details.
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
module Track
|
4
|
+
module ActiveRecord
|
5
|
+
|
6
|
+
@@config = nil
|
7
|
+
@@booted = false
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def boot!
|
12
|
+
unless @booted
|
13
|
+
@@config = Track.load_config_file!('database')
|
14
|
+
connect!
|
15
|
+
@@booted = true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def [](key)
|
20
|
+
@@config[key.to_s]
|
21
|
+
end
|
22
|
+
|
23
|
+
def connected?
|
24
|
+
::ActiveRecord::Base.connected?
|
25
|
+
end
|
26
|
+
|
27
|
+
def connect!
|
28
|
+
unless connected?
|
29
|
+
::ActiveRecord::Base.establish_connection(@@config)
|
30
|
+
::ActiveRecord::Base.connection # why isnt AR connected before this?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
data/lib/track/sequel.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'sequel'
|
2
|
+
|
3
|
+
module Track
|
4
|
+
module Sequel
|
5
|
+
|
6
|
+
@@config = nil
|
7
|
+
@@db = nil
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def boot!
|
12
|
+
@@config = Track.load_config_file!('database')
|
13
|
+
connect!
|
14
|
+
end
|
15
|
+
|
16
|
+
def [](key)
|
17
|
+
@@config[key.to_s]
|
18
|
+
end
|
19
|
+
|
20
|
+
def db
|
21
|
+
@@db
|
22
|
+
end
|
23
|
+
|
24
|
+
def connect!
|
25
|
+
@@db = ::Sequel.connect @@config
|
26
|
+
# @@db << "SET CLIENT_ENCODING TO 'UTF8';"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: track-plugins
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Lars Kuhnt
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-10 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rack
|
16
|
+
requirement: &70169242419820 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70169242419820
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70169242418240 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70169242418240
|
36
|
+
description: Plugin collection for the rack based nano framework Track, currently
|
37
|
+
containing ActiveRecord and Sequel plugins
|
38
|
+
email:
|
39
|
+
- lars.kuhnt@gmail.com
|
40
|
+
executables: []
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- lib/track/active_record.rb
|
45
|
+
- lib/track/sequel.rb
|
46
|
+
- LICENSE
|
47
|
+
- README.md
|
48
|
+
- CHANGELOG.md
|
49
|
+
homepage: http://github.com/larskuhnt/track-plugins
|
50
|
+
licenses: []
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.9'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.3.6
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.8.10
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Plugin collection for the rack based nano framework Track
|
73
|
+
test_files: []
|