guidebook 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/guidebook.rb +68 -0
  3. metadata +104 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2aa870f188d97ef1ce2679eeb85b95c01e1ada42f1a6dab26b2991aa115545c6
4
+ data.tar.gz: b0c53f7b35ba1cc6bc221a6368f7c4c7516f9a9cd7c31e42270c8aad4cf0cb2a
5
+ SHA512:
6
+ metadata.gz: b5128fb53c201803c566409d1fc79255524ca0f0f1bd803cfc2834bb23e98afea444976b100342d54ca02025626274373eaf2dfb7e90981df9cb6394f153cd3a
7
+ data.tar.gz: e9f74b571e412bcd2ac06d9bbc552d3af44587a1f3d1e5f93f99940c54732e9cfd3e06828a9ff8b8986ef87294e9eaf814fb8c9f6eb383d2a03a276ba153450b
data/lib/guidebook.rb ADDED
@@ -0,0 +1,68 @@
1
+ # Begin Guide Book Plugin work...
2
+ begin
3
+ require 'active_record'
4
+ require 'sqlite3'
5
+ require 'standalone_migrations'
6
+ rescue LoadError => e
7
+ raise MissingLibrary, "ActiveRecord could not be loaded (is it installed?): #{e.message}"
8
+ end
9
+
10
+ $AR_TO_BASE = %{
11
+ Base = ActiveRecord::Base unless const_defined? :Base
12
+ }
13
+
14
+ module Camping
15
+ module GuideBook
16
+
17
+ # ActiveRecordCloser is middleware that closes the connection to the database.
18
+ class ActiveRecordCloser
19
+ def initialize(app)
20
+ @app = app
21
+ end
22
+
23
+ def call(env)
24
+ @app.call(env)
25
+ ensure
26
+ conn = ActiveRecord::Base.connection
27
+ conn.close if conn.respond_to?(:close)
28
+ end
29
+ end
30
+
31
+ def self.setup(app, *a, &block)
32
+ app.use ActiveRecordCloser
33
+
34
+ # Puts the Base Class into your apps' Models module.
35
+ app::Models.module_eval $AR_TO_BASE
36
+
37
+ # The defaults are all for localhosting.
38
+ db_host = app.options[:db_host] ||= 'localhost'
39
+ adapter = app.options[:adapter] ||= 'sqlite3'
40
+ database = app.options[:database] ||= 'camping'
41
+ pool = app.options[:database_pool] ||= 5
42
+
43
+ # Establishes the database connection.
44
+ # Because we're doing all of this in the setup method
45
+ # The connection will take place when this gear is packed.
46
+ app::Models::Base.establish_connection(
47
+ :adapter => adapter,
48
+ :database => database,
49
+ :host => db_host,
50
+ :pool => pool
51
+ )
52
+ end
53
+
54
+ # TO DO:
55
+ # [] Map migration commands to Rake automatically somehow
56
+ # [] Map Generators to rake somehow too.
57
+ # [] Have a default spot that settings are grabbed from
58
+ # [] Have a setting where a database connection string is grabbed by default
59
+
60
+ # Notes:
61
+ # It would be cool If we could map Active Record generators to rake tasks
62
+ # automatically from Plugins.
63
+ #
64
+ # Camping needs a place to mount Command line arguments automagically.
65
+ # migrations is something that needs to be universal and good and stuff.
66
+
67
+ end
68
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guidebook
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Karl Oscar Weber
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-08-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: active_record
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '7.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 7.0.3.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '7.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 7.0.3.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: sqlite3
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.4'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.4.4
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.4'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.4.4
53
+ - !ruby/object:Gem::Dependency
54
+ name: standalone-migrations
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '7.1'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 7.1.0
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '7.1'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 7.1.0
73
+ description: Want models? Want migrations? GuideBook is a Camping Gear to give you
74
+ Database persistence and models through ActiveRecord.
75
+ email: me@kow.fm
76
+ executables: []
77
+ extensions: []
78
+ extra_rdoc_files: []
79
+ files:
80
+ - lib/guidebook.rb
81
+ homepage: https://rubygems.org/gems/guidebook
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubygems_version: 3.3.7
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Active Record in your Camping app
104
+ test_files: []