charsat 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0ff7e95c31aa09e725b10cf71af8c8837a4920d3
4
+ data.tar.gz: d7c675f40f2497722ab05f99157878bd534c273a
5
+ SHA512:
6
+ metadata.gz: 65a3ca33d0cda59825879699224b7d60ae26340f25b95c17f3c864bbc410876f738b86c5353928059a8490763e80e79ab89624679e098137c095ccbb69141d2d
7
+ data.tar.gz: 1a379b25e7b05cfd90063a0614a5ed36cc34ddce3369ec655d7a857dc3929c3643b82f935c54ba1c7bbdde50499cd1b3e6a5aabf962c96b11efd2d62dbeb8b05
data/.gitignore ADDED
@@ -0,0 +1,12 @@
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
12
+ .idea
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.3
5
+ before_install: gem install bundler -v 1.16.1
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 charsat.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ charsat (0.1.0)
5
+ cri
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ colored (1.2)
11
+ cri (2.10.1)
12
+ colored (~> 1.2)
13
+ diff-lcs (1.3)
14
+ rake (10.5.0)
15
+ rspec (3.7.0)
16
+ rspec-core (~> 3.7.0)
17
+ rspec-expectations (~> 3.7.0)
18
+ rspec-mocks (~> 3.7.0)
19
+ rspec-core (3.7.1)
20
+ rspec-support (~> 3.7.0)
21
+ rspec-expectations (3.7.0)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.7.0)
24
+ rspec-mocks (3.7.0)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.7.0)
27
+ rspec-support (3.7.1)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bundler (~> 1.16)
34
+ charsat!
35
+ rake (~> 10.0)
36
+ rspec (~> 3.0)
37
+
38
+ BUNDLED WITH
39
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Jason Cabot
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # CharsAt
2
+
3
+ A tool to read characters from stdin using 1-based indexing.
4
+
5
+ I use this for printing n characters from long, complex passwords for certain (banking) sites that require it
6
+
7
+ For example:
8
+
9
+ * Open password manager
10
+ * Copy complex password to clipboard
11
+ * Pipe clipboard content into this tool
12
+
13
+ ## License
14
+
15
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
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/charsat ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'charsat'
4
+ CharsAt::CLI.new.print(ARGV)
data/charsat.gemspec ADDED
@@ -0,0 +1,28 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "charsat/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "charsat"
8
+ spec.version = CharsAt::VERSION
9
+ spec.authors = ["Jason Cabot"]
10
+ spec.email = ["jasoncabot@gmail.com"]
11
+
12
+ spec.summary = %q{A tool to read characters from stdin using 1-based indexing}
13
+ spec.homepage = "https://github.com/jasoncabot/charsat"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "bin"
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.16"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+
27
+ spec.add_dependency 'cri'
28
+ end
data/lib/charsat.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "charsat/version"
2
+
3
+ module CharsAt
4
+ autoload :CLI, 'charsat/cli'
5
+ autoload :Model, 'charsat/model'
6
+ end
@@ -0,0 +1,41 @@
1
+ require 'charsat'
2
+ require 'cri'
3
+ require 'io/console'
4
+
5
+ module CharsAt
6
+ class CLI
7
+ def print(args)
8
+ command = Cri::Command.define do
9
+ name 'charsat'
10
+ usage "echo 'test' | charsat 1 2 3 # outputs t, e and s"
11
+ summary "Prints the n'th characters using 1-based indexing from STDIN"
12
+
13
+ skip_option_parsing
14
+
15
+ flag :h, :help, 'show help for this command' do |value, cmd|
16
+ puts cmd.help
17
+ exit 0
18
+ end
19
+
20
+ run do |opts, args, cmd|
21
+
22
+ if args.empty? || args.first == "--help" || args.first == "-h"
23
+ puts cmd.help
24
+ exit 1
25
+ end
26
+
27
+ string = (STDIN.tty?) ? STDIN.getpass("Enter string: ") : $stdin.read
28
+ indices = args.map(&:to_i).select { |i| i <= string.length }
29
+
30
+ if indices.empty?
31
+ puts cmd.help
32
+ exit 1
33
+ end
34
+
35
+ puts Model.new(string, indices).parsed.join(', ')
36
+ end
37
+ end
38
+ command.run(args)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,14 @@
1
+ require 'charsat'
2
+
3
+ module CharsAt
4
+ class Model
5
+ def initialize(content, indices)
6
+ @content = content
7
+ @indices = indices
8
+ end
9
+
10
+ def parsed
11
+ @indices.map { |i| @content[i.to_i - 1] }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module CharsAt
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: charsat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jason Cabot
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-19 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: cri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - jasoncabot@gmail.com
72
+ executables:
73
+ - charsat
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/charsat
86
+ - charsat.gemspec
87
+ - lib/charsat.rb
88
+ - lib/charsat/cli.rb
89
+ - lib/charsat/model.rb
90
+ - lib/charsat/version.rb
91
+ homepage: https://github.com/jasoncabot/charsat
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.6.14
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: A tool to read characters from stdin using 1-based indexing
115
+ test_files: []