tablature 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9a380696b917f7e478ea8823e9f9cd5fd0d1d77fbdfc540653d07fe7fc757922
4
+ data.tar.gz: 7bb88dc5ecc00fcba4c2fcb59a081bd89d183512bb9813287357e8bb54b4bdae
5
+ SHA512:
6
+ metadata.gz: c18d7668835780d2df9b692b53ae81f2fb81eb16d26c2f2a4bf45cfb77f519e9b5c7f9cbd591c6a246f29d321f3c77187fa52a471af796b50a3b1142cd8fb5bc
7
+ data.tar.gz: 3f4aa6a40d39775bf14a714bc025f4d0d50d5395ba8e4c3e10c6616401b00ab160f1d1cf29108fec628eb6ffff4f9a5ea91082e6282c95eba4d8e9a7679f9b77
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,7 @@
1
+ --color
2
+
3
+ --require spec_helper
4
+ --require rspec/instafail
5
+
6
+ --format RSpec::Instafail
7
+ --format progress
data/.rubocop.yml ADDED
@@ -0,0 +1,38 @@
1
+ Metrics/BlockLength:
2
+ Exclude:
3
+ - 'spec/**/*'
4
+
5
+ ClassAndModuleChildren:
6
+ Enabled: false
7
+
8
+ LineLength:
9
+ Max: 100
10
+
11
+ Style/FrozenStringLiteralComment:
12
+ Enabled: false
13
+
14
+ Style/Alias:
15
+ Enabled: false
16
+
17
+ Documentation:
18
+ Enabled: false
19
+
20
+ Style/SymbolArray:
21
+ Enabled: false
22
+
23
+ Style/WordArray:
24
+ Enabled: false
25
+
26
+ Style/NumericPredicate:
27
+ Enabled: false
28
+
29
+ Style/NegatedIf:
30
+ Enabled: false
31
+
32
+ Style/PercentLiteralDelimiters:
33
+ PreferredDelimiters:
34
+ '%w': '()'
35
+ '%i': '()'
36
+
37
+ Metrics/MethodLength:
38
+ Max: 15
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1 @@
1
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,99 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tablature (0.0.1)
5
+ activerecord (>= 5.0.0)
6
+ railties (>= 5.0.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionpack (5.2.1)
12
+ actionview (= 5.2.1)
13
+ activesupport (= 5.2.1)
14
+ rack (~> 2.0)
15
+ rack-test (>= 0.6.3)
16
+ rails-dom-testing (~> 2.0)
17
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
18
+ actionview (5.2.1)
19
+ activesupport (= 5.2.1)
20
+ builder (~> 3.1)
21
+ erubi (~> 1.4)
22
+ rails-dom-testing (~> 2.0)
23
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
24
+ activemodel (5.2.1)
25
+ activesupport (= 5.2.1)
26
+ activerecord (5.2.1)
27
+ activemodel (= 5.2.1)
28
+ activesupport (= 5.2.1)
29
+ arel (>= 9.0)
30
+ activesupport (5.2.1)
31
+ concurrent-ruby (~> 1.0, >= 1.0.2)
32
+ i18n (>= 0.7, < 2)
33
+ minitest (~> 5.1)
34
+ tzinfo (~> 1.1)
35
+ arel (9.0.0)
36
+ builder (3.2.3)
37
+ concurrent-ruby (1.1.3)
38
+ crass (1.0.4)
39
+ diff-lcs (1.3)
40
+ erubi (1.7.1)
41
+ i18n (1.1.1)
42
+ concurrent-ruby (~> 1.0)
43
+ loofah (2.2.2)
44
+ crass (~> 1.0.2)
45
+ nokogiri (>= 1.5.9)
46
+ method_source (0.9.0)
47
+ mini_portile2 (2.3.0)
48
+ minitest (5.11.3)
49
+ nokogiri (1.8.5)
50
+ mini_portile2 (~> 2.3.0)
51
+ pg (0.21.0)
52
+ rack (2.0.6)
53
+ rack-test (1.1.0)
54
+ rack (>= 1.0, < 3)
55
+ rails-dom-testing (2.0.3)
56
+ activesupport (>= 4.2.0)
57
+ nokogiri (>= 1.6)
58
+ rails-html-sanitizer (1.0.4)
59
+ loofah (~> 2.2, >= 2.2.2)
60
+ railties (5.2.1)
61
+ actionpack (= 5.2.1)
62
+ activesupport (= 5.2.1)
63
+ method_source
64
+ rake (>= 0.8.7)
65
+ thor (>= 0.19.0, < 2.0)
66
+ rake (10.5.0)
67
+ rspec (3.7.0)
68
+ rspec-core (~> 3.7.0)
69
+ rspec-expectations (~> 3.7.0)
70
+ rspec-mocks (~> 3.7.0)
71
+ rspec-core (3.7.1)
72
+ rspec-support (~> 3.7.0)
73
+ rspec-expectations (3.7.0)
74
+ diff-lcs (>= 1.2.0, < 2.0)
75
+ rspec-support (~> 3.7.0)
76
+ rspec-instafail (1.0.0)
77
+ rspec
78
+ rspec-mocks (3.7.0)
79
+ diff-lcs (>= 1.2.0, < 2.0)
80
+ rspec-support (~> 3.7.0)
81
+ rspec-support (3.7.1)
82
+ thor (0.20.0)
83
+ thread_safe (0.3.6)
84
+ tzinfo (1.2.5)
85
+ thread_safe (~> 0.1)
86
+
87
+ PLATFORMS
88
+ ruby
89
+
90
+ DEPENDENCIES
91
+ bundler (~> 1.16)
92
+ pg (~> 0.19)
93
+ rake (~> 10.0)
94
+ rspec (~> 3.0)
95
+ rspec-instafail
96
+ tablature!
97
+
98
+ BUNDLED WITH
99
+ 1.16.6
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Aliou Diallo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Tablature
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'tablature', github: 'aliou/tablature'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install tablature
18
+
19
+ ## Usage
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tablature.
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'tablature'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,35 @@
1
+ module Tablature
2
+ # Tablature database adapters.
3
+ #
4
+ # Tablature ships with a Postgres adapter only but can be extended with
5
+ # additional adapters. The {Adapters::Postgres} adapter provides the
6
+ # interface.
7
+ module Adapters
8
+ # An adapter for managing Postgres views.
9
+ #
10
+ # These methods are used interally by Tablature and are not intended for direct
11
+ # use. Methods that alter database schema are intended to be called via
12
+ # {Statements}.
13
+ #
14
+ # The methods are documented here for insight into specifics of how Tablature
15
+ # integrates with Postgres and the responsibilities of {Adapters}.
16
+ class Postgres
17
+ # Creates an instance of the Tablature Postgres adapter.
18
+ #
19
+ # This is the default adapter for Tablature. Configuring it via
20
+ # {Tablature.configure} is not required, but the example below shows how one
21
+ # would explicitly set it.
22
+ #
23
+ # @param [#connection] connectable An object that returns the connection
24
+ # for Tablature to use. Defaults to `ActiveRecord::Base`.
25
+ #
26
+ # @example
27
+ # Tablature.configure do |config|
28
+ # config.database = Tablature::Adapters::Postgres.new
29
+ # end
30
+ def initialize(connectable = ActiveRecord::Base)
31
+ @connectable = connectable
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,37 @@
1
+ module Tablature
2
+ class Configuration
3
+ # The Tablature database adapter instance to use when executing SQL.
4
+ #
5
+ # Defualts to an instance of {Adapters::Postgres}
6
+ # @return Tablature adapter
7
+ attr_accessor :database
8
+
9
+ def initialize
10
+ @database = Tablature::Adapters::Postgres.new
11
+ end
12
+ end
13
+
14
+ # @return [Tablature::Configuration] Tablature's current configuration
15
+ def self.configuration
16
+ @configuration ||= Configuration.new
17
+ end
18
+
19
+ # Set Tablature's configuration
20
+ #
21
+ # @param config [Tablature::Configuration]
22
+ def self.configuration=(config)
23
+ @configuration = config
24
+ end
25
+
26
+ # Modify Tablature's current configuration
27
+ #
28
+ # @yieldparam [Tablature::Configuration] config current Tablature config
29
+ # ```
30
+ # Tablature.configure do |config|
31
+ # config.database = Tablature::Adapters::Postgres.new
32
+ # end
33
+ # ```
34
+ def self.configure
35
+ yield configuration
36
+ end
37
+ end
@@ -0,0 +1,15 @@
1
+ require 'rails/railtie'
2
+
3
+ module Tablature
4
+ # Automatically initializes Tablature in the context of a Rails application when
5
+ # ActiveRecord is loaded.
6
+ #
7
+ # @see Tablature.load
8
+ class Railtie < Rails::Railtie
9
+ initializer 'tablature.load' do
10
+ ActiveSupport.on_load :active_record do
11
+ Tablature.load
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Tablature
2
+ VERSION = '0.0.1'.freeze
3
+ end
data/lib/tablature.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'tablature/adapters/postgres'
2
+ require 'tablature/configuration'
3
+ require 'tablature/railtie'
4
+ require 'tablature/version'
5
+
6
+ require 'active_record'
7
+
8
+ # Tablature adds methods to `ActiveRecord::Migration` to create and manage database
9
+ # views in Rails applications.
10
+ module Tablature
11
+ def self.load
12
+ end
13
+
14
+ def self.database
15
+ configuration.database
16
+ end
17
+ end
data/tablature.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'tablature/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'tablature'
7
+ spec.version = Tablature::VERSION
8
+ spec.authors = ['Aliou Diallo']
9
+ spec.email = ['code@aliou.me']
10
+
11
+ spec.summary = 'Rails + Postgres Partitions'
12
+ spec.description = 'Rails + Postgres Partitions'
13
+ spec.homepage = "https://aliou.me"
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = 'exe'
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.16'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.0'
26
+ spec.add_development_dependency 'rspec-instafail'
27
+ spec.add_development_dependency 'pg', '~> 0.19'
28
+
29
+ spec.add_dependency 'activerecord', '>= 5.0.0'
30
+ spec.add_dependency 'railties', '>= 5.0.0'
31
+ end
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tablature
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Aliou Diallo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-12-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-instafail
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: pg
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.19'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.19'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activerecord
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 5.0.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 5.0.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: railties
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 5.0.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 5.0.0
111
+ description: Rails + Postgres Partitions
112
+ email:
113
+ - code@aliou.me
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".rubocop.yml"
121
+ - ".travis.yml"
122
+ - Gemfile
123
+ - Gemfile.lock
124
+ - LICENSE.txt
125
+ - README.md
126
+ - Rakefile
127
+ - bin/console
128
+ - bin/setup
129
+ - lib/tablature.rb
130
+ - lib/tablature/adapters/postgres.rb
131
+ - lib/tablature/configuration.rb
132
+ - lib/tablature/railtie.rb
133
+ - lib/tablature/version.rb
134
+ - tablature.gemspec
135
+ homepage: https://aliou.me
136
+ licenses:
137
+ - MIT
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubyforge_project:
155
+ rubygems_version: 2.7.6
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: Rails + Postgres Partitions
159
+ test_files: []