reaver 0.7.1 → 0.10.1

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: 32fb1834d726c5f6883514c899661f2a3ad42ed4dd53c5ab64fc0a97bcafe96e
4
- data.tar.gz: fd73c58c53c159e86cc523960b795b30e3ca91a4333ef5340207bc438d71f6e9
3
+ metadata.gz: bdd577808ca0bae2cded787b089161dc9edf442705c2676ed89c8fb696a7190f
4
+ data.tar.gz: 9e83785bfffdc7a792ff630261cb39e30a165b0f3b58162015dc617f65d182b9
5
5
  SHA512:
6
- metadata.gz: 54ce812f876370d2579221723c9d005abfd6abb1568ff8617f2272016287a4cc98990e2a55202a8ab4a791d4d1148c7c5b0715e3d8fd3b4e74064687dde84c15
7
- data.tar.gz: 1e247b45ec3a47c90fa161c8e2677ae90dc8bea56b81e615db2a2c3f9c2ca68af82dc706825d412941b5aaabb398d5d06393bfd51c87c7780cadc638ecb2720f
6
+ metadata.gz: fd900ba9a85d977377b8ad011efcab4e1957b5a5334916e08245774ec8f6d15cff279e19a0fc0a35532fafceaa0acc47c67e1204f9019b67f171aa538ff4586e
7
+ data.tar.gz: 0dbf7794f0ae570ed6f742c77cbb417211dae02642951d27a77eab164859db62f8e1c7c3dcca9120aacaa8beacef54b3cbd7791d9b2135b2d1a99c1f056de62d
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 0.10.1
2
+ - For `all_to_dir_path` or `things.dest_dir`, all paths are relative to `$HOME` (or
3
+ /home/<name>), so don't include shell variable `~` or `$HOME`.
4
+ - unzip not interactive with `-o`.
5
+
6
+ ## 0.10.0, release 10/2024
7
+ - New variable for collections, all_into_dir, things.dest_dir, keep_name and
8
+ force_download.
9
+ -** Use [Marcel](https://github.com/rails/marcel) to detect file mime.
10
+ - Can decompress archive `zip` or `tar.gz (gzip)` using unzip and tar from `unix`.
11
+ - Cam move files to specific directory.
12
+
1
13
  ## 0.7.0, release 12/24/22
2
14
 
3
15
  * Each collections download things in separate directory.
data/README.md CHANGED
@@ -1,7 +1,12 @@
1
1
  # reaver
2
2
 
3
3
  A tool that allows to download and track the latest version of stuff on the net.
4
- Define your collections in .yml and launch Reaver to retrieve everything.
4
+ Define your collections in .yml and launch Reaver to retrieve everything and
5
+ move things to the right spot.
6
+
7
+ ## Dependencies
8
+
9
+ Reaver need only `unzip` and `tar`.
5
10
 
6
11
  ## Collections
7
12
 
@@ -30,10 +35,26 @@ things:
30
35
  - name: nerdtree.tar.gz
31
36
  url: https://github.com/preservim/nerdtree/archive/refs/heads/master.tar.gz
32
37
  time: 86000
38
+ all_into_dir: .config/pack/myvimpluggins/start
39
+ keep_name: true
33
40
  ```
34
41
 
35
- `time: 86000` (in second) is for search every day ( 60 * 60 * 24 ).
36
- The `name` must contain the path extension for now.
42
+ To see more examples, go
43
+ [here](https://github.com/szorfein/dots/tree/ansible/home/private_dot_config/reaver)
44
+
45
+ A collection can include:
46
+ - `all_into_dir: <dirname>` if all files go in a directory. Directory is created
47
+ if not exist.
48
+ - `keep_name: <boolean>`, if `true`, use the name of the thing for the dest, e.g, for a name `ombre.tar.gz`, the final dest will be `all_into_dir/ombre` or `dest_dir/ombre`.
49
+ - `force_download: <boolean>`, if you make change and want to download now, change to `true`.
50
+ - `things.dest_dir: <dirname>`, if each files go in differents directory, use this.
51
+ - `things.name` the new name after download, may include the file extension.
52
+ - `things.url: <string>`
53
+ - `time: 86000` (in second) is for search every day ( 60 * 60 * 24 ).
54
+
55
+ If `all_into_dir` is defined, `things.dest_dir` is not used.
56
+ All paths given are relative to `$HOME` so don't include `~` or any shell
57
+ variables.
37
58
 
38
59
  And start reaver simply with:
39
60
 
data/bin/reaver CHANGED
@@ -7,4 +7,4 @@ puts Reaver.banner
7
7
 
8
8
  Reaver.main
9
9
 
10
- puts "\nReaver v" + Reaver::VERSION
10
+ puts "\nReaver v#{Reaver::VERSION}"
@@ -5,6 +5,7 @@ require 'time'
5
5
  require 'digest'
6
6
 
7
7
  module Reaver
8
+ # Loading collection from ~/.config/reaver/<filename.yml> and threat them
8
9
  class Collection
9
10
  attr_reader :tasks
10
11
 
@@ -15,39 +16,59 @@ module Reaver
15
16
 
16
17
  def load_yaml
17
18
  puts ">> Loading #{@file}..."
18
- if RUBY_VERSION >= '3.0'
19
- @tasks = YAML.load_file(@file, permitted_classes: [Time, Symbol])
20
- else
21
- @tasks = YAML.load_file(@file)
22
- end
23
- rescue => error
24
- raise error, "loading YAML fail for #{@file}: #{error.message}"
19
+ @tasks = if RUBY_VERSION >= '3.0'
20
+ YAML.load_file(@file, permitted_classes: [Time, Symbol])
21
+ else
22
+ @tasks = YAML.load_file(@file)
23
+ end
24
+ rescue => e
25
+ raise e, "loading YAML fail for #{@file}: #{e.message}"
26
+ end
27
+
28
+ def save_yaml
29
+ in_yaml = YAML.dump(@tasks)
30
+ File.write(@file, in_yaml)
25
31
  end
26
32
 
27
33
  def launch(metadata)
28
- return unless @tasks
34
+ return unless @tasks || @tasks['things'].length.zero?
29
35
 
30
- if @tasks['things'].length >= 1
31
- @tasks['things'].each do |t|
32
- if File.exist? t['name']
33
- old_hash = Digest::MD5.file t['name']
34
- else
35
- @changed = true
36
- end
36
+ @tasks['things'].each do |task|
37
+ do_thing(task)
38
+ metadata.info['changed'] = @changed
39
+ end
40
+ end
37
41
 
38
- Reaver.download(t['url'], t['name'])
39
- compare_hash(t['name'], old_hash) if old_hash
42
+ protected
40
43
 
41
- metadata.info['changed'] = @changed
42
- end
43
- end
44
+ def do_thing(task)
45
+ hash_exist(task['name'])
46
+ Reaver.download(task['url'], task['name'])
47
+ compare_to_old_hash(task['name']) if @old_hash
48
+ need_to_do_something_with(task) if @changed || !@old_hash
49
+ @tasks['force_download'] = false
50
+ @changed = false
44
51
  end
45
52
 
46
53
  private
47
54
 
48
- def compare_hash(filename, old_hash)
55
+ def hash_exist(file)
56
+ if File.exist? file
57
+ @old_hash = Digest::MD5.file file
58
+ else
59
+ @changed = true
60
+ end
61
+ end
62
+
63
+ def compare_to_old_hash(filename)
49
64
  hash = Digest::MD5.file filename
50
- @changed = true if old_hash.hexdigest != hash.hexdigest
65
+ @changed = true if @old_hash.hexdigest != hash.hexdigest
66
+ end
67
+
68
+ def need_to_do_something_with(file)
69
+ dest = @tasks['all_to_dest_dir'] || file['dest_dir']
70
+ keep_name = @tasks['keep_name'] || false
71
+ Reaver::Walk.new(file['name'], dest, keep_name) if dest
51
72
  end
52
73
  end
53
74
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Reaver
4
- VERSION = '0.7.1'
4
+ VERSION = '0.10.1'
5
5
  end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'marcel'
4
+ require 'fileutils'
5
+
6
+ module Reaver
7
+ # extract, move file if need
8
+ class Walk
9
+ def initialize(filename, dest, keep_name)
10
+ @filename = filename
11
+ @dest = dest
12
+ @keep_name = keep_name || false
13
+ check_extension
14
+ check_name
15
+ x
16
+ end
17
+
18
+ def x
19
+ case @extension
20
+ when %r{^image/jpeg} || %r{^image/png}
21
+ copy_file
22
+ when %r{^application/zip}
23
+ extract_zip
24
+ when %r{^application/gzip}
25
+ extract_gzip
26
+ when %r{^font/ttf}
27
+ copy_file
28
+ else
29
+ puts "Filetype #{@extension} not yet supported, skipping..."
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def check_extension
36
+ File.open @filename do |f|
37
+ @extension = Marcel::MimeType.for f
38
+ end
39
+ end
40
+
41
+ def check_name
42
+ name = @filename.split('.').first
43
+ @final_dest = if @keep_name
44
+ "#{ENV['HOME']}/#{@dest}/#{name}"
45
+ else
46
+ "#{ENV['HOME']}/#{@dest}"
47
+ end
48
+ end
49
+
50
+ def copy_file
51
+ puts "Copying file #{@filename} at #{@final_dest}..."
52
+ FileUtils.mkdir_p @final_dest
53
+ FileUtils.cp @filename, "#{@final_dest}/#{@filename}"
54
+ end
55
+
56
+ def extract_zip
57
+ puts "Extracting zip archive #{@filename} at #{@final_dest}..."
58
+ FileUtils.mkdir_p @final_dest
59
+ `unzip -o -j #{@filename} -d #{@final_dest}`
60
+ end
61
+
62
+ def extract_gzip
63
+ puts "Extracting gzip archive #{@filename} at #{@final_dest}..."
64
+ FileUtils.mkdir_p @final_dest
65
+ `tar -x --strip-components=1 -f #{@filename} --one-top-level=#{@final_dest}`
66
+ end
67
+ end
68
+ end
data/lib/reaver.rb CHANGED
@@ -5,6 +5,7 @@ require_relative 'reaver/banner'
5
5
  require_relative 'reaver/download'
6
6
  require_relative 'reaver/metadata'
7
7
  require_relative 'reaver/collection'
8
+ require_relative 'reaver/walk'
8
9
 
9
10
  require 'whirly'
10
11
  require 'fileutils'
@@ -22,8 +23,8 @@ module Reaver
22
23
 
23
24
  # Configure Whirly
24
25
  Whirly.configure spinner: 'bouncingBar',
25
- color: true,
26
- ambiguous_characters_width: 1
26
+ color: true,
27
+ ambiguous_characters_width: 1
27
28
 
28
29
  def self.main
29
30
  FileUtils.mkdir_p(WORKDIR)
@@ -40,22 +41,27 @@ module Reaver
40
41
  collection = Collection.new(f)
41
42
  collection.load_yaml
42
43
 
43
- if collection.tasks
44
- metadata = MetaData.new(workdir, collection)
45
- metadata.load_yaml
46
- next_download = metadata.info['next']
44
+ #puts collection.tasks
47
45
 
48
- if next_download < Time.new
46
+ next unless collection.tasks
47
+
48
+ metadata = MetaData.new(workdir, collection)
49
+ metadata.load_yaml
50
+ next_download = metadata.info['next']
51
+ force_download = collection.tasks['force_download'] || false
52
+ #puts "should we force #{force_download}"
53
+
54
+ if next_download < Time.new || force_download
49
55
  #puts ' >> Download time for ' + name
50
- FileUtils.chdir(workdir)
51
- #puts " > chdir #{workdir}"
52
- collection.launch(metadata)
53
- else
54
- puts " > Next download > #{next_download}"
55
- end
56
-
57
- metadata.save_yaml
56
+ FileUtils.chdir(workdir)
57
+ #puts " > chdir #{workdir}"
58
+ collection.launch(metadata)
59
+ collection.save_yaml if force_download
60
+ else
61
+ puts " > Next download > #{next_download}"
58
62
  end
63
+
64
+ metadata.save_yaml
59
65
  end
60
66
  end
61
67
  end
data/reaver.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  'changelog_uri' => 'https://github.com/szorfein/reaver/blob/main/CHANGELOG.md',
25
25
  'source_code_uri' => 'https://github.com/szorfein/reaver',
26
26
  'wiki_uri' => 'https://github.com/szorfein/reaver/wiki',
27
- 'funding_uri' => 'https://patreon.com/szorfein',
27
+ 'funding_uri' => 'https://patreon.com/szorfein'
28
28
  }
29
29
 
30
30
  s.files = Dir.glob('{lib,bin}/**/*', File::FNM_DOTMATCH).reject do |f|
@@ -38,10 +38,11 @@ Gem::Specification.new do |s|
38
38
  s.executables << 'reaver'
39
39
  s.extra_rdoc_files = %w[README.md]
40
40
 
41
- s.cert_chain = %w[certs/szorfein.pem]
42
- s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
41
+ # s.cert_chain = %w[certs/szorfein.pem]
42
+ # s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
43
43
 
44
44
  s.required_ruby_version = '>=2.6'
45
- s.add_dependency 'whirly', '~> 0.3'
45
+ s.add_dependency 'marcel'
46
46
  s.add_dependency 'paint', '~> 2.3'
47
+ s.add_dependency 'whirly', '~> 0.3'
47
48
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reaver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - szorfein
@@ -12,46 +12,46 @@ cert_chain:
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIEhTCCAu2gAwIBAgIBATANBgkqhkiG9w0BAQsFADBEMREwDwYDVQQDDAhzem9y
14
14
  ZmVpbjEaMBgGCgmSJomT8ixkARkWCnByb3Rvbm1haWwxEzARBgoJkiaJk/IsZAEZ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8sr+BcMeuKpXaOwpbkP+xq/W2EKlUQKhPXMXS4jvC
35
- MuTi+RjpSNKZxzBrOlK2eMIpiFrugF7nzKcM9EGnWRWUb899drCcD4VJhjPtgpn+
36
- aEJeKq4/BlIwMlXPe+W5C8zp2i8hgG1/OYbwbGE1p2iRi1NIK7G/HyRqQjOqJxzE
37
- LLknX69FN7/G
29
+ AQsFAAOCAYEAFjnBWWfaMeA8hP0Q76WmBCFckGN5I42X5RQkVYRRXIaeXIS1td/t
30
+ O1v1iQLo6ABfASMi6We7T16+ita68xwNOmSkMNHHXBr/fdGbHExxFSX7BXNRbwla
31
+ SS6Vy0bXKMDJbXcvkrmIolpYhEFm1218FCRCT6ogM1oWAJAfhfF9pMeRxrxjQYFn
32
+ ko8XgjIHxb83miOILgdq/lgJ4gfD7PsGfJtLCLiCKCcxIb4TtmKAzRwCDVpb6wqM
33
+ 5xJZffAmHI7v8lVer53sPzm3INPu5xFZyfZ/SXYXPKKwln0efH63K5vuXYwEN7NI
34
+ SBSRTN03Hb65t86m6/r084SrNnLntQjCSqApzFBt1QwJ5cmiVilODN4V7y2hZpyK
35
+ hSk3b2VOotDPiWIm1p/IPXQDfm5x67Z5fJQPAlBTsse4jKyVyW1lZLmERSBuRZ2O
36
+ urXgRIzALxd/xazPCnoLSXPzfJSI6Y77S1EBvhPd9RaSO8IyH9RhPDP9mnTvW2Kl
37
+ NAUnoL+txK5a
38
38
  -----END CERTIFICATE-----
39
- date: 2022-12-28 00:00:00.000000000 Z
39
+ date: 2024-10-07 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
- name: whirly
42
+ name: marcel
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0.3'
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0.3'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: paint
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: whirly
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.3'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.3'
69
83
  description: |2
70
84
  A tool that allows to download and track the latest version of stuff on the net.
71
85
  Define your collections in .yml and launch Reaver to retrieve everything.
@@ -86,6 +100,7 @@ files:
86
100
  - lib/reaver/download.rb
87
101
  - lib/reaver/metadata.rb
88
102
  - lib/reaver/version.rb
103
+ - lib/reaver/walk.rb
89
104
  - reaver.gemspec
90
105
  homepage: https://github.com/szorfein/reaver
91
106
  licenses:
@@ -111,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
126
  - !ruby/object:Gem::Version
112
127
  version: '0'
113
128
  requirements: []
114
- rubygems_version: 3.3.23
129
+ rubygems_version: 3.3.25
115
130
  signing_key:
116
131
  specification_version: 4
117
132
  summary: A tool to downloads and track updates of things on the Net.
metadata.gz.sig CHANGED
Binary file