kelredd-activerecord-sinatra 0.2.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.
data/README.rdoc ADDED
@@ -0,0 +1,42 @@
1
+ = ActiverecordSinatra
2
+
3
+ == Description
4
+
5
+ A gem with some useful extensions for using Active Record with a sinatra app.
6
+
7
+ == Installation
8
+
9
+ sudo gem install activerecord-sinatra --source http://gems.github.com
10
+
11
+ == Usage
12
+
13
+ (in main app file)
14
+ require 'activerecord_sinatra'
15
+
16
+ (create a file config/database.yml, and put some typical active record configs in there)
17
+ (if you create a file, models.rb, this gem will auto require it, so put some model defs in there)
18
+
19
+ == License
20
+
21
+ Copyright (c) 2009 Kelly Redding.
22
+
23
+ Permission is hereby granted, free of charge, to any person
24
+ obtaining a copy of this software and associated documentation
25
+ files (the "Software"), to deal in the Software without
26
+ restriction, including without limitation the rights to use,
27
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
28
+ copies of the Software, and to permit persons to whom the
29
+ Software is furnished to do so, subject to the following
30
+ conditions:
31
+
32
+ The above copyright notice and this permission notice shall be
33
+ included in all copies or substantial portions of the Software.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
36
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
37
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
38
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
39
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
40
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
41
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
42
+ OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'rake/testtask'
4
+
5
+ require 'lib/activerecord_sinatra/version'
6
+
7
+ task :default => :test
8
+
9
+ spec = Gem::Specification.new do |s|
10
+ s.name = 'activerecord-sinatra'
11
+ s.version = ActiverecordSinatra::Version.to_s
12
+ s.has_rdoc = true
13
+ s.extra_rdoc_files = %w(README.rdoc)
14
+ s.rdoc_options = %w(--main README.rdoc)
15
+ s.summary = "A gem with some useful extensions for using Active Record with a sinatra app."
16
+ s.author = 'Kelredd'
17
+ s.email = ''
18
+ s.homepage = 'http://github.com/kelredd/activerecord-sinatra'
19
+ s.files = %w(README.rdoc Rakefile) + Dir.glob("{lib,test}/**/*")
20
+ # s.executables = ['activerecord-sinatra']
21
+
22
+ # s.add_dependency('gem_name', '~> 0.0.1')
23
+ end
24
+
25
+ Rake::GemPackageTask.new(spec) do |pkg|
26
+ pkg.gem_spec = spec
27
+ end
28
+
29
+ Rake::TestTask.new do |t|
30
+ t.libs << 'test'
31
+ t.test_files = FileList["test/**/*_test.rb"]
32
+ t.verbose = true
33
+ end
34
+
35
+ desc 'Generate the gemspec to serve this Gem from Github'
36
+ task :github do
37
+ file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
38
+ File.open(file, 'w') {|f| f << spec.to_ruby }
39
+ puts "Created gemspec: #{file}"
40
+ end
@@ -0,0 +1,2 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+ require 'activerecord_sinatra/base'
@@ -0,0 +1,35 @@
1
+ require 'sinatra/base'
2
+ require 'activerecord'
3
+ require File.join(Sinatra::Application.root,'models') if File.exists?(File.join(Sinatra::Application.root,'models'))
4
+
5
+ module Sinatra
6
+
7
+ module ActiveRecordSinatra
8
+ module Extensions
9
+ def self.production?
10
+ Sinatra::Application.environment.to_s == 'production'
11
+ end
12
+ def production?
13
+ self.production?
14
+ end
15
+ def self.development?
16
+ Sinatra::Application.environment.to_s == 'development'
17
+ end
18
+ def development?
19
+ self.development?
20
+ end
21
+ end
22
+
23
+ def self.database(environment)
24
+ db_config = YAML.load(ERB.new(IO.read(File.join(Sinatra::Application.root,'config',"database.yml"))).result) #YAML.load(ERB.new(IO.read(AR_DB_FILE)).result)
25
+ (db_config[environment.to_s]).symbolize_keys
26
+ end
27
+ end
28
+
29
+ ActiveRecord::Base.establish_connection(ActiveRecordSinatra.database(Sinatra::Application.environment))
30
+ if ActiveRecordSinatra::Extensions.development?
31
+ ActiveRecord::Base.logger = Logger.new(STDOUT)
32
+ end
33
+ ActiveRecord::Base.extend(ActiveRecordSinatra::Extensions)
34
+
35
+ end
@@ -0,0 +1,13 @@
1
+ module ActiverecordSinatra
2
+ module Version
3
+
4
+ MAJOR = 0
5
+ MINOR = 2
6
+ TINY = 0
7
+
8
+ def self.to_s # :nodoc:
9
+ [MAJOR, MINOR, TINY].join('.')
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ # http://sneaq.net/textmate-wtf
2
+ $:.reject! { |e| e.include? 'TextMate' }
3
+
4
+ require 'rubygems'
5
+ require 'test/unit'
6
+ require 'matchy'
7
+ require 'context'
8
+ require 'mocha'
9
+
10
+ require File.dirname(__FILE__) + '/../lib/activerecord_sinatra'
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ActiverecordSinatraTest < Test::Unit::TestCase
4
+
5
+ describe "An instance of the ActiverecordSinatra class" do
6
+
7
+ it "should flunk" do
8
+ flunk "Please provide some tests"
9
+ end
10
+
11
+ end
12
+
13
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kelredd-activerecord-sinatra
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Kelredd
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-22 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: ""
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - README.rdoc
26
+ - Rakefile
27
+ - lib/activerecord_sinatra
28
+ - lib/activerecord_sinatra/base.rb
29
+ - lib/activerecord_sinatra/version.rb
30
+ - lib/activerecord_sinatra.rb
31
+ - test/test_helper.rb
32
+ - test/unit
33
+ - test/unit/activerecord_sinatra_test.rb
34
+ has_rdoc: true
35
+ homepage: http://github.com/kelredd/activerecord-sinatra
36
+ post_install_message:
37
+ rdoc_options:
38
+ - --main
39
+ - README.rdoc
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ requirements: []
55
+
56
+ rubyforge_project:
57
+ rubygems_version: 1.2.0
58
+ signing_key:
59
+ specification_version: 2
60
+ summary: A gem with some useful extensions for using Active Record with a sinatra app.
61
+ test_files: []
62
+