shookach 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10c53341d7bdb6158be1e5e5d86a4ad63593b76e2c2649a13f6e691edc919992
4
- data.tar.gz: 90bf5ad2a2fa6b364b5f4ef4b83b7ed61eb4a7e33953173f3403ad17feb7ff92
3
+ metadata.gz: 865cd6643ebbfc5adc8f873a9c7f9b7e5a91fb5f719f03985541aa6cbcd7ef3d
4
+ data.tar.gz: 35c647ccc636e9441cd2df6d5c1dcc0ccb19eb38cd10b1520b5ee0594940b3d0
5
5
  SHA512:
6
- metadata.gz: efa4d6324507afafa2709502b166e83966036b2df56e220647d6c9fb0602e425a3ec75ec4bf36939f1d0e073c5e548813ce6e66152392ebe36456f79d71bdfe1
7
- data.tar.gz: dc5eb5012eeb4a440954fb856ccc6a6b84f1aab4b25030d19c77d8cad7b7eac2052101ee2915acc96d764d4d9b1c9c41fdefc42d8f9a925134ac335637028f12
6
+ metadata.gz: aeabad7c1dcd7daed2824662243d27f84ab9d7bc320b4df51bae527a321d56814e5e51135a92cc59aa8c29f664fddaa2c1717c8cbf52fd7e8baf7a7377995f4d
7
+ data.tar.gz: d8aca686d11a684a45f8f0c45b9e4515ec6fad2f9f8d1cc320ccfbba655b5c84e0445c8da9068be0d953bb06653e41bf0125c27dc89d64420a347f009fbef86e
@@ -1,52 +1,54 @@
1
- class Indexer
2
- def initialize(library_path, output_path)
3
- @library_path = library_path
4
- create_index_file(output_path)
5
- end
1
+ module Shookach
2
+ class Indexer
3
+ def initialize(library_path, output_path)
4
+ @library_path = library_path
5
+ create_index_file(output_path)
6
+ end
6
7
 
7
- def call
8
- write_dir_indexes
8
+ def call
9
+ write_dir_indexes
9
10
 
10
- @output_file.close
11
- end
11
+ @output_file.close
12
+ end
12
13
 
13
- private
14
+ private
14
15
 
15
- def create_index_file(path)
16
- Dir.mkdir(path) unless File.exists?(path)
16
+ def create_index_file(path)
17
+ Dir.mkdir(path) unless File.exists?(path)
17
18
 
18
- @output_file = File.open("#{path}indexes#{Time.now.strftime('%Y%m%d%H%M%S')}.yml", 'w')
19
- end
19
+ @output_file = File.open("#{path}indexes#{Time.now.strftime('%Y%m%d%H%M%S')}.yml", 'w')
20
+ end
20
21
 
21
- def write_dir_indexes
22
- puts "Indexing directory: #{@library_path}"
22
+ def write_dir_indexes
23
+ puts "Indexing directory: #{@library_path}"
23
24
 
24
- Dir.foreach(@library_path) do |filename|
25
- next if filename == '.' || filename == '..'
25
+ Dir.foreach(@library_path) do |filename|
26
+ next if filename == '.' || filename == '..'
26
27
 
27
- write_file_indexes(filename)
28
- end
28
+ write_file_indexes(filename)
29
+ end
29
30
 
30
- puts "Output file: #{@output_file.path}"
31
- end
31
+ puts "Output file: #{@output_file.path}"
32
+ end
32
33
 
33
- def write_file_indexes(filename)
34
- puts "Indexing file: #{filename}"
34
+ def write_file_indexes(filename)
35
+ puts "Indexing file: #{filename}"
35
36
 
36
- @file = File.open("#{@library_path}/#{filename}", 'r')
37
+ @file = File.open("#{@library_path}/#{filename}", 'r')
37
38
 
38
- sentences_arr.each_with_index do |sentence, s_index|
39
- words = sentence.split(' ')
39
+ sentences_arr.each_with_index do |sentence, s_index|
40
+ words = sentence.split(' ')
40
41
 
41
- words.each_with_index do |word, w_index|
42
- @output_file.write("#{word}:\r file: #{filename}\r sentence: #{s_index}\r word: #{w_index}\n")
42
+ words.each_with_index do |word, w_index|
43
+ @output_file.write("#{word}:\r file: #{filename}\r sentence: #{s_index}\r word: #{w_index}\n")
44
+ end
43
45
  end
44
- end
45
46
 
46
- @file.close
47
- end
47
+ @file.close
48
+ end
48
49
 
49
- def sentences_arr
50
- @file.read().gsub(',', ' ').gsub(/\n|\r/, ' ').split(/\.\s*/)
50
+ def sentences_arr
51
+ @file.read().gsub(',', ' ').gsub(/\n|\r/, ' ').split(/\.\s*/)
52
+ end
51
53
  end
52
54
  end
@@ -1,6 +1,6 @@
1
1
  require 'shookach'
2
2
 
3
- class Railtie < Rails::Railtie
3
+ class Shookach::Railtie < Rails::Railtie
4
4
  rake_tasks do
5
5
  load 'tasks/shookach.rake'
6
6
  end
@@ -1,3 +1,5 @@
1
- class Searcher
2
- #TODO would be implemented later
1
+ module Shookach
2
+ class Searcher
3
+ #TODO would be implemented later
4
+ end
3
5
  end
data/lib/shookach.rb CHANGED
@@ -2,15 +2,15 @@ require 'shookach/indexer'
2
2
  require 'shookach/searcher'
3
3
  require 'shookach/railtie' if defined?(Rails)
4
4
 
5
- class Shookach
5
+ module Shookach
6
6
  def self.index(options = {})
7
7
  @options = default_configs.merge(options)
8
8
 
9
- Indexer.new(@options[:library_path], @options[:output_path]).call
9
+ Shookach::Indexer.new(@options[:library_path], @options[:output_path]).call
10
10
  end
11
11
 
12
12
  def self.search
13
- # @searcher.call
13
+ # Shookach::Searcher.new
14
14
  end
15
15
 
16
16
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shookach
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
  - Bohdan Chaban