file_management 0.1.0 → 1.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
  SHA1:
3
- metadata.gz: f228b3fd51934e81872efdbe0c6a96ce2855488a
4
- data.tar.gz: 91bfbcec0c954ad101d1c210ee97319d4d64906b
3
+ metadata.gz: 88c312355ea61cbfba9a546e150b5574fa1caf89
4
+ data.tar.gz: cf856f66875629a4f7e0afd08a4d7aa2306a01ad
5
5
  SHA512:
6
- metadata.gz: 8ff71edf8b72d9056b22f9af7c73840794d66a9f9c4a35aa20fc9690d27021bbc87b4b9b64d2957272e61d024e5db61ac6a9bb1f6efe1f80899f644faa60eb56
7
- data.tar.gz: da19b553b6a5aa0f329de759314d466f3cd05a563c6aa22f65270b906a81a387ac48428b05774ce4fcc6f5d9312ff7e9d184f51bbfbd438197254f8f933de1f2
6
+ metadata.gz: ae61e341e48a70d1646591d2c42e75ff2e2172de93e46cbeb99cb7b57adb736a9922b22436c19f3abf863b9d12f2c416fb37f8848ad451f7c08204bf31e408b1
7
+ data.tar.gz: 2221b42e944ed1129f3e50fc207a72af48f7b13b03529d19c0ceb39c32855f4397c0336aa90d87d6307d917dadf6cc2c087bfe0eff1e05d97014b941ce31fc57
data/README.md CHANGED
@@ -1,9 +1,7 @@
1
1
  # FileManagement
2
2
  [![Build Status](https://travis-ci.org/Mikeks81/File-Management.svg?branch=master)](https://travis-ci.org/Mikeks81/File-Management)
3
3
 
4
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/file_management`. To experiment with that code, run `bin/console` for an interactive prompt.
5
-
6
- TODO: Delete this and the text above, and describe your gem
4
+ Simple File Management library for creating, deleting, file stats and listing all files in a directory. Gem is still in the very early phase of development. Please feel free to make suggestions or identify bugs.
7
5
 
8
6
  ## Installation
9
7
 
@@ -25,6 +23,7 @@ Or install it yourself as:
25
23
 
26
24
  ### initialize
27
25
  You can initialize the gem by telling it the path you would like to manage (via path) and and file that would like to ignore (via excludes). If you don't specify a path it will set to './'
26
+
28
27
  ```
29
28
  FileManager.new
30
29
  => #<FileManager:0x007fe2ab267790 @path="./", @excludes="">
@@ -33,8 +32,58 @@ FileManager.new(path: '/some/cool/path', excludes: 'ignore_me.rb')
33
32
  => #<FileManager:0x007fe2ab20f608 @path="some/cool/path", @excludes="ignore_me.rb">
34
33
  ```
35
34
 
36
- ### Methods
35
+ ## Methods
36
+ ### all_files
37
+ returns an array of files in the directory
38
+ all files listed in the excludes attribute are ignored and not added to the array
39
+ ```
40
+ f = FileManager.new(path: '/some/cool/path', excludes: 'ignore_me.rb')
41
+ f.all_files
42
+ => ["test.rb", "test1.rb", "test2.rb"]
43
+ ```
44
+ ### make_file(new_file)
45
+ returns the file path of the newly created file
46
+ returns false if the file name is already taken
47
+ ```
48
+ f.make_file('new_file.rb')
49
+ => ["test/test/new_file.rb"]
50
+ ```
51
+ ### pwd(file)
52
+ returns a string path
53
+ returns false if file doesn't exist or isn't found
54
+ ```
55
+ f.pwd('new_file.rb')
56
+ => "test/test/new_file.rb"
57
+ ```
58
+ ### file_exists?(file)
59
+ returns a boolean value of true if the file exists in the given director and false if it doesn't
60
+ ```
61
+ f.file_exists?('new_file.rb')
62
+ => true
63
+ ```
64
+ ### stats(file, request)
65
+ A Wrapper for File::Stat. The first argument is the file and the second is the stat method you would like. Currently if the the method from File::State isn't chained onto the end it is not supported ( directory? is one )
66
+ ```
67
+ f.stats('new_file.rb', 'birthtime')
68
+ => 2017-06-12 20:27:11 -0400
69
+
70
+ f.stats('new_file.rb', 'ftype')
71
+ => "file"
72
+ ```
37
73
 
74
+ ### file_size(file)
75
+ Gives you the file size in SI standard.
76
+ ```
77
+ f.file_size('file_manager.rb')
78
+ => "1.77 kB"
79
+ ```
80
+
81
+ ### rename(file, new_name)
82
+ Renames file if it's present in path. Returns 0 if successful and false if the file doesn't exist
83
+ ```
84
+ f.rename('new_file.rb', 'new_shit.rb')
85
+ => 0
86
+ ```
38
87
 
39
88
  ## Development
40
89
 
@@ -14,15 +14,6 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = "https://github.com/Mikeks81/File-Management"
15
15
  spec.license = "MIT"
16
16
 
17
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
- # to allow pushing to a single host or delete this section to allow pushing to any host.
19
- # if spec.respond_to?(:metadata)
20
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
- # else
22
- # raise "RubyGems 2.0 or newer is required to protect against " \
23
- # "public gem pushes."
24
- # end
25
-
26
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
18
  f.match(%r{^(test|spec|features)/})
28
19
  end
@@ -48,7 +48,7 @@ class FileManager
48
48
 
49
49
  def file_size(file)
50
50
  puts 'File does not exist' unless file_exists?(file)
51
- Filesize.new(file, Filesize::SI).pretty
51
+ Filesize.new(File.size(pwd(file)), Filesize::SI).pretty
52
52
  end
53
53
 
54
54
  def make_file(file)
@@ -57,7 +57,7 @@ class FileManager
57
57
  end
58
58
 
59
59
  def rename(file, new_name)
60
- return false unless file_exists?(File.split(new_name).last)
60
+ return false if file_exists?(File.split(new_name).last)
61
61
  File.rename(pwd(file), pwd(new_name))
62
62
  end
63
63
 
@@ -1,3 +1,3 @@
1
1
  module FileManagement
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_management
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-12 00:00:00.000000000 Z
11
+ date: 2017-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler