u-menu 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: 8875c259e47ba9b085a694458a93f2d77b0345e0e23606bf167634e7b680e5d7
4
- data.tar.gz: 7d101e412eedb22d8fd5e5d0c4e5306025ec7abdb51d4669d5a862a1628cbe03
3
+ metadata.gz: c6d032f982a5911f087289f6daf524e95abeafb01a12361977c234a3a5bedb00
4
+ data.tar.gz: 24b457dd8775626ec10947b2f4b5aae4ae6b3f33a94ee91734b16f77cffebe70
5
5
  SHA512:
6
- metadata.gz: 18c042a45cfdc6d836820e29799dbdbfe90177a41a93a29ebe43b921b19898678123ebfe015fc65a00cffd055cfd4251dc384f658528287fc42effbcdc396b6d
7
- data.tar.gz: 9d8224ccf34a310e9f37f54141ca1b59e908bb04c8327300b8962b07ddf8fd97eb18db68e592b5fcc6024ed9fd7c4a691395ad4389dcfec31fe061c960b4dfd5
6
+ metadata.gz: 02ebe5a7b058281495f04d0256a63eddf8f2878ba8cca8852c72e8d5a47e5a790fd081e0e06b7c4ff86b2853b1c7b47f4cd63f246d675284627d88b35dac3f15
7
+ data.tar.gz: a26ffd9335fd9dfa23eba00dd8bbd5fb67bba9130be71ba774e948789ec43f1bf514da66fe4f73c90c5cb3611f8321b0a88340154fd5fe5e466249e18c4955ad
data/bin/u-menu ADDED
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/inline'
4
+
5
+ gemfile do
6
+ source 'https://rubygems.org'
7
+
8
+ gem 'pastel'
9
+ gem 'tty-prompt'
10
+ end
11
+
12
+ require 'yaml'
13
+
14
+ config_path = File.expand_path("#{ENV.fetch('HOME', nil)}/.umenurc.yml", __dir__)
15
+ config_path ||= File.expand_path("#{ENV.fetch('HOME', nil)}/.umenu/umenurc.yml", __dir__)
16
+
17
+ config = YAML.load_file(config_path, symbolize_names: true)
18
+
19
+ pastel = Pastel.new
20
+ prompt = TTY::Prompt.new(prefix: pastel.magenta("\uea85 \u00b5menu "), interrupt: :signal)
21
+
22
+ icons = {
23
+ 'run' => "\ueb9e",
24
+ 'terminal' => "\uea85",
25
+ 'github' => "\uea84",
26
+ 'chart' => "\ue760",
27
+ 'jira' => "\ue75c",
28
+ 'settings' => "\ue615",
29
+ 'link' => "\ueb15"
30
+ }
31
+
32
+ thanks = [
33
+ "#{pastel.green('Great job! o/')}",
34
+ "#{pastel.green('See you later! =)')}",
35
+ "#{pastel.green('Baby bye bye bye...')}",
36
+ "Bring me #{pastel.green('a cookie')} when you come back!?",
37
+ "Have a nice #{pastel.cyan('day')}! =)",
38
+ "See you later #{pastel.green('olligator')}! =)"
39
+ ]
40
+
41
+ trap('INT') do
42
+ puts "\n\n#{thanks.sample}"
43
+ exit(0)
44
+ end
45
+
46
+ action = nil
47
+ title, options = config.values_at(:title, :options)
48
+
49
+ options << {
50
+ name: '{{settings}} Edit Settings',
51
+ type: 'edit',
52
+ value: 'settings',
53
+ execute: "#{config_path}"
54
+ }
55
+ options = options.sort { |a, b| a[:name] <=> b[:name] }
56
+
57
+ options.each do |option|
58
+ if option[:name].match(/\{\{(?<icon_name>.*)\}\}/)
59
+ icon_name = Regexp.last_match('icon_name')
60
+ option[:name].sub!("{{#{icon_name}}}", icons[icon_name])
61
+ else
62
+ option[:name] = "#{icons['terminal']} #{option[:name]}" if option[:type] == 'command'
63
+ option[:name] = "#{icons['link']} #{option[:name]}" if option[:type] == 'link'
64
+ end
65
+ end
66
+
67
+ loop do
68
+ choice = prompt.select(title, options, filter: true)
69
+ action = config[:options].find { |item| item[:value] == choice }
70
+
71
+ case action[:type]
72
+ when 'command'
73
+ system "#{action[:execute]} &"
74
+ when 'link'
75
+ puts "#{pastel.bold('Sure... opening link')} '#{pastel.cyan(action[:execute])}'"
76
+ system "open #{action[:execute]} &"
77
+ when 'edit'
78
+ puts "#{pastel.bold('Sure... opening file')} '#{pastel.cyan(action[:execute])}'"
79
+ system "#{config[:settings][:editor]} #{action[:execute]}"
80
+ end
81
+
82
+ exit(0)
83
+ rescue StandardError => e
84
+ puts "#{pastel.red('[error]')} #{e}"
85
+ exit(1)
86
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Micro
4
4
  module Menu
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
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,7 +1,7 @@
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.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Vinciguerra
@@ -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