tamarama 0.1.0

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
+ SHA1:
3
+ metadata.gz: 3da72114621dc24d9dea1d24356f8fa3bf717b8e
4
+ data.tar.gz: 5a82a4dd707a51e7a7b2b16178ced90bfbd5a026
5
+ SHA512:
6
+ metadata.gz: cc38762bf571ef53ff669a6747edaf154bbab72a3b005c2ff38d629f2ed964cf4a86ae6cb43330a87f60a2b94afebf30d987428a99f1d337b995f922d690bf3b
7
+ data.tar.gz: 48923f21322029ae46d3da87a91ba1f6c428278e8c91677bf9e4f025ba418ca3b4f703740bc640749628c4ee0a3a6e66ba01a495e5f22f79d005e4920f66ffc5
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ .env*
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # gem 'puma'
4
+ gem "rake"
5
+ gem 'sinatra'
6
+ gem 'pg'
7
+ gem "reform"
8
+ gem "trailblazer"
9
+ gem "trailblazer-loader"
10
+ gem "sequel"
11
+ gem "dry-validation"
12
+
13
+ group :development, :test do
14
+ gem 'dotenv'
15
+ gem "rack-test"
16
+ # gem "match_json"
17
+ gem 'database_cleaner'
18
+
19
+ gem "minitest"
20
+ end
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ ## Configuration
2
+
3
+ Tamarama uses the `dotenv` gem for managing environment variables such as database connection strings.
4
+
5
+ For you, this boils down to providing `.env.development` and `.env.test` files in the project root. Check out `example.env.test` for an example of what such a config file might look like.
6
+
7
+ ```ruby
8
+ # .env.test
9
+ DATABASE_URL="postgres://user:password@localhost/myblog_test"
10
+ ```
11
+
12
+ ## Migrations
13
+
14
+ ```
15
+ RACK_ENV=test rake db:migrate
16
+ RACK_ENV=test rake db:migrate[0]
17
+ ```
18
+
19
+ ## Testing Connection
20
+
21
+ ```
22
+ RACK_ENV=test rake db:debug
23
+ ```
data/Rakefile ADDED
File without changes
data/config.ru ADDED
@@ -0,0 +1,5 @@
1
+ require "rack"
2
+
3
+
4
+ require_relative "boot"
5
+ run Application
data/example.env.test ADDED
@@ -0,0 +1 @@
1
+ DATABASE_URL="postgres://nick:stawpmockingmay@localhost/exp_test"
@@ -0,0 +1,15 @@
1
+ module Tamarama
2
+ module DB
3
+ module Sequel
4
+ # Keeps the connection up on a infrequently visited website, but makes it slower.
5
+ module DatabaseValidator
6
+ def self.call(database_handle)
7
+ # via a middleware: https://gist.github.com/jacaetevha/3801154
8
+ database_handle.extension(:connection_validator)
9
+ database_handle.pool.connection_validation_timeout = -1 # apparently, this is very slow and shouldn't be really done.
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+
@@ -0,0 +1,22 @@
1
+ require "sequel"
2
+
3
+ module Tamarama
4
+ module DB
5
+ module Sequel
6
+ def self.call()
7
+ ::Sequel::Model.strict_param_setting = false
8
+ ::Sequel::Database.extension :pg_json
9
+ ::Sequel.extension :pg_json_ops
10
+
11
+ environment = ENV["RACK_ENV"]
12
+ connection_string = ENV["DATABASE_URL"]
13
+ raise "Missing Connection string" if connection_string.nil?
14
+
15
+ ::Sequel.connect(connection_string)
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ # Sequel::Database.extension :"uuid"
22
+ # Sequel::Model.plugin :timestamps
@@ -0,0 +1,7 @@
1
+ environment = ENV['RACK_ENV'] ||= 'development'
2
+
3
+ require 'dotenv'
4
+ Dotenv.load(".env.#{environment}")
5
+
6
+ require 'bundler'
7
+ Bundler.require :default, environment
@@ -0,0 +1,50 @@
1
+ # database tasks
2
+ require "dotenv/tasks"
3
+
4
+ namespace :db do
5
+ desc "Run migrations up to specified version or to latest."
6
+ task :migrate, [:version] => [:dotenv] do |_, args|
7
+ require_relative "env"
8
+ require_relative "db/sequel"
9
+ # DISCUSS: this should be `require_relative "application"` if you want to load the entire stack for migrations.
10
+
11
+ require "sequel/extensions/migration"
12
+
13
+ version = args[:version]
14
+ migrations_directory = "migrations"
15
+
16
+ db = DB.connect
17
+
18
+ message = if args[:version].nil?
19
+ Sequel::Migrator.run(db, migrations_directory)
20
+ "Migrated to latest"
21
+ else
22
+ Sequel::Migrator.run(db, migrations_directory, target: version.to_i)
23
+ "Migrated to version #{version}"
24
+ end
25
+
26
+ puts message# if environment != "test"
27
+ end
28
+
29
+ task :debug => [:dotenv] do
30
+ require "application"
31
+
32
+ db = DB.connect
33
+ puts "=== DB: #{db.uri}"
34
+ puts db.schema(:users).inspect
35
+ # puts User::Persistence.db_schema
36
+ # puts User::Persistence.dataset.all.inspect
37
+ end
38
+ end
39
+
40
+ task :default => :test
41
+ require "rake/testtask"
42
+
43
+ # the test task will require all test files, which in turn require test_helper.rb which in turn
44
+ # requires application.rb.
45
+ desc 'Default: run tests.'
46
+ Rake::TestTask.new(:test) do |test|
47
+ test.libs << 'test'
48
+ test.pattern = 'test/**/*_test.rb'
49
+ test.verbose = true
50
+ end
@@ -0,0 +1,3 @@
1
+ module Tamarama
2
+ VERSION = "0.1.0"
3
+ end
data/lib/tamarama.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Tamarama
2
+ end
3
+
4
+ # http://blog.andrewvc.com/quickly-constantize/
5
+ # "Net::HTTP".split('::').inject(Object) {|memo,name| memo = memo.const_get(name); memo}
data/tamarama.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'tamarama/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "tamarama"
7
+ spec.version = Tamarama::VERSION
8
+ spec.authors = ["Nick Sutterer"]
9
+ spec.email = ["apotonick@gmail.com"]
10
+ spec.summary = %q{The simplest web stack.}
11
+ spec.homepage = "http://trailblazer.to"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "rake"
20
+ spec.add_development_dependency "minitest"
21
+
22
+ spec.required_ruby_version = '>= 2.0.0'
23
+ end
@@ -0,0 +1,14 @@
1
+ ENV['RACK_ENV'] = 'test'
2
+ require "minitest/autorun"
3
+
4
+
5
+ require_relative "../stack/env"
6
+ require_relative "../stack/db"
7
+ DB.connect
8
+
9
+ require_relative "../application"
10
+
11
+ require 'rack/test'
12
+ Dir['./test/support/*.rb'].each { |file| require file }
13
+
14
+ # require "match_json"
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tamarama
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nick Sutterer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email:
43
+ - apotonick@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - README.md
51
+ - Rakefile
52
+ - config.ru
53
+ - example.env.test
54
+ - lib/tamarama.rb
55
+ - lib/tamarama/db/sequel.rb
56
+ - lib/tamarama/db/sequel/database_validator.rb
57
+ - lib/tamarama/env.rb
58
+ - lib/tamarama/rake_task.rb
59
+ - lib/tamarama/version.rb
60
+ - tamarama.gemspec
61
+ - test/test_helper.rb
62
+ homepage: http://trailblazer.to
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 2.0.0
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.6.8
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: The simplest web stack.
86
+ test_files:
87
+ - test/test_helper.rb