sanky-pf 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +9 -0
- data/bin/sanky-pf +3 -0
- data/lib/sanky/pathfinder/finder.rb +49 -0
- data/lib/sanky/pathfinder/options.rb +35 -0
- data/lib/sanky/pathfinder/runner.rb +16 -0
- data/lib/sanky/pathfinder/version.rb +5 -0
- data/sanky-pf.gemspec +20 -0
- data/tags +27 -0
- data/test/test_finder.rb +33 -0
- data/test/test_options.rb +22 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6d285ac85508bf85f66922d16f6aacadf50ed0c6
|
4
|
+
data.tar.gz: cf8dd2177485dfc7000947eb71bc082b92d3b3cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3cb66f400f687e7516bd591364880ec468cb23c50eff65e8ffbcfec624fc30b0e2002a3258407f3798b4da1d627fd790aecff2859c92f68953dabfb54012b6cb
|
7
|
+
data.tar.gz: 8f8e1acc2b938bf4e56e157a3df1567da7977265fbc5606819c71cba447d200db42516b2dcda4fa0ff643a6e586dc5be4d1ed655d1022ca91a47fcad81784241
|
data/README.md
ADDED
data/bin/sanky-pf
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
3
|
+
module Sanky
|
4
|
+
module PathFinder
|
5
|
+
class Finder
|
6
|
+
def initialize(arguments)
|
7
|
+
@arguments = arguments
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
@arguments
|
12
|
+
end
|
13
|
+
|
14
|
+
def convert
|
15
|
+
@arguments.map! do |original|
|
16
|
+
# subsitute windows backslashes for forwardslashes and strip whitespace
|
17
|
+
original = original.strip.gsub(/\\/, "/")
|
18
|
+
original.sub!(/L:/, "/Volumes/SankNet Drive")
|
19
|
+
original.sub!(/Z:/, "/Volumes/Sanky Direct Drive/Sanky Shared")
|
20
|
+
original.sub!(/Z:/, "/Volumes/Sanky Direct Drive/Sanky Shared")
|
21
|
+
original.sub!(/smb:\/\/sankycomserver/, "/Volumes")
|
22
|
+
# if no leading / add one
|
23
|
+
original.sub!(/^(?!\/)/, "/")
|
24
|
+
# if it doesn't start with /Volumes add it
|
25
|
+
original.sub!(/^(?!\/Volumes)/, "/Volumes")
|
26
|
+
# String.sub returns nil if no sub was performed, always return the og
|
27
|
+
original
|
28
|
+
end
|
29
|
+
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def open
|
34
|
+
@arguments.each do |target|
|
35
|
+
begin
|
36
|
+
# pipe STDERR to dev null in favor of custom prompt
|
37
|
+
`open -g '#{target}' > /dev/null 2>/dev/null`
|
38
|
+
ensure
|
39
|
+
if $? == 0
|
40
|
+
puts "Opening the file in the background...".yellow
|
41
|
+
else
|
42
|
+
puts "Failed to find #{target.red}!"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Sanky
|
4
|
+
module PathFinder
|
5
|
+
class Options
|
6
|
+
attr_reader :arguments
|
7
|
+
|
8
|
+
def initialize(argv)
|
9
|
+
parse(argv)
|
10
|
+
@arguments = argv
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def parse(argv)
|
16
|
+
OptionParser.new do |opts|
|
17
|
+
opts.banner = "Usage: sankypf file [ file ] ..."
|
18
|
+
|
19
|
+
opts.on("-h", "--help", "Show this message") do
|
20
|
+
puts opts
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
|
24
|
+
begin
|
25
|
+
argv = ["-h"] if argv.empty?
|
26
|
+
opts.parse!(argv)
|
27
|
+
rescue OptionParser::ParseError => e
|
28
|
+
STDERR.puts e.message, "\n", opts
|
29
|
+
exit(1)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative 'options'
|
2
|
+
require_relative 'finder'
|
3
|
+
|
4
|
+
module Sanky
|
5
|
+
module PathFinder
|
6
|
+
class Runner
|
7
|
+
def initialize(argv)
|
8
|
+
@options = Options.new(argv)
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
Sanky::PathFinder::Finder.new(@options.arguments).convert.open
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/sanky-pf.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path('../lib/sanky/pathfinder/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "sanky-pf"
|
5
|
+
s.summary = "Open files on the sanky server"
|
6
|
+
s.description = File.read("./README.md")
|
7
|
+
s.version = Sanky::PathFinder::VERSION
|
8
|
+
s.author = "Matt Ryan"
|
9
|
+
s.email = "m@mrevd.me"
|
10
|
+
s.homepage = "https://github.com/sankynet/sankypf"
|
11
|
+
s.platform = Gem::Platform::RUBY
|
12
|
+
s.required_ruby_version = ">=1.9"
|
13
|
+
s.files = Dir['**/**']
|
14
|
+
s.executables = [ "sanky-pf" ]
|
15
|
+
s.test_files = Dir['test/test*.rb']
|
16
|
+
s.has_rdoc = false
|
17
|
+
|
18
|
+
s.add_runtime_dependency 'colorize'
|
19
|
+
s.add_development_dependency 'shoulda'
|
20
|
+
end
|
data/tags
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
|
2
|
+
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
|
3
|
+
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
|
4
|
+
!_TAG_PROGRAM_NAME Exuberant Ctags //
|
5
|
+
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
|
6
|
+
!_TAG_PROGRAM_VERSION 5.8 //
|
7
|
+
Finder lib/sanky/pathfinder/finder.rb /^ class Finder$/;" c class:Sanky.PathFinder
|
8
|
+
Options lib/sanky/pathfinder/options.rb /^ class Options$/;" c class:Sanky.PathFinder
|
9
|
+
PathFinder lib/sanky/pathfinder/finder.rb /^ module PathFinder$/;" m class:Sanky
|
10
|
+
PathFinder lib/sanky/pathfinder/options.rb /^ module PathFinder$/;" m class:Sanky
|
11
|
+
PathFinder lib/sanky/pathfinder/runner.rb /^ module PathFinder$/;" m class:Sanky
|
12
|
+
PathFinder lib/sanky/pathfinder/version.rb /^ module PathFinder$/;" m class:Sanky
|
13
|
+
Runner lib/sanky/pathfinder/runner.rb /^ class Runner$/;" c class:Sanky.PathFinder
|
14
|
+
Sanky lib/sanky/pathfinder/finder.rb /^module Sanky$/;" m
|
15
|
+
Sanky lib/sanky/pathfinder/options.rb /^module Sanky$/;" m
|
16
|
+
Sanky lib/sanky/pathfinder/runner.rb /^module Sanky$/;" m
|
17
|
+
Sanky lib/sanky/pathfinder/version.rb /^module Sanky$/;" m
|
18
|
+
TestFinder test/test_finder.rb /^class TestFinder < Test::Unit::TestCase$/;" c
|
19
|
+
TestOptions test/test_options.rb /^class TestOptions < Test::Unit::TestCase$/;" c
|
20
|
+
convert lib/sanky/pathfinder/finder.rb /^ def convert$/;" f class:Sanky.PathFinder.Finder
|
21
|
+
initialize lib/sanky/pathfinder/finder.rb /^ def initialize(arguments)$/;" f class:Sanky.PathFinder.Finder
|
22
|
+
initialize lib/sanky/pathfinder/options.rb /^ def initialize(argv)$/;" f class:Sanky.PathFinder.Options
|
23
|
+
initialize lib/sanky/pathfinder/runner.rb /^ def initialize(argv)$/;" f class:Sanky.PathFinder.Runner
|
24
|
+
open lib/sanky/pathfinder/finder.rb /^ def open$/;" f class:Sanky.PathFinder.Finder
|
25
|
+
parse lib/sanky/pathfinder/options.rb /^ def parse(argv)$/;" f class:Sanky.PathFinder.Options
|
26
|
+
run lib/sanky/pathfinder/runner.rb /^ def run$/;" f class:Sanky.PathFinder.Runner
|
27
|
+
to_s lib/sanky/pathfinder/finder.rb /^ def to_s$/;" f class:Sanky.PathFinder.Finder
|
data/test/test_finder.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'shoulda'
|
3
|
+
require_relative '../lib/sanky/pathfinder/finder'
|
4
|
+
|
5
|
+
class TestFinder < Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "finder" do
|
8
|
+
setup do
|
9
|
+
@args = ['/test/doc1.txt', 'test/doc2.txt', 'volumes/doc3.txt', '/Volumes/doc4.txt']
|
10
|
+
@finder = Sanky::PathFinder::Finder.new(@args)
|
11
|
+
end
|
12
|
+
|
13
|
+
context "initalization" do
|
14
|
+
should "include arguements" do
|
15
|
+
assert_equal @args, @finder.to_s
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "conversion" do
|
20
|
+
should "properly parse paths" do
|
21
|
+
expected_results = [
|
22
|
+
'/Volumes/test/doc1.txt',
|
23
|
+
'/Volumes/test/doc2.txt',
|
24
|
+
'/Volumes/volumes/doc3.txt',
|
25
|
+
'/Volumes/doc4.txt'
|
26
|
+
]
|
27
|
+
|
28
|
+
assert_equal expected_results, @finder.convert.to_s
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'shoulda'
|
3
|
+
require_relative '../lib/sanky/pathfinder/options'
|
4
|
+
|
5
|
+
class TestOptions < Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "specifying a file" do
|
8
|
+
should "return it" do
|
9
|
+
opts = Sanky::PathFinder::Options.new(["/Volumes/Test/document.txt"])
|
10
|
+
assert_equal ["/Volumes/Test/document.txt"], opts.arguments
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "specifying multiple files" do
|
15
|
+
should "return them" do
|
16
|
+
docs = ["/doc1.txt", "doc2.txt"]
|
17
|
+
opts = Sanky::PathFinder::Options.new(docs)
|
18
|
+
assert_equal docs, opts.arguments
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sanky-pf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Ryan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: shoulda
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: |
|
42
|
+
# SANKY PATHFINDER
|
43
|
+
|
44
|
+
Installation is simple:
|
45
|
+
|
46
|
+
`gem install sankypf`
|
47
|
+
|
48
|
+
Usage is simple:
|
49
|
+
|
50
|
+
`sankypf escaped\ path\ to/file.txt`
|
51
|
+
email: m@mrevd.me
|
52
|
+
executables:
|
53
|
+
- sanky-pf
|
54
|
+
extensions: []
|
55
|
+
extra_rdoc_files: []
|
56
|
+
files:
|
57
|
+
- bin/sanky-pf
|
58
|
+
- lib/sanky/pathfinder/finder.rb
|
59
|
+
- lib/sanky/pathfinder/options.rb
|
60
|
+
- lib/sanky/pathfinder/runner.rb
|
61
|
+
- lib/sanky/pathfinder/version.rb
|
62
|
+
- README.md
|
63
|
+
- sanky-pf.gemspec
|
64
|
+
- tags
|
65
|
+
- test/test_finder.rb
|
66
|
+
- test/test_options.rb
|
67
|
+
homepage: https://github.com/sankynet/sankypf
|
68
|
+
licenses: []
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '1.9'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.1.11
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Open files on the sanky server
|
90
|
+
test_files:
|
91
|
+
- test/test_finder.rb
|
92
|
+
- test/test_options.rb
|