communard 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b9d35465b96eb5d58be0796c018ee8621dc2d139
4
- data.tar.gz: 262fddbd090945bd223795f180b3cde77cfb7f75
3
+ metadata.gz: 803308ca6f5424ff74123dcbb892f6ef6b76ecd0
4
+ data.tar.gz: 310a953d2846d2f7f0b7f0188ae69c84635260d9
5
5
  SHA512:
6
- metadata.gz: b761f87f3f14335888116e531945b8b400a0f87d586c768058ce8778b3e6ec146b515e3f6688708ec31dce614fff11147d3adc0903f4f0e6022f08c5dcf9963c
7
- data.tar.gz: 0007179282297452070dc6a6283290a7bb0bfa2a65d94a33705326e1f30990bc931520aa235a778323062383e97f1cdb7a3407e4109ce31877812b091c5304e7
6
+ metadata.gz: bcd25b010ae79cc52aa3c50cea57d74072d924f68b3d84873d7399396052305d67beacf728d920e788ea7c0ca11bcd870cb6d036b5994938dc28e3eaa85f0f3d
7
+ data.tar.gz: e5c9d2270735b60a121e5057215f7d359268472398e16f4101bd605c09bb509f64162d9f1cedfaba4fe216be5f9b6b37befe056383a9148925287b5e66ca7223
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --color
2
+ --format documentation
3
+ --order random
4
+ --require spec_helper
data/Rakefile CHANGED
@@ -1,2 +1,13 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ rescue LoadError
7
+ task :spec do
8
+ puts "RSpec not installed"
9
+ exit 1
10
+ end
11
+ end
12
+
13
+ task :default => :spec
data/communard.gemspec CHANGED
@@ -22,4 +22,9 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.6"
24
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "sqlite3"
27
+ spec.add_development_dependency "pg"
28
+ spec.add_development_dependency "mysql2"
29
+ spec.add_development_dependency "aruba"
25
30
  end
@@ -1,6 +1,3 @@
1
- require "logger"
2
- require "pathname"
3
-
4
1
  module Communard
5
2
  class Configuration
6
3
 
@@ -1,5 +1,3 @@
1
- require "sequel"
2
-
3
1
  module Communard
4
2
  class Context
5
3
 
@@ -32,7 +30,9 @@ module Communard
32
30
  end
33
31
 
34
32
  def create_database(env: environment)
35
- run_without_database("CREATE DATABASE %{database_name}", env: env)
33
+ unless adapter(env: env) == "sqlite"
34
+ run_without_database("CREATE DATABASE %{database_name}", env: env)
35
+ end
36
36
  rescue Sequel::DatabaseError => error
37
37
  if /database (.*) already exists/ === error.message
38
38
  loggers.each { |logger| logger.info "Database #{$1} already exists, which is fine." }
@@ -43,7 +43,14 @@ module Communard
43
43
 
44
44
  def drop_database(env: environment)
45
45
  fail ArgumentError, "Don't drop the production database, you monkey!" if env.to_s == "production"
46
- run_without_database("DROP DATABASE IF EXISTS %{database_name}", env: env)
46
+ if adapter(env: env) == "sqlite"
47
+ file = options(env: env).fetch("database")
48
+ if File.exist?(file)
49
+ File.rm(file)
50
+ end
51
+ else
52
+ run_without_database("DROP DATABASE IF EXISTS %{database_name}", env: env)
53
+ end
47
54
  end
48
55
 
49
56
  def migrate(target: nil, env: environment)
@@ -87,7 +94,7 @@ module Communard
87
94
 
88
95
  private
89
96
 
90
- def maintenance(env: env)
97
+ def maintenance(env: environment)
91
98
  Maintenance.new(connection: connect(options(env: env)), root: root)
92
99
  end
93
100
 
@@ -103,5 +110,9 @@ module Communard
103
110
  configuration.loggers
104
111
  end
105
112
 
113
+ def adapter(env: environment)
114
+ options(env: env).fetch("adapter").to_s
115
+ end
116
+
106
117
  end
107
118
  end
@@ -1,3 +1,3 @@
1
1
  module Communard
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/communard.rb CHANGED
@@ -1,3 +1,7 @@
1
+ require "sequel"
2
+ require "logger"
3
+ require "pathname"
4
+
1
5
  require "communard/version"
2
6
  require "communard/maintenance"
3
7
  require "communard/configuration"
@@ -0,0 +1,94 @@
1
+ require "yaml"
2
+
3
+ RSpec.describe "Integration", type: :aruba do
4
+
5
+ example "SQLite" do
6
+ run_tests(
7
+ "adapter" => "sqlite",
8
+ "database" => "db/test.sqlite3",
9
+ "pool" => 5,
10
+ "timeout" => 5000,
11
+ )
12
+ end
13
+
14
+ example "PostgreSQL" do
15
+ run_tests(
16
+ "adapter" => "postgres",
17
+ "database" => "communard_test",
18
+ "pool" => 5,
19
+ "timeout" => 5000,
20
+ )
21
+ end
22
+
23
+ example "MySQL" do
24
+ run_tests(
25
+ "adapter" => "mysql2",
26
+ "database" => "communard_test",
27
+ "username" => "root",
28
+ "pool" => 5,
29
+ "timeout" => 5000,
30
+ )
31
+ end
32
+
33
+
34
+ def run_tests(database_config)
35
+
36
+ write_file "config/database.yml", { "development" => database_config }.to_yaml
37
+
38
+ write_file "Rakefile", <<-FILE.gsub(/^\s{6}/, "")
39
+ $LOAD_PATH.unshift(File.expand_path("../../../lib", __FILE__))
40
+ require "yaml"
41
+ require "communard/rake"
42
+ Communard::Rake.add_tasks
43
+ FILE
44
+
45
+ run_simple "bundle exec communard --generate-migration create_posts"
46
+
47
+ file = Dir[absolute_path("db/migrate/*_create_posts.rb")].first
48
+
49
+ expect(File.read(file)).to eq <<-FILE.gsub(/^\s{6}/, "").chomp
50
+ Sequel.migration do
51
+ change do
52
+ end
53
+ end
54
+ FILE
55
+
56
+ write_file file, <<-FILE.gsub(/^\s{6}/, "")
57
+ Sequel.migration do
58
+ change do
59
+ create_table :posts do
60
+ primary_key :id
61
+ String :name
62
+ end
63
+ end
64
+ end
65
+ FILE
66
+
67
+ run_simple "rake db:drop"
68
+
69
+ run_simple "rake db:create"
70
+
71
+ run_simple "rake db:migrate"
72
+
73
+ write_file "app.rb", <<-FILE.gsub(/^\s{6}/, "")
74
+ $LOAD_PATH.unshift(File.expand_path("../../../lib", __FILE__))
75
+ require "yaml"
76
+ require "communard"
77
+
78
+ db = Communard.connect
79
+ posts = db[:posts]
80
+
81
+ 4.times do
82
+ posts.insert(name: "hello world")
83
+ end
84
+
85
+ puts "Post count: '\#{posts.count}'"
86
+ FILE
87
+
88
+ run_simple "ruby app.rb"
89
+
90
+ assert_partial_output("Post count: '4'", all_stdout)
91
+ end
92
+
93
+
94
+ end
@@ -0,0 +1,22 @@
1
+ require 'aruba/api'
2
+ require 'aruba/reporting'
3
+
4
+ RSpec.configure do |config|
5
+ config.disable_monkey_patching!
6
+ config.include Aruba::Api, type: :aruba
7
+
8
+ config.before :each do
9
+ next unless self.class.include?(Aruba::Api)
10
+ restore_env
11
+ clean_current_dir
12
+
13
+ if ENV["DEBUG"] == "true"
14
+ @announce_stdout = true
15
+ @announce_stderr = true
16
+ @announce_cmd = true
17
+ @announce_dir = true
18
+ @announce_env = true
19
+ end
20
+ end
21
+
22
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: communard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - iain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-13 00:00:00.000000000 Z
11
+ date: 2015-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -52,6 +52,76 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pg
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: mysql2
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: aruba
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
55
125
  description: Adds some conventions from ActiveRecord to Sequel.
56
126
  email:
57
127
  - iain@iain.nl
@@ -61,6 +131,7 @@ extensions: []
61
131
  extra_rdoc_files: []
62
132
  files:
63
133
  - ".gitignore"
134
+ - ".rspec"
64
135
  - Gemfile
65
136
  - LICENSE.txt
66
137
  - README.md
@@ -73,6 +144,8 @@ files:
73
144
  - lib/communard/maintenance.rb
74
145
  - lib/communard/rake.rb
75
146
  - lib/communard/version.rb
147
+ - spec/integration_spec.rb
148
+ - spec/spec_helper.rb
76
149
  homepage: https://github.com/yourkarma/communard
77
150
  licenses:
78
151
  - MIT
@@ -93,9 +166,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
166
  version: '0'
94
167
  requirements: []
95
168
  rubyforge_project:
96
- rubygems_version: 2.2.2
169
+ rubygems_version: 2.4.5
97
170
  signing_key:
98
171
  specification_version: 4
99
172
  summary: Adds some conventions from ActiveRecord to Sequel.
100
- test_files: []
101
- has_rdoc:
173
+ test_files:
174
+ - spec/integration_spec.rb
175
+ - spec/spec_helper.rb