u-menu 0.6.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cfb79ad584788fb2205a567eef99fac9881cb7aac9bef195be99062de4f8af4
4
- data.tar.gz: ec105fc48dcd1520dfdd7320f3f0c194ce2ede0dba0f3fc880963ff4d4513b0e
3
+ metadata.gz: 81e7fceb9a93546bc4faf4e7b03b6e6433e507dd2b2c4cfdfb4682e205e22869
4
+ data.tar.gz: 96603b243c958dee0033e0b64a9e9d665a895ea6df4da4578db5b4d93fd62573
5
5
  SHA512:
6
- metadata.gz: e8c7e430dca9ed7b865b8a0a9a384ed5f10419963487bde9d86a43f7b0e4cce788b55a9ba8d51bc71578a761c7e81ec29096eb91b5e649e22da20036c5237466
7
- data.tar.gz: eb9f1f36bb549c73836306a15d87de2741acf0313fc3822f43ef353fcd222da01205de5ccaf4fdf99e2dc74f05e7616ed6c52622f4008d4ee8dfecb4df94c691
6
+ metadata.gz: 897f5db9b62aaa5b63a31a440014d4f9feb24ccb96c3d06bb8377da5fa4641742e452399183806570bc99e2387691f05ea98c7591b7278e49a61a4240c436a60
7
+ data.tar.gz: 242a1bbdc6c5960eb19f6557a84092fc4a91af5c802c6350d8ea812efef6032cd4a6223253b2a8cb4d767bd96b465e9fc16c3ae2bed2347c565369dcec87e9b9
data/Gemfile CHANGED
@@ -9,8 +9,11 @@ gem 'rake', '~> 13.0'
9
9
  gem 'rspec', '~> 3.0'
10
10
 
11
11
  group :development do
12
- gem "guard-rspec", "~> 4.7"
13
- gem "rubocop", "~> 1.51"
14
- gem "rubocop-rspec", "~> 2.22"
12
+ gem 'guard-rspec', '~> 4.7'
13
+ gem 'rubocop', '~> 1.51'
14
+ gem 'rubocop-rspec', '~> 2.22'
15
15
  end
16
16
 
17
+ group :test do
18
+ gem 'simplecov', '~> 0.22.0', require: false
19
+ end
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- u-menu (0.6.0)
5
- pastel
6
- tty-prompt
4
+ u-menu (0.8.0)
5
+ pastel (~> 0.8.0)
6
+ tty-prompt (~> 0.23.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -11,6 +11,7 @@ GEM
11
11
  ast (2.4.2)
12
12
  coderay (1.1.3)
13
13
  diff-lcs (1.5.0)
14
+ docile (1.4.0)
14
15
  ffi (1.15.5)
15
16
  formatador (1.1.0)
16
17
  guard (2.18.0)
@@ -87,6 +88,12 @@ GEM
87
88
  rubocop-factory_bot (~> 2.22)
88
89
  ruby-progressbar (1.13.0)
89
90
  shellany (0.0.1)
91
+ simplecov (0.22.0)
92
+ docile (~> 1.1)
93
+ simplecov-html (~> 0.11)
94
+ simplecov_json_formatter (~> 0.1)
95
+ simplecov-html (0.12.3)
96
+ simplecov_json_formatter (0.1.4)
90
97
  thor (1.2.2)
91
98
  tty-color (0.6.0)
92
99
  tty-cursor (0.7.1)
@@ -110,6 +117,7 @@ DEPENDENCIES
110
117
  rspec (~> 3.0)
111
118
  rubocop (~> 1.51)
112
119
  rubocop-rspec (~> 2.22)
120
+ simplecov (~> 0.22.0)
113
121
  u-menu!
114
122
 
115
123
  BUNDLED WITH
data/bin/u-menu CHANGED
@@ -4,48 +4,53 @@ require_relative '../lib/u-menu'
4
4
 
5
5
  require 'tty-prompt'
6
6
 
7
- config = Micro::Menu.configurations.load
7
+ command = ARGV.first
8
8
 
9
- colors = Micro::Menu.colors
10
- prompt = TTY::Prompt.new(prefix: colors.magenta("\uea85 \u00b5menu "), interrupt: :signal)
9
+ if command == 'init'
10
+ puts "\n\nCreating a simple config file at ``"
11
+ Micro::Menu.configurations.init
12
+ end
11
13
 
14
+ config = Micro::Menu.configurations.load
15
+ colors = Micro::Menu.colors
12
16
  icons = Micro::Menu.icons.all
13
-
14
- thanks = [
15
- colors.green('Great job! o/'),
16
- colors.green('See you later! =)'),
17
- colors.green('Baby bye bye bye...'),
18
- "Bring me #{colors.green('a cookie')} when you come back!?",
19
- "Have a nice #{colors.cyan('day')}! =)",
20
- "See you later #{colors.green('olligator')}! =)"
21
- ]
17
+ messages = Micro::Menu.messages
22
18
 
23
19
  trap('INT') do
20
+ thanks = messages.thanks
21
+
24
22
  puts "\n\n#{thanks.sample}"
25
23
  exit(0)
26
24
  end
27
25
 
28
- action = nil
29
- title, options = config.values_at(:title, :options)
26
+ title, options, use_icons =
27
+ config.values_at(:title, :options, :use_icons)
28
+
29
+ use_icons ||= false
30
+
31
+ prompt = TTY::Prompt.new(
32
+ prefix: colors.magenta("#{use_icons ? "\uea85" : ''} u-menu "),
33
+ interrupt: :signal
34
+ )
30
35
 
36
+ # create a default edit settings option
31
37
  options << {
32
- name: '{{settings}} Edit Settings',
33
- type: 'edit',
34
- value: 'settings',
35
- execute: config[:_path]
38
+ name: '{{settings}} Edit Settings', type: 'edit', value: 'settings', execute: config[:_path]
36
39
  }
40
+
37
41
  options = options.sort { |a, b| a[:name] <=> b[:name] }
38
42
 
39
43
  options.each do |option|
40
44
  if option[:name].match(/\{\{(?<icon_name>.*)\}\}/)
41
45
  icon_name = Regexp.last_match('icon_name')
42
- option[:name].sub!("{{#{icon_name}}}", icons[icon_name])
46
+ option[:name].sub!("{{#{icon_name}}}", use_icons ? icons[icon_name] : '')
43
47
  else
44
- option[:name] = "#{icons['terminal']} #{option[:name]}" if option[:type] == 'command'
45
- option[:name] = "#{icons['link']} #{option[:name]}" if option[:type] == 'link'
48
+ option[:name] = "#{use_icons ? icons['terminal'] : ''} #{option[:name]}" if option[:type] == 'command'
49
+ option[:name] = "#{use_icons ? icons['link'] : ''} #{option[:name]}" if option[:type] == 'link'
46
50
  end
47
51
  end
48
52
 
53
+ action = nil
49
54
  loop do
50
55
  choice = prompt.select(title, options, filter: true)
51
56
  action = config[:options].find { |item| item[:value] == choice }
@@ -57,6 +62,11 @@ loop do
57
62
  puts "#{colors.bold('Sure... opening link')} '#{colors.cyan(action[:execute])}'"
58
63
  system "open #{action[:execute]} &"
59
64
  when 'edit'
65
+ unless config.dig(:settings, :editor)
66
+ warn '[error] key `settings > editor` not found into config file.'
67
+ exit(1)
68
+ end
69
+
60
70
  puts "#{colors.bold('Sure... opening file')} '#{colors.cyan(action[:execute])}'"
61
71
  system "#{config[:settings][:editor]} #{action[:execute]}"
62
72
  end
@@ -4,16 +4,74 @@ require 'yaml'
4
4
 
5
5
  module Micro
6
6
  module Menu
7
+ # Configuration module
8
+ # @private
7
9
  module Configurations
8
10
  CONFIGURATION_PATHS = [
9
11
  File.expand_path("#{Dir.home}/.umenurc.yml", __dir__),
10
- File.expand_path("#{Dir.home}/.umenu/umenurc.yml", __dir__),
12
+ File.expand_path("#{Dir.home}/.umenu/umenurc.yml", __dir__)
11
13
  ]
12
14
 
13
- def self.load
14
- path = CONFIGURATION_PATHS.first { |file_path| File.exist? file_path }
15
- @@config = YAML.load_file(path, symbolize_names: true)
16
- @@config.update(_path: path)
15
+ class << self
16
+ def load
17
+ path = CONFIGURATION_PATHS.first { |file_path| File.exist? file_path }
18
+ @@config = YAML.load_file(path, symbolize_names: true)
19
+ @@config.update(_path: path)
20
+ end
21
+
22
+ def init(path = nil)
23
+ path ||= CONFIGURATION_PATHS.first
24
+ return if File.exist?(path)
25
+
26
+ File.write(path, <<~CONFIG)
27
+ ---
28
+ version: 0.1
29
+ title: apps
30
+ settings:
31
+ editor: 'nvim'
32
+ options:
33
+ - name: 'DuckDuckGo /Search'
34
+ value: duckduckgo
35
+ type: link
36
+ execute: 'https://duckduckgo.com'
37
+ - name: '{{github}} Github'
38
+ value: github
39
+ type: link
40
+ execute: 'https://github.com'
41
+ - name: '{{github}} Github /Pull Requests'
42
+ value: github_pulls
43
+ type: link
44
+ execute: 'https://github.com/pulls?q=is%3Apr+is%3Aopen+author%3A%40me+archived%3Afalse+sort%3Aupdated-desc'
45
+ - name: '{{github}} Github /Issues'
46
+ value: github_issues
47
+ type: link
48
+ execute: 'https://github.com/issues?q=is%3Aissue+is%3Aopen+author%3A%40me+archived%3Afalse+sort%3Aupdated-desc'
49
+ - name: '{{github}} Github /Profile'
50
+ value: github_profile
51
+ type: link
52
+ execute: 'https://github.com/dvinciguerra'
53
+ - name: 'Rubygems'
54
+ value: rubygems
55
+ type: link
56
+ execute: 'https://rubygems.org'
57
+ - name: 'File Explorer'
58
+ value: files
59
+ type: command
60
+ execute: 'ranger ${pwd}'
61
+ - name: 'Tmux'
62
+ value: tmux
63
+ type: command
64
+ execute: 'tmux'
65
+ - name: 'Tmux /New Window'
66
+ value: tmux_new_window
67
+ type: command
68
+ execute: 'tmux new-window'
69
+ - name: 'Tmux /Kill Window'
70
+ value: tmux_kill_window
71
+ type: command
72
+ execute: 'tmux kill-window'
73
+ CONFIG
74
+ end
17
75
  end
18
76
  end
19
77
  end
@@ -10,7 +10,78 @@ module Micro
10
10
  'chart' => "\ue760",
11
11
  'jira' => "\ue75c",
12
12
  'settings' => "\ue615",
13
- 'link' => "\ueb15"
13
+ 'link' => "\ueb15",
14
+ 'ai' => '',
15
+ 'android' => '',
16
+ 'apple' => '',
17
+ 'audio' => '',
18
+ 'avro' => '',
19
+ 'c' => '',
20
+ 'clj' => '',
21
+ 'coffee' => '',
22
+ 'conf' => '',
23
+ 'cpp' => '',
24
+ 'css' => '',
25
+ 'd' => '',
26
+ 'dart' => '',
27
+ 'db' => '',
28
+ 'diff' => '',
29
+ 'doc' => '',
30
+ 'docker' => '',
31
+ 'ebook' => '',
32
+ 'env' => '',
33
+ 'epub' => '',
34
+ 'erl' => '',
35
+ 'file' => '',
36
+ 'font' => '',
37
+ 'gform' => '',
38
+ 'git' => '',
39
+ 'go' => '',
40
+ 'gruntfile' => '',
41
+ 'hs' => '',
42
+ 'html' => '',
43
+ 'image' => '',
44
+ 'iml' => '',
45
+ 'java' => '',
46
+ 'js' => '',
47
+ 'json' => '',
48
+ 'jsx' => '',
49
+ 'less' => '',
50
+ 'log' => '',
51
+ 'lua' => '',
52
+ 'md' => '',
53
+ 'mustache' => '',
54
+ 'npmignore' => '',
55
+ 'pdf' => '',
56
+ 'php' => '',
57
+ 'pl' => '',
58
+ 'ppt' => '',
59
+ 'psd' => '',
60
+ 'py' => '',
61
+ 'r' => '',
62
+ 'rb' => '',
63
+ 'rdb' => '',
64
+ 'react' => 'ﰆ',
65
+ 'rss' => '',
66
+ 'rubydoc' => '',
67
+ 'sass' => '',
68
+ 'scala' => '',
69
+ 'shell' => '',
70
+ 'sqlite3' => '',
71
+ 'styl' => '',
72
+ 'tex' => '',
73
+ 'ts' => '',
74
+ 'twig' => '',
75
+ 'txt' => '',
76
+ 'video' => '',
77
+ 'vim' => '',
78
+ 'vue' => '﵂',
79
+ 'windows' => '',
80
+ 'xls' => '',
81
+ 'xml' => '',
82
+ 'yarn' => '',
83
+ 'yml' => '',
84
+ 'zip' => ''
14
85
  }
15
86
 
16
87
  def self.all
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+ module Micro
5
+ module Menu
6
+ module Messages
7
+ class << self
8
+ def thanks
9
+ [
10
+ colors.green('Great job! o/'),
11
+ colors.green('See you later! =)'),
12
+ colors.green('Baby bye bye bye...'),
13
+ "Bring me #{colors.green('a cookie')} when you come back!?",
14
+ "Have a nice #{colors.cyan('day')}! =)",
15
+ "See you later #{colors.green('olligator')}! =)"
16
+ ]
17
+ end
18
+
19
+ private
20
+
21
+ def colors
22
+ Micro::Menu.colors
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Micro
4
4
  module Menu
5
- VERSION = '0.6.0'
5
+ VERSION = '0.10.0'
6
6
  end
7
7
  end
data/lib/micro/menu.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative 'menu/configurations'
4
4
  require_relative 'menu/icons'
5
+ require_relative 'menu/messages'
5
6
  require_relative 'menu/version'
6
7
 
7
8
  require 'pastel'
@@ -10,16 +11,22 @@ module Micro
10
11
  module Menu
11
12
  class Error < StandardError; end
12
13
 
13
- def self.configurations
14
- Configurations
15
- end
14
+ class << self
15
+ def configurations
16
+ Configurations
17
+ end
16
18
 
17
- def self.icons
18
- Icons
19
- end
19
+ def icons
20
+ Icons
21
+ end
22
+
23
+ def colors
24
+ @colors ||= Pastel.new
25
+ end
20
26
 
21
- def self.colors
22
- @colors ||= Pastel.new
27
+ def messages
28
+ Messages
29
+ end
23
30
  end
24
31
  end
25
32
  end
data/u-menu.gemspec CHANGED
@@ -31,8 +31,8 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  # Uncomment to register a new dependency of your gem
33
33
  # spec.add_dependency "example-gem", "~> 1.0"
34
- spec.add_dependency 'pastel'
35
- spec.add_dependency 'tty-prompt'
34
+ spec.add_dependency 'pastel', '~> 0.8.0'
35
+ spec.add_dependency 'tty-prompt', '~> 0.23.1'
36
36
 
37
37
  # For more information and examples about making a new gem, check out our
38
38
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: u-menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.10.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-18 00:00:00.000000000 Z
11
+ date: 2023-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pastel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.8.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.8.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tty-prompt
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.23.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.23.1
41
41
  description: u-menu is a simple command pallet for terminal to increase productivity,
42
42
  keeping what you need closer
43
43
  email:
@@ -60,6 +60,7 @@ files:
60
60
  - lib/micro/menu.rb
61
61
  - lib/micro/menu/configurations.rb
62
62
  - lib/micro/menu/icons.rb
63
+ - lib/micro/menu/messages.rb
63
64
  - lib/micro/menu/version.rb
64
65
  - lib/u-menu.rb
65
66
  - u-menu.gemspec