cd 1.0.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 +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +18 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +5 -0
- data/MIT-LICENSE.txt +20 -0
- data/README.md +27 -0
- data/Rakefile +30 -0
- data/cd.gemspec +21 -0
- data/lib/cd.rb +49 -0
- data/lib/cd/version.rb +5 -0
- data/spec/cd_spec.rb +17 -0
- metadata +56 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ae17225f7423e50879d19952000855b1531f1370
|
4
|
+
data.tar.gz: 41c159da2f48e7a4ef945d6503078d1a7776580c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b89ce0c203b1c905d7566206e42ae222a4de465a893c0b7de036e8954959d33445f571885f54b61c92987d1ce22487e2f00b3d2931b0781cc04827bee5b03c32
|
7
|
+
data.tar.gz: e907d4b41a47e5be058bea3f51f84fad2ce5b302eaa566a5b83bb4a40756a37ea3cb608d875625b5b82f1590a35fd07859bfd31d7d5dcb604c5d799b71f4804d
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gemfile.lock
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2015 Jan Lelis, mail@janlelis.de
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# cd [![[version]](https://badge.fury.io/rb/cd.svg)](http://badge.fury.io/rb/cd)
|
2
|
+
|
3
|
+
Enhanced cd command for the Ruby console.
|
4
|
+
|
5
|
+
|
6
|
+
## Setup
|
7
|
+
|
8
|
+
```
|
9
|
+
gem install cd
|
10
|
+
```
|
11
|
+
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
require 'cd'
|
17
|
+
extend Cd
|
18
|
+
|
19
|
+
cd 'some/dir' # change to that directory and list its content
|
20
|
+
~cd # change to home directory
|
21
|
+
-cd # change to last directory
|
22
|
+
```
|
23
|
+
|
24
|
+
|
25
|
+
## MIT License
|
26
|
+
|
27
|
+
Copyright (C) 2015 Jan Lelis <http://janlelis.com>. Released under the MIT license.
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# # #
|
2
|
+
# Get gemspec info
|
3
|
+
|
4
|
+
gemspec_file = Dir['*.gemspec'].first
|
5
|
+
gemspec = eval File.read(gemspec_file), binding, gemspec_file
|
6
|
+
info = "#{gemspec.name} | #{gemspec.version} | " \
|
7
|
+
"#{gemspec.runtime_dependencies.size} dependencies | " \
|
8
|
+
"#{gemspec.files.size} files"
|
9
|
+
|
10
|
+
|
11
|
+
# # #
|
12
|
+
# Gem build and install task
|
13
|
+
|
14
|
+
desc info
|
15
|
+
task :gem do
|
16
|
+
puts info + "\n\n"
|
17
|
+
print " "; sh "gem build #{gemspec_file}"
|
18
|
+
FileUtils.mkdir_p 'pkg'
|
19
|
+
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
|
20
|
+
puts; sh %{gem install --no-document pkg/#{gemspec.name}-#{gemspec.version}.gem}
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# # #
|
25
|
+
# Start an IRB session with the gem loaded
|
26
|
+
|
27
|
+
desc "#{gemspec.name} | IRB"
|
28
|
+
task :irb do
|
29
|
+
sh "irb -I ./lib -r #{gemspec.name.gsub '-','/'}"
|
30
|
+
end
|
data/cd.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + "/lib/cd"
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "cd"
|
7
|
+
gem.version = Cd::VERSION
|
8
|
+
gem.summary = "Enhanced cd command for the Ruby console"
|
9
|
+
gem.description = "Enhanced cd command for the Ruby console."
|
10
|
+
gem.authors = ["Jan Lelis"]
|
11
|
+
gem.email = "mail@janlelis.de"
|
12
|
+
gem.homepage = "https://github.com/janlelis/cd"
|
13
|
+
gem.license = "MIT"
|
14
|
+
|
15
|
+
gem.files = Dir['{**/}{.*,*}'].select{ |path| File.file?(path) && path !~ /^pkg/ }
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
|
20
|
+
gem.required_ruby_version = '~> 2.0'
|
21
|
+
end
|
data/lib/cd.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Cd
|
4
|
+
VERSION = '1.0.0'
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def cd(path = nil)
|
8
|
+
if !path
|
9
|
+
Cd::Proxy
|
10
|
+
else
|
11
|
+
Cd::Proxy[path]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module Proxy
|
16
|
+
def self.~
|
17
|
+
cd '~'
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.-@
|
21
|
+
if @last_path
|
22
|
+
cd @last_path
|
23
|
+
else
|
24
|
+
warn "Sorry, there is no previous directory."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.[](path)
|
29
|
+
next_last_path = pwd
|
30
|
+
FileUtils::Verbose.cd File.expand_path(path)
|
31
|
+
@last_path = next_last_path
|
32
|
+
Cd::Proxy.ls
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.ls(path = '.')
|
36
|
+
Dir["#{path}/*"].map{ |filename| File.basename filename }
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.pwd
|
40
|
+
FileUtils.pwd
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.inspect
|
44
|
+
"#{to_s}[#{pwd.inspect}]"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
data/lib/cd/version.rb
ADDED
data/spec/cd_spec.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative "../lib/cd"
|
2
|
+
require "minitest/autorun"
|
3
|
+
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
describe Cd do
|
7
|
+
include Cd
|
8
|
+
|
9
|
+
it "changes the directory" do
|
10
|
+
FileUtils.cd "/"
|
11
|
+
old_directory = FileUtils.pwd
|
12
|
+
cd "~"
|
13
|
+
new_directory = FileUtils.pwd
|
14
|
+
assert new_directory != old_directory
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan Lelis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Enhanced cd command for the Ruby console.
|
14
|
+
email: mail@janlelis.de
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- ".gitignore"
|
20
|
+
- ".travis.yml"
|
21
|
+
- CHANGELOG.md
|
22
|
+
- Gemfile
|
23
|
+
- MIT-LICENSE.txt
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- cd.gemspec
|
27
|
+
- lib/cd.rb
|
28
|
+
- lib/cd/version.rb
|
29
|
+
- spec/cd_spec.rb
|
30
|
+
homepage: https://github.com/janlelis/cd
|
31
|
+
licenses:
|
32
|
+
- MIT
|
33
|
+
metadata: {}
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '2.0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 2.4.6
|
51
|
+
signing_key:
|
52
|
+
specification_version: 4
|
53
|
+
summary: Enhanced cd command for the Ruby console
|
54
|
+
test_files:
|
55
|
+
- spec/cd_spec.rb
|
56
|
+
has_rdoc:
|