neocities-red 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eec23bd190087f4364c5a68d394b5662a3709e1a567663e0f218c025d0eeb83a
4
- data.tar.gz: 3f22fc98249d04d665e9d848cae49507cc475949efc1c0253a3e7f606a487650
3
+ metadata.gz: c066652075fa4d602042ac55ae6238a14d38c6367897d75cb74dd2a116bf3981
4
+ data.tar.gz: 6025df450863903e6ac46b2c580d7623671206a574bd0e3668dd589ef59ff364
5
5
  SHA512:
6
- metadata.gz: '0966d54d18cafd78536595231de74f89ca46664b87227b65b17263ef1101c9e9b3fb684909b8a5d3393c2a3df3f510c93c77f8cf5809dd6597fc9c5ebbfe2d9b'
7
- data.tar.gz: bbef63e19889dd92d1d676c0137b0843feaf6845afaf2f3282b1122281411a51d06d8df63873e8c99f240223676595c38460204963165bf71c147f4219488bc0
6
+ metadata.gz: 982178ffcfe2a7c8cf11ec9cb1610de806ae05186a165a6a7d9bb23daabc43b1b05a68074cde75088d77f17b5e5858f993378db153b3dc8231028df87b636d3c
7
+ data.tar.gz: 8ee3d7c9a53e6c2f81a9edbb783033faeff72c8ec305becae26ee4bfb63d870dbe9df33da92164ada450061d0922d046239a3835025c4fbf132b0e31c26f66e7
data/lib/neocities/cli.rb CHANGED
@@ -15,7 +15,7 @@ MAX_THREADS = 5
15
15
 
16
16
  module Neocities
17
17
  class CLI
18
- SUBCOMMANDS = %w[upload delete list info push logout pizza pull].freeze
18
+ SUBCOMMANDS = %w[upload delete list info push logout pizza pull purge].freeze
19
19
  HELP_SUBCOMMANDS = ['-h', '--help', 'help'].freeze
20
20
  PENELOPE_MOUTHS = %w[^ o ~ - v U].freeze
21
21
  PENELOPE_EYES = %w[o ~ O].freeze
@@ -62,6 +62,7 @@ module Neocities
62
62
  display_help_and_exit
63
63
  elsif @subargs.join('').match(HELP_SUBCOMMANDS.join('|')) && @subcmd != 'info'
64
64
  send "display_#{@subcmd}_help_and_exit"
65
+
65
66
  end
66
67
 
67
68
  unless @api_key
@@ -303,7 +304,7 @@ module Neocities
303
304
  end
304
305
  next if path.nil? || path.directory?
305
306
 
306
- Neocities::FileUploader.new(@client, path).upload
307
+ Neocities::FileUploader.new(@client, path, path).upload
307
308
  end
308
309
  end
309
310
  end
@@ -326,7 +327,11 @@ module Neocities
326
327
  end
327
328
  end
328
329
 
329
- FileUploader.new(@client, @subargs[0], @subargs[1]).upload
330
+ if File.file?(@subargs[0])
331
+ FileUploader.new(@client, @subargs[0], @subargs[1]).upload
332
+ elsif File.directory?(@subargs[0])
333
+ FolderUploader.new(@client, @subargs[0], @subargs[1]).upload
334
+ end
330
335
  end
331
336
 
332
337
  def pull
@@ -340,6 +345,23 @@ module Neocities
340
345
  .export(quiet, last_pull_time, last_pull_loc)
341
346
  end
342
347
 
348
+ # only for development purposes
349
+ def purge
350
+ pruned_dirs = []
351
+ resp = @client.list
352
+ resp[:files].each do |file|
353
+ print @pastel.bold("Deleting #{file[:path]} ... ")
354
+ resp = @client.delete_wrapper_with_dry_run file[:path], @dry_run
355
+
356
+ if resp[:result] == 'success'
357
+ print "#{@pastel.green.bold('SUCCESS')}\n"
358
+ else
359
+ print "\n"
360
+ display_response resp
361
+ end
362
+ end
363
+ end
364
+
343
365
  def pizza
344
366
  display_pizza_help_and_exit
345
367
  end
@@ -24,11 +24,9 @@ module Neocities
24
24
  return
25
25
  end
26
26
 
27
- remote_path = @remote_path || path
27
+ puts @pastel.bold("Uploading #{path} to #{@remote_path} ...")
28
28
 
29
- puts @pastel.bold("Uploading #{path} to #{remote_path} ...")
30
-
31
- response = @client.upload(path, remote_path)
29
+ response = @client.upload(path, @remote_path)
32
30
  puts response if response[:result] == 'error'
33
31
 
34
32
  if response[:result] == 'error' && response[:error_type] == 'file_exists'
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+ require 'pastel'
5
+
6
+ module Neocities
7
+ class FileIsNotExists < StandardError; end
8
+
9
+ class FolderUploader
10
+ def initialize(client, filepath, remote_path = nil)
11
+ @client = client
12
+ @filepath = filepath
13
+ @remote_path = remote_path
14
+ @pastel = Pastel.new(eachline: "\n")
15
+ end
16
+
17
+ def upload
18
+ path = Pathname(@filepath)
19
+
20
+ raise FileIsNotExists, "#{path} does not exist locally." unless path.exist?
21
+
22
+ if path.file?
23
+ puts @pastel.bold("#{path} is not a directory, skipping")
24
+ return
25
+ end
26
+
27
+ Dir.chdir(path) do
28
+ files = Dir.glob('**', File::FNM_DOTMATCH)[1..]
29
+ files.each do |file|
30
+ remote_path = File.join(@remote_path, file)
31
+ FileUploader.new(@client, file, remote_path).upload
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Neocities
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
data/lib/neocities.rb CHANGED
@@ -5,6 +5,7 @@ require File.join(File.dirname(__FILE__), 'neocities', 'client')
5
5
  require File.join(File.dirname(__FILE__), 'neocities', 'cli')
6
6
  require File.join(File.dirname(__FILE__), 'neocities', 'profile_info')
7
7
  require File.join(File.dirname(__FILE__), 'neocities', 'file_uploader')
8
+ require File.join(File.dirname(__FILE__), 'neocities', 'folder_uploader')
8
9
  require File.join(File.dirname(__FILE__), 'neocities', 'file_remover')
9
10
  require File.join(File.dirname(__FILE__), 'neocities', 'file_list')
10
11
  require File.join(File.dirname(__FILE__), 'neocities', 'site_exporter')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neocities-red
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Drake
@@ -177,6 +177,7 @@ files:
177
177
  - lib/neocities/file_list.rb
178
178
  - lib/neocities/file_remover.rb
179
179
  - lib/neocities/file_uploader.rb
180
+ - lib/neocities/folder_uploader.rb
180
181
  - lib/neocities/pizza.rb
181
182
  - lib/neocities/profile_info.rb
182
183
  - lib/neocities/site_exporter.rb