website_cloner 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/website-cloner +11 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6cf619743fb9004bcf6f71f1e3b2c46d84de142bcce103f23f9a586313f359d0
4
- data.tar.gz: 0edffbf83649bc7ccf64ddfee41ff2ce4d27c7d1f0cc2308ff3ed24a521f1db3
3
+ metadata.gz: e29501c6c5c642cdcebd2649ccd8b2c826af2ca541d3590951768e2714c3394f
4
+ data.tar.gz: 1e913c634f159d0f99192a82216402c648fb72bdb9a678bfd08e3474fdd4914a
5
5
  SHA512:
6
- metadata.gz: a30298db58d805eb7b46c5a8d86a142b29b62acb5d59236cf187355a14a63e424b3fcc6d5fef50b205daa801d43852492c03aa95fe3851b734e3ec3cbb2b8a40
7
- data.tar.gz: 0042c1aec924eb4290762253d1fb10120dce548178b4ac774fbab97b65343df902bbc806919fdf460dedc6c99a182446777b779526e42237b400a9718f90c939
6
+ metadata.gz: a595638198f94dd1467dbb04ebaa4c4dd76564e2a551a343169d28ee24f35c406b028b8537431cb7fdf24793ed895e6e76a8fa9165fe9739c84b24bda902fb28
7
+ data.tar.gz: 1e591691504be97971bdc21f1bac590f0185b7c29f78985d72d46eb9d59e37e1adad789b38d6c6cd073b69a2d31217831f4b5dbad142ed0b72c124677f3c84fd
data/bin/website-cloner CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative '../lib/website_cloner'
4
4
  require 'optparse'
5
+ require 'uri'
5
6
 
6
7
  options = {
7
8
  max_pages: 20,
@@ -9,7 +10,7 @@ options = {
9
10
  }
10
11
 
11
12
  OptionParser.new do |opts|
12
- opts.banner = "Usage: website-cloner <url> <output_directory> [options]"
13
+ opts.banner = "Usage: website-cloner <url> [output_directory] [options]"
13
14
 
14
15
  opts.on("-m", "--max-pages PAGES", Integer, "Maximum number of pages to clone (default: 20)") do |m|
15
16
  options[:max_pages] = m
@@ -25,8 +26,8 @@ OptionParser.new do |opts|
25
26
  end
26
27
  end.parse!
27
28
 
28
- if ARGV.length != 2
29
- puts "Usage: website-cloner <url> <output_directory> [options]"
29
+ if ARGV.length < 1
30
+ puts "Usage: website-cloner <url> [output_directory] [options]"
30
31
  puts "Run 'website-cloner --help' for more information."
31
32
  exit 1
32
33
  end
@@ -34,10 +35,16 @@ end
34
35
  url = ARGV[0]
35
36
  output_dir = ARGV[1]
36
37
 
38
+ if output_dir.nil?
39
+ uri = URI.parse(url)
40
+ domain = uri.host.sub(/^www\./, '')
41
+ output_dir = "./#{domain}"
42
+ end
43
+
37
44
  begin
38
45
  WebsiteCloner.clone(url, output_dir, max_pages: options[:max_pages], session_cookie: options[:session_cookie])
39
46
 
40
- puts "\nWebsite cloned successfully!"
47
+ puts "\nWebsite cloned successfully into '#{output_dir}'!"
41
48
  rescue StandardError => e
42
49
  puts "\nAn error occurred during cloning: #{e.message}"
43
50
  rescue Interrupt
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: website_cloner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bhavyansh Yadav
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-11 00:00:00.000000000 Z
11
+ date: 2024-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri