osmosis 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -12
- data/lib/osmosis/command.rb +49 -0
- data/lib/osmosis/railtie.rb +14 -0
- data/lib/osmosis/tasks/db/restore.rake +7 -0
- data/lib/osmosis/version.rb +1 -1
- data/lib/osmosis.rb +4 -1
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e26e371d8fc36471c8162c5f15e996bfa801a35009a49ae5a23871582b55a1c5
|
4
|
+
data.tar.gz: 8a087b4531e00b93febd10fcd44684239c4876dee89bbd9d60fa9e4e6d5babe4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d8e6d0b9b2fdd4bd7a577aeee586e803310a72ff2a73cc7d4f327fd29f575a61d2553dc017c46b0f1de4f8102bafa65235226682b7b0294130bd195839b3b47
|
7
|
+
data.tar.gz: 2615c4c7a1e7c442a32f779612c29f6b46fb2e419892fee63f90abcc6f100ee78c4687914d3197a03a7e418bfd6dc451cbab20e269f7134ce4bd61650c1f6df6
|
data/README.md
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# Osmosis
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/osmosis`. To experiment with that code, run `bin/console` for an interactive prompt.
|
3
|
+
A versatile database utility library that streamlines common tasks like exporting and importing data.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
-
|
11
7
|
Install the gem and add to the application's Gemfile by executing:
|
12
8
|
|
13
|
-
$ bundle add
|
9
|
+
$ bundle add osmosis
|
14
10
|
|
15
11
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
12
|
|
17
|
-
$ gem install
|
13
|
+
$ gem install osmosis
|
18
14
|
|
19
15
|
## Usage
|
20
16
|
|
21
|
-
|
17
|
+
Osmosis provides you with different rake tasks that simplify the management of your database.
|
18
|
+
|
19
|
+
### Database restore
|
20
|
+
|
21
|
+
|
22
22
|
|
23
23
|
## Development
|
24
24
|
|
@@ -26,10 +26,6 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
26
26
|
|
27
27
|
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
28
28
|
|
29
|
-
## Release
|
30
|
-
|
31
|
-
To release the gem to rubygems.org, run `rake release`, and enter your credentials when asked.
|
32
|
-
|
33
29
|
## Contributing
|
34
30
|
|
35
31
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/osmosis.
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module Osmosis
|
4
|
+
class Command
|
5
|
+
def self.restore(argv)
|
6
|
+
files = Dir.glob("./*.dump")
|
7
|
+
case files.size
|
8
|
+
when 0
|
9
|
+
return [
|
10
|
+
OpenStruct.new(type: :print, command: "No backups found for *.dump")
|
11
|
+
]
|
12
|
+
when 1
|
13
|
+
file = files.first
|
14
|
+
host = ActiveRecord::Base.connection_db_config.host
|
15
|
+
database = ActiveRecord::Base.connection_db_config.database
|
16
|
+
username = ActiveRecord::Base.connection_db_config.configuration_hash[:username]
|
17
|
+
password = ActiveRecord::Base.connection_db_config.configuration_hash[:password]
|
18
|
+
cmd = "PGPASSWORD=#{password} pg_restore -U #{username} -h #{host} -d #{database} -cO --if-exists -w < #{file}"
|
19
|
+
Rake::Task["db:drop"].invoke
|
20
|
+
Rake::Task["db:create"].invoke
|
21
|
+
return [
|
22
|
+
OpenStruct.new(type: :rake, command: 'db:drop'),
|
23
|
+
OpenStruct.new(type: :rake, command: 'db:create'),
|
24
|
+
OpenStruct.new(type: :cmd, command: cmd),
|
25
|
+
OpenStruct.new(type: :print, command: "Restored database '#{database}'"),
|
26
|
+
]
|
27
|
+
else
|
28
|
+
return [
|
29
|
+
OpenStruct.new(type: :print, command: "Too many backups found for *.dump:"),
|
30
|
+
OpenStruct.new(type: :print, command: ' ' + files.join("\n ")),
|
31
|
+
]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.run(commands)
|
36
|
+
commands.each do |cmd|
|
37
|
+
if cmd.type == :rake
|
38
|
+
Rake::Task[cmd.command].invoke
|
39
|
+
elsif cmd.type == :cmd
|
40
|
+
system cmd.command
|
41
|
+
elsif cmd.type == :print
|
42
|
+
puts cmd.command
|
43
|
+
else
|
44
|
+
raise StandardError, "Unknown command type #{cmd.type}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/osmosis/version.rb
CHANGED
data/lib/osmosis.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "osmosis/version"
|
4
|
+
require_relative "osmosis/command"
|
5
|
+
require_relative "osmosis/railtie"
|
4
6
|
|
5
7
|
module Osmosis
|
6
8
|
class Error < StandardError; end
|
7
|
-
|
9
|
+
|
10
|
+
require 'osmosis/railtie' if defined?(Rails)
|
8
11
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osmosis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas_Skywalker
|
@@ -9,7 +9,21 @@ autorequire:
|
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2024-08-20 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
13
27
|
description: This powerful database utility library simplifies and automates common
|
14
28
|
database tasks, including exports, imports, and data migrations. With its intuitive
|
15
29
|
interface and robust feature set, it enables developers to manage databases more
|
@@ -26,6 +40,9 @@ files:
|
|
26
40
|
- README.md
|
27
41
|
- Rakefile
|
28
42
|
- lib/osmosis.rb
|
43
|
+
- lib/osmosis/command.rb
|
44
|
+
- lib/osmosis/railtie.rb
|
45
|
+
- lib/osmosis/tasks/db/restore.rake
|
29
46
|
- lib/osmosis/version.rb
|
30
47
|
- sig/osmosis.rbs
|
31
48
|
homepage: https://github.com/code-fabrik/osmosis
|