pass-station 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b9ea9f62eaff1a5166ac66df8b994d5928173eb1d23fb997f02ca3cbdc5f712
4
- data.tar.gz: 1cb19d830a7b18b49e6317911c5a6ca8411e0641921d2471749bc2f81c64cb12
3
+ metadata.gz: 12c331db3e7fcee2924f24bb97d63319642414e8bd7b0c04005b48e8dc4f111c
4
+ data.tar.gz: b8b8f2a92526afc046b5ae6a011aa3967475d8d6a57cbdceee6670a9bf0c585f
5
5
  SHA512:
6
- metadata.gz: 89a6526c063b14e47d3316b6bb544396a03fd95e98fe488d366061e4837bb0e3b3994e2d402381d11fb5a2831479d2efa3ce252f168b85a5bb200939ff1ddb98
7
- data.tar.gz: bec11f0af9253d0d54c05192aa6544e335d502b0d8cf00296c6a3a7b4473bb3e9352ac942a102e5c6d2d3b4380132fb50fb6fe1340b2a9129df5d93cc7ee47f9
6
+ metadata.gz: e20f71eee6eccc0eab06c0485eba0d358ed1053926333aab03e1e240f35775c2e5cdef2b69b3335353be101a983f142d5964d5564fae0627ada21ed6d4a29ab7
7
+ data.tar.gz: 670188256f1790be404edad7b3214d53ef26afb0920d710e9cfd1f3afdb8f6810603853b3f314a1566a258dc485587d3f3b2fbb599d661a236bb426096b60280
@@ -4,4 +4,4 @@
4
4
  require 'pass_station'
5
5
  require 'irb'
6
6
 
7
- IRB.start(__FILE__)
7
+ IRB.start(__FILE__)
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::Table+ format
28
- # @return [CSV::Table] pasword database
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
@@ -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::Table]
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::Table+ into a simple table with justified columns
72
- # @param table [CSV::Table] a +CSV::Table+
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::Table]
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::Table]
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::Table+ into a simple table with justified columns
151
- # @param table [CSV::Table] a +CSV::Table+
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
@@ -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::Table] table of +CSV::Row+, each row contains three
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, @config).sort_by do |s|
29
+ @data = CSV.table(@database_path, **@config).sort_by do |s|
30
30
  s[sort].downcase
31
31
  end
32
32
  end
@@ -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::Table] table of +CSV::Row+, each row contains three
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Version
4
- VERSION = '1.0.0'
5
- end
4
+ VERSION = '1.1.0'
5
+ end
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.0.0
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-09 00:00:00.000000000 Z
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.4.0
196
+ version: 2.6.0
197
197
  - - "<"
198
198
  - !ruby/object:Gem::Version
199
199
  version: '3.0'