active_wrapper 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{MIT-LICENSE → LICENSE} +2 -2
- data/{README.markdown → README.md} +0 -0
- data/lib/active_wrapper.rb +10 -11
- data/lib/active_wrapper/version.rb +3 -0
- metadata +50 -34
- data/Rakefile +0 -54
- data/gemspec.rb +0 -23
- data/resources/migration.template +0 -11
- data/spec/active_wrapper/db_spec.rb +0 -48
- data/spec/active_wrapper/log_spec.rb +0 -28
- data/spec/active_wrapper/mail_spec.rb +0 -36
- data/spec/example_project/Rakefile +0 -8
- data/spec/example_project/config/database.yml +0 -6
- data/spec/example_project/config/mail.yml +0 -17
- data/spec/example_project/db/migrate/001_test.rb +0 -10
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -16
data/{MIT-LICENSE → LICENSE}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2010 Winton Welsh
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
4
|
this software and associated documentation files (the "Software"), to deal in
|
@@ -15,4 +15,4 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
15
15
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
16
16
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
17
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
File without changes
|
data/lib/active_wrapper.rb
CHANGED
@@ -1,19 +1,18 @@
|
|
1
|
-
Dir["#{File.dirname(__FILE__)}/../vendor/*/lib"].each do |path|
|
2
|
-
$:.unshift path
|
3
|
-
end
|
4
|
-
|
5
1
|
require 'rubygems'
|
6
|
-
|
7
|
-
gem 'actionmailer', '=2.3.5'
|
8
|
-
require 'active_record'
|
9
|
-
require 'action_mailer'
|
2
|
+
require 'bundler'
|
10
3
|
require 'fileutils'
|
11
4
|
require 'logger'
|
12
5
|
require 'yaml'
|
13
6
|
|
14
|
-
require
|
15
|
-
|
16
|
-
|
7
|
+
Bundler.require(:lib)
|
8
|
+
|
9
|
+
$:.unshift File.dirname(__FILE__) + '/active_wrapper'
|
10
|
+
|
11
|
+
require 'version'
|
12
|
+
|
13
|
+
require 'db'
|
14
|
+
require 'log'
|
15
|
+
require 'mail'
|
17
16
|
|
18
17
|
module ActiveWrapper
|
19
18
|
class <<self
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 19
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Winton Welsh
|
@@ -9,57 +15,61 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-07-12 00:00:00 -07:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
|
-
name: activerecord
|
17
22
|
type: :runtime
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
name: bundler
|
25
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
20
27
|
requirements:
|
21
28
|
- - "="
|
22
29
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
30
|
+
hash: 62196359
|
31
|
+
segments:
|
32
|
+
- 1
|
33
|
+
- 0
|
34
|
+
- 0
|
35
|
+
- beta
|
36
|
+
- 2
|
37
|
+
version: 1.0.0.beta.2
|
38
|
+
requirement: *id001
|
25
39
|
- !ruby/object:Gem::Dependency
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
name: rspec
|
43
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
30
45
|
requirements:
|
31
46
|
- - "="
|
32
47
|
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
48
|
+
hash: 27
|
49
|
+
segments:
|
50
|
+
- 1
|
51
|
+
- 3
|
52
|
+
- 0
|
53
|
+
version: 1.3.0
|
54
|
+
requirement: *id002
|
55
|
+
description: Wraps ActiveRecord and Logger for use in non-Rails environments
|
56
|
+
email:
|
57
|
+
- mail@wintoni.us
|
37
58
|
executables: []
|
38
59
|
|
39
60
|
extensions: []
|
40
61
|
|
41
|
-
extra_rdoc_files:
|
42
|
-
|
62
|
+
extra_rdoc_files: []
|
63
|
+
|
43
64
|
files:
|
44
|
-
- gemspec.rb
|
45
65
|
- lib/active_wrapper/db.rb
|
46
66
|
- lib/active_wrapper/log.rb
|
47
67
|
- lib/active_wrapper/mail.rb
|
48
68
|
- lib/active_wrapper/tasks.rb
|
69
|
+
- lib/active_wrapper/version.rb
|
49
70
|
- lib/active_wrapper.rb
|
50
|
-
-
|
51
|
-
-
|
52
|
-
- README.markdown
|
53
|
-
- resources/migration.template
|
54
|
-
- spec/active_wrapper/db_spec.rb
|
55
|
-
- spec/active_wrapper/log_spec.rb
|
56
|
-
- spec/active_wrapper/mail_spec.rb
|
57
|
-
- spec/example_project/config/database.yml
|
58
|
-
- spec/example_project/config/mail.yml
|
59
|
-
- spec/example_project/db/migrate/001_test.rb
|
60
|
-
- spec/example_project/Rakefile
|
61
|
-
- spec/spec.opts
|
62
|
-
- spec/spec_helper.rb
|
71
|
+
- LICENSE
|
72
|
+
- README.md
|
63
73
|
has_rdoc: true
|
64
74
|
homepage: http://github.com/winton/active_wrapper
|
65
75
|
licenses: []
|
@@ -70,21 +80,27 @@ rdoc_options: []
|
|
70
80
|
require_paths:
|
71
81
|
- lib
|
72
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
73
84
|
requirements:
|
74
85
|
- - ">="
|
75
86
|
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 0
|
76
90
|
version: "0"
|
77
|
-
version:
|
78
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
79
93
|
requirements:
|
80
94
|
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
96
|
+
hash: 3
|
97
|
+
segments:
|
98
|
+
- 0
|
82
99
|
version: "0"
|
83
|
-
version:
|
84
100
|
requirements: []
|
85
101
|
|
86
102
|
rubyforge_project:
|
87
|
-
rubygems_version: 1.3.
|
103
|
+
rubygems_version: 1.3.7
|
88
104
|
signing_key:
|
89
105
|
specification_version: 3
|
90
106
|
summary: Wraps ActiveRecord and Logger for use in non-Rails environments
|
data/Rakefile
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'rake/gempackagetask'
|
4
|
-
require 'spec/rake/spectask'
|
5
|
-
require 'gemspec'
|
6
|
-
|
7
|
-
desc "Generate gemspec"
|
8
|
-
task :gemspec do
|
9
|
-
File.open("#{Dir.pwd}/#{GEM_NAME}.gemspec", 'w') do |f|
|
10
|
-
f.write(GEM_SPEC.to_ruby)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
desc "Install gem"
|
15
|
-
task :install do
|
16
|
-
Rake::Task['gem'].invoke
|
17
|
-
`gem install pkg/#{GEM_NAME}*.gem`
|
18
|
-
`rm -Rf pkg`
|
19
|
-
end
|
20
|
-
|
21
|
-
desc "Package gem"
|
22
|
-
Rake::GemPackageTask.new(GEM_SPEC) do |pkg|
|
23
|
-
pkg.gem_spec = GEM_SPEC
|
24
|
-
end
|
25
|
-
|
26
|
-
desc "Setup project"
|
27
|
-
task :setup do
|
28
|
-
name = File.basename(Dir.pwd)
|
29
|
-
`rm -Rf .git`
|
30
|
-
begin
|
31
|
-
dir = Dir['**/gem_template*']
|
32
|
-
from = dir.pop
|
33
|
-
if from
|
34
|
-
rb = from.include?('.rb')
|
35
|
-
to = File.dirname(from) + "/#{name}#{'.rb' if rb}"
|
36
|
-
FileUtils.mv(from, to)
|
37
|
-
end
|
38
|
-
end while dir.length > 0
|
39
|
-
Dir["**/*"].each do |path|
|
40
|
-
next if path.include?('Rakefile')
|
41
|
-
if File.file?(path)
|
42
|
-
`sed -i "" 's/gem_template/#{name}/g' #{path}`
|
43
|
-
end
|
44
|
-
end
|
45
|
-
`git init`
|
46
|
-
end
|
47
|
-
|
48
|
-
desc "Run specs"
|
49
|
-
Spec::Rake::SpecTask.new do |t|
|
50
|
-
t.spec_opts = ["--format", "specdoc", "--colour"]
|
51
|
-
t.spec_files = FileList["spec/**/*_spec.rb"]
|
52
|
-
end
|
53
|
-
|
54
|
-
task :default => :spec
|
data/gemspec.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
GEM_NAME = 'active_wrapper'
|
2
|
-
GEM_FILES = FileList['**/*'] - FileList[
|
3
|
-
'coverage', 'coverage/**/*',
|
4
|
-
'pkg', 'pkg/**/*',
|
5
|
-
'spec/example_project/log', 'spec/example_project/log/*'
|
6
|
-
]
|
7
|
-
GEM_SPEC = Gem::Specification.new do |s|
|
8
|
-
# == CONFIGURE ==
|
9
|
-
s.author = "Winton Welsh"
|
10
|
-
s.email = "mail@wintoni.us"
|
11
|
-
s.homepage = "http://github.com/winton/#{GEM_NAME}"
|
12
|
-
s.summary = "Wraps ActiveRecord and Logger for use in non-Rails environments"
|
13
|
-
# == CONFIGURE ==
|
14
|
-
s.add_dependency('activerecord', '=2.3.5')
|
15
|
-
s.add_dependency('actionmailer', '=2.3.5')
|
16
|
-
s.extra_rdoc_files = [ "README.markdown" ]
|
17
|
-
s.files = GEM_FILES.to_a
|
18
|
-
s.has_rdoc = false
|
19
|
-
s.name = GEM_NAME
|
20
|
-
s.platform = Gem::Platform::RUBY
|
21
|
-
s.require_path = "lib"
|
22
|
-
s.version = "0.2.7"
|
23
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe ActiveWrapper::Db do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
$db, $log, $mail = ActiveWrapper.setup(
|
7
|
-
:base => SPEC + '/example_project',
|
8
|
-
:env => 'test'
|
9
|
-
)
|
10
|
-
$db.drop_db
|
11
|
-
$db.create_db
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should establish a connection" do
|
15
|
-
$db.disconnect!
|
16
|
-
$db.establish_connection
|
17
|
-
$db.connected?.should == true
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should create a database" do
|
21
|
-
$db.current_database.should == 'active_wrapper'
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should drop a database" do
|
25
|
-
$db.drop_db
|
26
|
-
$db.current_database.should == nil
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should migrate a database" do
|
30
|
-
$db.migrate
|
31
|
-
$db.execute('insert into tests () values ()')
|
32
|
-
$db.execute('select * from tests').num_rows.should == 1
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should migrate reset a database" do
|
36
|
-
$db.migrate
|
37
|
-
$db.execute('insert into tests () values ()')
|
38
|
-
$db.migrate_reset
|
39
|
-
$db.execute('select * from tests').num_rows.should == 0
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should generate a migration" do
|
43
|
-
$db.generate_migration 'another_test'
|
44
|
-
path = SPEC + "/example_project/db/migrate/002_another_test.rb"
|
45
|
-
File.exists?(path).should == true
|
46
|
-
FileUtils.rm_f path
|
47
|
-
end
|
48
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
|
2
|
-
|
3
|
-
describe ActiveWrapper::Log do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
FileUtils.rm_f(@path = SPEC + "/example_project/log/test.log")
|
7
|
-
$db, $log, $mail = ActiveWrapper.setup(
|
8
|
-
:base => SPEC + '/example_project',
|
9
|
-
:env => 'test'
|
10
|
-
)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should create a log file" do
|
14
|
-
File.exists?(@path).should == true
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should log to the log file" do
|
18
|
-
$log.info "test"
|
19
|
-
File.read(@path).include?('test').should == true
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should clear the log file while keeping the logger intact" do
|
23
|
-
$log.clear
|
24
|
-
File.read(@path).include?('test').should == false
|
25
|
-
$log.info "test"
|
26
|
-
File.read(@path).include?('test').should == true
|
27
|
-
end
|
28
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe ActiveWrapper::Db do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
$db, $log, $mail = ActiveWrapper.setup(
|
7
|
-
:base => SPEC + '/example_project',
|
8
|
-
:env => 'test'
|
9
|
-
)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should set instance variables" do
|
13
|
-
$mail.base.should =~ %r{active_wrapper/spec/example_project}
|
14
|
-
$mail.config.should == {
|
15
|
-
:sendmail => false,
|
16
|
-
:smtp => {
|
17
|
-
:address => "smtp.gmail.com",
|
18
|
-
:authentication => :plain,
|
19
|
-
:domain => "mydomain.com",
|
20
|
-
:password => "password",
|
21
|
-
:port => 587,
|
22
|
-
:enable_starttls_auto => true,
|
23
|
-
:user_name => "test@mydomain.com"
|
24
|
-
},
|
25
|
-
:imap => {
|
26
|
-
:password => "password",
|
27
|
-
:port => 993,
|
28
|
-
:server => "imap.gmail.com",
|
29
|
-
:ssl => true,
|
30
|
-
:use_login => true,
|
31
|
-
:username => "test@mydomain.com"
|
32
|
-
}
|
33
|
-
}
|
34
|
-
$mail.env.should == 'test'
|
35
|
-
end
|
36
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
test:
|
2
|
-
imap:
|
3
|
-
password: password
|
4
|
-
port: 993
|
5
|
-
server: imap.gmail.com
|
6
|
-
ssl: true
|
7
|
-
use_login: true
|
8
|
-
username: test@mydomain.com
|
9
|
-
smtp:
|
10
|
-
address: smtp.gmail.com
|
11
|
-
authentication: :plain
|
12
|
-
domain: mydomain.com
|
13
|
-
password: password
|
14
|
-
port: 587
|
15
|
-
enable_starttls_auto: true
|
16
|
-
user_name: test@mydomain.com
|
17
|
-
sendmail: false
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/spec/spec_helper.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
$TESTING=true
|
2
|
-
SPEC = File.dirname(__FILE__)
|
3
|
-
$:.unshift File.expand_path("#{SPEC}/../lib")
|
4
|
-
|
5
|
-
require 'active_wrapper'
|
6
|
-
require 'pp'
|
7
|
-
|
8
|
-
Spec::Runner.configure do |config|
|
9
|
-
end
|
10
|
-
|
11
|
-
# For use with rspec textmate bundle
|
12
|
-
def debug(object)
|
13
|
-
puts "<pre>"
|
14
|
-
puts object.pretty_inspect.gsub('<', '<').gsub('>', '>')
|
15
|
-
puts "</pre>"
|
16
|
-
end
|