kuzya 0.0.1.1 → 0.0.2

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: e4fe4adf9430d135c2cdcd912705b90f2039756258e29ad117d221c93e0b0179
4
- data.tar.gz: 6086af47542494045995230fad323e212899fd0ab76bd424c8831f69d676c6b9
3
+ metadata.gz: 5470ee51a09a0a749319011ec6c7953cdb52cd41157255681f1022ed9ea08cf7
4
+ data.tar.gz: 805b328585d384158e123ec79d5552acb5c15edf30327543b1bd477092fcecfc
5
5
  SHA512:
6
- metadata.gz: eddeb0e22e39bd568dbbb62da4a6c1e4f7ff1a687bacf73490b6005b0cb6a12f484c08b9898b4d6a93fbbc8400e0d0bd9cadcb3ca6333e22c127c7caf974fec9
7
- data.tar.gz: 8e564f49b5ea400510f9d8826f9fe5115f5d766d8ca0dfe5376607f7c865fd09d558afa65f6a4eb7727e9a60895c038d7d1ea3b5f9213446f9402dab7d4c7ccd
6
+ metadata.gz: b84aa1c1db641b163f3b9d39078089486a0d8be1d9aad1ef4a7b5cc4a63da1f096994c500ed1b4fbf1b06e8f47edf8cf0f9282c59c94d4a77829aae9ab254a00
7
+ data.tar.gz: bd1c559fa78a7a95f605cd2bef1ef1f45bf14386935a1d39ab85a6fa784bf3f052627a840beb18198368a2f4914012a809f464abd03f51869db2bc8b59346c1e
data/Changelog ADDED
@@ -0,0 +1,11 @@
1
+ Version 0.0.2:
2
+ - new 'version' command
3
+ - Add aliases for commands:
4
+ - for 'version' command - '-v', '--version'
5
+ - for 'remove' command - 'rm'
6
+ - fix issue with backslash at the end of URL
7
+ - change license to MIT
8
+ - show broken urls in list
9
+
10
+ Version 0.0.1:
11
+ - Kuzya created.
data/README.md CHANGED
@@ -4,6 +4,8 @@ __Kuzya__ - application to quickly open links from you terminal without mouse.
4
4
 
5
5
  ___
6
6
 
7
+ > Note: currently tested only on Linux
8
+
7
9
  ## How to install
8
10
 
9
11
  ### by rubygems
@@ -76,14 +78,5 @@ kuzya help
76
78
  ```
77
79
 
78
80
  ___
79
- ___
80
-
81
- https://opensource.org/licenses/isc-license.txt
82
-
83
- ISC License (ISC)
84
-
85
- Copyright (c) 2021 Dmitry Krushinsky
86
-
87
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
88
-
89
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
81
+ ## License
82
+ The gem is available as open source under the terms of the MIT License.
data/kuzya.gemspec CHANGED
@@ -1,14 +1,20 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'kuzya'
3
- s.version = '0.0.1.1'
3
+ s.version = '0.0.2'
4
4
  s.summary = 'Utility to open urls in browser from terminal.'
5
- s.description = "Utility to open urls in browser from terminal."
6
- s.metadata = { "homepage_uri" => "https://github.com/d-krushinsky/kuzya", "source_code_uri" => "https://github.com/d-krushinsky/kuzya" } if s.respond_to? :metadata=
5
+ s.description = 'Utility to open urls in browser from terminal with shortcuts.'
6
+ s.homepage = 'https://github.com/d-krushinsky/kuzya'
7
+ if s.respond_to?(:metadata=)
8
+ s.metadata = {
9
+ 'homepage_uri' => 'https://github.com/d-krushinsky/kuzya',
10
+ 'source_code_uri' => 'https://github.com/d-krushinsky/kuzya'
11
+ }
12
+ end
7
13
  s.author = 'Dmitry Krushinsky'
8
14
  s.email = 'd.krushinsky.00@gmail.com'
9
15
  s.files = `git ls-files`.split("\n")
10
- s.license = 'ICS'
11
- s.required_ruby_version = Gem::Requirement.new(">= 2.4.0".freeze)
16
+ s.license = 'MIT'
17
+ s.required_ruby_version = Gem::Requirement.new('>= 2.4.0'.freeze)
12
18
 
13
19
  s.add_dependency 'launchy'
14
20
 
data/lib/kuzya/cli.rb CHANGED
@@ -1,29 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Kuzya
4
- class CLI < Kuzya::Service
5
- def initialize(args)
6
- @args = args
7
- end
3
+ class Kuzya::CLI < Kuzya::Service
4
+ def initialize(args)
5
+ @args = args
6
+ end
8
7
 
9
- def call
10
- config = Kuzya::Config.new
8
+ def call
9
+ config = Kuzya::Config.new
11
10
 
12
- build_command.call(args, config)
13
- end
11
+ build_command.call(args, config)
12
+ end
14
13
 
15
- private
14
+ private
16
15
 
17
- attr_reader :args
16
+ attr_reader :args
18
17
 
19
- def build_command
20
- command = Kuzya::Commands.reserved?(args.first) ? args.first : 'open'
18
+ def build_command
19
+ command = Kuzya::Commands.fetch_command(args.first)
21
20
 
22
- Object.const_get("Kuzya::Commands::#{command.capitalize}")
23
- end
21
+ Object.const_get("Kuzya::Commands::#{command.capitalize}")
22
+ end
24
23
 
25
- def args_without_command
26
- args.dup.tap { |ary| ary.shift }
27
- end
24
+ def args_without_command
25
+ args.dup.tap { |ary| ary.shift }
28
26
  end
29
27
  end
@@ -1,10 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Kuzya
4
- module Commands
5
- class Add < Kuzya::Commands::Base
6
- class << self
7
- def info
3
+ class Kuzya::Commands::Add < Kuzya::Commands::Base
4
+ class << self
5
+ def info
8
6
  <<-INFO
9
7
  #{'add'.bold} - to add new shortcut use #{'kuzya add short www.example.com'.italic}.
10
8
  You can adds shortcuts inside other shurtcuts, e.g.
@@ -12,27 +10,27 @@ You can adds shortcuts inside other shurtcuts, e.g.
12
10
  #{'kuzya add stack q questions'.italic}
13
11
  #{'kuzya add stack q active ?tab=Active'.italic}
14
12
  And now if run '#{'kuzya stack q active'.italic}' you will see all active questions
15
- Note: You can't add first-level shortcuts named as [add, remove, list, help]
13
+ Note: You can't add first-level shortcuts named as [add, remove, rm, list, help, version, -v, --version]
16
14
  INFO
17
- end
18
-
19
- def prepare(args, config)
20
- [args_without_command(args), config]
21
- end
22
- end
15
+ end
23
16
 
24
- def initialize(args, config)
25
- @args = args
26
- @config = config
27
- end
17
+ def prepare(args, config)
18
+ [args_without_command(args), config]
19
+ end
20
+ end
28
21
 
29
- def call
30
- config.add(args)
31
- end
22
+ def initialize(args, config)
23
+ @args = args
24
+ @config = config
25
+ end
32
26
 
33
- private
27
+ def call
28
+ config.add(args)
34
29
 
35
- attr_reader :args, :config
36
- end
30
+ puts 'Done.'
37
31
  end
32
+
33
+ private
34
+
35
+ attr_reader :args, :config
38
36
  end
@@ -1,26 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Kuzya
4
- module Commands
5
- class Base
6
- class << self
7
- def info
8
- raise NotImplementedError
9
- end
3
+ class Kuzya::Commands::Base
4
+ class << self
5
+ def info
6
+ raise NotImplementedError
7
+ end
10
8
 
11
- def call(args, config)
12
- new(*prepare(args, config)).call
13
- end
9
+ def call(args, config)
10
+ new(*prepare(args, config)).call
11
+ end
14
12
 
15
- # Returns array of arguments that will be passed to constructor
16
- def prepare(_args, _config)
17
- raise NotImplementedError
18
- end
13
+ # Returns array of arguments that will be passed to constructor
14
+ def prepare(_args, _config)
15
+ raise NotImplementedError
16
+ end
19
17
 
20
- def args_without_command(args)
21
- args.dup.tap { |ary| ary.shift }
22
- end
23
- end
18
+ def args_without_command(args)
19
+ args.dup.tap { |ary| ary.shift }
24
20
  end
25
21
  end
22
+
23
+ def call
24
+ raise NotImplementedError
25
+ end
26
26
  end
@@ -1,38 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Kuzya
4
- module Commands
5
- class Help < Kuzya::Commands::Base
6
- SUPPORTED_COMMANDS = [
7
- Kuzya::Commands::Open,
8
- Kuzya::Commands::Help,
9
- Kuzya::Commands::Add,
10
- Kuzya::Commands::Remove,
11
- Kuzya::Commands::List
12
- ].freeze
3
+ class Kuzya::Commands::Help < Kuzya::Commands::Base
4
+ SUPPORTED_COMMANDS = [
5
+ Kuzya::Commands::Open,
6
+ Kuzya::Commands::Help,
7
+ Kuzya::Commands::Version,
8
+ Kuzya::Commands::Add,
9
+ Kuzya::Commands::Remove,
10
+ Kuzya::Commands::List
11
+ ].freeze
13
12
 
14
- class << self
15
- def info
13
+ class << self
14
+ def info
16
15
  <<-INFO
17
16
  #{'help'.bold} - to read info about kuzya's commands run '#{'kuzya help'.italic}'
18
17
  INFO
19
- end
18
+ end
20
19
 
21
- def prepare(_args, _config)
22
- # Do nothing
23
- end
24
- end
20
+ def prepare(_args, _config)
21
+ # Do nothing
22
+ end
23
+ end
25
24
 
26
- def initialize
27
- end
25
+ def initialize
26
+ end
28
27
 
29
- def call
30
- puts "#{Kuzya::SUMMARY}\n\n"
28
+ def call
29
+ puts "#{Kuzya::SUMMARY}\n\n"
31
30
 
32
- SUPPORTED_COMMANDS.each do |command|
33
- puts "#{command.info.to_s}\n"
34
- end
35
- end
31
+ SUPPORTED_COMMANDS.each do |command|
32
+ puts "#{command.info.to_s}\n"
36
33
  end
37
34
  end
38
35
  end
@@ -1,59 +1,61 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Kuzya
4
- module Commands
5
- class List < Kuzya::Commands::Base
6
- class << self
7
- def info
3
+ class Kuzya::Commands::List < Kuzya::Commands::Base
4
+ class << self
5
+ def info
8
6
  <<-INFO
9
7
  #{'list'.bold} - to see all shortcuts run '#{'kuzya list'.italic}'
10
8
  INFO
11
- end
9
+ end
12
10
 
13
- def prepare(_args, config)
14
- [config]
15
- end
16
- end
11
+ def prepare(_args, config)
12
+ [config]
13
+ end
14
+ end
17
15
 
18
- def initialize(config)
19
- @config = config
20
- end
16
+ def initialize(config)
17
+ @config = config
18
+ end
21
19
 
22
- def call
23
- resolved = []
24
- resolve_shortcuts([], [], fetch_keys(config.shortcuts), resolved)
20
+ def call
21
+ resolved = []
22
+ resolve_shortcuts([], [], fetch_keys(config.shortcuts), resolved)
25
23
 
26
- resolved.each do |shortcuts|
27
- puts "#{shortcuts.join(' ').bold}: #{Kuzya::UrlBuilder.call(shortcuts, config).italic}"
28
- end
29
- end
24
+ resolved.each do |shortcuts|
25
+ puts "#{shortcuts.join(' ').bold}: #{build_url(shortcuts, config)}"
26
+ end
27
+ end
30
28
 
31
- private
29
+ private
32
30
 
33
- attr_reader :config
31
+ attr_reader :config
34
32
 
35
- def fetch_keys(hash)
36
- hash.dup.tap { |h| h.delete('_url') }.map do |key, value|
37
- next key unless value.is_a?(Hash)
33
+ def fetch_keys(hash)
34
+ hash.dup.tap { |h| h.delete('_url') }.map do |key, value|
35
+ next key unless value.is_a?(Hash)
38
36
 
39
- result = [key, fetch_keys(value)].reject(&:empty?)
40
- result.length == 1 ? key : result
41
- end.reject(&:empty?)
42
- end
37
+ result = [key, fetch_keys(value)].reject(&:empty?)
38
+ result.length == 1 ? key : result
39
+ end.reject(&:empty?)
40
+ end
43
41
 
44
- def resolve_shortcuts(com, prev_com, shortcuts, resolved)
45
- shortcuts.each do |arg|
46
- if arg.is_a?(String)
47
- com = prev_com.dup.concat([arg])
48
- resolved.push(com)
49
- next
50
- end
51
-
52
- prev_com = com.dup
53
- resolve_shortcuts(com, prev_com, arg, resolved)
54
- com = []
55
- end
42
+ def resolve_shortcuts(com, prev_com, shortcuts, resolved)
43
+ shortcuts.each do |arg|
44
+ if arg.is_a?(String)
45
+ com = prev_com.dup.concat([arg])
46
+ resolved.push(com)
47
+ next
56
48
  end
49
+
50
+ prev_com = com.dup
51
+ resolve_shortcuts(com, prev_com, arg, resolved)
52
+ com = []
57
53
  end
58
54
  end
55
+
56
+ def build_url(shortcuts, config)
57
+ "#{Kuzya::UrlBuilder.call(shortcuts, config).italic}"
58
+ rescue
59
+ "#{'BROKEN URL'.red}".italic
60
+ end
59
61
  end
@@ -2,43 +2,39 @@
2
2
 
3
3
  require 'launchy'
4
4
 
5
- module Kuzya
6
- module Commands
7
- class Open < Kuzya::Commands::Base
8
- URL_REGEXP = /\A#{URI::regexp(['http', 'https'])}\z/.freeze
9
-
10
- class << self
11
- def info
12
- <<-INFO
5
+ class Kuzya::Commands::Open < Kuzya::Commands::Base
6
+ URL_REGEXP = /\A#{URI::regexp(['http', 'https'])}\z/.freeze
7
+
8
+ class << self
9
+ def info
10
+ <<-INFO
13
11
  #{'open'.bold} - to open any link run '#{'kuzya www.example.com'.italic}'
14
12
  Also you can use your saved shortcuts instead of writing entire URL
15
13
  e.g. add 'gh' shortcut as 'https://github.com' and 'rb' as 'ruby'
16
14
  with 'kuzya add' command and run '#{'kuzya gh rb rake'.italic}'. Kuzya will make
17
15
  the URL and open 'https://github.com/ruby/rake'.
18
- INFO
19
- end
16
+ INFO
17
+ end
20
18
 
21
- def prepare(args, config)
22
- [Kuzya::UrlBuilder.call(args, config)]
23
- end
24
- end
19
+ def prepare(args, config)
20
+ [Kuzya::UrlBuilder.call(args, config)]
21
+ end
22
+ end
25
23
 
26
- def initialize(url)
27
- @url = url
28
- end
24
+ def initialize(url)
25
+ @url = url
26
+ end
29
27
 
30
- def call
31
- puts "Open #{url}"
32
- raise unless url =~ URL_REGEXP
28
+ def call
29
+ puts "Open #{url}"
30
+ raise unless url =~ URL_REGEXP
33
31
 
34
- Launchy.open(url)
35
- rescue
36
- puts "Can't open '#{url}', please check it, maybe you don't have shortcuts or URL is invalid".red
37
- end
32
+ Launchy.open(url)
33
+ rescue
34
+ puts "Can't open '#{url}', please check it, maybe you don't have shortcuts or URL is invalid".red
35
+ end
38
36
 
39
- private
37
+ private
40
38
 
41
- attr_reader :url
42
- end
43
- end
39
+ attr_reader :url
44
40
  end
@@ -1,36 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Kuzya
4
- module Commands
5
- class Remove < Kuzya::Commands::Base
6
- class << self
7
- def info
3
+ class Kuzya::Commands::Remove < Kuzya::Commands::Base
4
+ class << self
5
+ def info
8
6
  <<-INFO
9
7
  #{'remove'.bold} - if you want to remove shortcut you can run:
10
8
  #{'kuzya remove shortcut_name'.italic}
11
9
  Also you can remove nested shortcuts, to do it run:
12
10
  #{'kuzya remove parent_shortcut child_shortcut'.italic}
13
11
  Note: Removing shortcut that have nested shortcuts also removes them
12
+ aliases: #{'rm'.italic}
14
13
  INFO
15
- end
14
+ end
16
15
 
17
- def prepare(args, config)
18
- [args_without_command(args), config]
19
- end
20
- end
16
+ def prepare(args, config)
17
+ [args_without_command(args), config]
18
+ end
19
+ end
21
20
 
22
- def initialize(args, config)
23
- @args = args
24
- @config = config
25
- end
21
+ def initialize(args, config)
22
+ @args = args
23
+ @config = config
24
+ end
26
25
 
27
- def call
28
- config.remove(args)
29
- end
26
+ def call
27
+ config.remove(args)
28
+ end
30
29
 
31
- private
30
+ private
32
31
 
33
- attr_reader :args, :config
34
- end
35
- end
32
+ attr_reader :args, :config
36
33
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Kuzya::Commands::Version < Kuzya::Commands::Base
4
+ class << self
5
+ def info
6
+ <<-INFO
7
+ #{'version'.bold} - print installed kuzya's version.
8
+ aliases: #{'-v'.italic}, #{'--version'.italic}
9
+ INFO
10
+ end
11
+
12
+ def prepare(_, _)
13
+ end
14
+ end
15
+
16
+ def initialize
17
+ end
18
+
19
+ def call
20
+ puts "kuzya - #{Kuzya::VERSION}"
21
+ end
22
+ end
@@ -1,21 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Kuzya
4
- module Commands
5
- RESERVED_COMMANDS = %w[
6
- add
7
- remove
8
- list
9
- help
10
- ].freeze
3
+ module Kuzya::Commands
4
+ COMMANDS_MAPPING = {
5
+ /^(version|-v|--version)$/ => 'version',
6
+ /^(add)$/ => 'add',
7
+ /^(remove|rm)$/ => 'remove',
8
+ /^(list)$/ => 'list',
9
+ /^(help)$/ => 'help'
10
+ }.freeze
11
11
 
12
- def self.reserved?(first_arg)
13
- RESERVED_COMMANDS.include? first_arg
14
- end
12
+ def self.fetch_command(first_arg)
13
+ COMMANDS_MAPPING.detect { |regex, _| first_arg =~ regex }&.[](1) || 'open'
15
14
  end
16
15
  end
17
16
 
18
17
  require 'kuzya/commands/base'
18
+ require 'kuzya/commands/version'
19
19
  require 'kuzya/commands/open'
20
20
  require 'kuzya/commands/add'
21
21
  require 'kuzya/commands/remove'
data/lib/kuzya/config.rb CHANGED
@@ -3,65 +3,61 @@
3
3
  require 'fileutils'
4
4
  require 'yaml'
5
5
 
6
- module Kuzya
7
- class Config
8
- PATH_TO_DIR = "#{Dir.home}/.kuzya".freeze
9
- PATH_TO_CONFIG = "#{Dir.home}/.kuzya/kuzya.yml".freeze
6
+ class Kuzya::Config
7
+ PATH_TO_DIR = "#{Dir.home}/.kuzya".freeze
8
+ PATH_TO_CONFIG = "#{Dir.home}/.kuzya/kuzya.yml".freeze
10
9
 
11
- attr_reader :shortcuts
10
+ attr_reader :shortcuts
12
11
 
13
- def initialize
14
- FileUtils.mkdir_p(PATH_TO_DIR) # Creates file if not exists
15
- FileUtils.touch(PATH_TO_CONFIG) # Creating file if not exists
16
- @shortcuts = YAML.load(File.read(PATH_TO_CONFIG)) || {}
17
- end
18
-
19
- def add(keys)
20
- value = keys.pop
12
+ def initialize
13
+ FileUtils.mkdir_p(PATH_TO_DIR) # Creates file if not exists
14
+ FileUtils.touch(PATH_TO_CONFIG) # Creating file if not exists
15
+ @shortcuts = YAML.load(File.read(PATH_TO_CONFIG)) || {}
16
+ end
21
17
 
22
- scan_shortcuts(keys)
18
+ def add(keys)
19
+ value = keys.pop
23
20
 
24
- new_shortcut = build_shortcut(keys, value)
25
- @shortcuts.deep_merge!(new_shortcut)
26
- save
21
+ scan_shortcuts(keys)
27
22
 
28
- puts 'Done.'
29
- end
23
+ new_shortcut = build_shortcut(keys, value)
24
+ @shortcuts.deep_merge!(new_shortcut)
25
+ save
26
+ end
30
27
 
31
- def remove(keys)
32
- scan_shortcuts(keys)
28
+ def remove(keys)
29
+ scan_shortcuts(keys)
33
30
 
34
- empty_shortcut = build_empty_shortcut(keys)
35
- @shortcuts.deep_merge!(empty_shortcut)
36
- @shortcuts = Hash.deep_compact(@shortcuts)
31
+ empty_shortcut = build_empty_shortcut(keys)
32
+ @shortcuts.deep_merge!(empty_shortcut)
33
+ @shortcuts = Hash.deep_compact(@shortcuts)
37
34
 
38
- save
39
- end
35
+ save
36
+ end
40
37
 
41
- private
38
+ private
42
39
 
43
- def save
44
- File.open(PATH_TO_CONFIG, 'w') { |file| file.write(@shortcuts.to_yaml) }
45
- end
40
+ def save
41
+ File.open(PATH_TO_CONFIG, 'w') { |file| file.write(@shortcuts.to_yaml) }
42
+ end
46
43
 
47
- def build_empty_shortcut(keys)
48
- keys.reverse.inject(nil) { |assigned_value, key| { key => assigned_value } }
49
- end
44
+ def build_empty_shortcut(keys)
45
+ keys.reverse.inject(nil) { |assigned_value, key| { key => assigned_value } }
46
+ end
50
47
 
51
- def build_shortcut(keys, value)
52
- keys.reverse.inject({ '_url' => value }) do |assigned_value, key|
53
- { key => assigned_value }
54
- end
48
+ def build_shortcut(keys, value)
49
+ keys.reverse.inject({ '_url' => value }) do |assigned_value, key|
50
+ { key => assigned_value }
55
51
  end
52
+ end
56
53
 
57
- def scan_shortcuts(keys)
58
- shortcuts.dup do |hash|
59
- keys.each do |key|
60
- next hash = hash[key] if hash.key?(key)
54
+ def scan_shortcuts(keys)
55
+ shortcuts.dup do |hash|
56
+ keys.each do |key|
57
+ next hash = hash[key] if hash.key?(key)
61
58
 
62
- puts "Key '#{key}' not found. Check spelling or add it by 'kuzya #{keys.join(' ')} www.example.com'."
63
- exit(1)
64
- end
59
+ puts "Key '#{key}' not found. Check spelling or add it by 'kuzya #{keys.join(' ')} www.example.com'."
60
+ exit(1)
65
61
  end
66
62
  end
67
63
  end
data/lib/kuzya/service.rb CHANGED
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Kuzya
4
- class Service
5
- def self.call(*args)
6
- new(*args).call
7
- end
3
+ class Kuzya::Service
4
+ def self.call(*args)
5
+ new(*args).call
8
6
  end
9
7
  end
@@ -1,27 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Kuzya
4
- class UrlBuilder < Kuzya::Service
5
- def initialize(args, config)
6
- @args = args
7
- @config = config
8
- end
3
+ class Kuzya::UrlBuilder < Kuzya::Service
4
+ def initialize(args, config)
5
+ @args = args
6
+ @config = config
7
+ end
9
8
 
10
- def call
11
- url = ''
9
+ def call
10
+ url = ''
12
11
 
13
- config.shortcuts.dup.tap do |conf|
14
- args.each do |key|
15
- conf = conf.fetch(key, { '_url' => key })
16
- url += "#{conf.fetch('_url')}/"
17
- end
12
+ config.shortcuts.dup.tap do |conf|
13
+ args.each do |key|
14
+ conf = conf.fetch(key, { '_url' => key })
15
+ url += "#{conf.fetch('_url')}/"
18
16
  end
19
-
20
- url
21
17
  end
22
18
 
23
- private
24
-
25
- attr_reader :config, :args
19
+ url.chop
26
20
  end
21
+
22
+ private
23
+
24
+ attr_reader :config, :args
27
25
  end
data/lib/kuzya.rb CHANGED
@@ -3,6 +3,8 @@ require 'kuzya/core_ext/hash/deep_compact'
3
3
  require 'kuzya/core_ext/string/formatting'
4
4
 
5
5
  module Kuzya
6
+ VERSION = 'v0.0.2'.freeze
7
+
6
8
  SUMMARY = "#{'Kuzya'.bold} - app to open link from you lovely terminal!".freeze
7
9
  end
8
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kuzya
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Krushinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-11 00:00:00.000000000 Z
11
+ date: 2021-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: launchy
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description: Utility to open urls in browser from terminal.
27
+ description: Utility to open urls in browser from terminal with shortcuts.
28
28
  email: d.krushinsky.00@gmail.com
29
29
  executables:
30
30
  - kuzya
@@ -32,6 +32,7 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - ".gitignore"
35
+ - Changelog
35
36
  - README.md
36
37
  - bin/kuzya
37
38
  - kuzya.gemspec
@@ -44,15 +45,16 @@ files:
44
45
  - lib/kuzya/commands/list.rb
45
46
  - lib/kuzya/commands/open.rb
46
47
  - lib/kuzya/commands/remove.rb
48
+ - lib/kuzya/commands/version.rb
47
49
  - lib/kuzya/config.rb
48
50
  - lib/kuzya/core_ext/hash/deep_compact.rb
49
51
  - lib/kuzya/core_ext/hash/deep_merge.rb
50
52
  - lib/kuzya/core_ext/string/formatting.rb
51
53
  - lib/kuzya/service.rb
52
54
  - lib/kuzya/url_builder.rb
53
- homepage:
55
+ homepage: https://github.com/d-krushinsky/kuzya
54
56
  licenses:
55
- - ICS
57
+ - MIT
56
58
  metadata:
57
59
  homepage_uri: https://github.com/d-krushinsky/kuzya
58
60
  source_code_uri: https://github.com/d-krushinsky/kuzya