pass-station 1.0.0 → 1.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 +4 -4
- data/bin/pass-station_console +1 -1
- data/lib/pass_station.rb +2 -4
- data/lib/pass_station/output.rb +47 -7
- data/lib/pass_station/parse.rb +2 -2
- data/lib/pass_station/search.rb +1 -1
- data/lib/pass_station/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12c331db3e7fcee2924f24bb97d63319642414e8bd7b0c04005b48e8dc4f111c
|
4
|
+
data.tar.gz: b8b8f2a92526afc046b5ae6a011aa3967475d8d6a57cbdceee6670a9bf0c585f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e20f71eee6eccc0eab06c0485eba0d358ed1053926333aab03e1e240f35775c2e5cdef2b69b3335353be101a983f142d5964d5564fae0627ada21ed6d4a29ab7
|
7
|
+
data.tar.gz: 670188256f1790be404edad7b3214d53ef26afb0920d710e9cfd1f3afdb8f6810603853b3f314a1566a258dc485587d3f3b2fbb599d661a236bb426096b60280
|
data/bin/pass-station_console
CHANGED
data/lib/pass_station.rb
CHANGED
@@ -15,8 +15,6 @@ module PassStation
|
|
15
15
|
class DB
|
16
16
|
# Get / set storage location, where will be stored the password database.
|
17
17
|
# @return [String] database storage location. Default to +data/+.
|
18
|
-
# @example
|
19
|
-
# PassStation.storage_location = '/srv/downloads/'
|
20
18
|
attr_accessor :storage_location
|
21
19
|
|
22
20
|
# Get / set the password database name
|
@@ -24,8 +22,8 @@ module PassStation
|
|
24
22
|
# +DefaultCreds-Cheat-Sheet.csv+.
|
25
23
|
attr_accessor :database_name
|
26
24
|
|
27
|
-
# Get the password database in +CSV::
|
28
|
-
# @return [CSV::
|
25
|
+
# Get the password database in +Array<CSV::Row>+ format
|
26
|
+
# @return [Array<CSV::Row>] pasword database
|
29
27
|
attr_reader :data
|
30
28
|
|
31
29
|
# A new instance of Pass Station
|
data/lib/pass_station/output.rb
CHANGED
@@ -13,7 +13,7 @@ module PassStation
|
|
13
13
|
class DB
|
14
14
|
# Output the data in the chosen format
|
15
15
|
# @param formatter [String] Engine to use to format the data: +table+, +'pretty-table'+, +JSON+, +CSV+, +YAML+
|
16
|
-
# @param data [CSV::
|
16
|
+
# @param data [Array<CSV::Row>]
|
17
17
|
# @return [Array<String>] formatted output
|
18
18
|
def output(formatter, data)
|
19
19
|
# Convert string to class
|
@@ -68,8 +68,8 @@ module PassStation
|
|
68
68
|
# Simple table formatter
|
69
69
|
class Table
|
70
70
|
class << self
|
71
|
-
# Format the +CSV::
|
72
|
-
# @param table [CSV::
|
71
|
+
# Format the +Array<CSV::Row>+ into a simple table with justified columns
|
72
|
+
# @param table [Array<CSV::Row>] an +Array<CSV::Row>+
|
73
73
|
# @return [Array<String>] the formatted table ready to be printed
|
74
74
|
def format(table)
|
75
75
|
out = []
|
@@ -82,7 +82,7 @@ module PassStation
|
|
82
82
|
end
|
83
83
|
|
84
84
|
# Calculate column size (max item size)
|
85
|
-
# @param table [CSV::
|
85
|
+
# @param table [Array<CSV::Row>]
|
86
86
|
# @param column [Symbol] the symbol of the column
|
87
87
|
# @return [Integer] the column size
|
88
88
|
def colsize_count(table, column)
|
@@ -90,7 +90,7 @@ module PassStation
|
|
90
90
|
end
|
91
91
|
|
92
92
|
# Calculate the size of all columns (max item size)
|
93
|
-
# @param table [CSV::
|
93
|
+
# @param table [Array<CSV::Row>]
|
94
94
|
# @return [Hash] keys are columns name, values are columns size
|
95
95
|
def colsizes_count(table)
|
96
96
|
colsizes = table.first.to_h.keys.each_with_object({}) do |c, h|
|
@@ -147,8 +147,8 @@ module PassStation
|
|
147
147
|
# Pretty table with ASCII borders formatter
|
148
148
|
class PrettyTable < Table
|
149
149
|
class << self
|
150
|
-
# Format the +CSV::
|
151
|
-
# @param table [CSV::
|
150
|
+
# Format the +Array<CSV::Row>+ into a simple table with justified columns
|
151
|
+
# @param table [Array<CSV::Row>] an +Array<CSV::Row>+
|
152
152
|
# @return [Array<String>] the formatted table ready to be printed
|
153
153
|
def format(table)
|
154
154
|
out = []
|
@@ -200,5 +200,45 @@ module PassStation
|
|
200
200
|
protected :dividers, :headers, :justify_row, :justify
|
201
201
|
end
|
202
202
|
end
|
203
|
+
|
204
|
+
# CSV formatter
|
205
|
+
class Csv
|
206
|
+
class << self
|
207
|
+
# Format the +Array<CSV::Row>+ into a CSV
|
208
|
+
# @param table [Array<CSV::Row>] an +Array<CSV::Row>+
|
209
|
+
# @return [Array<String>] the formatted CSV ready to be printed
|
210
|
+
def format(table)
|
211
|
+
CSV::Table.new(table).to_csv.split("\n")
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
# JSON formatter
|
217
|
+
class Json
|
218
|
+
class << self
|
219
|
+
# Format the +Array<CSV::Row>+ into JSON
|
220
|
+
# @param table [Array<CSV::Row>] an +Array<CSV::Row>+
|
221
|
+
# @return [Array<String>] the formatted JSON ready to be printed (only
|
222
|
+
# one element on the array, keep an array for compatibility with
|
223
|
+
# {highlight_found} and homogeneity with other formatters)
|
224
|
+
def format(table)
|
225
|
+
[table.map(&:to_h).to_json]
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
# YAML formatter
|
231
|
+
class Yaml
|
232
|
+
class << self
|
233
|
+
# Format the +Array<CSV::Row>+ into YAML
|
234
|
+
# @param table [Array<CSV::Row>] an +Array<CSV::Row>+
|
235
|
+
# @return [Array<String>] the formatted YAML ready to be printed (only
|
236
|
+
# one element on the array, keep an array for compatibility with
|
237
|
+
# {highlight_found} and homogeneity with other formatters)
|
238
|
+
def format(table)
|
239
|
+
[table.map(&:to_h).to_yaml]
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
203
243
|
end
|
204
244
|
end
|
data/lib/pass_station/parse.rb
CHANGED
@@ -23,10 +23,10 @@ module PassStation
|
|
23
23
|
|
24
24
|
# Parse, sort and sanitize the password database
|
25
25
|
# @param sort [Symbol] column name to sort by: +:productvendor+, +:username+, +:password+
|
26
|
-
# @return [CSV::
|
26
|
+
# @return [Array<CSV::Row>] table of +CSV::Row+, each row contains three
|
27
27
|
# attributes: :productvendor, :username, :password
|
28
28
|
def parse(sort = :productvendor)
|
29
|
-
@data = CSV.table(@database_path,
|
29
|
+
@data = CSV.table(@database_path, **@config).sort_by do |s|
|
30
30
|
s[sort].downcase
|
31
31
|
end
|
32
32
|
end
|
data/lib/pass_station/search.rb
CHANGED
@@ -8,7 +8,7 @@ module PassStation
|
|
8
8
|
# @param term [String] the searched term
|
9
9
|
# @param col [Symbol] the column to search in: :productvendor | :username | :password | :all (all columns)
|
10
10
|
# @see build_regexp for +opts+ param description
|
11
|
-
# @return [CSV::
|
11
|
+
# @return [Array<CSV::Row>] table of +CSV::Row+, each row contains three
|
12
12
|
# attributes: :productvendor, :username, :password
|
13
13
|
def search(term, col, opts = {})
|
14
14
|
r1 = prepare_search(term, opts)
|
data/lib/pass_station/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pass-station
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre ZANNI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|
@@ -193,7 +193,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
193
193
|
requirements:
|
194
194
|
- - ">="
|
195
195
|
- !ruby/object:Gem::Version
|
196
|
-
version: 2.
|
196
|
+
version: 2.6.0
|
197
197
|
- - "<"
|
198
198
|
- !ruby/object:Gem::Version
|
199
199
|
version: '3.0'
|