u-menu 0.1.0 → 0.4.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: 8875c259e47ba9b085a694458a93f2d77b0345e0e23606bf167634e7b680e5d7
4
- data.tar.gz: 7d101e412eedb22d8fd5e5d0c4e5306025ec7abdb51d4669d5a862a1628cbe03
3
+ metadata.gz: 413a453b9fa4da63d069763afd994f5fe0afe3298057dbc58afc5a25df3fe2a0
4
+ data.tar.gz: fa0edfa226e1026d15556b429706bd4b6f17d407c58c8bafd01aa9783e0f31c6
5
5
  SHA512:
6
- metadata.gz: 18c042a45cfdc6d836820e29799dbdbfe90177a41a93a29ebe43b921b19898678123ebfe015fc65a00cffd055cfd4251dc384f658528287fc42effbcdc396b6d
7
- data.tar.gz: 9d8224ccf34a310e9f37f54141ca1b59e908bb04c8327300b8962b07ddf8fd97eb18db68e592b5fcc6024ed9fd7c4a691395ad4389dcfec31fe061c960b4dfd5
6
+ metadata.gz: c76ebb0ccad068b713cd1adfdc32b796748a51a7dba9a657dafcffc73f005df750ff3371600c6607659f850b235fd3e314360b03fab06f8876ef58ab70aa30df
7
+ data.tar.gz: c4f80d5d1abc512a810eac30d4c4f79a70097594f9bdec0f54074c74a72e8b7ce5a948091899cd4600a1813ab8501170b5a2318b82ace4f87b80a82923f20456
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # u-menu
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/u/menu`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Maintainability](https://api.codeclimate.com/v1/badges/384f1905e6b7e6dc8153/maintainability)](https://codeclimate.com/github/dvinciguerra/u-menu/maintainability)
4
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/384f1905e6b7e6dc8153/test_coverage)](https://codeclimate.com/github/dvinciguerra/u-menu/test_coverage)
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
+ micro-menu is a command line tool that delivers a simple and customized command pallet.
6
7
 
7
8
  ## Installation
8
9
 
data/bin/u-menu ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pastel'
4
+ require 'tty-prompt'
5
+
6
+ require 'yaml'
7
+
8
+ paths = [
9
+ File.expand_path("#{Dir.home}/.umenurc.yml", __dir__),
10
+ File.expand_path("#{Dir.home}/.umenu/umenurc.yml", __dir__),
11
+ ]
12
+
13
+ config_path = paths.first { |path| File.exist? path }
14
+ config = YAML.load_file(config_path, symbolize_names: true)
15
+
16
+ pastel = Pastel.new
17
+ prompt = TTY::Prompt.new(prefix: pastel.magenta("\uea85 \u00b5menu "), interrupt: :signal)
18
+
19
+ icons = {
20
+ 'run' => "\ueb9e",
21
+ 'terminal' => "\uea85",
22
+ 'github' => "\uea84",
23
+ 'chart' => "\ue760",
24
+ 'jira' => "\ue75c",
25
+ 'settings' => "\ue615",
26
+ 'link' => "\ueb15"
27
+ }
28
+
29
+ thanks = [
30
+ pastel.green('Great job! o/'),
31
+ pastel.green('See you later! =)'),
32
+ pastel.green('Baby bye bye bye...'),
33
+ "Bring me #{pastel.green('a cookie')} when you come back!?",
34
+ "Have a nice #{pastel.cyan('day')}! =)",
35
+ "See you later #{pastel.green('olligator')}! =)"
36
+ ]
37
+
38
+ trap('INT') do
39
+ puts "\n\n#{thanks.sample}"
40
+ exit(0)
41
+ end
42
+
43
+ action = nil
44
+ title, options = config.values_at(:title, :options)
45
+
46
+ options << {
47
+ name: '{{settings}} Edit Settings',
48
+ type: 'edit',
49
+ value: 'settings',
50
+ execute: config_path
51
+ }
52
+ options = options.sort { |a, b| a[:name] <=> b[:name] }
53
+
54
+ options.each do |option|
55
+ if option[:name].match(/\{\{(?<icon_name>.*)\}\}/)
56
+ icon_name = Regexp.last_match('icon_name')
57
+ option[:name].sub!("{{#{icon_name}}}", icons[icon_name])
58
+ else
59
+ option[:name] = "#{icons['terminal']} #{option[:name]}" if option[:type] == 'command'
60
+ option[:name] = "#{icons['link']} #{option[:name]}" if option[:type] == 'link'
61
+ end
62
+ end
63
+
64
+ loop do
65
+ choice = prompt.select(title, options, filter: true)
66
+ action = config[:options].find { |item| item[:value] == choice }
67
+
68
+ case action[:type]
69
+ when 'command'
70
+ system action[:execute]
71
+ when 'link'
72
+ puts "#{pastel.bold('Sure... opening link')} '#{pastel.cyan(action[:execute])}'"
73
+ system "open #{action[:execute]} &"
74
+ when 'edit'
75
+ puts "#{pastel.bold('Sure... opening file')} '#{pastel.cyan(action[:execute])}'"
76
+ system "#{config[:settings][:editor]} #{action[:execute]}"
77
+ end
78
+
79
+ exit(0)
80
+ rescue StandardError => e
81
+ puts "#{pastel.red('[error]')} #{e}"
82
+ exit(1)
83
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Micro
4
4
  module Menu
5
- VERSION = '0.1.0'
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  end
data/lib/micro/menu.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'menu/version'
4
+ require_relative 'menu/icons'
4
5
 
5
6
  module Micro
6
7
  module Menu
data/u-menu.gemspec CHANGED
@@ -22,11 +22,11 @@ Gem::Specification.new do |spec|
22
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
23
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
24
  `git ls-files -z`.split("\x0").reject do |f|
25
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
26
  end
27
27
  end
28
28
  # spec.bindir = 'exe'
29
- # spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ['lib']
31
31
 
32
32
  # Uncomment to register a new dependency of your gem
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: u-menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Vinciguerra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-02 00:00:00.000000000 Z
11
+ date: 2023-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pastel
@@ -42,7 +42,8 @@ description: u-menu is a simple command pallet for terminal to increase producti
42
42
  keeping what you need closer
43
43
  email:
44
44
  - daniel.vinciguerra@bivee.com.br
45
- executables: []
45
+ executables:
46
+ - u-menu
46
47
  extensions: []
47
48
  extra_rdoc_files: []
48
49
  files:
@@ -53,6 +54,7 @@ files:
53
54
  - LICENSE.txt
54
55
  - README.md
55
56
  - Rakefile
57
+ - bin/u-menu
56
58
  - lib/micro/menu.rb
57
59
  - lib/micro/menu/version.rb
58
60
  - lib/u-menu.rb