active_wrapper 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 0
9
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Winton Welsh
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-30 00:00:00 -08:00
17
+ date: 2011-01-02 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -23,15 +23,16 @@ dependencies:
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
26
- - - ">="
26
+ - - ~>
27
27
  - !ruby/object:Gem::Version
28
28
  segments:
29
+ - 3
29
30
  - 0
30
- version: "0"
31
+ version: "3.0"
31
32
  type: :runtime
32
33
  version_requirements: *id001
33
34
  - !ruby/object:Gem::Dependency
34
- name: mysql2
35
+ name: rake
35
36
  prerelease: false
36
37
  requirement: &id002 !ruby/object:Gem::Requirement
37
38
  none: false
@@ -40,8 +41,10 @@ dependencies:
40
41
  - !ruby/object:Gem::Version
41
42
  segments:
42
43
  - 0
43
- version: "0"
44
- type: :runtime
44
+ - 8
45
+ - 7
46
+ version: 0.8.7
47
+ type: :development
45
48
  version_requirements: *id002
46
49
  - !ruby/object:Gem::Dependency
47
50
  name: rspec
@@ -49,11 +52,12 @@ dependencies:
49
52
  requirement: &id003 !ruby/object:Gem::Requirement
50
53
  none: false
51
54
  requirements:
52
- - - ">="
55
+ - - ~>
53
56
  - !ruby/object:Gem::Version
54
57
  segments:
58
+ - 1
55
59
  - 0
56
- version: "0"
60
+ version: "1.0"
57
61
  type: :development
58
62
  version_requirements: *id003
59
63
  description: Wraps ActiveRecord and Logger for use in non-Rails environments
@@ -64,30 +68,8 @@ extensions: []
64
68
 
65
69
  extra_rdoc_files: []
66
70
 
67
- files:
68
- - .gitignore
69
- - LICENSE
70
- - README.md
71
- - Rakefile
72
- - active_wrapper.gemspec
73
- - config/gemsets.yml
74
- - config/gemspec.yml
75
- - lib/active_wrapper.rb
76
- - lib/active_wrapper/db.rb
77
- - lib/active_wrapper/gems.rb
78
- - lib/active_wrapper/log.rb
79
- - lib/active_wrapper/tasks.rb
80
- - resources/migration.template
81
- - spec/active_wrapper/db_spec.rb
82
- - spec/active_wrapper/gems_spec.rb
83
- - spec/active_wrapper/log_spec.rb
84
- - spec/fixtures/example_project/Rakefile
85
- - spec/fixtures/example_project/config/database.yml
86
- - spec/fixtures/example_project/db/migrate/001_test.rb
87
- - spec/fixtures/gemsets.yml
88
- - spec/fixtures/gemspec.yml
89
- - spec/spec.opts
90
- - spec/spec_helper.rb
71
+ files: []
72
+
91
73
  has_rdoc: true
92
74
  homepage: http://github.com/winton/active_wrapper
93
75
  licenses: []
@@ -120,14 +102,5 @@ rubygems_version: 1.3.7
120
102
  signing_key:
121
103
  specification_version: 3
122
104
  summary: Wraps ActiveRecord and Logger for use in non-Rails environments
123
- test_files:
124
- - spec/active_wrapper/db_spec.rb
125
- - spec/active_wrapper/gems_spec.rb
126
- - spec/active_wrapper/log_spec.rb
127
- - spec/fixtures/example_project/Rakefile
128
- - spec/fixtures/example_project/config/database.yml
129
- - spec/fixtures/example_project/db/migrate/001_test.rb
130
- - spec/fixtures/gemsets.yml
131
- - spec/fixtures/gemspec.yml
132
- - spec/spec.opts
133
- - spec/spec_helper.rb
105
+ test_files: []
106
+
data/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- .DS_Store
2
- *.gem
3
- *.log
4
- coverage
5
- pkg
6
- tmp
data/LICENSE DELETED
@@ -1,18 +0,0 @@
1
- Copyright (c) 2010
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- this software and associated documentation files (the "Software"), to deal in
5
- the Software without restriction, including without limitation the rights to
6
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
- the Software, and to permit persons to whom the Software is furnished to do so,
8
- subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
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.
data/README.md DELETED
@@ -1,75 +0,0 @@
1
- ActiveWrapper
2
- =============
3
-
4
- Wraps ActiveRecord and Logger for use in non-Rails environments.
5
-
6
- Compatibility
7
- -------------
8
-
9
- Maintained under Ruby 1.9.2.
10
-
11
- Setup
12
- -----
13
-
14
- <pre>
15
- gem install active_wrapper
16
- </pre>
17
-
18
- Usage
19
- -----
20
-
21
- <pre>
22
- require 'rubygems'
23
- require 'active_wrapper'
24
-
25
- $db, $log = ActiveWrapper.setup(
26
- :base => File.dirname(__FILE__),
27
- :env => 'development',
28
- :log => 'custom',
29
- :stdout => true
30
- )
31
-
32
- $db.drop_db
33
- $db.create_db
34
- $db.establish_connection
35
- $db.generate_migration('my_migration')
36
- $db.migrate('001')
37
- $db.migrate_reset
38
- $log.info('log this')
39
- $log.clear
40
- </pre>
41
-
42
- <code>ActiveWrapper</code> looks for the following files within the <code>:base</code> directory:
43
-
44
- * <b>config/database.yml</b>
45
- * <b>db/migrate/*.rb</b>
46
-
47
- The <code>:env</code> option is <code>"development"</code> by default.
48
-
49
- Logger
50
- ------
51
-
52
- In the previous example, the log is stored in <b>log/custom.log</b>.
53
-
54
- If no <code>:log</code> name is specified, the <code>:env</code> option is used for the log name.
55
-
56
- You may also set <code>:log</code> to false to disable logging entirely.
57
-
58
- Setting <code>:stdout</code> to true causes stdout and stderr to redirect to the logger. It is false by default.
59
-
60
- Rakefile
61
- --------
62
-
63
- Add this to your project's <b>Rakefile</b> for database migration and log tasks:
64
-
65
- <pre>
66
- require 'rubygems'
67
- require 'rake'
68
- require 'active_wrapper/tasks'
69
-
70
- ActiveWrapper::Tasks.new(:log => 'custom') do
71
- # Put stuff you would normally put in the environment task here
72
- end
73
- </pre>
74
-
75
- Pass the same options to <code>ActiveWrapper::Tasks.new</code> as you would <code>ActiveWrapper.new</code>.
data/Rakefile DELETED
@@ -1,72 +0,0 @@
1
- require File.dirname(__FILE__) + '/lib/active_wrapper/gems'
2
-
3
- ActiveWrapper::Gems.activate %w(rake rspec)
4
-
5
- require 'rake'
6
- require 'rake/gempackagetask'
7
- require 'spec/rake/spectask'
8
-
9
- def gemspec
10
- @gemspec ||= begin
11
- file = File.expand_path('../active_wrapper.gemspec', __FILE__)
12
- eval(File.read(file), binding, file)
13
- end
14
- end
15
-
16
- if defined?(Rake::GemPackageTask)
17
- Rake::GemPackageTask.new(gemspec) do |pkg|
18
- pkg.gem_spec = gemspec
19
- end
20
- task :gem => :gemspec
21
- end
22
-
23
- if defined?(Spec::Rake::SpecTask)
24
- desc "Run specs"
25
- Spec::Rake::SpecTask.new do |t|
26
- t.spec_files = FileList['spec/**/*_spec.rb']
27
- t.spec_opts = %w(-fs --color)
28
- end
29
- task :spec
30
- end
31
-
32
- namespace :gems do
33
- desc "Install gems (DEV=0 DOCS=0 GEMSPEC=default SUDO=0)"
34
- task :install do
35
- dev = ENV['DEV'] == '1'
36
- docs = ENV['DOCS'] == '1' ? '' : '--no-ri --no-rdoc'
37
- gemset = ENV['GEMSET']
38
- sudo = ENV['SUDO'] == '1' ? 'sudo' : ''
39
-
40
- ActiveWrapper::Gems.gemset = gemset if gemset
41
-
42
- if dev
43
- gems = ActiveWrapper::Gems.gemspec.development_dependencies
44
- else
45
- gems = ActiveWrapper::Gems.gemspec.dependencies
46
- end
47
-
48
- gems.each do |name|
49
- name = name.to_s
50
- version = ActiveWrapper::Gems.versions[name]
51
- if Gem.source_index.find_name(name, version).empty?
52
- version = version ? "-v #{version}" : ''
53
- system "#{sudo} gem install #{name} #{version} #{docs}"
54
- else
55
- puts "already installed: #{name} #{version}"
56
- end
57
- end
58
- end
59
- end
60
-
61
- desc "Validate the gemspec"
62
- task :gemspec do
63
- gemspec.validate
64
- end
65
-
66
- desc "Install gem locally"
67
- task :install => :package do
68
- sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
69
- end
70
-
71
- task :default => :spec
72
- task :package => :gemspec
@@ -1,27 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib/', __FILE__)
3
- $:.unshift lib unless $:.include?(lib)
4
-
5
- require 'active_wrapper/gems'
6
- ActiveWrapper::Gems.gemset ||= :default
7
-
8
- Gem::Specification.new do |s|
9
- ActiveWrapper::Gems.gemspec.hash.each do |key, value|
10
- unless %w(dependencies development_dependencies).include?(key)
11
- s.send "#{key}=", value
12
- end
13
- end
14
-
15
- ActiveWrapper::Gems.gemspec.dependencies.each do |g|
16
- s.add_dependency g.to_s, ActiveWrapper::Gems.versions[g]
17
- end
18
-
19
- ActiveWrapper::Gems.gemspec.development_dependencies.each do |g|
20
- s.add_development_dependency g.to_s, ActiveWrapper::Gems.versions[g]
21
- end
22
-
23
- s.executables = `git ls-files -- {bin}/*`.split("\n").collect { |f| File.basename(f) }
24
- s.files = `git ls-files`.split("\n")
25
- s.require_paths = %w(lib)
26
- s.test_files = `git ls-files -- {features,test,spec}/*`.split("\n")
27
- end
data/config/gemsets.yml DELETED
@@ -1,9 +0,0 @@
1
- active_wrapper:
2
- rake: =0.8.7
3
- rspec: =1.3.1
4
- default:
5
- activerecord: =3.0.3
6
- mysql2: =0.2.6
7
- activerecord_2:
8
- activerecord: =2.3.10
9
- mysql: =2.8.1
data/config/gemspec.yml DELETED
@@ -1,13 +0,0 @@
1
- name: active_wrapper
2
- version: 0.4.0
3
- authors:
4
- - Winton Welsh
5
- email: mail@wintoni.us
6
- homepage: http://github.com/winton/active_wrapper
7
- summary: Wraps ActiveRecord and Logger for use in non-Rails environments
8
- description: Wraps ActiveRecord and Logger for use in non-Rails environments
9
- dependencies:
10
- - activerecord
11
- - mysql2
12
- development_dependencies:
13
- - rspec
@@ -1,40 +0,0 @@
1
- require File.dirname(__FILE__) + '/active_wrapper/gems'
2
-
3
- case ActiveWrapper::Gems.gemset
4
- when :default
5
- ActiveWrapper::Gems.activate %w(activerecord mysql2)
6
- when :activerecord_2
7
- ActiveWrapper::Gems.activate %w(activerecord mysql)
8
- end
9
-
10
- require 'active_record'
11
- require 'fileutils'
12
- require 'logger'
13
- require 'yaml'
14
-
15
- $:.unshift File.dirname(__FILE__) + '/active_wrapper'
16
-
17
- require 'db'
18
- require 'log'
19
-
20
- module ActiveWrapper
21
- class <<self
22
-
23
- def setup(options={})
24
-
25
- env = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || ENV['MERB_ENV'] || 'development'
26
- options = {
27
- :base => File.dirname($0),
28
- :env => options[:env] || env,
29
- :log => options[:env] || env
30
- }.merge(options.reject { |k, v| v.nil? })
31
-
32
- db = Db.new(options)
33
- log = Log.new(options)
34
-
35
- [ db, log ]
36
- end
37
- end
38
- end
39
-
40
- ActiveRecord::Base.default_timezone = :utc
@@ -1,107 +0,0 @@
1
- module ActiveWrapper
2
- class Db
3
-
4
- attr_reader :base, :config, :env
5
-
6
- def initialize(options)
7
- @base = options[:base]
8
- if File.exists?(path = "#{base}/config/database.yml")
9
- @config = YAML::load(File.open(path))
10
- else
11
- raise "Could not find #{path}"
12
- end
13
- @env = options[:env].to_s
14
- unless config[env]
15
- raise "Environment \"#{env}\" not found in #{path}"
16
- end
17
- end
18
-
19
- def connected?
20
- ActiveRecord::Base.connected?
21
- end
22
-
23
- def create_db
24
- establish_connection('database' => nil)
25
- ActiveRecord::Base.connection.create_database config[env]['database']
26
- establish_connection({})
27
- end
28
-
29
- def drop_db
30
- establish_connection('database' => nil)
31
- ActiveRecord::Base.connection.drop_database config[env]['database']
32
- end
33
-
34
- def establish_connection(options=nil)
35
- if !connected? || options
36
- config_clone = Marshal.load(Marshal.dump(config))
37
- config_clone[env].merge!(options || {})
38
- ActiveRecord::Base.configurations = config_clone
39
- ActiveRecord::Base.establish_connection(env)
40
- end
41
- end
42
-
43
- def migrate(version=nil)
44
- establish_connection
45
- redirect_stdout do
46
- ActiveRecord::Migrator.migrate("#{base}/db/migrate", version)
47
- end
48
- end
49
-
50
- def migrate_reset
51
- redirect_stdout do
52
- migrate(0)
53
- migrate
54
- end
55
- end
56
-
57
- def generate_migration(name=nil)
58
- redirect_stdout do
59
- raise "Please specify desired migration name with NAME=my_migration_name" unless name
60
-
61
- migration_name = name.strip.chomp
62
- migrations_path = "#{base}/db/migrate"
63
- migrations_template = File.expand_path("#{File.dirname(__FILE__)}/../../resources/migration.template")
64
-
65
- # Find the highest existing migration version or set to 1
66
- if (existing_migrations = Dir[File.join(migrations_path, '*.rb')]).length > 0
67
- version = File.basename(existing_migrations.sort.reverse.first)[/^(\d+)_/,1].to_i + 1
68
- else
69
- version = 1
70
- end
71
-
72
- # Read the contents of the migration template into string
73
- migrations_template = File.read(migrations_template)
74
-
75
- # Replace the migration name in template with the acutal one
76
- migration_content = migrations_template.gsub('__migration_name__', migration_name.camelize)
77
- migration_content = migration_content.gsub('__migration_table__', migration_name)
78
-
79
- # Generate migration filename
80
- migration_filename = "#{"%03d" % version}_#{migration_name}.rb"
81
-
82
- # Write the migration
83
- File.open(File.join(migrations_path, migration_filename), "w+") do |migration|
84
- migration.puts migration_content
85
- end
86
-
87
- # Done!
88
- puts "Successfully created migration #{migration_filename}"
89
- end
90
- end
91
-
92
- def method_missing(method, *args)
93
- ActiveRecord::Base.connection.send(method, *args)
94
- end
95
-
96
- def redirect_stdout(&block)
97
- if env == 'test'
98
- stdout = $stdout.dup
99
- $stdout = $stdout.reopen(RUBY_PLATFORM =~ /mswin/ ? "NUL" : "/dev/null")
100
- end
101
- yield
102
- if env == 'test'
103
- $stdout.reopen(stdout)
104
- end
105
- end
106
- end
107
- end
@@ -1,106 +0,0 @@
1
- unless defined?(ActiveWrapper::Gems)
2
-
3
- require 'yaml'
4
-
5
- module ActiveWrapper
6
- module Gems
7
- class <<self
8
-
9
- attr_accessor :config, :gemset, :gemsets, :versions
10
-
11
- class SimpleStruct
12
- attr_accessor :hash
13
-
14
- def initialize(hash)
15
- @hash = hash
16
- @hash.each do |key, value|
17
- self.class.send(:define_method, key) { hash[key] }
18
- self.class.send(:define_method, "#{key}=") { |v| hash[key] = v }
19
- end
20
- end
21
- end
22
-
23
- Gems.config = SimpleStruct.new(
24
- :gemsets => [ "#{File.expand_path('../../../', __FILE__)}/config/gemsets.yml" ],
25
- :gemspec => "#{File.expand_path('../../../', __FILE__)}/config/gemspec.yml",
26
- :warn => true
27
- )
28
-
29
- def activate(*gems)
30
- begin
31
- require 'rubygems' unless defined?(::Gem)
32
- rescue LoadError
33
- puts "rubygems library could not be required" if @config.warn
34
- end
35
-
36
- self.gemset = :default unless defined?(@gemset) && @gemset
37
-
38
- gems.flatten.collect(&:to_sym).each do |name|
39
- version = @versions[name]
40
- if defined?(gem)
41
- gem name.to_s, version
42
- else
43
- puts "#{name} #{"(#{version})" if version} failed to activate" if @config.warn
44
- end
45
- end
46
- end
47
-
48
- def gemset=(gemset)
49
- if gemset
50
- @gemset = gemset.to_sym
51
-
52
- @gemsets = @config.gemsets.reverse.collect { |config|
53
- if config.is_a?(::String)
54
- YAML::load(File.read(config)) rescue {}
55
- elsif config.is_a?(::Hash)
56
- config
57
- end
58
- }.inject({}) do |hash, config|
59
- deep_merge(hash, symbolize_keys(config))
60
- end
61
-
62
- @versions = @gemsets[gemspec.name.to_sym].inject({}) do |hash, (key, value)|
63
- if value.is_a?(::String)
64
- hash[key] = value
65
- elsif value.is_a?(::Hash) && key == @gemset
66
- value.each { |k, v| hash[k] = v }
67
- end
68
- hash
69
- end
70
- else
71
- @gemset = nil
72
- @gemsets = nil
73
- @versions = nil
74
- end
75
- end
76
-
77
- def gemspec(reload=false)
78
- if @gemspec && !reload
79
- @gemspec
80
- else
81
- data = YAML::load(File.read(@config.gemspec)) rescue {}
82
- @gemspec = SimpleStruct.new(data)
83
- end
84
- end
85
-
86
- private
87
-
88
- def deep_merge(first, second)
89
- merger = lambda do |key, v1, v2|
90
- Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2
91
- end
92
- first.merge(second, &merger)
93
- end
94
-
95
- def symbolize_keys(hash)
96
- return {} unless hash.is_a?(::Hash)
97
- hash.inject({}) do |options, (key, value)|
98
- value = symbolize_keys(value) if value.is_a?(::Hash)
99
- options[(key.to_sym rescue key) || key] = value
100
- options
101
- end
102
- end
103
- end
104
- end
105
- end
106
- end
@@ -1,39 +0,0 @@
1
- module ActiveWrapper
2
- class Log
3
-
4
- attr_reader :base, :log, :logger, :stdout
5
-
6
- def initialize(options)
7
- @base = options[:base]
8
- @log = options[:log]
9
- @stdout = options[:stdout]
10
-
11
- return if @log == false
12
-
13
- FileUtils.mkdir_p("#{base}/log")
14
- file = File.open("#{base}/log/#{log}.log", 'a')
15
- file.sync = true
16
-
17
- if stdout
18
- @logger = Logger.new($stdout)
19
- $stdout.reopen(file)
20
- $stderr.reopen(file)
21
- else
22
- @logger = Logger.new(file)
23
- end
24
-
25
- ActiveRecord::Base.logger = @logger
26
- end
27
-
28
- def clear
29
- Dir["#{base}/log/*.log"].each do |file|
30
- f = File.open(file, "w")
31
- f.close
32
- end
33
- end
34
-
35
- def method_missing(method, *args)
36
- logger.send(method, *args)
37
- end
38
- end
39
- end
@@ -1,43 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../active_wrapper")
2
-
3
- module ActiveWrapper
4
- class Tasks
5
-
6
- def initialize(options={}, &block)
7
-
8
- task :environment do
9
- $db, $log = ActiveWrapper.setup(options)
10
- yield if block
11
- end
12
-
13
- namespace :db do
14
- desc "Create the database"
15
- task :create => :environment do
16
- $db.create_db
17
- end
18
-
19
- desc "Drop the database"
20
- task :drop => :environment do
21
- $db.drop_db
22
- end
23
-
24
- desc "Migrate the database with optional VERSION"
25
- task :migrate => :environment do
26
- $db.migrate(ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
27
- end
28
-
29
- desc "Generate a migration with given NAME"
30
- task :migration => :environment do
31
- $db.generate_migration(ENV['NAME'])
32
- end
33
- end
34
-
35
- namespace :log do
36
- desc "Clear all logs"
37
- task :clear => :environment do
38
- $log.clear
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,11 +0,0 @@
1
- class __migration_name__ < ActiveRecord::Migration
2
- def self.up
3
- create_table :__migration_table__ do |t|
4
-
5
- end
6
- end
7
-
8
- def self.down
9
- drop_table :__migration_table__
10
- end
11
- 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 => $root + '/spec/fixtures/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 = $root + "/spec/fixtures/example_project/db/migrate/002_another_test.rb"
45
- File.exists?(path).should == true
46
- FileUtils.rm_f path
47
- end
48
- end
@@ -1,161 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveWrapper::Gems do
4
-
5
- before(:each) do
6
- @old_config = ActiveWrapper::Gems.config
7
-
8
- ActiveWrapper::Gems.config.gemspec = "#{$root}/spec/fixtures/gemspec.yml"
9
- ActiveWrapper::Gems.config.gemsets = [
10
- "#{$root}/spec/fixtures/gemsets.yml"
11
- ]
12
- ActiveWrapper::Gems.config.warn = true
13
-
14
- ActiveWrapper::Gems.gemspec true
15
- ActiveWrapper::Gems.gemset = nil
16
- end
17
-
18
- after(:each) do
19
- ActiveWrapper::Gems.config = @old_config
20
- end
21
-
22
- describe :activate do
23
- it "should activate gems" do
24
- ActiveWrapper::Gems.stub!(:gem)
25
- ActiveWrapper::Gems.should_receive(:gem).with('rspec', '=1.3.1')
26
- ActiveWrapper::Gems.should_receive(:gem).with('rake', '=0.8.7')
27
- ActiveWrapper::Gems.activate :rspec, 'rake'
28
- end
29
- end
30
-
31
- describe :gemset= do
32
- before(:each) do
33
- ActiveWrapper::Gems.config.gemsets = [
34
- {
35
- :name => {
36
- :rake => '>0.8.6',
37
- :default => {
38
- :externals => '=1.0.2'
39
- }
40
- }
41
- },
42
- "#{$root}/spec/fixtures/gemsets.yml"
43
- ]
44
- end
45
-
46
- describe :default do
47
- before(:each) do
48
- ActiveWrapper::Gems.gemset = :default
49
- end
50
-
51
- it "should set @gemset" do
52
- ActiveWrapper::Gems.gemset.should == :default
53
- end
54
-
55
- it "should set @gemsets" do
56
- ActiveWrapper::Gems.gemsets.should == {
57
- :name => {
58
- :rake => ">0.8.6",
59
- :default => {
60
- :externals => '=1.0.2',
61
- :rspec => "=1.3.1"
62
- },
63
- :rspec2 => { :rspec => "=2.3.0" }
64
- }
65
- }
66
- end
67
-
68
- it "should set Gems.versions" do
69
- ActiveWrapper::Gems.versions.should == {
70
- :rake => ">0.8.6",
71
- :rspec => "=1.3.1",
72
- :externals => "=1.0.2"
73
- }
74
- end
75
-
76
- it "should set everything to nil if gemset given nil value" do
77
- ActiveWrapper::Gems.gemset = nil
78
- ActiveWrapper::Gems.gemset.should == nil
79
- ActiveWrapper::Gems.gemsets.should == nil
80
- ActiveWrapper::Gems.versions.should == nil
81
- end
82
- end
83
-
84
- describe :rspec2 do
85
- before(:each) do
86
- ActiveWrapper::Gems.gemset = "rspec2"
87
- end
88
-
89
- it "should set @gemset" do
90
- ActiveWrapper::Gems.gemset.should == :rspec2
91
- end
92
-
93
- it "should set @gemsets" do
94
- ActiveWrapper::Gems.gemsets.should == {
95
- :name => {
96
- :rake => ">0.8.6",
97
- :default => {
98
- :externals => '=1.0.2',
99
- :rspec => "=1.3.1"
100
- },
101
- :rspec2 => { :rspec => "=2.3.0" }
102
- }
103
- }
104
- end
105
-
106
- it "should set Gems.versions" do
107
- ActiveWrapper::Gems.versions.should == {
108
- :rake => ">0.8.6",
109
- :rspec => "=2.3.0"
110
- }
111
- end
112
- end
113
-
114
- describe :nil do
115
- before(:each) do
116
- ActiveWrapper::Gems.gemset = nil
117
- end
118
-
119
- it "should set everything to nil" do
120
- ActiveWrapper::Gems.gemset.should == nil
121
- ActiveWrapper::Gems.gemsets.should == nil
122
- ActiveWrapper::Gems.versions.should == nil
123
- end
124
- end
125
- end
126
-
127
- describe :reload_gemspec do
128
- it "should populate @gemspec" do
129
- ActiveWrapper::Gems.gemspec.hash.should == {
130
- "name" => "name",
131
- "version" => "0.1.0",
132
- "authors" => ["Author"],
133
- "email" => "email@email.com",
134
- "homepage" => "http://github.com/author/name",
135
- "summary" => "Summary",
136
- "description" => "Description",
137
- "dependencies" => ["rake"],
138
- "development_dependencies" => ["rspec"]
139
- }
140
- end
141
-
142
- it "should create methods from keys of @gemspec" do
143
- ActiveWrapper::Gems.gemspec.name.should == "name"
144
- ActiveWrapper::Gems.gemspec.version.should == "0.1.0"
145
- ActiveWrapper::Gems.gemspec.authors.should == ["Author"]
146
- ActiveWrapper::Gems.gemspec.email.should == "email@email.com"
147
- ActiveWrapper::Gems.gemspec.homepage.should == "http://github.com/author/name"
148
- ActiveWrapper::Gems.gemspec.summary.should == "Summary"
149
- ActiveWrapper::Gems.gemspec.description.should == "Description"
150
- ActiveWrapper::Gems.gemspec.dependencies.should == ["rake"]
151
- ActiveWrapper::Gems.gemspec.development_dependencies.should == ["rspec"]
152
- end
153
-
154
- it "should produce a valid gemspec" do
155
- ActiveWrapper::Gems.gemset = :default
156
- gemspec = File.expand_path("../../../active_wrapper.gemspec", __FILE__)
157
- gemspec = eval(File.read(gemspec), binding, gemspec)
158
- gemspec.validate.should == true
159
- end
160
- end
161
- 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 = $root + "/spec/fixtures/example_project/log/test.log")
7
- $db, $log, $mail = ActiveWrapper.setup(
8
- :base => $root + '/spec/fixtures/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,8 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require File.expand_path(File.dirname(__FILE__) + "/../../lib/active_wrapper/tasks")
4
-
5
- ActiveWrapper::Tasks.new(
6
- :base => File.dirname(__FILE__),
7
- :env => 'test'
8
- )
@@ -1,6 +0,0 @@
1
- test:
2
- database: active_wrapper
3
- adapter: mysql
4
- username: root
5
- password:
6
- host: localhost
@@ -1,10 +0,0 @@
1
- class Test < ActiveRecord::Migration
2
- def self.up
3
- create_table :tests do |t|
4
- end
5
- end
6
-
7
- def self.down
8
- drop_table :tests
9
- end
10
- end
@@ -1,6 +0,0 @@
1
- name:
2
- rake: =0.8.7
3
- default:
4
- rspec: =1.3.1
5
- rspec2:
6
- rspec: =2.3.0
@@ -1,12 +0,0 @@
1
- name: name
2
- version: 0.1.0
3
- authors:
4
- - Author
5
- email: email@email.com
6
- homepage: http://github.com/author/name
7
- summary: Summary
8
- description: Description
9
- dependencies:
10
- - rake
11
- development_dependencies:
12
- - rspec
data/spec/spec.opts DELETED
@@ -1 +0,0 @@
1
- --color
data/spec/spec_helper.rb DELETED
@@ -1,12 +0,0 @@
1
- $root = File.expand_path('../../', __FILE__)
2
-
3
- require "#{$root}/lib/active_wrapper/gems"
4
-
5
- ActiveWrapper::Gems.gemset = ENV['GEMSET'] if ENV['GEMSET']
6
- ActiveWrapper::Gems.activate :rspec
7
-
8
- require "#{$root}/lib/active_wrapper"
9
- require 'pp'
10
-
11
- Spec::Runner.configure do |config|
12
- end