subconvtr 0.0.8 → 0.0.9

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/subconvtr.rb +50 -31
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac3cab80cb75a34c3985f846380dbf6738d4f25a
4
- data.tar.gz: e6c1756b389539cdec3dd3aead3b1f16de863cdf
3
+ metadata.gz: a45f46b6fe63745c7d3e26240a02b25ffd88344e
4
+ data.tar.gz: fd3b93ff9f2e01f2604aa2e210dcb124bf081251
5
5
  SHA512:
6
- metadata.gz: 328421dae122108bc2c8940b4edbf01404bd4de87648de5d92cdc45839ac1c5c2e8ca0656944b8d40d7a940b582919f7f7d4f7908b745e05dee47a636a01ad56
7
- data.tar.gz: 9f1e190d257af75d82c1c36653a6a3058b250b79ae9fd7cf5c09ea7e23397ebbf142edd7388676eb7e0c635c36d13f957235ae19848b32c59866e0e0170175b5
6
+ metadata.gz: 6ab0cb5121757aa4312a08cb5c9d0b7651ce8c5e7ea821f37a2da8489332c4575e8669b51b6ddec900d0930dd4c01593bb3558a6e51c33a76e3e0202c2ac58f8
7
+ data.tar.gz: 0ff9b0d6b70faf04fc0788b2e2e8eeef55769ef6310d573a5bbbbd45c6a12fb7d99d42bf37a1dc30a0e0761c036d06fa111e470aa5cebaf9fbe376c83c5aab28
data/lib/subconvtr.rb CHANGED
@@ -1,33 +1,52 @@
1
1
  module Subconvtr
2
- class Monitor
3
-
4
- # Converts the target file from windows-1254 to utf-8 encoding.
5
- def run
6
- # puts "merhaba #{target_file_name}!"
7
- #file = #{target_file_name} \
8
- # nice = `iconv -f windows-1254 -t utf-8 "#{target_file_name}" > temp24124eqqweqwrfsdf.srt && mv temp24124eqqweqwrfsdf.srt "#{target_file_name}" && rm temp24124eqqweqwrfsdf.srt`
9
- # puts 'OUTPUT: ' + output
10
-
11
- output = `ls | grep -E ".srt"`.split("\n")
12
- # puts output
13
- output.each do |current|
14
-
15
- if !(`file -I "#{current}"`.include? "charset=utf-8")
16
- puts `file -I "#{current}"`
17
- `iconv -f windows-1254 -t utf-8 "#{current}" > temp24124eqqweqwrfsdf.srt && mv temp24124eqqweqwrfsdf.srt "#{current}" && rm temp24124eqqweqwrfsdf.srt`
18
- puts `file -I "#{current}"`
19
- else
20
- print '.'
21
- end
22
- end
23
- sleep 1
24
- end
25
-
26
- def self.start
27
- loop do
28
- self.new.run
29
- end
30
- end
31
- end
2
+
3
+ class Monitor
4
+
5
+ def initialize
6
+ end
7
+ # Converts the target file from windows-1254 to utf-8 encoding.
8
+ def run
9
+
10
+ output = `ls | grep -E ".srt"`.split("\n")
11
+
12
+ # puts output
13
+ output.each do |current|
14
+ if !(`file -I "#{current}"`.include? "charset=utf-8")
15
+ puts `file -I "#{current}"`
16
+ `iconv -f windows-1254 -t utf-8 "#{current}" > temp24124eqqweqwrfsdf.srt && mv temp24124eqqweqwrfsdf.srt "#{current}"`
17
+ puts `file -I "#{current}"`
18
+ else
19
+ # print '.'
20
+ end
21
+ end
22
+
23
+ sleep 1
24
+ end
25
+
26
+ def self.start
27
+ loop do
28
+ self.new.run
29
+ end
30
+ end
31
+ end
32
32
  end
33
- Subconvtr::Monitor.start
33
+
34
+ # trapping the ctrl+c exit
35
+ trap "SIGINT" do
36
+ puts ""
37
+ puts "Exiting"
38
+ puts "......."
39
+ puts "See you next time 🐰"
40
+ puts ""
41
+ exit 130
42
+ end
43
+
44
+ puts `pwd`
45
+ puts 'Folder above is being watched 🤓'
46
+ puts 'Observing for .srt files, i.e. ones having windows-1254 charset will be converted into utf-8'
47
+ puts 'Files will be analyzed before conversion 🚀'
48
+ puts ''
49
+ puts 'Press Ctrl+C to exit'
50
+
51
+ Subconvtr::Monitor.start
52
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subconvtr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - ardarda