sequelizer 0.0.3 → 0.0.4

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: 850cd00d16c6c1ffa076c95ac826cf48322ff678
4
- data.tar.gz: fa352fe12ffb3d6affc33402ea40f3492af5349a
3
+ metadata.gz: c861615a451de131f3bc64e53d8c49ed94f28478
4
+ data.tar.gz: 6b8a256ee95cb64202a6be965f8a53ac254eb53a
5
5
  SHA512:
6
- metadata.gz: 8401cda3328933d79d078bbc20143d9089db5faa638a476eae64ce3fc4bf50dfe7b08fe50c04de0e2e9cee4f0628f55371d4138d7d98dcaf9e816857c18a879d
7
- data.tar.gz: 57a62e5da3227d41f3825e5ba75aad372b9ebd54d8fa72e798e0c7de9ee53e1568909863a9e15e0825373768043059e9ad4ca41bce729be39d1c049d2e9b7f9d
6
+ metadata.gz: fcf9bd9a65a46f889495ccaab52b4eeae644a005ddeb597329ceb7a37ca2d0184a6d4b0289957f0e8dba8b62f22c8dfbd9b87fd331a5bbc2f3ece7172f0384fa
7
+ data.tar.gz: b4e6facc90132c5d95f1a3c5863cbc207f7e448bf47f383df04d5b27471048e00be7dedb61df052fcc370cc99571673764afa8a80a47d79c20aa445e1dba1aac
data/CHANGELOG.md CHANGED
@@ -1,6 +1,21 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 0.0.4 - 2014-08-18
5
+
6
+ ### Added
7
+ - `init_env` command to bin/sequelizer
8
+ - Prefer `search_path` over `schema_search_path` option
9
+
10
+ ### Deprecated
11
+ - Nothing.
12
+
13
+ ### Removed
14
+ - Nothing.
15
+
16
+ ### Fixed
17
+ - Nothing.
18
+
4
19
  ## 0.0.3 - 2014-07-10
5
20
 
6
21
  ### Added
data/lib/sequelizer.rb CHANGED
@@ -21,11 +21,6 @@ module Sequelizer
21
21
  # If no options are provided, options are read from
22
22
  # config/database.yml or from .env or from environment variables.
23
23
  def new_db(options = nil)
24
- cm = ConnectionMaker.new(options)
25
- conn = cm.connection
26
- conn.define_singleton_method(:sequelizer_options) do
27
- cm.options
28
- end
29
- conn
24
+ ConnectionMaker.new(options).connection
30
25
  end
31
26
  end
@@ -11,9 +11,53 @@ module Sequelizer
11
11
  GemfileModifier.new(options).modify
12
12
  end
13
13
 
14
+ desc 'init_env', 'creates a .env file with the parameters listed'
15
+ option :adapter,
16
+ aliases: :a,
17
+ desc: 'adapter for database'
18
+ option :host,
19
+ aliases: :h,
20
+ banner: 'localhost',
21
+ desc: 'host for database'
22
+ option :username,
23
+ aliases: :u,
24
+ desc: 'username for database'
25
+ option :password,
26
+ aliases: :P,
27
+ desc: 'password for database'
28
+ option :port,
29
+ aliases: :p,
30
+ type: :numeric,
31
+ banner: '5432',
32
+ desc: 'port for database'
33
+ option :database,
34
+ aliases: :d,
35
+ desc: 'database for database'
36
+ option :search_path,
37
+ aliases: :s,
38
+ desc: 'schema for database (PostgreSQL only)'
39
+ def init_env
40
+ if File.exist?('.env')
41
+ puts ".env already exists! I'm too cowardly to overwrite it!"
42
+ puts "Here's what I would have put in there:"
43
+ puts make_env(options)
44
+ exit(1)
45
+ end
46
+ File.open('.env', 'w') do |file|
47
+ file.puts make_env(options)
48
+ end
49
+ end
50
+
14
51
  desc 'config', 'prints out the connection parameters'
15
52
  def config
16
53
  pp Options.new.to_hash
17
54
  end
55
+
56
+ private
57
+ def make_env(options)
58
+ options.map do |key, value|
59
+ "SEQUELIZER_#{key.upcase}=#{value}"
60
+ end.join("\n")
61
+ end
18
62
  end
19
63
  end
@@ -22,7 +22,12 @@ module Sequelizer
22
22
 
23
23
  # Returns a Sequel connection to the database
24
24
  def connection
25
- Sequel.connect(options.to_hash)
25
+ conn = Sequel.connect(options.to_hash)
26
+ cm = self
27
+ conn.define_singleton_method(:sequelizer_options) do
28
+ cm.options
29
+ end
30
+ conn
26
31
  end
27
32
  end
28
33
  end
@@ -31,7 +31,7 @@ module Sequelizer
31
31
 
32
32
  if sequelizer_options[:adapter] =~ /^postgres/
33
33
  sequelizer_options[:adapter] = 'postgres'
34
- paths = %w(schema_search_path search_path schema).map { |key| sequelizer_options.delete(key) }.compact
34
+ paths = %w(search_path schema_search_path schema).map { |key| sequelizer_options.delete(key) }.compact
35
35
 
36
36
  unless paths.empty?
37
37
  sequelizer_options[:schema_search_path] = paths.first
@@ -1,4 +1,4 @@
1
1
  module Sequelizer
2
2
  # Version for the gem
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
@@ -29,6 +29,12 @@ class TestOptions < Minitest::Test
29
29
  assert_equal('path', options.schema_search_path)
30
30
  end
31
31
 
32
+ def test_prefers_schema_path_over_schema_search_path
33
+ options = Sequelizer::Options.new(Sequelizer::OptionsHash.new(adapter: 'postgres', search_path: 'path', schema_search_path: 'path2'))
34
+
35
+ assert_equal('path', options.schema_search_path)
36
+ end
37
+
32
38
  def test_returns_a_hash_even_if_given_nil
33
39
  options = Sequelizer::Options.new
34
40
  assert_equal({}, options.to_hash)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequelizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Duryea
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-10 00:00:00.000000000 Z
11
+ date: 2014-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler