SafeFile 1.0.0 → 1.1.0

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +33 -1
  3. data/lib/safefile.rb +10 -0
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6558e12a3e762649ebacd215e2bb1caac71b1c6e6a4559068cf01aaf8d9e6d6a
4
- data.tar.gz: 3822d2a657ad366bad578c20261db62e9757ab0f4d004a0153d8026f9d86d253
3
+ metadata.gz: 9a7526fc0f29fc5762ce49b1a54909aade9232259e46282b1c5dd500e73cf926
4
+ data.tar.gz: 2e3849347fcce2da355c00db71e3f382e795a10abd49083c97093711886be11e
5
5
  SHA512:
6
- metadata.gz: 34e1c8f4f354fe3077a64e17d5150c60a7bd0716409b2eb7b2fc6a7e206056020c2d2d362ea3f27cc85a754eac32c5450d33507c0f2fd9abc34b173c892e1a74
7
- data.tar.gz: dac3916a294ff24517d7650b1a16fca6b2707064903d5380c721f40ca1e22bbc0840a037a6f6d67cb4b871f83359b6a3982dcf049af4231a497d7601e19b404f
6
+ metadata.gz: 8029d1b179db70f93818588dc519be5bf30fab10235e4b09c98d1c82e95b128f01980d01ef0de58fc2559f0630786467a09b814a842ab412d55b88c89fd3c25c
7
+ data.tar.gz: f8de802c3977c2b6aebe633f57c52cd16708d059f6e2d7866553e2d601e494c9ac4674c0f9620829bd5d7fd96a36040b1a7b18c3464c15f3a4601c507053d677
data/README.md CHANGED
@@ -1,3 +1,35 @@
1
1
  # SafeFile
2
2
 
3
- Strict file access library for Ruby
3
+ Strict file access library for Ruby
4
+
5
+ ## Installing
6
+ > [!WARNING]
7
+ > When installing this Gem, **capitalization matters**, for some reason..
8
+
9
+ You can either use Gem
10
+ ```sh
11
+ gem install SafeFile
12
+ ```
13
+ or put it in your Gemfile
14
+ ```gemfile
15
+ gem "SafeFile"
16
+ ```
17
+
18
+ ## Usage
19
+ It's really easy to use this. You can use it the same way you'd use the File Class. It currently only supports these actions: `SafeFile.read`, `SafeFile.open`, `SafeFile.write`, `SafeFile.foreach`.
20
+
21
+ ### Adding safe directories
22
+ By default, the parent working directory is marked as safe. You may change this with the line below
23
+ ```ruby
24
+ SafeFile.safe.allowPWD = false
25
+ ```
26
+ If you'd like to add other safe directories you may use the `SafeFile.safe.append` method
27
+ ```ruby
28
+ SafeFile.safe.append "/tmp/projectCache"
29
+ ```
30
+ or remove a safe directory with
31
+ ```ruby
32
+ SafeFile.safe.remove "/tmp/projectCache"
33
+ ```
34
+
35
+ If you need an example of everything, you may take a look at the test document located in the tests directory.
data/lib/safefile.rb CHANGED
@@ -28,6 +28,16 @@ module SafeFile
28
28
  end
29
29
  end
30
30
 
31
+ def foreach file, &block
32
+ file = file.gsub "~/", "#{ENV["HOME"]}/"
33
+
34
+ if performCheck File.expand_path file
35
+ File.foreach file do |line|
36
+ block.call line
37
+ end
38
+ end
39
+ end
40
+
31
41
  def safe
32
42
  def append dir
33
43
  dir = dir.gsub "~/", "#{ENV["HOME"]}/"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: SafeFile
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sky.Bit