my-local-putio 1.0.1 → 2.0.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: c20b3bf5804c220a60d9e0bc08e6c1c2e2a3d4ea427677093de87b2234c511cc
4
- data.tar.gz: a34051392a5360d8a41c509e71319f87b48122a0268c89a52131a7219a030c80
3
+ metadata.gz: a1fda62376b386445ef3068eeedc6709cd81d8b51d858ff74f9217a4437c1408
4
+ data.tar.gz: cf24f1efbaf4d1f0c8524cf2f07f47f56e5935df823eceb2eb0d8ba32b22473a
5
5
  SHA512:
6
- metadata.gz: e9b5055ffcd3fb0a8055675a87a7bf94791f1f3ecb63e7f83723ad0af75bf958d6eceaea2f21b173c39fb75292135f2824d1ac301b378329a8376643e274e8e2
7
- data.tar.gz: d6c17907348ab1578ef9d6ee70e2747328beff85cbfe73209fd8e84b3bb2f4a4d9911b450978bc1d1101f8b91cf638e2b928f981e59d3371b172cbdb7b1f4552
6
+ metadata.gz: 5ab8bb987a3ad33f15e97cac86823c51d70a3f95552c0ccf5790fb1622fcdcd4c40209b58003d0facdf7b366b021d579022f0b8f7450703145db484e660c7c94
7
+ data.tar.gz: 7dd182463935fbce5ccae3c447f473b13f2df3a3f60fd85bba1775d39bc9fc871701c66a503a9a797eebc986a4fa0c6a9ca0059f9235bf91a27d786ac9daa22d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # v2.0.0
2
+
3
+ - Breaking changes parameters
4
+ - --verbose (-v) was removed. By default all messages will be printed out.
5
+ - --silent option was introduced to mute the output.
6
+ - --destination (-d) was removed and replaced by --local-destination
7
+ - introduced -d option for --debug
8
+
9
+
1
10
  # v1.0.1
2
11
 
3
12
  - Fixing small require bug
data/README.md CHANGED
@@ -38,19 +38,19 @@ For now the script only supports download the content from your account and keep
38
38
  my-local-putio -h
39
39
 
40
40
  Usage: my-local-putio [options]
41
- -t, --token TOKEN Put.io access token [REQUIRED]
42
- -d, --destination DESTINATION Destination path [REQUIRED]
43
- -v, --verbose Show messages and progress bar
44
- --debug Debug mode [Developer mode]
41
+ -t, --token TOKEN Put.io access token [REQUIRED]
42
+ -l, --local-destination PATH Local destination path [REQUIRED]
43
+ -s, --silent Hide all messages and progress bar
44
+ -d, --debug Debug mode [Developer mode]
45
45
 
46
46
  #### Required attributes:
47
47
  * **-t** or **--token**: Your Put.io Token. This attribute becames optional if you set `PUTIO_TOKEN` env variable with your token (Can be inline or into your bash profile). Check examples below.
48
- * **-d** or **--destination**: Local destination folder
48
+ * **-l** or **--local-destination**: Local destination folder
49
49
 
50
50
  Examples:
51
51
 
52
- my-local-putio -t 123 -d Downloads
53
- my-local-putio -d Downloads --token 123
52
+ my-local-putio -t 123 -l Downloads
53
+ my-local-putio -l Downloads --token 123
54
54
 
55
55
  With Token variable (inline or exporting):
56
56
 
@@ -61,15 +61,15 @@ With Token variable (inline or exporting):
61
61
 
62
62
  #### Others attributes:
63
63
  * **-h**: Print the help usage message
64
- * **-v** or **--verbose**: Show useful information about your downloads
65
- * **--debug**: Developer mode: Prints everything (also verbose messages) and expose URLs with tokens for debug purposes.
64
+ * **-s** or **--silent**: Hide all messages and progress bar
65
+ * **-d** or **--debug**: Developer mode: Prints everything and expose URLs with tokens for debug purposes.
66
66
 
67
67
  Examples:
68
68
 
69
69
  my-local-putio -h
70
- my-local-putio -t 123 -d Downloads --verbose
71
- my-local-putio -t 123 -d Downloads -v
72
- my-local-putio --destination Downloads -t 123 --debug
70
+ my-local-putio -t 123 -l Downloads --silent
71
+ my-local-putio -t 123 -l Downloads -s
72
+ my-local-putio --local-destination Downloads -t 123 --debug
73
73
 
74
74
  Verbose output example:
75
75
 
@@ -1,6 +1,6 @@
1
- # Put.io Fetcher
1
+ # My Local Put.io
2
2
  #
3
- # Put.io download script! The easiest way to have all all your put.io files locally.
3
+ # The easiest script to synchronise all your put.io files locally.
4
4
  #
5
5
  # Created by: Rafael Biriba - biribarj@gmail.com
6
6
  # More info: https://github.com/rafaelbiriba/my-local-putio
@@ -1,6 +1,6 @@
1
1
  module MyLocalPutio
2
2
  class Configuration
3
- attr_reader :token, :destination, :verbose, :debug
3
+ attr_reader :token, :local_destination, :silent, :debug
4
4
  def initialize
5
5
  read_args_from_envs!
6
6
  parse_args!
@@ -11,9 +11,9 @@ module MyLocalPutio
11
11
  def parse_args!
12
12
  OptionParser.new do |opt|
13
13
  opt.on("-t", "--token TOKEN", "Put.io access token [REQUIRED]") { |v| @token = v }
14
- opt.on("-d", "--destination DESTINATION", "Destination path [REQUIRED]") { |v| @destination = v }
15
- opt.on("-v", "--verbose", "Show messages and progress bar") { |v| @verbose = true }
16
- opt.on("--debug", "Debug mode [Developer mode]") { |v| @debug = true }
14
+ opt.on("-l", "--local-destination PATH", "Local destination path [REQUIRED]") { |v| @local_destination = v }
15
+ opt.on("-s", "--silent", "Hide all messages and progress bar") { |v| @silent = true }
16
+ opt.on("-d", "--debug", "Debug mode [Developer mode]") { |v| @debug = true }
17
17
  end.parse!
18
18
  end
19
19
 
@@ -22,8 +22,8 @@ module MyLocalPutio
22
22
  raise OptionParser::MissingArgument.new("--token")
23
23
  end
24
24
 
25
- unless @destination
26
- raise OptionParser::MissingArgument.new("--destination")
25
+ unless @local_destination
26
+ raise OptionParser::MissingArgument.new("--local-destination")
27
27
  end
28
28
  end
29
29
 
@@ -12,7 +12,7 @@ module MyLocalPutio
12
12
 
13
13
  protected
14
14
 
15
- def fetch_files(id: nil, path: configuration.destination)
15
+ def fetch_files(id: nil, path: configuration.local_destination)
16
16
  FileUtils.mkdir_p(path)
17
17
  logger.log "Getting files for #{path}"
18
18
  files = cli.get_files(id)["files"]
@@ -40,7 +40,7 @@ module MyLocalPutio
40
40
  command = [
41
41
  "curl", "--progress-bar", "-L", "--retry", "5", "-S", "-C", "-", "-o", path, url.to_s
42
42
  ]
43
- command.push("--silent") unless logger.verbose?
43
+ command.push("--silent") if logger.silent?
44
44
  system(*command)
45
45
  end
46
46
  end
@@ -6,8 +6,8 @@ module MyLocalPutio
6
6
  @configuration = configuration
7
7
  end
8
8
 
9
- def verbose?
10
- configuration.verbose
9
+ def silent?
10
+ configuration.silent
11
11
  end
12
12
 
13
13
  def debug?
@@ -16,16 +16,20 @@ module MyLocalPutio
16
16
 
17
17
  def debug(msg)
18
18
  return unless debug?
19
- puts "[DEBUG][#{time_now}] #{msg}"
19
+ print_msg "[DEBUG][#{time_now}] #{msg}"
20
20
  end
21
21
 
22
22
  def log(msg)
23
- return unless verbose? || debug?
24
- puts "[LOG][#{time_now}] #{msg}"
23
+ print_msg "[LOG][#{time_now}] #{msg}"
25
24
  end
26
25
 
27
26
  private
28
27
 
28
+ def print_msg(msg)
29
+ return if silent?
30
+ puts msg
31
+ end
32
+
29
33
  def time_now
30
34
  Time.now.strftime("%F %H:%M:%S")
31
35
  end
@@ -16,7 +16,6 @@ module MyLocalPutio
16
16
  end
17
17
 
18
18
  def get_download_url(id)
19
- # Follow redirect plz
20
19
  url = to_url("files/#{id}/download")
21
20
  url.query = URI.encode_www_form to_args()
22
21
  url
@@ -24,11 +23,6 @@ module MyLocalPutio
24
23
 
25
24
  protected
26
25
 
27
- def log(msg)
28
- return unless configuration.verbose
29
- puts msg
30
- end
31
-
32
26
  def get(path, args={})
33
27
  url = to_url(path)
34
28
  url.query = URI.encode_www_form to_args(args)
@@ -1,3 +1,3 @@
1
1
  module MyLocalPutio
2
- VERSION = "1.0.1"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my-local-putio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Biriba