openbox 0.1.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: 21387e3425ced629a43bb32997f2c5f8f9cd10647ce9fc75c6353afa53d2c465
4
- data.tar.gz: 565964314f2846373e9e94dcf4bacf096cb0918f42dcf195993fb2b4b5492932
3
+ metadata.gz: 905c948832fb826dd639688aafec9e39fc2527ed047bb35ee1a8871a198acc31
4
+ data.tar.gz: b3568ee2c518336993a421abbd24c841c1ce776792a98e62c124123e57d37de9
5
5
  SHA512:
6
- metadata.gz: c4214b43a54cab99c7331f92082c9716cd2f706081de4513ae57887b3e2fc05478ffa0eb80c92c3365b8710a2ac91a8daa9ae294ca423a6385ae1b9330a7b8c5
7
- data.tar.gz: 306cf0aa7af340df144ed52e9bd85cfe55276397307d54ce77190e7c33aafd2bdcadc3dd03f94813cb5cfd51c908d93dfc0d46dcb90e15cbb91ea78c2a481fa8
6
+ metadata.gz: 372e2b1efd3dcd11e33798d5c094be2348c7e1553a5f304d571178a77370d63360b089f0051dc69b3745fead40093a0d32175893b7f41fc64a6f6e379a5831ce
7
+ data.tar.gz: 60156481a01491f8ba3aaa3612cb4c573f643dd4e13c8922e5d9b8c9639c7331061582aead5071fd762d6c9fa7f627dd3a137bde626ffb5b942b0c569f51d313
data/.rubocop.yml CHANGED
@@ -12,3 +12,7 @@
12
12
  AllCops:
13
13
  TargetRubyVersion: 2.5
14
14
  NewCops: enable
15
+
16
+ Metrics/BlockLength:
17
+ Exclude:
18
+ - spec/**/*_spec.rb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openbox (0.1.0)
4
+ openbox (0.2.0)
5
5
  thor (~> 1.0)
6
6
 
7
7
  GEM
data/exe/openbox CHANGED
@@ -4,4 +4,4 @@
4
4
 
5
5
  require 'openbox'
6
6
 
7
- Openbox::Command.start(ARGV)
7
+ Openbox::Entrypoint.start(ARGV)
@@ -1,24 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'thor'
4
- require 'openbox/runtime'
5
4
 
6
5
  module Openbox
7
- # The Container Entrypoint
6
+ # The base command of openbox
8
7
  #
9
8
  # @since 0.1.0
10
- class Command < Thor
9
+ class Command < Thor::Group
10
+ # Execute command
11
+ #
11
12
  # @since 0.1.0
12
- desc 'server', 'Start Application Server'
13
- def server
14
- Openbox.database.ensure_connection!
15
- return exec('bundle exec rails server') if Openbox.runtime.rails?
16
-
17
- exec('bundle exec rackup -o 0.0.0.0')
18
- end
19
-
20
- def self.exit_on_failure?
21
- true
13
+ def execute
14
+ raise NotImplementedError
22
15
  end
23
16
  end
24
17
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openbox
4
+ # :nodoc:
5
+ module Commands
6
+ # The Console Command
7
+ #
8
+ # @since 0.1.0
9
+ class Console < Openbox::Command
10
+ # Run rails console
11
+ #
12
+ # @since 0.1.0
13
+ def execute
14
+ Openbox.database.ensure_connection!
15
+ exec('bundle exec rails console')
16
+ end
17
+ end
18
+
19
+ Openbox::Entrypoint.register(Console, 'console', 'console', 'Run rails console') if Openbox.runtime.has?('rails')
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openbox
4
+ # :nodoc:
5
+ module Commands
6
+ # The Migrate Command
7
+ #
8
+ # @since 0.1.0
9
+ class Migrate < Openbox::Command
10
+ # Run rails migrate
11
+ #
12
+ # @since 0.1.0
13
+ def execute
14
+ Openbox.database.ensure_connection!
15
+ exec('bundle exec rails db:migrate')
16
+ end
17
+ end
18
+
19
+ Openbox::Entrypoint.register(Migrate, 'migrate', 'migrate', 'Run rails migrate') if Openbox.runtime.has?('rails')
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openbox
4
+ # :nodoc:
5
+ module Commands
6
+ # The Rake Command
7
+ #
8
+ # @since 0.1.0
9
+ class Rake < Openbox::Command
10
+ # Run rake task with database connection check
11
+ #
12
+ # @since 0.1.0
13
+ def execute
14
+ Openbox.database.ensure_connection!
15
+ exec("bundle exec rake #{args}")
16
+ end
17
+ end
18
+
19
+ Openbox::Entrypoint.register(Rake, 'rake', 'rake', 'Run rake task') if Openbox.runtime.has?('rails', 'rake')
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openbox
4
+ # :nodoc:
5
+ module Commands
6
+ # The Seed Command
7
+ #
8
+ # @since 0.1.0
9
+ class Seed < Openbox::Command
10
+ # Run rails seed
11
+ #
12
+ # @since 0.1.0
13
+ def execute
14
+ Openbox.database.ensure_connection!
15
+ exec('bundle exec rails db:seed')
16
+ end
17
+ end
18
+
19
+ Openbox::Entrypoint.register(Seed, 'seed', 'seed', 'Run rails seed') if Openbox.runtime.has?('rails')
20
+ end
21
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openbox
4
+ # :nodoc:
5
+ module Commands
6
+ # The Server Command
7
+ #
8
+ # @since 0.1.0
9
+ class Server < Openbox::Command
10
+ # Run Application Server
11
+ #
12
+ # @since 0.1.0
13
+ def execute
14
+ Openbox.database.ensure_connection!
15
+ return exec('bundle exec rails server') if Openbox.runtime.rails?
16
+
17
+ exec('bundle exec rackup -o 0.0.0.0')
18
+ end
19
+ end
20
+
21
+ if Openbox.runtime.has?('rails', 'rack')
22
+ Openbox::Entrypoint.register(Server, 'server', 'server', 'Start application server')
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openbox
4
+ # :nodoc:
5
+ module Commands
6
+ # The Sidekiq Command
7
+ #
8
+ # @since 0.1.0
9
+ class Sidekiq < Openbox::Command
10
+ # Run sidekiq
11
+ #
12
+ # @since 0.1.0
13
+ def execute
14
+ Openbox.database.ensure_connection!
15
+ exec('bundle exec sidekiq')
16
+ end
17
+ end
18
+
19
+ Openbox::Entrypoint.register(Sidekiq, 'sidekiq', 'sidekiq', 'Run rails sidekiq') if Openbox.runtime.has?('sidekiq')
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+ require 'openbox/runtime'
5
+ require 'openbox/command'
6
+
7
+ module Openbox
8
+ # The Container Entrypoint
9
+ #
10
+ # @since 0.1.0
11
+ class Entrypoint < Thor
12
+ # :nodoc:
13
+ def self.exit_on_failure?
14
+ true
15
+ end
16
+
17
+ require 'openbox/commands/server'
18
+ require 'openbox/commands/rake'
19
+ require 'openbox/commands/migrate'
20
+ require 'openbox/commands/seed'
21
+ require 'openbox/commands/console'
22
+ require 'openbox/commands/sidekiq'
23
+ end
24
+ end
@@ -7,6 +7,13 @@ module Openbox
7
7
  #
8
8
  # @since 0.1.0
9
9
  class Runtime
10
+ # @param dependencies [Array<Bundler::Dependency>]
11
+ #
12
+ # @since 0.1.0
13
+ def initialize(dependencies = [])
14
+ @dependencies = dependencies
15
+ end
16
+
10
17
  # Check for Rails environment
11
18
  #
12
19
  # @return [TrueClass|FalseClass]
@@ -22,9 +29,7 @@ module Openbox
22
29
  #
23
30
  # @since 0.1.0
24
31
  def select(*names)
25
- Bundler
26
- .definition
27
- .current_dependencies
32
+ @dependencies
28
33
  .select { |dep| names.include?(dep.name) && (dep.groups & groups).any? }
29
34
  end
30
35
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Openbox
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/openbox.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  require_relative 'openbox/version'
4
4
  require_relative 'openbox/database'
5
5
  require_relative 'openbox/runtime'
6
- require_relative 'openbox/command'
7
6
 
8
7
  # The tool to build Ruby container easier
9
8
  #
@@ -20,7 +19,12 @@ module Openbox
20
19
  return @runtime if @runtime
21
20
 
22
21
  LOCK.synchronize do
23
- @runtime ||= Runtime.new
22
+ dependencies = if defined?(Bundler)
23
+ Bundler.definition.current_dependencies
24
+ else
25
+ []
26
+ end
27
+ @runtime ||= Runtime.new(dependencies)
24
28
  end
25
29
  end
26
30
 
@@ -34,4 +38,6 @@ module Openbox
34
38
  @database ||= Database.new
35
39
  end
36
40
  end
41
+
42
+ require_relative 'openbox/entrypoint'
37
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 蒼時弦也
@@ -46,7 +46,14 @@ files:
46
46
  - exe/openbox
47
47
  - lib/openbox.rb
48
48
  - lib/openbox/command.rb
49
+ - lib/openbox/commands/console.rb
50
+ - lib/openbox/commands/migrate.rb
51
+ - lib/openbox/commands/rake.rb
52
+ - lib/openbox/commands/seed.rb
53
+ - lib/openbox/commands/server.rb
54
+ - lib/openbox/commands/sidekiq.rb
49
55
  - lib/openbox/database.rb
56
+ - lib/openbox/entrypoint.rb
50
57
  - lib/openbox/runtime.rb
51
58
  - lib/openbox/version.rb
52
59
  - openbox.gemspec