urly 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 723c2d2d02971508c08c02c6b667b8b02ac966c4fa38c45965d58c473f02956e
4
+ data.tar.gz: 4c60bda64b0e2a288138d158224dec29f0ef95146639b2610eec9f8cfef4f4c6
5
+ SHA512:
6
+ metadata.gz: f7d32e71275fc4609f6d2189ea5a7b15a08ef68e77d206a01b36ef4e9027bec21edf3b7b493fd8e3f12d97ad480d7c38f98e4480bfc93ab46eff1624f4769232
7
+ data.tar.gz: 6daa11051e1b8ea8535f38119ccbb5e085944632f1f4a90ba1956c0a9aed7b27e7e008d2120b795601622888cedebeeab08fb9209c8726443140278e67b7303d
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.4.4
7
+ before_install: gem install bundler -v 1.17.0
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at jeroenpjagt@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in rly.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,131 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ urly (0.1.1)
5
+ pastel (~> 0.7.2)
6
+ thor (~> 0.20.0)
7
+ tty-box (~> 0.4.1)
8
+ tty-color (~> 0.5)
9
+ tty-command (~> 0.9.0)
10
+ tty-config (~> 0.3.2)
11
+ tty-cursor (~> 0.7)
12
+ tty-editor (~> 0.5)
13
+ tty-file (~> 0.8.0)
14
+ tty-font (~> 0.4.0)
15
+ tty-logger (~> 0.2.0)
16
+ tty-markdown (~> 0.6.0)
17
+ tty-pager (~> 0.12)
18
+ tty-pie (~> 0.3.0)
19
+ tty-platform (~> 0.2)
20
+ tty-progressbar (~> 0.17)
21
+ tty-prompt (~> 0.19)
22
+ tty-screen (~> 0.7)
23
+ tty-spinner (~> 0.9)
24
+ tty-table (~> 0.11.0)
25
+ tty-tree (~> 0.3)
26
+ tty-which (~> 0.4)
27
+
28
+ GEM
29
+ remote: https://rubygems.org/
30
+ specs:
31
+ diff-lcs (1.3)
32
+ equatable (0.6.1)
33
+ kramdown (1.16.2)
34
+ necromancer (0.5.0)
35
+ pastel (0.7.3)
36
+ equatable (~> 0.6)
37
+ tty-color (~> 0.5)
38
+ rake (10.5.0)
39
+ rouge (3.11.1)
40
+ rspec (3.8.0)
41
+ rspec-core (~> 3.8.0)
42
+ rspec-expectations (~> 3.8.0)
43
+ rspec-mocks (~> 3.8.0)
44
+ rspec-core (3.8.2)
45
+ rspec-support (~> 3.8.0)
46
+ rspec-expectations (3.8.6)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.8.0)
49
+ rspec-mocks (3.8.2)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.8.0)
52
+ rspec-support (3.8.3)
53
+ strings (0.1.6)
54
+ strings-ansi (~> 0.1)
55
+ unicode-display_width (~> 1.5)
56
+ unicode_utils (~> 1.4)
57
+ strings-ansi (0.1.0)
58
+ thor (0.20.3)
59
+ tty-box (0.4.1)
60
+ pastel (~> 0.7.2)
61
+ strings (~> 0.1.6)
62
+ tty-cursor (~> 0.7)
63
+ tty-color (0.5.0)
64
+ tty-command (0.9.0)
65
+ pastel (~> 0.7.0)
66
+ tty-config (0.3.2)
67
+ tty-cursor (0.7.0)
68
+ tty-editor (0.5.1)
69
+ tty-prompt (~> 0.19)
70
+ tty-which (~> 0.4)
71
+ tty-file (0.8.0)
72
+ diff-lcs (~> 1.3)
73
+ pastel (~> 0.7.2)
74
+ tty-prompt (~> 0.18)
75
+ tty-font (0.4.0)
76
+ tty-logger (0.2.0)
77
+ pastel (~> 0.7.0)
78
+ tty-markdown (0.6.0)
79
+ kramdown (~> 1.16.2)
80
+ pastel (~> 0.7.2)
81
+ rouge (~> 3.3)
82
+ strings (~> 0.1.4)
83
+ tty-color (~> 0.4)
84
+ tty-screen (~> 0.6)
85
+ tty-pager (0.12.1)
86
+ strings (~> 0.1.4)
87
+ tty-screen (~> 0.6)
88
+ tty-which (~> 0.4)
89
+ tty-pie (0.3.0)
90
+ pastel (~> 0.7.3)
91
+ tty-cursor (~> 0.7)
92
+ tty-platform (0.2.1)
93
+ tty-progressbar (0.17.0)
94
+ strings-ansi (~> 0.1.0)
95
+ tty-cursor (~> 0.7)
96
+ tty-screen (~> 0.7)
97
+ unicode-display_width (~> 1.6)
98
+ tty-prompt (0.19.0)
99
+ necromancer (~> 0.5.0)
100
+ pastel (~> 0.7.0)
101
+ tty-reader (~> 0.6.0)
102
+ tty-reader (0.6.0)
103
+ tty-cursor (~> 0.7)
104
+ tty-screen (~> 0.7)
105
+ wisper (~> 2.0.0)
106
+ tty-screen (0.7.0)
107
+ tty-spinner (0.9.1)
108
+ tty-cursor (~> 0.7)
109
+ tty-table (0.11.0)
110
+ equatable (~> 0.6)
111
+ necromancer (~> 0.5)
112
+ pastel (~> 0.7.2)
113
+ strings (~> 0.1.5)
114
+ tty-screen (~> 0.7)
115
+ tty-tree (0.3.0)
116
+ tty-which (0.4.1)
117
+ unicode-display_width (1.6.0)
118
+ unicode_utils (1.4.0)
119
+ wisper (2.0.0)
120
+
121
+ PLATFORMS
122
+ ruby
123
+
124
+ DEPENDENCIES
125
+ bundler (~> 1.17)
126
+ rake (~> 10.0)
127
+ rspec (~> 3.0)
128
+ urly!
129
+
130
+ BUNDLED WITH
131
+ 1.17.0
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Jeroen Jagt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # rly
2
+
3
+ rly is a gem that adds URL shortcuts to your CLI per directory, so that you can save & open URLs conveniently in a given directory.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'urly'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install urly
20
+
21
+ ## Usage
22
+
23
+ Run `rly` in your CLI. todo: more detailed usage?
24
+
25
+ Important to note is that this saves shortcuts per directory! So adding a shortcut will mean it's only usable in that directory.
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rly.
36
+
37
+ ## Copyright
38
+
39
+ Copyright (c) 2019 Jeroen Jagt. See [MIT License](LICENSE.txt) for further details.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rly"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # TODO
9
+ # sudo mkdir '/var/lib/rly'
10
+ # sudo chmod 777 '/var/lib/rly'
data/exe/rly ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ lib_path = File.expand_path('../lib', __dir__)
5
+ $:.unshift(lib_path) if !$:.include?(lib_path)
6
+ require 'rly/cli'
7
+
8
+ Signal.trap('INT') do
9
+ warn("\n#{caller.join("\n")}: interrupted")
10
+ exit(1)
11
+ end
12
+
13
+ begin
14
+ Rly::CLI.start
15
+ rescue Rly::CLI::Error => err
16
+ puts "ERROR: #{err.message}"
17
+ exit 1
18
+ end
data/lib/rly.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "rly/version"
2
+
3
+ module Rly
4
+ class Error < StandardError; end
5
+ # Your code goes here...
6
+ end
data/lib/rly/cli.rb ADDED
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+
5
+ module Rly
6
+ # Handle the application command line parsing
7
+ # and the dispatch to various command objects
8
+ #
9
+ # @api public
10
+ class CLI < Thor
11
+ # Error raised by this runner
12
+ Error = Class.new(StandardError)
13
+
14
+ desc 'version', 'rly version'
15
+ def version
16
+ require_relative 'version'
17
+ puts "v#{Rly::VERSION}"
18
+ end
19
+ map %w(--version -v) => :version
20
+
21
+ desc 'open NAME', 'Open a shortcut'
22
+ method_option :help, aliases: '-h', type: :boolean,
23
+ desc: 'Display usage information'
24
+ def open(name)
25
+ if options[:help]
26
+ invoke :help, ['open']
27
+ else
28
+ require_relative 'commands/open'
29
+ Rly::Commands::Open.new(name, options).execute
30
+ end
31
+ end
32
+ desc 'o NAME', 'Alias for rly open NAME'
33
+ alias :o :open
34
+
35
+ desc 'list', 'List all shortcuts'
36
+ method_option :help, aliases: '-h', type: :boolean,
37
+ desc: 'Display usage information'
38
+ def list(*)
39
+ if options[:help]
40
+ invoke :help, ['list']
41
+ else
42
+ require_relative 'commands/list'
43
+ Rly::Commands::List.new(options).execute
44
+ end
45
+ end
46
+
47
+ desc 'add NAME URL', 'Add shortcut named NAME which opens URL'
48
+ method_option :help, aliases: '-h', type: :boolean,
49
+ desc: 'Display usage information'
50
+ method_option :force, aliases: '-f', type: :boolean,
51
+ desc: 'overwrite if shortcut exists'
52
+ def add(name, url)
53
+ if options[:help]
54
+ invoke :help, ['add']
55
+ else
56
+ require_relative 'commands/add'
57
+ Rly::Commands::Add.new(name, url, options).execute
58
+ end
59
+ end
60
+
61
+ desc 'remove NAME', 'Remove shortcut'
62
+ method_option :help, aliases: '-h', type: :boolean,
63
+ desc: 'Display usage information'
64
+ def remove(name)
65
+ if options[:help]
66
+ invoke :help, ['remove']
67
+ else
68
+ require_relative 'commands/remove'
69
+ Rly::Commands::Remove.new(name, options).execute
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,121 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+
5
+ module Rly
6
+ class Command
7
+ extend Forwardable
8
+
9
+ def_delegators :command, :run
10
+
11
+ # Execute this command
12
+ #
13
+ # @api public
14
+ def execute(*)
15
+ raise(
16
+ NotImplementedError,
17
+ "#{self.class}##{__method__} must be implemented"
18
+ )
19
+ end
20
+
21
+ # The external commands runner
22
+ #
23
+ # @see http://www.rubydoc.info/gems/tty-command
24
+ #
25
+ # @api public
26
+ def command(**options)
27
+ require 'tty-command'
28
+ TTY::Command.new(options)
29
+ end
30
+
31
+ # The cursor movement
32
+ #
33
+ # @see http://www.rubydoc.info/gems/tty-cursor
34
+ #
35
+ # @api public
36
+ def cursor
37
+ require 'tty-cursor'
38
+ TTY::Cursor
39
+ end
40
+
41
+ # Open a file or text in the user's preferred editor
42
+ #
43
+ # @see http://www.rubydoc.info/gems/tty-editor
44
+ #
45
+ # @api public
46
+ def editor
47
+ require 'tty-editor'
48
+ TTY::Editor
49
+ end
50
+
51
+ # File manipulation utility methods
52
+ #
53
+ # @see http://www.rubydoc.info/gems/tty-file
54
+ #
55
+ # @api public
56
+ def generator
57
+ require 'tty-file'
58
+ TTY::File
59
+ end
60
+
61
+ # Terminal output paging
62
+ #
63
+ # @see http://www.rubydoc.info/gems/tty-pager
64
+ #
65
+ # @api public
66
+ def pager(**options)
67
+ require 'tty-pager'
68
+ TTY::Pager.new(options)
69
+ end
70
+
71
+ # Terminal platform and OS properties
72
+ #
73
+ # @see http://www.rubydoc.info/gems/tty-pager
74
+ #
75
+ # @api public
76
+ def platform
77
+ require 'tty-platform'
78
+ TTY::Platform.new
79
+ end
80
+
81
+ # The interactive prompt
82
+ #
83
+ # @see http://www.rubydoc.info/gems/tty-prompt
84
+ #
85
+ # @api public
86
+ def prompt(**options)
87
+ require 'tty-prompt'
88
+ TTY::Prompt.new(options)
89
+ end
90
+
91
+ # Get terminal screen properties
92
+ #
93
+ # @see http://www.rubydoc.info/gems/tty-screen
94
+ #
95
+ # @api public
96
+ def screen
97
+ require 'tty-screen'
98
+ TTY::Screen
99
+ end
100
+
101
+ # The unix which utility
102
+ #
103
+ # @see http://www.rubydoc.info/gems/tty-which
104
+ #
105
+ # @api public
106
+ def which(*args)
107
+ require 'tty-which'
108
+ TTY::Which.which(*args)
109
+ end
110
+
111
+ # Check if executable exists
112
+ #
113
+ # @see http://www.rubydoc.info/gems/tty-which
114
+ #
115
+ # @api public
116
+ def exec_exist?(*args)
117
+ require 'tty-which'
118
+ TTY::Which.exist?(*args)
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../command'
4
+ require_relative '../shortcuts'
5
+
6
+ module Rly
7
+ module Commands
8
+ class Add < Rly::Command
9
+ def initialize(name, url, options)
10
+ @name = name
11
+ @url = url
12
+ @options = options
13
+ end
14
+
15
+ def execute(input: $stdin, output: $stdout)
16
+ shortcuts = Rly::Shortcuts.new
17
+ if !shortcuts.exist?(@name) || @options[:force]
18
+ shortcuts.create(@name, @url)
19
+ output.puts "rly #{@name} in this directory will now open #{@url}"
20
+ else
21
+ output.puts "that name is used already. if you want to overwrite, use -f"
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../command'
4
+ require_relative '../shortcuts'
5
+
6
+ module Rly
7
+ module Commands
8
+ class List < Rly::Command
9
+ def initialize(options)
10
+ @options = options
11
+ end
12
+
13
+ def execute(input: $stdin, output: $stdout)
14
+ shortcuts = Rly::Shortcuts.new
15
+ if shortcuts.all.empty?
16
+ output.puts "no shortcuts added yet for current directory (#{Dir.pwd})"
17
+ else
18
+ shortcuts.all.each do |name, url|
19
+ output.puts "#{name} => #{url}\n"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../command'
4
+ require_relative '../shortcuts'
5
+
6
+ module Rly
7
+ module Commands
8
+ class Open < Rly::Command
9
+ def initialize(name, options)
10
+ @name = name
11
+ @options = options
12
+ end
13
+
14
+ def execute(input: $stdin, output: $stdout)
15
+ shortcuts = Rly::Shortcuts.new
16
+ if shortcuts.exist?(@name)
17
+ open(shortcuts.find(@name))
18
+ else
19
+ output.puts "can't find shortcut with name #{@name}"
20
+ end
21
+ end
22
+
23
+ def open(url)
24
+ if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
25
+ system "start #{url}"
26
+ elsif RbConfig::CONFIG['host_os'] =~ /darwin/
27
+ system "open #{url}"
28
+ elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/
29
+ system "xdg-open #{url}"
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../command'
4
+ require_relative '../shortcuts'
5
+
6
+ module Rly
7
+ module Commands
8
+ class Remove < Rly::Command
9
+ def initialize(name, options)
10
+ @name = name
11
+ @options = options
12
+ end
13
+
14
+ def execute(input: $stdin, output: $stdout)
15
+ shortcuts = Rly::Shortcuts.new
16
+ if shortcuts.exist?(@name)
17
+ shortcuts.destroy(@name)
18
+ output.puts "removed #{@name} for this directory"
19
+ else
20
+ output.puts "can't find shortcut with name #{@name}"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,51 @@
1
+ require 'json'
2
+
3
+ module Rly
4
+ # shortcuts repository
5
+ class Shortcuts
6
+ def initialize
7
+ @name = Dir.pwd.tr('/', '')
8
+ @filename = %(/var/lib/rly/#{@name}.json)
9
+ @shortcuts = read
10
+ end
11
+
12
+ def all
13
+ @shortcuts
14
+ end
15
+
16
+ def find(name)
17
+ @shortcuts[name]
18
+ end
19
+
20
+ def exist?(name)
21
+ @shortcuts.key?(name)
22
+ end
23
+
24
+ def create(name, url)
25
+ @shortcuts[name] = url
26
+ save
27
+ end
28
+
29
+ def destroy(name)
30
+ @shortcuts.delete(name)
31
+ save
32
+ end
33
+
34
+ private
35
+
36
+ def read
37
+ return {} unless File.file?(@filename)
38
+ f = File.read(@filename)
39
+ return {} if f == ""
40
+ JSON.parse(f)
41
+ end
42
+
43
+ def save
44
+ unless File.file?(@filename)
45
+
46
+ end
47
+
48
+ File.write(@filename, @shortcuts.to_json)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1 @@
1
+ #
@@ -0,0 +1 @@
1
+ #
@@ -0,0 +1 @@
1
+ #
@@ -0,0 +1 @@
1
+ #
@@ -0,0 +1 @@
1
+ #
@@ -0,0 +1,3 @@
1
+ module Rly
2
+ VERSION = "0.1.1"
3
+ end
data/rly.gemspec ADDED
@@ -0,0 +1,65 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "rly/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "urly"
8
+ spec.license = "MIT"
9
+ spec.version = Rly::VERSION
10
+ spec.authors = ["Jeroen Jagt"]
11
+ spec.email = ["jeroenpjagt@gmail.com"]
12
+
13
+ spec.summary = %q{Create URL shortcuts per directory.}
14
+ spec.description = %q{Add, open, and remove URL shortcuts per directory.}
15
+ spec.homepage = "https://github.com/JeroenPJ/rly"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
+
22
+ # spec.metadata["homepage_uri"] = spec.homepage
23
+ # spec.metadata["source_code_uri"] = "https://github.com/JeroenPJ/rly"
24
+ # # spec.metadata["changelog_uri"] = "https://github.com/JeroenPJ/rly/CHANGELOG.md"
25
+ # else
26
+ # raise "RubyGems 2.0 or newer is required to protect against " \
27
+ # "public gem pushes."
28
+ # end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_dependency "tty-box", "~> 0.4.1"
40
+ spec.add_dependency "tty-color", "~> 0.5"
41
+ spec.add_dependency "tty-command", "~> 0.9.0"
42
+ spec.add_dependency "tty-config", "~> 0.3.2"
43
+ spec.add_dependency "tty-cursor", "~> 0.7"
44
+ spec.add_dependency "tty-editor", "~> 0.5"
45
+ spec.add_dependency "tty-file", "~> 0.8.0"
46
+ spec.add_dependency "tty-font", "~> 0.4.0"
47
+ spec.add_dependency "tty-logger", "~> 0.2.0"
48
+ spec.add_dependency "tty-markdown", "~> 0.6.0"
49
+ spec.add_dependency "tty-pager", "~> 0.12"
50
+ spec.add_dependency "tty-pie", "~> 0.3.0"
51
+ spec.add_dependency "tty-platform", "~> 0.2"
52
+ spec.add_dependency "tty-progressbar", "~> 0.17"
53
+ spec.add_dependency "tty-prompt", "~> 0.19"
54
+ spec.add_dependency "tty-screen", "~> 0.7"
55
+ spec.add_dependency "tty-spinner", "~> 0.9"
56
+ spec.add_dependency "tty-table", "~> 0.11.0"
57
+ spec.add_dependency "tty-tree", "~> 0.3"
58
+ spec.add_dependency "tty-which", "~> 0.4"
59
+ spec.add_dependency "pastel", "~> 0.7.2"
60
+ spec.add_dependency "thor", "~> 0.20.0"
61
+
62
+ spec.add_development_dependency "bundler", "~> 1.17"
63
+ spec.add_development_dependency "rake", "~> 10.0"
64
+ spec.add_development_dependency "rspec", "~> 3.0"
65
+ end
metadata ADDED
@@ -0,0 +1,422 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: urly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Jeroen Jagt
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-10-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tty-box
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.4.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.4.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: tty-color
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: tty-command
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.9.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-config
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.3.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: tty-cursor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.7'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tty-editor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.5'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.5'
97
+ - !ruby/object:Gem::Dependency
98
+ name: tty-file
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.8.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.8.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: tty-font
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.4.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.4.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: tty-logger
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.2.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.2.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: tty-markdown
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 0.6.0
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.6.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: tty-pager
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.12'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.12'
167
+ - !ruby/object:Gem::Dependency
168
+ name: tty-pie
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 0.3.0
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.3.0
181
+ - !ruby/object:Gem::Dependency
182
+ name: tty-platform
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '0.2'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '0.2'
195
+ - !ruby/object:Gem::Dependency
196
+ name: tty-progressbar
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '0.17'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '0.17'
209
+ - !ruby/object:Gem::Dependency
210
+ name: tty-prompt
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '0.19'
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '0.19'
223
+ - !ruby/object:Gem::Dependency
224
+ name: tty-screen
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '0.7'
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '0.7'
237
+ - !ruby/object:Gem::Dependency
238
+ name: tty-spinner
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '0.9'
244
+ type: :runtime
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '0.9'
251
+ - !ruby/object:Gem::Dependency
252
+ name: tty-table
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: 0.11.0
258
+ type: :runtime
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: 0.11.0
265
+ - !ruby/object:Gem::Dependency
266
+ name: tty-tree
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: '0.3'
272
+ type: :runtime
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: '0.3'
279
+ - !ruby/object:Gem::Dependency
280
+ name: tty-which
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: '0.4'
286
+ type: :runtime
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: '0.4'
293
+ - !ruby/object:Gem::Dependency
294
+ name: pastel
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - "~>"
298
+ - !ruby/object:Gem::Version
299
+ version: 0.7.2
300
+ type: :runtime
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - "~>"
305
+ - !ruby/object:Gem::Version
306
+ version: 0.7.2
307
+ - !ruby/object:Gem::Dependency
308
+ name: thor
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - "~>"
312
+ - !ruby/object:Gem::Version
313
+ version: 0.20.0
314
+ type: :runtime
315
+ prerelease: false
316
+ version_requirements: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - "~>"
319
+ - !ruby/object:Gem::Version
320
+ version: 0.20.0
321
+ - !ruby/object:Gem::Dependency
322
+ name: bundler
323
+ requirement: !ruby/object:Gem::Requirement
324
+ requirements:
325
+ - - "~>"
326
+ - !ruby/object:Gem::Version
327
+ version: '1.17'
328
+ type: :development
329
+ prerelease: false
330
+ version_requirements: !ruby/object:Gem::Requirement
331
+ requirements:
332
+ - - "~>"
333
+ - !ruby/object:Gem::Version
334
+ version: '1.17'
335
+ - !ruby/object:Gem::Dependency
336
+ name: rake
337
+ requirement: !ruby/object:Gem::Requirement
338
+ requirements:
339
+ - - "~>"
340
+ - !ruby/object:Gem::Version
341
+ version: '10.0'
342
+ type: :development
343
+ prerelease: false
344
+ version_requirements: !ruby/object:Gem::Requirement
345
+ requirements:
346
+ - - "~>"
347
+ - !ruby/object:Gem::Version
348
+ version: '10.0'
349
+ - !ruby/object:Gem::Dependency
350
+ name: rspec
351
+ requirement: !ruby/object:Gem::Requirement
352
+ requirements:
353
+ - - "~>"
354
+ - !ruby/object:Gem::Version
355
+ version: '3.0'
356
+ type: :development
357
+ prerelease: false
358
+ version_requirements: !ruby/object:Gem::Requirement
359
+ requirements:
360
+ - - "~>"
361
+ - !ruby/object:Gem::Version
362
+ version: '3.0'
363
+ description: Add, open, and remove URL shortcuts per directory.
364
+ email:
365
+ - jeroenpjagt@gmail.com
366
+ executables:
367
+ - rly
368
+ extensions: []
369
+ extra_rdoc_files: []
370
+ files:
371
+ - ".gitignore"
372
+ - ".rspec"
373
+ - ".travis.yml"
374
+ - CODE_OF_CONDUCT.md
375
+ - Gemfile
376
+ - Gemfile.lock
377
+ - LICENSE.txt
378
+ - README.md
379
+ - Rakefile
380
+ - bin/console
381
+ - bin/setup
382
+ - exe/rly
383
+ - lib/rly.rb
384
+ - lib/rly/cli.rb
385
+ - lib/rly/command.rb
386
+ - lib/rly/commands/add.rb
387
+ - lib/rly/commands/list.rb
388
+ - lib/rly/commands/open.rb
389
+ - lib/rly/commands/remove.rb
390
+ - lib/rly/shortcuts.rb
391
+ - lib/rly/templates/.gitkeep
392
+ - lib/rly/templates/add/.gitkeep
393
+ - lib/rly/templates/list/.gitkeep
394
+ - lib/rly/templates/open/.gitkeep
395
+ - lib/rly/templates/remove/.gitkeep
396
+ - lib/rly/version.rb
397
+ - rly.gemspec
398
+ homepage: https://github.com/JeroenPJ/rly
399
+ licenses:
400
+ - MIT
401
+ metadata: {}
402
+ post_install_message:
403
+ rdoc_options: []
404
+ require_paths:
405
+ - lib
406
+ required_ruby_version: !ruby/object:Gem::Requirement
407
+ requirements:
408
+ - - ">="
409
+ - !ruby/object:Gem::Version
410
+ version: '0'
411
+ required_rubygems_version: !ruby/object:Gem::Requirement
412
+ requirements:
413
+ - - ">="
414
+ - !ruby/object:Gem::Version
415
+ version: '0'
416
+ requirements: []
417
+ rubyforge_project:
418
+ rubygems_version: 2.7.7
419
+ signing_key:
420
+ specification_version: 4
421
+ summary: Create URL shortcuts per directory.
422
+ test_files: []