lsi 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 +5 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +60 -0
- data/LICENSE +21 -0
- data/README.md +3 -0
- data/Rakefile +24 -0
- data/bin/console +14 -0
- data/bin/lsi +27 -0
- data/bin/setup +8 -0
- data/lib/lsi.rb +45 -0
- data/lib/lsi/command.rb +44 -0
- data/lib/lsi/list.rb +34 -0
- data/lib/lsi/version.rb +3 -0
- data/lsi.gemspec +27 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8177f0ce12e9776e1e110d2f8451732a80f755ea
|
4
|
+
data.tar.gz: f83f7ed1378d8ad71bc6f219f74db0d9381f1e4a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 72b0c5c7574363938c408dfaa241633249ee919999308adfd971e1431520e97cfef5b24cc7b87ddfbc788cd5f48a2380bb149a4c49dc72f786a8157179866756
|
7
|
+
data.tar.gz: 1bb10a6f657d070e6f0b0882fddbcdbb13e35fec7be003b7979d39e610236eefe590cd5ba63bdf4b49f39f524e3698df94bcd1f251c3c0167277f087ac7ed8d5
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
lsi (1.0.0)
|
5
|
+
methadone (~> 1.9.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
aruba (0.14.1)
|
11
|
+
childprocess (~> 0.5.6)
|
12
|
+
contracts (~> 0.9)
|
13
|
+
cucumber (>= 1.3.19)
|
14
|
+
ffi (~> 1.9.10)
|
15
|
+
rspec-expectations (>= 2.99)
|
16
|
+
thor (~> 0.19)
|
17
|
+
builder (3.2.2)
|
18
|
+
childprocess (0.5.9)
|
19
|
+
ffi (~> 1.0, >= 1.0.11)
|
20
|
+
contracts (0.14.0)
|
21
|
+
cucumber (2.4.0)
|
22
|
+
builder (>= 2.1.2)
|
23
|
+
cucumber-core (~> 1.5.0)
|
24
|
+
cucumber-wire (~> 0.0.1)
|
25
|
+
diff-lcs (>= 1.1.3)
|
26
|
+
gherkin (~> 4.0)
|
27
|
+
multi_json (>= 1.7.5, < 2.0)
|
28
|
+
multi_test (>= 0.1.2)
|
29
|
+
cucumber-core (1.5.0)
|
30
|
+
gherkin (~> 4.0)
|
31
|
+
cucumber-wire (0.0.1)
|
32
|
+
diff-lcs (1.2.5)
|
33
|
+
ffi (1.9.14)
|
34
|
+
gherkin (4.0.0)
|
35
|
+
methadone (1.9.2)
|
36
|
+
bundler
|
37
|
+
multi_json (1.12.1)
|
38
|
+
multi_test (0.1.2)
|
39
|
+
power_assert (0.3.0)
|
40
|
+
rake (11.2.2)
|
41
|
+
rspec-expectations (3.5.0)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.5.0)
|
44
|
+
rspec-support (3.5.0)
|
45
|
+
test-unit (3.2.1)
|
46
|
+
power_assert
|
47
|
+
thor (0.19.1)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
ruby
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
aruba (~> 0.14)
|
54
|
+
bundler (~> 1.12)
|
55
|
+
lsi!
|
56
|
+
rake (~> 11.2)
|
57
|
+
test-unit (~> 3.2)
|
58
|
+
|
59
|
+
BUNDLED WITH
|
60
|
+
1.12.5
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 Jonathan Hoyt
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, 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,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "bundler"
|
2
|
+
require "rake/clean"
|
3
|
+
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
require "cucumber"
|
7
|
+
require "cucumber/rake/task"
|
8
|
+
|
9
|
+
include Rake::DSL
|
10
|
+
|
11
|
+
Bundler::GemHelper.install_tasks
|
12
|
+
|
13
|
+
Rake::TestTask.new do |t|
|
14
|
+
t.pattern = "test/*_test.rb"
|
15
|
+
end
|
16
|
+
|
17
|
+
CUKE_RESULTS = "results.html"
|
18
|
+
CLEAN << CUKE_RESULTS
|
19
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
20
|
+
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
|
21
|
+
t.fork = false
|
22
|
+
end
|
23
|
+
|
24
|
+
task :default => [:test,:features]
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "lsi"
|
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
|
data/bin/lsi
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
require "methadone"
|
5
|
+
lib = File.expand_path("../../lib", __FILE__)
|
6
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
7
|
+
require "lsi"
|
8
|
+
|
9
|
+
class App
|
10
|
+
include Methadone::Main
|
11
|
+
include Methadone::CLILogging
|
12
|
+
|
13
|
+
main do |command, path|
|
14
|
+
Lsi.start(command: command, path: path, list_command: options[:l])
|
15
|
+
end
|
16
|
+
|
17
|
+
on("-l LIST_COMMAND", "Custom list command")
|
18
|
+
|
19
|
+
arg :command, :optional
|
20
|
+
arg :path, :optional
|
21
|
+
|
22
|
+
version Lsi::VERSION
|
23
|
+
|
24
|
+
use_log_level_option :toggle_debug_on_signal => "USR1"
|
25
|
+
|
26
|
+
go!
|
27
|
+
end
|
data/bin/setup
ADDED
data/lib/lsi.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require "open3"
|
2
|
+
require "lsi/command"
|
3
|
+
require "lsi/list"
|
4
|
+
require "lsi/version"
|
5
|
+
|
6
|
+
class Lsi
|
7
|
+
def self.start(*args)
|
8
|
+
new(*args).start
|
9
|
+
end
|
10
|
+
|
11
|
+
def start
|
12
|
+
list.items.each do |item|
|
13
|
+
ask_question(item)
|
14
|
+
wait_for_and_process_input(item)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(command:, path:, list_command:)
|
19
|
+
@command = Command.new(command: command)
|
20
|
+
@list = List.new(path: path, list_command: list_command)
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :command, :list
|
24
|
+
|
25
|
+
def ask_question(item)
|
26
|
+
if command.custom?
|
27
|
+
print "Run `#{command.command} #{list.item_human_name(item)}`? [y,n,q] (y): "
|
28
|
+
else
|
29
|
+
print "Get info for `#{list.item_human_name(item)}`? [y,n,q] (y): "
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def wait_for_and_process_input(item)
|
34
|
+
case STDIN.gets.chomp
|
35
|
+
when "y", ""
|
36
|
+
command.run(item)
|
37
|
+
when "n"
|
38
|
+
# noop
|
39
|
+
when "q"
|
40
|
+
exit
|
41
|
+
else
|
42
|
+
exit!
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/lsi/command.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "open3"
|
2
|
+
|
3
|
+
class Lsi
|
4
|
+
class Command
|
5
|
+
def initialize(command:)
|
6
|
+
@command = command
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :command
|
10
|
+
|
11
|
+
def custom?
|
12
|
+
!!command
|
13
|
+
end
|
14
|
+
|
15
|
+
def run(item)
|
16
|
+
if custom?
|
17
|
+
custom(item)
|
18
|
+
else
|
19
|
+
default(item)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def custom(item)
|
24
|
+
stdout, stderr, status = Open3.capture3("#{command} #{item}")
|
25
|
+
|
26
|
+
if status.success?
|
27
|
+
puts stdout
|
28
|
+
else
|
29
|
+
puts stderr
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def default(path)
|
34
|
+
filename = File.basename(path)
|
35
|
+
stat = File.stat(path)
|
36
|
+
|
37
|
+
if stat.directory?
|
38
|
+
puts "#{filename} is a directory with permissions #{sprintf("%o", stat.mode)}"
|
39
|
+
else
|
40
|
+
puts "#{filename} is a #{stat.size} byte file with permissions #{sprintf("%o", stat.mode)}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/lsi/list.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
class Lsi
|
2
|
+
class List
|
3
|
+
def initialize(path:, list_command:)
|
4
|
+
@path = path
|
5
|
+
@list_command = list_command
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader :path, :list_command
|
9
|
+
|
10
|
+
def items
|
11
|
+
if list_command
|
12
|
+
stdout, stderr, status = Open3.capture3(list_command)
|
13
|
+
|
14
|
+
if status.success?
|
15
|
+
stdout.split("\n")
|
16
|
+
end
|
17
|
+
else
|
18
|
+
directory_listing
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def item_human_name(item)
|
23
|
+
if list_command
|
24
|
+
item
|
25
|
+
else
|
26
|
+
File.basename(item)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def directory_listing
|
31
|
+
Dir["#{path || Dir.pwd}/*"]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/lsi/version.rb
ADDED
data/lsi.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "lsi/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "lsi"
|
8
|
+
spec.license=""
|
9
|
+
spec.version = Lsi::VERSION
|
10
|
+
spec.authors = ["Jonathan Hoyt"]
|
11
|
+
spec.email = ["hoyt@github.com"]
|
12
|
+
|
13
|
+
spec.summary = "Interactively operate on a list"
|
14
|
+
spec.description = "Interactively operate on a list."
|
15
|
+
spec.homepage = "https://github.com/jonmagic/lsi"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
23
|
+
spec.add_development_dependency "aruba", "~> 0.14"
|
24
|
+
spec.add_development_dependency "rake", "~> 11.2"
|
25
|
+
spec.add_development_dependency "test-unit", "~> 3.2"
|
26
|
+
spec.add_dependency "methadone", "~> 1.9"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lsi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonathan Hoyt
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aruba
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.14'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.14'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '11.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '11.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: test-unit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: methadone
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.9'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.9'
|
83
|
+
description: Interactively operate on a list.
|
84
|
+
email:
|
85
|
+
- hoyt@github.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- Gemfile.lock
|
93
|
+
- LICENSE
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/console
|
97
|
+
- bin/lsi
|
98
|
+
- bin/setup
|
99
|
+
- lib/lsi.rb
|
100
|
+
- lib/lsi/command.rb
|
101
|
+
- lib/lsi/list.rb
|
102
|
+
- lib/lsi/version.rb
|
103
|
+
- lsi.gemspec
|
104
|
+
homepage: https://github.com/jonmagic/lsi
|
105
|
+
licenses:
|
106
|
+
- ''
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.4.5.1
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Interactively operate on a list
|
128
|
+
test_files: []
|