ginbin 0.1.0 → 1.0.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: d68e01e4a606eb5d093ca7c4e623affdf539e78900e354156bb28ab85a0bb909
4
- data.tar.gz: 69b9c339366fe5188e382e72af90f26029d3cf4f0eb0a4a14d142c0fe6ae4b96
3
+ metadata.gz: 373ed38b8d48b1ca35609c3252b55e4f06376ea0658bf274e4b55aed33b80c08
4
+ data.tar.gz: 0b081671fe299110ad55a1bfa202f02bf436808139a2116a287298c403b3644d
5
5
  SHA512:
6
- metadata.gz: 5fb3b44f7732402ca12b1b54392a9e52ff0e24ed33176b45183bb42ff00dee9223d9cbacd98361f462d7d3669e4db6ff7e222206d2617173695d0aad99a2b739
7
- data.tar.gz: deec65ab12b8b1822bae664b080bfc06e8903fc5001f6f5e09f546da58386b8df45d1e561ec76666f94ccbc77bb647ebf1903b5e50c4e7bbb752c8d926a4f50d
6
+ metadata.gz: adef20ff41ae6b103b5e8efec4580d1e623f1fa01ee3f3793ab198dd9d88059930fde679725b02395efe03c28f44ae73eb44c8fe64688625ce578f4f4ce5f72e
7
+ data.tar.gz: 850e5f347a4d5d9b923a7e1be9eab86718d472bdfc240aafa78282c885265abdffec042da2d920dc94e3a7ad8eca70e87e47ba9e353d8ff2b9862186d938efcb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.0.0] - 2022-08-29
4
+
5
+ * submenu
6
+
3
7
  ## [0.1.0] - 2022-06-10
4
8
 
5
- - Initial release
9
+ * Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ginbin (0.1.0)
4
+ ginbin (1.0.0)
5
5
  tty-prompt
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,37 +1,34 @@
1
1
  # Ginbin
2
2
 
3
- 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/ginbin`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Build interactive menu from most used shell commands.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ ## Install
6
6
 
7
- ## Installation
8
-
9
- Install the gem and add to the application's Gemfile by executing:
10
-
11
- $ bundle add ginbin
12
-
13
- If bundler is not being used to manage dependencies, install the gem by executing:
14
-
15
- $ gem install ginbin
7
+ ```bash
8
+ gem install ginbin
9
+ ```
16
10
 
17
11
  ## Usage
18
12
 
19
- TODO: Write usage instructions here
20
-
21
- ## Development
22
-
23
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
-
25
- 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).
13
+ Create config ~/.ginbin.yml:
26
14
 
27
- ## Contributing
15
+ ```yaml
16
+ commands:
17
+ - title: "Connect to server"
18
+ cmd: ssh my-server.com -t "cd /opt/app && bash -l"
28
19
 
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/sergio-fry/ginbin. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/sergio-fry/ginbin/blob/master/CODE_OF_CONDUCT.md).
20
+ - title: "Build report"
21
+ cmd: /usr/bin/report
30
22
 
31
- ## License
23
+ # short command desc without titlwe
24
+ - echo `date`
32
25
 
33
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
26
+ - menu: Submenu
27
+ commands:
28
+ - echo 1
29
+ - echo 2
30
+ ```
34
31
 
35
- ## Code of Conduct
32
+ Then run `ginbin`
36
33
 
37
- Everyone interacting in the Ginbin project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/sergio-fry/ginbin/blob/master/CODE_OF_CONDUCT.md).
34
+ It is also possible to have project-specific commands. Just put another .ginbin.yml inside current dir.
@@ -0,0 +1,24 @@
1
+ require "ginbin/command"
2
+ require 'yaml'
3
+
4
+ module Ginbin
5
+ class Items
6
+ include Enumerable
7
+
8
+ def initialize(items)
9
+ @items = items
10
+ end
11
+
12
+ def each
13
+ (@items).each do |item|
14
+ if !item['menu'].nil?
15
+ yield Menu.new(items: item['commands'], title: item['menu'])
16
+ elsif item['title'].nil?
17
+ yield Command.new(cmd: item, title: item)
18
+ else
19
+ yield Command.new(cmd: item['cmd'], title: item['title'])
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,27 +1,22 @@
1
- require "ginbin/command"
2
1
  require 'yaml'
3
2
 
4
3
  module Ginbin
5
- class Commands
4
+ class ItemsFromConfig
6
5
  include Enumerable
7
6
 
8
7
  def each
9
- (local_commads + home_commads).each do |command_desc|
10
- if command_desc['title'].nil?
11
- yield Command.new(cmd: command_desc, title: command_desc)
12
- else
13
- yield Command.new(cmd: command_desc['cmd'], title: command_desc['title'])
14
- end
8
+ (local_items + home_items).each do |item|
9
+ yield item
15
10
  end
16
11
  end
17
12
 
18
- def local_commads
13
+ def local_items
19
14
  return [] if at_home?
20
15
  return [] unless File.exists? '.ginbin.yml'
21
16
  YAML.load_file('.ginbin.yml')["commands"]
22
17
  end
23
18
 
24
- def home_commads
19
+ def home_items
25
20
  return [] unless File.exists? File.join(Dir.home, '.ginbin.yml')
26
21
 
27
22
  YAML.load_file(File.join(Dir.home, '.ginbin.yml'))["commands"]
data/lib/ginbin/menu.rb CHANGED
@@ -1,23 +1,27 @@
1
1
  require "tty-prompt"
2
2
 
3
- require_relative "commands"
3
+ require_relative "items"
4
+ require_relative "items_from_config"
4
5
 
5
6
  module Ginbin
6
7
  class Menu
8
+ attr_reader :title
9
+
10
+ def initialize(items: ItemsFromConfig.new, title: "Root")
11
+ @items = items
12
+ @title = title
13
+ end
14
+
7
15
  def call
8
16
  prompt = TTY::Prompt.new
9
17
 
10
- prompt.enum_select("Select an editor?", choices).call
18
+ prompt.enum_select("Choose command", choices).call
11
19
  end
12
20
 
13
21
  def choices
14
- commands.map do |command|
22
+ Items.new(@items).map do |command|
15
23
  { name: command.title, value: command }
16
24
  end
17
25
  end
18
-
19
- def commands
20
- Commands.new
21
- end
22
26
  end
23
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ginbin
4
- VERSION = "0.1.0"
4
+ VERSION = "1.0.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ginbin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergei O. Udalov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-10 00:00:00.000000000 Z
11
+ date: 2022-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-prompt
@@ -45,7 +45,8 @@ files:
45
45
  - ginbin.gemspec
46
46
  - lib/ginbin.rb
47
47
  - lib/ginbin/command.rb
48
- - lib/ginbin/commands.rb
48
+ - lib/ginbin/items.rb
49
+ - lib/ginbin/items_from_config.rb
49
50
  - lib/ginbin/menu.rb
50
51
  - lib/ginbin/version.rb
51
52
  - sig/ginbin.rbs