storazzo 0.5.7 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -5
  3. data/Makefile +8 -6
  4. data/Rakefile +15 -13
  5. data/VERSION +1 -1
  6. data/bin/hello-storazzo +1 -0
  7. data/bin/ricdisk-magic +33 -30
  8. data/bin/stats-with-md5 +182 -157
  9. data/bin/storazzo +112 -114
  10. data/bin/storazzo-symlink.rb +1 -0
  11. data/lib/storazzo/colors.rb +77 -36
  12. data/lib/storazzo/common.rb +72 -68
  13. data/lib/storazzo/debug.rb +2 -0
  14. data/lib/storazzo/hashify.rb +7 -5
  15. data/lib/storazzo/main.rb +59 -49
  16. data/lib/storazzo/media/abstract_ric_disk.rb +188 -179
  17. data/lib/storazzo/media/gcs_bucket.rb +76 -58
  18. data/lib/storazzo/media/local_folder.rb +56 -42
  19. data/lib/storazzo/media/mount_point.rb +20 -12
  20. data/lib/storazzo/ric_disk.rb +386 -383
  21. data/lib/storazzo/ric_disk_config.rb +227 -209
  22. data/lib/storazzo/ric_disk_sample_config.rb +26 -24
  23. data/lib/storazzo/ric_disk_statsfile.rb +19 -17
  24. data/lib/storazzo/ric_disk_ugly.rb +1 -0
  25. data/lib/storazzo/version.rb +3 -3
  26. data/lib/storazzo.rb +6 -7
  27. data/storazzo.gemspec +24 -16
  28. data/test/benchmark/for_future_use.rb +4 -2
  29. data/test/benchmark/test_hashing_functions-speed.rb +17 -0
  30. data/test/bin/new-idea.rb +17 -0
  31. data/test/bin/storazzo.rb +22 -25
  32. data/test/media/test_abstract_ric_disk.rb +5 -3
  33. data/test/media/test_gcs_bucket.rb +24 -23
  34. data/test/media/test_local_folder.rb +24 -23
  35. data/test/media/test_mount_point.rb +6 -5
  36. data/test/test_ric_disk.rb +6 -4
  37. data/test/test_ric_disk_config.rb +12 -11
  38. data/test/test_ric_disk_stats_file.rb +5 -3
  39. data/test/test_storazzo.rb +6 -4
  40. data/var/test/disks/disk02-full/Rakefile +7 -5
  41. data/var/test/disks/ricdisk_stats_v11.rds +11 -0
  42. metadata +13 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb18e024b54651bcd5bfc08aa3d67691b9dec1a1d725ffd66a4369ab16fbc634
4
- data.tar.gz: '0870aa94ba6e3e9393aefea8e7ddcfc5df6103e3ff0942b1c4bc2ee9e0c648b5'
3
+ metadata.gz: e82c96fbdff7b8d2f78556899257b431ec1e58ec255321bae2afb4ba3b1ac309
4
+ data.tar.gz: f343d195bce5121d18f456b3fd90f8032a41427ae41e4248f5b8628aca1b0a3e
5
5
  SHA512:
6
- metadata.gz: e4c821df6d4345a2b3ead5853583175a443f8f4ae96ff2ca4f04fc1272c6aa7e25dbb2a4116be68bea51f797251967e607c2b3128c3401dd321d8efcdc232fcb
7
- data.tar.gz: b6452fc5e1cb20d5808cf82f763b2cfd65529195afb006fd30bcee4d08254b45e3a0fb3cc53c7e8e60ff3be36273636c8142c12036b0d88eefba94393d7da035
6
+ metadata.gz: d9aa08e7fcc62e0d8a3510db4d26f27e227aa778f8e9d8e6d7831676936c282e97f72f57f08febdc7383dec2f1e4c66beb42eb94dae3638f422fc6073292f204
7
+ data.tar.gz: e75cb487f55943dbae3d23242909ca61a83c39aaf5ef793225c074181f6914290d7f11aa3fa537f43010db4feab239efb14e88c5f30d91f737465081ad825309
data/Gemfile CHANGED
@@ -1,10 +1,12 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # to troubleshoot/debug things
4
- gem 'rubocop'
5
- gem "ruby-lsp", "~> 0.0.4", :group => :development
6
6
  gem 'rake'
7
+ gem 'rubocop'
8
+ gem 'ruby-lsp', '~> 0.0.4', group: :development
9
+
7
10
  # gem 'pry'
8
- gem 'pry', :group => :development
9
- # gem 'require_all' # yup I'm lazy: https://stackoverflow.com/questions/735073/best-way-to-require-all-files-from-a-directory-in-ruby
11
+ gem 'pry', group: :development
10
12
  # gem 'after_do' # To allow AFTER calling instance to do LOAD() automagically. Naah I can do without :)
data/Makefile CHANGED
@@ -10,14 +10,14 @@ help:
10
10
  build-local:
11
11
  gem build storazzo.gemspec
12
12
 
13
- build: build-local
13
+ build: build-local
14
14
 
15
15
  install:
16
16
  gem install ./storazzo-$(VER).gem
17
17
 
18
18
  push-to-rubygems: build-local test
19
19
  gem push ./storazzo-$(VER).gem
20
- push-to-rubygems-without-tests: build-local
20
+ push-to-rubygems-without-tests: build-local
21
21
  gem push ./storazzo-$(VER).gem
22
22
 
23
23
  list:
@@ -31,7 +31,7 @@ test-all:
31
31
  #bin/ricdisk-magic Ciao-da-Makefile
32
32
  echo 3. run rake test.. ont configured yet just a memo for the future.
33
33
  RUBYOPT="-W0" rake test
34
- echo 4. Prove I can include local gem in irb and play around. Similarly to rails console without reload.
34
+ echo 4. Prove I can include local gem in irb and play around. Similarly to rails console without reload.
35
35
  make irb-test
36
36
  @echo 'OK: ALL TESTS PASSED. #STIKA'
37
37
 
@@ -62,9 +62,9 @@ test-local-folder:
62
62
  test-media-subfolder:
63
63
  rake test TEST="test/media/*.rb"
64
64
  test-verbose:
65
- rake test:verbose --verbose
65
+ rake test:verbose --verbose
66
66
  test-silent:
67
- RUBYOPT="-W0" rake test:silent --verbose
67
+ RUBYOPT="-W0" rake test:silent --verbose
68
68
  test-single-file-continuously:
69
69
  \watch -n 5 --color rake test TEST="test/media/test_local_folder.rb"
70
70
 
@@ -72,4 +72,6 @@ test-binary-with-local-gem:
72
72
  ruby -Ilib bin/hello-storazzo
73
73
  test-binary-with-system-gem:
74
74
  bin/hello-storazzo
75
-
75
+
76
+ lint:
77
+ rubocop --auto-correct
data/Rakefile CHANGED
@@ -1,43 +1,45 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # require 'rake'
2
4
 
3
5
  # from hola: https://guides.rubygems.org/make-your-own-gem/#adding-an-executable
4
- require "rake/testtask"
6
+ require 'rake/testtask'
5
7
 
6
- desc "Run Unit tests"
8
+ desc 'Run Unit tests'
7
9
  Rake::TestTask.new(:test) do |t|
8
- t.libs << "test"
9
- t.libs << "test/media"
10
- # note this is only useful for this: https://chriskottom.com/articles/command-line-flags-for-minitest-in-the-raw/
10
+ t.libs << 'test'
11
+ t.libs << 'test/media'
12
+ # NOTE: this is only useful for this: https://chriskottom.com/articles/command-line-flags-for-minitest-in-the-raw/
11
13
  t.verbose = false
12
14
  t.warning = false
13
15
  # puts "[RiccardoOnly]: t.pattern: #{t.pattern}"
14
16
  t.pattern = 'test/**/test_*.rb'
15
17
  end
16
18
 
17
- desc "By default, Run Unit tests"
19
+ desc 'By default, Run Unit tests'
18
20
  task default: :test
19
21
 
20
22
  # Adding test/media directory to rake test.
21
- desc "Test tests/media/* code sobenem"
23
+ desc 'Test tests/media/* code sobenem'
22
24
  namespace :test do
23
25
  desc "Test Verbosely by default since I'm too stupid to toggle via ENV var dammit"
24
26
  Rake::TestTask.new(:verbose) do |t|
25
- t.libs << "test"
26
- t.libs << "test/media"
27
+ t.libs << 'test'
28
+ t.libs << 'test/media'
27
29
  t.verbose = true
28
30
  t.warning = true
29
31
  t.pattern = 'test/**/test_*.rb'
30
32
  $DEBUG = true
31
33
  end
32
34
 
33
- desc "Test Silently and removes VERBOSITY"
35
+ desc 'Test Silently and removes VERBOSITY'
34
36
  Rake::TestTask.new(:silent) do |t|
35
- t.libs << "test"
36
- t.libs << "test/media"
37
+ t.libs << 'test'
38
+ t.libs << 'test/media'
37
39
  t.verbose = false
38
40
  t.warning = false
39
41
  t.pattern = 'test/**/test_*.rb'
40
- puts "Note: Best to call me with RUBYOPT='-W0'. Now RUBYOPT=#{ ENV['RUBYOPT'] }" if ENV['RUBYOPT'].nil?
42
+ puts "Note: Best to call me with RUBYOPT='-W0'. Now RUBYOPT=#{ENV['RUBYOPT']}" if ENV['RUBYOPT'].nil?
41
43
  $DEBUG = false
42
44
  end
43
45
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.7
1
+ 0.6.1
data/bin/hello-storazzo CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'storazzo'
4
5
 
data/bin/ricdisk-magic CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  ############# ############# ############# ############# ############# ############# ############# #############
4
5
  # placeholder until i make it work..
@@ -32,7 +33,7 @@ include Storazzo::Common # instead
32
33
  # extend Storazzo::Colors
33
34
 
34
35
  if RUBY_VERSION.split('.')[0] == 1
35
- puts "Refusing to launch a script form Ruby 1. Sorry Ric, its 2020 damn it!"
36
+ puts 'Refusing to launch a script form Ruby 1. Sorry Ric, its 2020 damn it!'
36
37
  exit 2020
37
38
  end
38
39
 
@@ -47,23 +48,21 @@ HISTORY = <<-BIG_LONG_MULTILINE
47
48
  2022-07-DD v0.2 Some private stuff on GIC
48
49
  BIG_LONG_MULTILINE
49
50
 
50
- =begin
51
-
52
- ############################################################
53
- @author: Riccardo Carlesso
54
- @email: riccardo.carlesso@gmail.com
55
- @maturity: development
56
- @language: Ruby
57
- @synopsis: Brief Description here
58
- @tags: development, rcarlesso, test
59
- @description: See description
60
- ############################################################
61
-
62
- =end
51
+ #
52
+ # ############################################################
53
+ # @author: Riccardo Carlesso
54
+ # @email: riccardo.carlesso@gmail.com
55
+ # @maturity: development
56
+ # @language: Ruby
57
+ # @synopsis: Brief Description here
58
+ # @tags: development, rcarlesso, test
59
+ # @description: See description
60
+ # ############################################################
61
+ #
63
62
 
64
63
  $myconf = {
65
- :app_name => "RicDisk Magic should be sth like #{$0}",
66
- :description => "
64
+ app_name: "RicDisk Magic should be sth like #{$PROGRAM_NAME}",
65
+ description: "
67
66
  This program is loosely inspired to ricdisk-magic.sh but its much better.
68
67
  The idea is: iterate through all ARGV elements and build a DB of all files with length and MD5.
69
68
  Then if folder is writeable, put this list INSIDE IT as its so conveniente.
@@ -74,13 +73,13 @@ $myconf = {
74
73
  Note. This software is part of the Storazzo gem ('sai chi ti saluta un casino?'):
75
74
 
76
75
  $ gem install storazzo
77
- ".strip.gsub(/^\s+/, "").gsub(/\s+$/, ""),
78
- # TODO move to some class default
79
- :media_dirs => %w{/media/riccardo/ /Volumes/ /mnt/ ~/git/storazzo/var/test/
80
- /sobenme/giusto/per/imparare/ad/ammutolire/gli/errori/},
81
- :mount_types => %w{vfat ntfs},
76
+ ".strip.gsub(/^\s+/, '').gsub(/\s+$/, ''),
77
+ # TODO: move to some class default
78
+ media_dirs: %w[/media/riccardo/ /Volumes/ /mnt/ ~/git/storazzo/var/test/
79
+ /sobenme/giusto/per/imparare/ad/ammutolire/gli/errori/],
80
+ mount_types: %w[vfat ntfs]
82
81
  }
83
- $stats_file = "ricdisk_stats_v11.rds" # => RicDiskStatsFile
82
+ $stats_file = 'ricdisk_stats_v11.rds' # => RicDiskStatsFile
84
83
  $gcs_bucket = 'TODO-CHANGE-CONFIG-palladius'
85
84
 
86
85
  # This template from scripta.rb. from 2.1.0 removed aby ric gem dependency.
@@ -91,14 +90,15 @@ $TEMPLATE_VER = '2.1.1'
91
90
  def usage(comment = nil)
92
91
  puts white($optparse.banner)
93
92
  puts($optparse.summarize)
94
- puts("Description: " + gray($myconf[:description]))
93
+ puts("Description: #{gray($myconf[:description])}")
95
94
  puts red(comment) if comment
96
95
  # puts "Description: #{ $myconf[:description] }"
97
96
  exit 13
98
97
  end
99
98
 
100
99
  # include it in main if you want a custome one
101
- def init() # see lib_autoinit in lib/util.rb
100
+ # see lib_autoinit in lib/util.rb
101
+ def init
102
102
  $opts = {}
103
103
  # setting defaults
104
104
  $opts[:verbose] = false
@@ -107,8 +107,11 @@ def init() # see lib_autoinit in lib/util.rb
107
107
  $opts[:force] = false
108
108
 
109
109
  $optparse = OptionParser.new do |opts|
110
- opts.banner = "#{$0} v.#{$PROG_VER}\n Usage: #{File.basename $0} [options] file1 file2 ..."
111
- opts.on('-d', '--debug', 'enables debug (DFLT=false)') { $opts[:debug] = true; $DEBUG = true }
110
+ opts.banner = "#{$PROGRAM_NAME} v.#{$PROG_VER}\n Usage: #{File.basename $PROGRAM_NAME} [options] file1 file2 ..."
111
+ opts.on('-d', '--debug', 'enables debug (DFLT=false)') do
112
+ $opts[:debug] = true
113
+ $DEBUG = true
114
+ end
112
115
  opts.on('-f', '--force', 'force stuff (DFLT=false)') { $opts[:force] = true }
113
116
  opts.on('-h', '--help', 'Display this screen') { usage }
114
117
  # opts.on( '-j', '--jabba', 'Activates my Jabber powerful CLI' ) { $opts[:jabba] = true }
@@ -120,7 +123,7 @@ def init() # see lib_autoinit in lib/util.rb
120
123
  end
121
124
 
122
125
  def real_program
123
- deb("Hello world from a templated '#{yellow $0}'")
126
+ deb("Hello world from a templated '#{yellow $PROGRAM_NAME}'")
124
127
  deb "+ Options are: #{gray $opts}"
125
128
  deb "+ Depured args: #{azure ARGV}"
126
129
  deb "+ Script-specifig super-cool conf: #{green $prog_conf_d}"
@@ -130,7 +133,7 @@ def real_program
130
133
  puts white("Hello world from #{$myconf[:app_name]}!")
131
134
  puts "Description: '''#{white $myconf[:description]}'''"
132
135
 
133
- config = Storazzo::RicDiskConfig.instance()
136
+ config = Storazzo::RicDiskConfig.instance
134
137
  config.load
135
138
  puts "StorazzoConfig: #{config}"
136
139
  # config.load # auto_sbrodola(ARGV)
@@ -167,8 +170,8 @@ def main(filename)
167
170
  # warn "[warn] template v#{$TEMPLATE_VER }: proviamo il warn che magari depreca il DEB"
168
171
  real_program
169
172
 
170
- if ($DEBUG)
171
- puts "First I need to figure out how to bring in all the libraries in here.."
173
+ if $DEBUG
174
+ puts 'First I need to figure out how to bring in all the libraries in here..'
172
175
  Storazzo::Main.say_hi("ARGV is: #{ARGV.join ', '}")
173
176
  puts Storazzo.version
174
177
  end