u-menu 0.4.0 → 0.8.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: 413a453b9fa4da63d069763afd994f5fe0afe3298057dbc58afc5a25df3fe2a0
4
- data.tar.gz: fa0edfa226e1026d15556b429706bd4b6f17d407c58c8bafd01aa9783e0f31c6
3
+ metadata.gz: 752e9401c942d535e54ba495ed964ec8c75b39b43a88b1eade2fc41ee9363ceb
4
+ data.tar.gz: 76a095e14abf9b1e96ea75995eeea37d59b29d67bb1c4e4c25b8af91798a62bd
5
5
  SHA512:
6
- metadata.gz: c76ebb0ccad068b713cd1adfdc32b796748a51a7dba9a657dafcffc73f005df750ff3371600c6607659f850b235fd3e314360b03fab06f8876ef58ab70aa30df
7
- data.tar.gz: c4f80d5d1abc512a810eac30d4c4f79a70097594f9bdec0f54074c74a72e8b7ce5a948091899cd4600a1813ab8501170b5a2318b82ace4f87b80a82923f20456
6
+ metadata.gz: 0ffe250fa89b1165dd6861793b72146e000fcde4a8528fe0bcfb1ea8eff7b42fb790d0c724d8b4e9ebd96be94e3169be0ea201dde3226eac4426793612320f94
7
+ data.tar.gz: '08d802fd502f95d5607e780cfeb1dfa9924d3e79bf497222db104dfe2be631d9db21e32b074b4c355a2e5133f24ba7a2800d9d15677d2e422af10d06f932c9d6'
data/Gemfile CHANGED
@@ -7,3 +7,10 @@ gemspec
7
7
 
8
8
  gem 'rake', '~> 13.0'
9
9
  gem 'rspec', '~> 3.0'
10
+
11
+ group :development do
12
+ gem "guard-rspec", "~> 4.7"
13
+ gem "rubocop", "~> 1.51"
14
+ gem "rubocop-rspec", "~> 2.22"
15
+ end
16
+
data/Gemfile.lock ADDED
@@ -0,0 +1,116 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ u-menu (0.6.0)
5
+ pastel
6
+ tty-prompt
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ coderay (1.1.3)
13
+ diff-lcs (1.5.0)
14
+ ffi (1.15.5)
15
+ formatador (1.1.0)
16
+ guard (2.18.0)
17
+ formatador (>= 0.2.4)
18
+ listen (>= 2.7, < 4.0)
19
+ lumberjack (>= 1.0.12, < 2.0)
20
+ nenv (~> 0.1)
21
+ notiffany (~> 0.0)
22
+ pry (>= 0.13.0)
23
+ shellany (~> 0.0)
24
+ thor (>= 0.18.1)
25
+ guard-compat (1.2.1)
26
+ guard-rspec (4.7.3)
27
+ guard (~> 2.1)
28
+ guard-compat (~> 1.1)
29
+ rspec (>= 2.99.0, < 4.0)
30
+ json (2.6.3)
31
+ listen (3.8.0)
32
+ rb-fsevent (~> 0.10, >= 0.10.3)
33
+ rb-inotify (~> 0.9, >= 0.9.10)
34
+ lumberjack (1.2.8)
35
+ method_source (1.0.0)
36
+ nenv (0.3.0)
37
+ notiffany (0.1.3)
38
+ nenv (~> 0.1)
39
+ shellany (~> 0.0)
40
+ parallel (1.23.0)
41
+ parser (3.2.2.1)
42
+ ast (~> 2.4.1)
43
+ pastel (0.8.0)
44
+ tty-color (~> 0.5)
45
+ pry (0.14.2)
46
+ coderay (~> 1.1)
47
+ method_source (~> 1.0)
48
+ rainbow (3.1.1)
49
+ rake (13.0.6)
50
+ rb-fsevent (0.11.2)
51
+ rb-inotify (0.10.1)
52
+ ffi (~> 1.0)
53
+ regexp_parser (2.8.0)
54
+ rexml (3.2.5)
55
+ rspec (3.12.0)
56
+ rspec-core (~> 3.12.0)
57
+ rspec-expectations (~> 3.12.0)
58
+ rspec-mocks (~> 3.12.0)
59
+ rspec-core (3.12.1)
60
+ rspec-support (~> 3.12.0)
61
+ rspec-expectations (3.12.2)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.12.0)
64
+ rspec-mocks (3.12.4)
65
+ diff-lcs (>= 1.2.0, < 2.0)
66
+ rspec-support (~> 3.12.0)
67
+ rspec-support (3.12.0)
68
+ rubocop (1.51.0)
69
+ json (~> 2.3)
70
+ parallel (~> 1.10)
71
+ parser (>= 3.2.0.0)
72
+ rainbow (>= 2.2.2, < 4.0)
73
+ regexp_parser (>= 1.8, < 3.0)
74
+ rexml (>= 3.2.5, < 4.0)
75
+ rubocop-ast (>= 1.28.0, < 2.0)
76
+ ruby-progressbar (~> 1.7)
77
+ unicode-display_width (>= 2.4.0, < 3.0)
78
+ rubocop-ast (1.28.1)
79
+ parser (>= 3.2.1.0)
80
+ rubocop-capybara (2.18.0)
81
+ rubocop (~> 1.41)
82
+ rubocop-factory_bot (2.22.0)
83
+ rubocop (~> 1.33)
84
+ rubocop-rspec (2.22.0)
85
+ rubocop (~> 1.33)
86
+ rubocop-capybara (~> 2.17)
87
+ rubocop-factory_bot (~> 2.22)
88
+ ruby-progressbar (1.13.0)
89
+ shellany (0.0.1)
90
+ thor (1.2.2)
91
+ tty-color (0.6.0)
92
+ tty-cursor (0.7.1)
93
+ tty-prompt (0.23.1)
94
+ pastel (~> 0.8)
95
+ tty-reader (~> 0.8)
96
+ tty-reader (0.9.0)
97
+ tty-cursor (~> 0.7)
98
+ tty-screen (~> 0.8)
99
+ wisper (~> 2.0)
100
+ tty-screen (0.8.1)
101
+ unicode-display_width (2.4.2)
102
+ wisper (2.0.1)
103
+
104
+ PLATFORMS
105
+ ruby
106
+
107
+ DEPENDENCIES
108
+ guard-rspec (~> 4.7)
109
+ rake (~> 13.0)
110
+ rspec (~> 3.0)
111
+ rubocop (~> 1.51)
112
+ rubocop-rspec (~> 2.22)
113
+ u-menu!
114
+
115
+ BUNDLED WITH
116
+ 2.4.13
data/Guardfile ADDED
@@ -0,0 +1,42 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec --format documentation" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+ end
data/bin/u-menu CHANGED
@@ -1,66 +1,56 @@
1
1
  #!/usr/bin/env ruby
2
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
- ]
3
+ require_relative '../lib/u-menu'
12
4
 
13
- config_path = paths.first { |path| File.exist? path }
14
- config = YAML.load_file(config_path, symbolize_names: true)
5
+ require 'tty-prompt'
15
6
 
16
- pastel = Pastel.new
17
- prompt = TTY::Prompt.new(prefix: pastel.magenta("\uea85 \u00b5menu "), interrupt: :signal)
7
+ command = ARGV.first
18
8
 
19
- icons = {
20
- 'run' => "\ueb9e",
21
- 'terminal' => "\uea85",
22
- 'github' => "\uea84",
23
- 'chart' => "\ue760",
24
- 'jira' => "\ue75c",
25
- 'settings' => "\ue615",
26
- 'link' => "\ueb15"
27
- }
9
+ if command == 'init'
10
+ puts "\n\nCreating a simple config file at ``"
11
+ Micro::Menu.configurations.init
12
+ end
28
13
 
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
- ]
14
+ config = Micro::Menu.configurations.load
15
+ colors = Micro::Menu.colors
16
+ icons = Micro::Menu.icons.all
17
+ messages = Micro::Menu.messages
37
18
 
38
19
  trap('INT') do
20
+ thanks = messages.thanks
21
+
39
22
  puts "\n\n#{thanks.sample}"
40
23
  exit(0)
41
24
  end
42
25
 
43
- action = nil
44
- 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
45
30
 
31
+ prompt = TTY::Prompt.new(
32
+ prefix: colors.magenta("#{use_icons ? "\uea85" : ''} u-menu "),
33
+ interrupt: :signal
34
+ )
35
+
36
+ # create a default edit settings option
46
37
  options << {
47
- name: '{{settings}} Edit Settings',
48
- type: 'edit',
49
- value: 'settings',
50
- execute: config_path
38
+ name: '{{settings}} Edit Settings', type: 'edit', value: 'settings', execute: config[:_path]
51
39
  }
40
+
52
41
  options = options.sort { |a, b| a[:name] <=> b[:name] }
53
42
 
54
43
  options.each do |option|
55
44
  if option[:name].match(/\{\{(?<icon_name>.*)\}\}/)
56
45
  icon_name = Regexp.last_match('icon_name')
57
- option[:name].sub!("{{#{icon_name}}}", icons[icon_name])
46
+ option[:name].sub!("{{#{icon_name}}} ", use_icons ? icons[icon_name] : '')
58
47
  else
59
- option[:name] = "#{icons['terminal']} #{option[:name]}" if option[:type] == 'command'
60
- 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'
61
50
  end
62
51
  end
63
52
 
53
+ action = nil
64
54
  loop do
65
55
  choice = prompt.select(title, options, filter: true)
66
56
  action = config[:options].find { |item| item[:value] == choice }
@@ -69,15 +59,15 @@ loop do
69
59
  when 'command'
70
60
  system action[:execute]
71
61
  when 'link'
72
- puts "#{pastel.bold('Sure... opening link')} '#{pastel.cyan(action[:execute])}'"
62
+ puts "#{colors.bold('Sure... opening link')} '#{colors.cyan(action[:execute])}'"
73
63
  system "open #{action[:execute]} &"
74
64
  when 'edit'
75
- puts "#{pastel.bold('Sure... opening file')} '#{pastel.cyan(action[:execute])}'"
65
+ puts "#{colors.bold('Sure... opening file')} '#{colors.cyan(action[:execute])}'"
76
66
  system "#{config[:settings][:editor]} #{action[:execute]}"
77
67
  end
78
68
 
79
69
  exit(0)
80
70
  rescue StandardError => e
81
- puts "#{pastel.red('[error]')} #{e}"
71
+ puts "#{colors.red('[error]')} #{e}"
82
72
  exit(1)
83
73
  end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ module Micro
6
+ module Menu
7
+ # Configuration module
8
+ # @private
9
+ module Configurations
10
+ CONFIGURATION_PATHS = [
11
+ File.expand_path("#{Dir.home}/.umenurc.yml", __dir__),
12
+ File.expand_path("#{Dir.home}/.umenu/umenurc.yml", __dir__)
13
+ ]
14
+
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
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Micro
4
+ module Menu
5
+ module Icons
6
+ ICON_LIST = {
7
+ 'run' => "\ueb9e",
8
+ 'terminal' => "\uea85",
9
+ 'github' => "\uea84",
10
+ 'chart' => "\ue760",
11
+ 'jira' => "\ue75c",
12
+ 'settings' => "\ue615",
13
+ 'link' => "\ueb15"
14
+ }
15
+
16
+ def self.all
17
+ ICON_LIST
18
+ end
19
+ end
20
+ end
21
+ end
@@ -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.4.0'
5
+ VERSION = '0.8.0'
6
6
  end
7
7
  end
data/lib/micro/menu.rb CHANGED
@@ -1,10 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'menu/version'
3
+ require_relative 'menu/configurations'
4
4
  require_relative 'menu/icons'
5
+ require_relative 'menu/messages'
6
+ require_relative 'menu/version'
7
+
8
+ require 'pastel'
5
9
 
6
10
  module Micro
7
11
  module Menu
8
12
  class Error < StandardError; end
13
+
14
+ class << self
15
+ def configurations
16
+ Configurations
17
+ end
18
+
19
+ def icons
20
+ Icons
21
+ end
22
+
23
+ def colors
24
+ @colors ||= Pastel.new
25
+ end
26
+
27
+ def messages
28
+ Messages
29
+ end
30
+ end
9
31
  end
10
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.4.0
4
+ version: 0.8.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-10 00:00:00.000000000 Z
11
+ date: 2023-05-29 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:
@@ -51,11 +51,16 @@ files:
51
51
  - CHANGELOG.md
52
52
  - CODE_OF_CONDUCT.md
53
53
  - Gemfile
54
+ - Gemfile.lock
55
+ - Guardfile
54
56
  - LICENSE.txt
55
57
  - README.md
56
58
  - Rakefile
57
59
  - bin/u-menu
58
60
  - lib/micro/menu.rb
61
+ - lib/micro/menu/configurations.rb
62
+ - lib/micro/menu/icons.rb
63
+ - lib/micro/menu/messages.rb
59
64
  - lib/micro/menu/version.rb
60
65
  - lib/u-menu.rb
61
66
  - u-menu.gemspec
@@ -82,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
87
  - !ruby/object:Gem::Version
83
88
  version: '0'
84
89
  requirements: []
85
- rubygems_version: 3.4.12
90
+ rubygems_version: 3.4.13
86
91
  signing_key:
87
92
  specification_version: 4
88
93
  summary: u-menu (micro menu) is a simple command pallet for terminals