obfs 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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/obfs.rb +18 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60ad552589248d9ac27f0560e71ad3ddd4dfd32407c50fc4c10ee9732b17945a
4
- data.tar.gz: 89bfcf071f49f51bc9ad25768c4fdc9e3e7b1c67a9305c7f6aaa358859798ed4
3
+ metadata.gz: 62ca2bff9fda087f834b3823adac6a193fd419c78e3dd72bdbf37b4b104c0e00
4
+ data.tar.gz: 07a819a4eb162a7bcbc43d3310f1a68ed4c6dd35b7cc1a333b69b57d536fc8bd
5
5
  SHA512:
6
- metadata.gz: 64ec76f87128169a5cad3d118dd8b13bf08a4fe2841e7b0b312fbd1f93becbf00e652a8da21466ed85c14e9f42523c723bca51e429b7cef28fb254f5073f79ef
7
- data.tar.gz: 3389becdd8b5533ee7883b95907071bcaa77c5a2e9a54a7a7bbd89da7a758a4819ec525691dd244905c5f7fcb2443682a4a641a29ac8b1d891b370fc6b3c99cf
6
+ metadata.gz: df53e0a7fed4b2f6e2b78fabe11ac0e40acc055128eff51119b9f615a25fe5bfe61becbac770043422c958d6ecc43fbb11b091fcfca68d91a5adf836d3320675
7
+ data.tar.gz: 45765a1f45e9b0969c8597003ca1f4b8e56fcc8bdba79bc5c6a326653b2cd2d682837d3e1d7e928226a40f2d32bef3426c2ccb7569bf2bfc3378907843c346af
@@ -36,9 +36,9 @@ class OBFS
36
36
 
37
37
  # write data
38
38
  if data == nil
39
- FileUtils.rm_rf File.join @path, method_name
39
+ FileUtils.rm_rf (File.join @path, method_name)
40
40
  else
41
- FileUtils.rm_rf @path, method_name if File.exist? File.join @path, method_name
41
+ FileUtils.rm_rf (File.join @path, method_name) if File.exist? (File.join @path, method_name)
42
42
  FileUtils.mkpath @path if !File.directory? @path
43
43
  write(@path, method_name, data)
44
44
  end
@@ -79,7 +79,7 @@ class OBFS
79
79
  end
80
80
 
81
81
  # searches directory contents (1 level) and returns array sorted by relevance
82
- def _find(term = '', records = 10, tolerance = 10)
82
+ def _find(term = '', records = 1000, tolerance = 10)
83
83
  output = []
84
84
  search_space = Dir.entries(@path).reject { |k| k == '.' || k == '..' } rescue []
85
85
  search_space.each do |search_space_term|
@@ -88,15 +88,27 @@ class OBFS
88
88
  end
89
89
  end
90
90
  output.first(records)
91
- end
91
+ end
92
+
93
+ # searches directory contents (1 level) and returns boolean if term exist
94
+ def _exist(term = '')
95
+ exist_space = Dir.entries(@path).reject { |k| k != term.to_s }
96
+ if exist_space.length > 0
97
+ true
98
+ else
99
+ false
100
+ end
101
+ end
92
102
 
93
103
  private
94
104
 
95
105
  # filesystem R/W
96
106
 
97
107
  def write(path, filename, data)
98
- curr_path = File.join path, filename
99
- File.write(curr_path, JSON.unparse(data))
108
+ Thread.new {
109
+ curr_path = File.join path, filename
110
+ File.write(curr_path, JSON.unparse(data))
111
+ }
100
112
  end
101
113
 
102
114
  def read(path, filename)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obfs
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
  - Jensel Gatchalian
@@ -17,7 +17,7 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/obfs.rb
20
- homepage: https://rubygems.org/gems/obfs
20
+ homepage: https://github.com/jenselg/obfs-ruby
21
21
  licenses:
22
22
  - MIT
23
23
  metadata: {}