foob 0.0.3 → 0.0.4

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: ec596bad78ddfeea395b31e3e26965b248b39631b28ac75a0354700ba26546b3
4
- data.tar.gz: 5cc388522848e9ded1d0905ae873f4a59a7412c1e209d1d9b1b1aaa629ce5bb4
3
+ metadata.gz: bcc56eb0bd3a01ac7e3bbd7ec6b7438b8788451d3e4df53f13559a2f55cd923b
4
+ data.tar.gz: c52ff726a1d78ac0e0574e812240eeb847ad6dc1e5aa0810c0a250988ea789df
5
5
  SHA512:
6
- metadata.gz: ee272f855d5171b03b27900b239b1b9c2d48edaa35fac07cef5a103728bcaf778072885641fc503ac89e734fef74464b2d23fbc51eca84787895f34f1f4a98de
7
- data.tar.gz: b0d2f7e417082dc782c93cd8d7d9017ffda603059dcb72849b955c0f9333843ac1c5818593b5dbd3172791c1f130bbdce7a7e5fcba4933cfcb7998cee2450c0e
6
+ metadata.gz: a6af7bc051e063fd8f8e3b7e0ca6de53dc2593407e967a0a27bc0d753b118489f00c89cb018aee8563b9881e7dcb6ef3d6afaf48bdb446f7c3ed904ce17338d4
7
+ data.tar.gz: 207982825f084b416308af29ef7c10fa4d2f3cf38abc0a6d642fee5df93594c5de6b224ef03347057aa073f276f8f6f7a3388565d7932be2cb91830da28a2ec9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [0.0.4] - 2024-06-19
2
+
3
+ - Add --version
4
+ - Don't assume Bundle is loaded
5
+
1
6
  ## [0.0.3] - 2024-06-18
2
7
 
3
8
  - Fix bug preventing foob from loading
data/bin/foob CHANGED
@@ -1,8 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # TODO: maybe just check for presence of ./Gemfile??
4
3
  if File.exist?("../Gemfile")
5
- # ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
4
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
6
5
  end
7
6
 
8
7
  require "bundler/setup"
data/src/action_parser.rb CHANGED
@@ -4,11 +4,13 @@ module Foobara
4
4
  class ActionParser < ShCliConnector::ActionParser
5
5
  def supported_actions
6
6
  # TODO: implement a shortcut feature for this stuff
7
- [*super, "generate", "console"]
7
+ [*super, "generate", "console", "version"]
8
8
  end
9
9
 
10
10
  def normalize_action(action)
11
11
  case action
12
+ when "v"
13
+ "version"
12
14
  when "c"
13
15
  # :nocov:
14
16
  "console"
data/src/commands/help.rb CHANGED
@@ -18,7 +18,7 @@ module Foobara
18
18
  end
19
19
 
20
20
  def known_actions
21
- [*super, "generate"]
21
+ [*super, "generate", "version", "console"]
22
22
  end
23
23
  end
24
24
  end
@@ -0,0 +1,23 @@
1
+ require_relative "../../version"
2
+
3
+ module Foobara
4
+ module CommandConnectors
5
+ class Foob < ShCliConnector
6
+ module Commands
7
+ class Version < Foobara::Command
8
+ def execute
9
+ set_version
10
+
11
+ version
12
+ end
13
+
14
+ attr_accessor :version
15
+
16
+ def set_version
17
+ self.version = Foobara::Foob::VERSION
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
data/src/foob.rb CHANGED
@@ -41,6 +41,9 @@ module Foobara
41
41
  transformed_command_class = nil
42
42
 
43
43
  case action
44
+ when "version"
45
+ transformed_command_class = Commands::Version
46
+ request.command_class = transformed_command_class
44
47
  when "generate"
45
48
  generator_key = request.argument
46
49
 
@@ -69,8 +72,12 @@ module Foobara
69
72
  when "console"
70
73
  # Not going to bother creating a command for this one
71
74
  # :nocov:
72
- Bundler.with_unbundled_env do
73
- exec({ "IRB_PROMPT_PREFIX" => "foob" }, "./bin/console")
75
+ run_console = -> { exec({ "IRB_PROMPT_PREFIX" => "foob" }, "./bin/console") }
76
+
77
+ if Bundler.respond_to?(:with_unbundled_env)
78
+ Bundler.with_unbundled_env(&run_console)
79
+ else
80
+ run_console.call
74
81
  end
75
82
  # :nocov:
76
83
  else
@@ -0,0 +1,16 @@
1
+ module Foobara
2
+ module CommandConnectors
3
+ class Foob < ShCliConnector
4
+ class GlobalishParser < ShCliConnector::GlobalishParser
5
+ def setup_parser
6
+ super
7
+
8
+ # TODO: just move this to ShCliConnector::GlobalishParser?
9
+ parser.on("-v", "--version", "Show version information") do
10
+ result.parsed[:action] = "version"
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
data/src/request.rb CHANGED
@@ -5,6 +5,10 @@ module Foobara
5
5
  def action_parser
6
6
  @action_parser ||= ActionParser.new
7
7
  end
8
+
9
+ def globalish_parser
10
+ @globalish_parser ||= GlobalishParser.new
11
+ end
8
12
  end
9
13
  end
10
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-18 00:00:00.000000000 Z
11
+ date: 2024-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foobara
@@ -279,7 +279,9 @@ files:
279
279
  - lib/foobara/foob.rb
280
280
  - src/action_parser.rb
281
281
  - src/commands/help.rb
282
+ - src/commands/version.rb
282
283
  - src/foob.rb
284
+ - src/globalish_parser.rb
283
285
  - src/request.rb
284
286
  homepage: https://github.com/foobara/foob
285
287
  licenses: