ftpro 0.0.1 → 0.0.2

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -4
  3. data/ftpro.gemspec +3 -3
  4. data/lib/ftpro.rb +10 -4
  5. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0dc808727ea1103f4995a294a3a9598c54bef16c
4
- data.tar.gz: 190bbaa562c9d834cc691bb61f3baa256234448b
3
+ metadata.gz: 200829bd1279a029c8d7b83f4bf95a90030d2705
4
+ data.tar.gz: 4e0f310bfaed38f4c3d02181f1a8324599b29252
5
5
  SHA512:
6
- metadata.gz: 5c4abfc0acc7982f2485a8d3096420cd377f913dae56c79ddbba515894deefd9fbc7eb30aa0bdcb5f4839efa74530f05b4ff2a968e41243f7eca77c4865d4570
7
- data.tar.gz: 7e3755773dead0533e4b423c4215be138ddc2a6ed28b50a32b43c71ad9fc94f6dd850b76c4e2b38414fcd0cbec18bb79265de00d94591c0d709528c98c3e77ea
6
+ metadata.gz: 4083090043db008756ad912025c8fc30765808bdcd70e19463d293c6dfbace8578061b5ab53e23061e0790486e0a26da17088b713cc8d08f360ca7b0462db268
7
+ data.tar.gz: bd67d60935b2b7e0439786736942313bee3975b54ece52c409f160b7d473376559216e385de00bb47b101b8baf7715974c22159bfc75dd0128c5114324823c9e
data/README.md CHANGED
@@ -18,10 +18,6 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install ftpro
20
20
 
21
- Or include it in your project's Gemfile
22
-
23
- $ gem ‘ftpro’
24
-
25
21
  ## Usage
26
22
 
27
23
  This gem provide a ruby class `Ftpro`, you can use it like `Net::FTP`:
@@ -4,11 +4,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "ftpro"
7
- spec.version = '0.0.1'
7
+ spec.version = '0.0.2'
8
8
  spec.authors = ["dddd1919"]
9
9
  spec.email = ["dingrank@gmail.com"]
10
- spec.summary = %q{"The enhanced version of net/ftp"}
11
- spec.description = %q{"Provide all net/ftp method and some additional functionality"}
10
+ spec.summary = %q{The enhanced version of net/ftp}
11
+ spec.description = %q{Provide all net/ftp method and some additional functionality}
12
12
  spec.homepage = "https://github.com/dddd1919/ftpro"
13
13
  spec.license = "MIT"
14
14
 
@@ -4,20 +4,24 @@ class Ftpro < Net::FTP
4
4
 
5
5
  ## Net::FTP extension
6
6
 
7
- def nlst_a(dir)
8
- ## Function like nlst and also show hide files
7
+ ## Function like nlst and also show hide files
8
+ def nlst_a(dir = nil)
9
9
  cmd = "NLST -a"
10
+ rule_out1, rule_out2 =
11
+ dir.nil? ? [".", ".."] : ["/.", "/.."]
10
12
  if dir
11
13
  cmd = cmd + " " + dir
12
14
  end
13
15
  files = []
14
16
  retrlines(cmd) do |line|
15
- files.push(line) if !line.end_with?("/.", "/..")
17
+ files.push(line) if !line.end_with?(rule_out1, rule_out2)
16
18
  end
17
19
  return files
18
20
  end
19
21
 
20
22
  ## File function mirror
23
+
24
+ ## Check if dir is a directory type
21
25
  def directory?(dir)
22
26
  current_dir = pwd
23
27
  begin
@@ -30,10 +34,12 @@ class Ftpro < Net::FTP
30
34
  end
31
35
  end
32
36
 
37
+ ## Check if file_path is a file type
33
38
  def file?(file_path)
34
39
  nlst(file_path)[0] == file_path
35
40
  end
36
41
 
42
+ ## Check if dir exist
37
43
  def exist?(dir)
38
44
  return true if !nlst(dir).empty? ## File or not empty directory
39
45
  ## Check if a empty directory
@@ -50,8 +56,8 @@ class Ftpro < Net::FTP
50
56
  return new_dir if exist?(new_dir)
51
57
  end
52
58
 
59
+ ## Upload local directory to ftp server with local directory name
53
60
  def put_r(local_dir, remote_dir)
54
- ## Upload local directory to ftp server with local directory name
55
61
  return false if !File.directory?(local_dir)
56
62
  upload_dir(local_dir, remote_dir)
57
63
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ftpro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - dddd1919
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-29 00:00:00.000000000 Z
11
+ date: 2014-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: '"Provide all net/ftp method and some additional functionality"'
55
+ description: Provide all net/ftp method and some additional functionality
56
56
  email:
57
57
  - dingrank@gmail.com
58
58
  executables: []
@@ -91,7 +91,7 @@ rubyforge_project:
91
91
  rubygems_version: 2.2.2
92
92
  signing_key:
93
93
  specification_version: 4
94
- summary: '"The enhanced version of net/ftp"'
94
+ summary: The enhanced version of net/ftp
95
95
  test_files:
96
96
  - spec/ftpro_spec.rb
97
97
  - spec/spec_helper.rb