tahweel 0.1.1 → 0.1.3

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.
data/README.md CHANGED
@@ -1,43 +1,487 @@
1
- # Tahweel
1
+ <p align="center">
2
+ <img src="assets/logo.png" alt="شعار تحويل" width="200" />
3
+ </p>
2
4
 
3
- TODO: Delete this and the text below, and describe your gem
5
+ <h1 dir="rtl" align="center">تحويل (Tahweel)</h1>
4
6
 
5
- 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/tahweel`. To experiment with that code, run `bin/console` for an interactive prompt.
7
+ <p dir="rtl" align="center">
8
+ <strong>تحويل ملفات PDF والصور إلى نصوص باستخدام التعرف الضوئي من Google Drive</strong>
9
+ </p>
6
10
 
7
- ## Installation
11
+ <p align="center">
12
+ <a href="https://rubygems.org/gems/tahweel"><img src="https://img.shields.io/gem/v/tahweel.svg" alt="إصدار الجوهرة" /></a>
13
+ <a href="https://github.com/ieasybooks/tahweel.rb/blob/main/LICENSE.txt"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="الرخصة" /></a>
14
+ <img src="https://img.shields.io/badge/ruby-%3E%3D%203.2-ruby.svg" alt="إصدار Ruby" />
15
+ </p>
8
16
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
17
+ <p align="center">
18
+ <a href="#المميزات">المميزات</a> •
19
+ <a href="#التثبيت">التثبيت</a> •
20
+ <a href="#المتطلبات">المتطلبات</a> •
21
+ <a href="#المصادقة">المصادقة</a> •
22
+ <a href="#الاستخدام">الاستخدام</a> •
23
+ <a href="#واجهة-البرمجة">واجهة البرمجة</a> •
24
+ <a href="#المساهمة">المساهمة</a>
25
+ </p>
10
26
 
11
- Install the gem and add to the application's Gemfile by executing:
27
+ <p align="center">
28
+ <a href="README.en.md">🌐 English</a>
29
+ </p>
30
+
31
+ ---
32
+
33
+ <p dir="rtl"><strong>تحويل</strong> (بالإنجليزية: Tahweel، وتعني "التحويل") هي أداة Ruby قوية لتحويل ملفات PDF والصور إلى نصوص قابلة للتحرير باستخدام تقنية التعرف الضوئي من Google Drive. تم تحسينها بشكل خاص للنصوص العربية، لكنها تعمل بامتياز مع جميع اللغات التي يدعمها محرك Google.</p>
34
+
35
+ <h2 dir="rtl">المميزات</h2>
36
+
37
+ <ul dir="rtl">
38
+ <li>🔤 <strong>تعرف ضوئي عالي الجودة</strong> — يستخدم محرك Google Drive القوي لاستخراج النصوص بدقة</li>
39
+ <li>📄 <strong>صيغ إدخال متعددة</strong> — يدعم ملفات PDF و JPG و JPEG و PNG</li>
40
+ <li>📝 <strong>صيغ إخراج متعددة</strong> — تصدير إلى TXT أو DOCX أو JSON</li>
41
+ <li>🌐 <strong>دعم النصوص العربية</strong> — اكتشاف تلقائي لاتجاه النص من اليمين لليسار</li>
42
+ <li>⚡ <strong>معالجة متزامنة</strong> — معالجة متعددة الخيوط على مستوى الملفات والصفحات</li>
43
+ <li>📊 <strong>تتبع التقدم اللحظي</strong> — واجهة طرفية جميلة مع تتبع التقدم لكل خيط</li>
44
+ <li>🖥️ <strong>واجهة رسومية</strong> — واجهة سطح مكتب عبر المنصات بالعربية والإنجليزية</li>
45
+ <li>🔄 <strong>تخطي ذكي</strong> — يتخطى الملفات تلقائياً عندما يكون الإخراج موجوداً</li>
46
+ <li>📁 <strong>الحفاظ على هيكل المجلدات</strong> — يحافظ على التسلسل الهرمي للمجلدات في الإخراج</li>
47
+ <li>🛡️ <strong>معالجة أخطاء قوية</strong> — إعادة المحاولة بتأخير تصاعدي لحدود واجهة البرمجة</li>
48
+ </ul>
49
+
50
+ <h2 dir="rtl">التثبيت</h2>
51
+
52
+ <h3 dir="rtl">من RubyGems</h3>
53
+
54
+ ```bash
55
+ gem install tahweel
56
+ ```
57
+
58
+ <h3 dir="rtl">باستخدام Bundler</h3>
59
+
60
+ <p dir="rtl">أضف هذا السطر إلى ملف Gemfile الخاص بتطبيقك:</p>
61
+
62
+ ```ruby
63
+ gem 'tahweel'
64
+ ```
65
+
66
+ <p dir="rtl">ثم نفّذ:</p>
67
+
68
+ ```bash
69
+ bundle install
70
+ ```
71
+
72
+ <h3 dir="rtl">من المصدر</h3>
73
+
74
+ ```bash
75
+ git clone https://github.com/ieasybooks/tahweel.rb.git
76
+ cd tahweel.rb
77
+ bundle install
78
+ ```
79
+
80
+ <h2 dir="rtl">المتطلبات</h2>
81
+
82
+ <h3 dir="rtl">إصدار Ruby</h3>
83
+
84
+ <p dir="rtl">يتطلب تحويل <strong>Ruby 3.2.0</strong> أو أحدث.</p>
85
+
86
+ <h3 dir="rtl">أدوات Poppler</h3>
87
+
88
+ <p dir="rtl">يستخدم تحويل أدوات Poppler (<code dir="ltr">pdftoppm</code> و <code dir="ltr">pdfinfo</code>) لتقسيم ملفات PDF إلى صور.</p>
89
+
90
+ <p dir="rtl"><strong>macOS:</strong></p>
91
+
92
+ ```bash
93
+ brew install poppler
94
+ ```
95
+
96
+ <p dir="rtl"><strong>Ubuntu/Debian:</strong></p>
97
+
98
+ ```bash
99
+ sudo apt install poppler-utils
100
+ ```
101
+
102
+ <p dir="rtl"><strong>Windows:</strong></p>
103
+
104
+ <p dir="rtl">يقوم تحويل بتنزيل وتثبيت Poppler تلقائياً على Windows عند التشغيل لأول مرة.</p>
105
+
106
+ <h3 dir="rtl">حساب Google</h3>
107
+
108
+ <p dir="rtl">ستحتاج إلى حساب Google للمصادقة مع خدمة التعرف الضوئي في Google Drive. في أول تشغيل لتحويل، سيفتح نافذة متصفح للمصادقة عبر OAuth.</p>
109
+
110
+ <h2 dir="rtl">المصادقة</h2>
111
+
112
+ <p dir="rtl">يستخدم تحويل OAuth 2.0 للمصادقة مع Google Drive. عند التشغيل لأول مرة:</p>
113
+
114
+ <ol dir="rtl">
115
+ <li>ستفتح نافذة متصفح تلقائياً</li>
116
+ <li>سجّل الدخول بحسابك في Google</li>
117
+ <li>امنح تحويل صلاحية إنشاء وإدارة الملفات في Google Drive الخاص بك</li>
118
+ <li>بعد المصادقة، سترى صفحة نجاح ويمكنك إغلاق المتصفح</li>
119
+ </ol>
120
+
121
+ <p dir="rtl"><strong>ملاحظة:</strong> يقوم تحويل فقط بإنشاء ملفات مؤقتة لمعالجة التعرف الضوئي ويحذفها فوراً بعد الاستخراج. يستخدم نطاق <code dir="ltr">drive.file</code> الذي يسمح فقط بالوصول إلى الملفات التي أنشأها التطبيق.</p>
122
+
123
+ <p dir="rtl">يتم تخزين بيانات الاعتماد بشكل آمن في:</p>
124
+
125
+ <ul dir="rtl">
126
+ <li><strong>Linux/macOS:</strong> <code dir="ltr">~/.cache/tahweel/token.yaml</code></li>
127
+ <li><strong>Windows:</strong> <code dir="ltr">%LOCALAPPDATA%\tahweel\token.yaml</code></li>
128
+ </ul>
129
+
130
+ <h3 dir="rtl">مسح بيانات الاعتماد</h3>
131
+
132
+ <p dir="rtl">لإزالة بيانات الاعتماد المخزنة وإعادة المصادقة:</p>
133
+
134
+ ```bash
135
+ tahweel-clear
136
+ ```
137
+
138
+ <h2 dir="rtl">الاستخدام</h2>
139
+
140
+ <h3 dir="rtl">واجهة سطر الأوامر</h3>
141
+
142
+ <h4 dir="rtl">الاستخدام الأساسي</h4>
143
+
144
+ <p dir="rtl">تحويل ملف PDF واحد:</p>
145
+
146
+ ```bash
147
+ tahweel document.pdf
148
+ ```
149
+
150
+ <p dir="rtl">تحويل جميع ملفات PDF في مجلد:</p>
151
+
152
+ ```bash
153
+ tahweel /path/to/documents/
154
+ ```
155
+
156
+ <h4 dir="rtl">صيغ الإخراج</h4>
157
+
158
+ <p dir="rtl">تحديد صيغ الإخراج (الافتراضي: <code dir="ltr">txt,docx</code>):</p>
159
+
160
+ ```bash
161
+ # Text only
162
+ tahweel document.pdf -f txt
163
+
164
+ # DOCX only
165
+ tahweel document.pdf -f docx
166
+
167
+ # JSON only
168
+ tahweel document.pdf -f json
169
+
170
+ # Multiple formats
171
+ tahweel document.pdf -f txt,docx,json
172
+ ```
173
+
174
+ <h4 dir="rtl">مجلد إخراج مخصص</h4>
175
+
176
+ ```bash
177
+ tahweel document.pdf -o /path/to/output/
178
+ ```
179
+
180
+ <h4 dir="rtl">التصفية حسب امتدادات الملفات</h4>
181
+
182
+ ```bash
183
+ # Process only PDF files
184
+ tahweel /path/to/documents/ -e pdf
185
+
186
+ # Process only images
187
+ tahweel /path/to/documents/ -e jpg,jpeg,png
188
+ ```
189
+
190
+ <h4 dir="rtl">إعدادات التزامن</h4>
12
191
 
13
192
  ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
193
+ # Process 4 files concurrently
194
+ tahweel /path/to/documents/ -F 4
195
+
196
+ # Use 8 concurrent OCR operations per file
197
+ tahweel /path/to/documents/ -O 8
15
198
  ```
16
199
 
17
- If bundler is not being used to manage dependencies, install the gem by executing:
200
+ <h4 dir="rtl">إعدادات DPI</h4>
201
+
202
+ <p dir="rtl">DPI أعلى ينتج جودة أفضل لكن معالجة أبطأ:</p>
18
203
 
19
204
  ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
205
+ tahweel document.pdf --dpi 300
21
206
  ```
22
207
 
23
- ## Usage
208
+ <h4 dir="rtl">فاصل صفحات مخصص (إخراج TXT)</h4>
209
+
210
+ ```bash
211
+ tahweel document.pdf --page-separator "\\n---PAGE BREAK---\\n"
212
+ ```
24
213
 
25
- TODO: Write usage instructions here
214
+ <h3 dir="rtl">مرجع خيارات سطر الأوامر</h3>
26
215
 
27
- ## Development
216
+ <div dir="rtl">
28
217
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
218
+ | الخيار | المختصر | الوصف | الافتراضي |
219
+ |--------|---------|-------|-----------|
220
+ | `--extensions` | `-e` | امتدادات الملفات للمعالجة | `pdf,jpg,jpeg,png` |
221
+ | `--dpi` | | DPI لتحويل PDF إلى صورة | `150` |
222
+ | `--processor` | `-p` | معالج OCR المستخدم | `google_drive` |
223
+ | `--file-concurrency` | `-F` | أقصى عدد ملفات للمعالجة المتزامنة | `المعالجات - 2` |
224
+ | `--ocr-concurrency` | `-O` | أقصى عمليات OCR متزامنة | `12` |
225
+ | `--formats` | `-f` | صيغ الإخراج (مفصولة بفواصل) | `txt,docx` |
226
+ | `--page-separator` | | فاصل الصفحات لإخراج TXT | `\n\nPAGE_SEPARATOR\n\n` |
227
+ | `--output` | `-o` | مجلد الإخراج | مجلد ملف الإدخال |
228
+ | `--version` | `-v` | عرض الإصدار | |
30
229
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
230
+ </div>
231
+
232
+ <h3 dir="rtl">الواجهة الرسومية</h3>
233
+
234
+ <p dir="rtl">لتشغيل واجهة سطح المكتب:</p>
235
+
236
+ ```bash
237
+ tahweel-ui
238
+ ```
239
+
240
+ <p dir="rtl">توفر الواجهة الرسومية:</p>
241
+
242
+ <ul dir="rtl">
243
+ <li>تحويل ملف واحد أو مجلد كامل</li>
244
+ <li>واجهة بالعربية والإنجليزية</li>
245
+ <li>تتبع التقدم للمستوى العام ولكل ملف</li>
246
+ <li>فتح مجلد الإخراج تلقائياً عند الانتهاء</li>
247
+ </ul>
248
+
249
+ <h3 dir="rtl">عرض التقدم</h3>
250
+
251
+ <p dir="rtl">تعرض واجهة سطر الأوامر لوحة تقدم لحظية:</p>
252
+
253
+ ```
254
+ Total Progress: [3/10] 30.0% | Time: 45s
255
+ [Worker 1] document1.pdf | Ocr | 75.0% (6/8)
256
+ [Worker 2] document2.pdf | Splitting | 50.0% (5/10)
257
+ [Worker 3] Idle
258
+ [Worker 4] document4.pdf | Ocr | 25.0% (2/8)
259
+ ```
260
+
261
+ <h2 dir="rtl">صيغ الإخراج</h2>
262
+
263
+ <h3 dir="rtl">TXT (نص عادي)</h3>
264
+
265
+ <p dir="rtl">إخراج نصي بسيط مع فواصل صفحات قابلة للتخصيص:</p>
266
+
267
+ ```
268
+ محتوى الصفحة 1 هنا...
269
+
270
+ PAGE_SEPARATOR
271
+
272
+ محتوى الصفحة 2 هنا...
273
+ ```
274
+
275
+ <h3 dir="rtl">DOCX (Microsoft Word)</h3>
276
+
277
+ <p dir="rtl">مستندات Word منسقة مع:</p>
278
+
279
+ <ul dir="rtl">
280
+ <li>صفحة محتوى واحدة لكل صفحة مستند</li>
281
+ <li>اتجاه نص تلقائي (RTL للعربية، LTR لغيرها)</li>
282
+ <li>فواصل أسطر متوافقة مع جميع المنصات</li>
283
+ <li>دمج ذكي للأسطر لقراءة أفضل</li>
284
+ </ul>
285
+
286
+ <h3 dir="rtl">JSON (بيانات منظمة)</h3>
287
+
288
+ <p dir="rtl">إخراج منظم صفحة بصفحة:</p>
289
+
290
+ ```json
291
+ [
292
+ {
293
+ "page": 1,
294
+ "content": "محتوى الصفحة 1 هنا..."
295
+ },
296
+ {
297
+ "page": 2,
298
+ "content": "محتوى الصفحة 2 هنا..."
299
+ }
300
+ ]
301
+ ```
302
+
303
+ <h2 dir="rtl">واجهة البرمجة</h2>
304
+
305
+ <h3 dir="rtl">تحويل ملفات PDF</h3>
306
+
307
+ ```ruby
308
+ require 'tahweel'
309
+
310
+ # Convert a PDF to text (returns array of page texts)
311
+ pages = Tahweel.convert('document.pdf')
312
+
313
+ # With options
314
+ pages = Tahweel.convert(
315
+ 'document.pdf',
316
+ dpi: 300, # Higher quality
317
+ processor: :google_drive,
318
+ concurrency: 8
319
+ )
320
+
321
+ # With progress tracking
322
+ pages = Tahweel.convert('document.pdf') do |progress|
323
+ puts "Stage: #{progress[:stage]}"
324
+ puts "Progress: #{progress[:percentage]}%"
325
+ puts "Current page: #{progress[:current_page]}"
326
+ end
327
+ ```
328
+
329
+ <h3 dir="rtl">استخراج النص من الصور</h3>
330
+
331
+ ```ruby
332
+ require 'tahweel'
333
+
334
+ # Extract text from a single image
335
+ text = Tahweel.extract('image.png')
336
+ text = Tahweel.extract('photo.jpg', processor: :google_drive)
337
+ ```
338
+
339
+ <h3 dir="rtl">كتابة ملفات الإخراج</h3>
340
+
341
+ ```ruby
342
+ require 'tahweel'
343
+
344
+ pages = Tahweel.convert('document.pdf')
345
+
346
+ # Write to multiple formats
347
+ Tahweel::Writer.write(pages, 'output', formats: [:txt, :docx, :json])
348
+
349
+ # Write to a single format with options
350
+ Tahweel::Writer.write(
351
+ pages,
352
+ 'output',
353
+ formats: [:txt],
354
+ page_separator: "\n---\n"
355
+ )
356
+ ```
357
+
358
+ <h3 dir="rtl">خط معالجة كامل</h3>
359
+
360
+ ```ruby
361
+ require 'tahweel'
362
+
363
+ # Using the CLI FileProcessor for complete workflow
364
+ Tahweel::CLI::FileProcessor.process('document.pdf', {
365
+ dpi: 150,
366
+ processor: :google_drive,
367
+ ocr_concurrency: 12,
368
+ formats: [:txt, :docx],
369
+ output: '/path/to/output'
370
+ }) do |progress|
371
+ puts "#{progress[:stage]}: #{progress[:percentage]}%"
372
+ end
373
+ ```
374
+
375
+ <h3 dir="rtl">جمع الملفات من مجلد</h3>
376
+
377
+ ```ruby
378
+ require 'tahweel'
379
+
380
+ # Get all supported files in a directory
381
+ files = Tahweel::CLI::FileCollector.collect('/path/to/documents/')
382
+
383
+ # Filter by specific extensions
384
+ files = Tahweel::CLI::FileCollector.collect(
385
+ '/path/to/documents/',
386
+ extensions: ['pdf']
387
+ )
388
+ ```
389
+
390
+ <h2 dir="rtl">أمثلة</h2>
391
+
392
+ <h3 dir="rtl">تحويل دفعي للكتب العربية</h3>
393
+
394
+ ```bash
395
+ # Convert all PDFs in an Arabic books directory with high quality
396
+ tahweel ~/arabic-books/ -f txt,docx --dpi 200 -o ~/converted-books/
397
+ ```
398
+
399
+ <h3 dir="rtl">معالجة المستندات الممسوحة ضوئياً</h3>
400
+
401
+ ```bash
402
+ # Convert scanned images to searchable text
403
+ tahweel ~/scanned-docs/ -e jpg,png -f txt -o ~/ocr-output/
404
+ ```
405
+
406
+ <h3 dir="rtl">التكامل مع المكتبة</h3>
407
+
408
+ ```ruby
409
+ require 'tahweel'
410
+
411
+ # Convert and process in your application
412
+ def process_document(pdf_path)
413
+ pages = Tahweel.convert(pdf_path) do |progress|
414
+ update_progress_bar(progress[:percentage])
415
+ end
416
+
417
+ # Process the extracted text
418
+ full_text = pages.join("\n\n")
419
+ word_count = full_text.split.size
420
+
421
+ {
422
+ pages: pages.size,
423
+ words: word_count,
424
+ text: full_text
425
+ }
426
+ end
427
+ ```
428
+
429
+ <h2 dir="rtl">استكشاف الأخطاء وإصلاحها</h2>
430
+
431
+ <h3 dir="rtl">حدود واصفات الملفات</h3>
432
+
433
+ <p dir="rtl">إذا واجهت أخطاء اتصال أو تجمد مع دفعات كبيرة:</p>
434
+
435
+ ```bash
436
+ ulimit -n 4096
437
+ ```
438
+
439
+ <h3 dir="rtl">تحديد المعدل</h3>
440
+
441
+ <p dir="rtl">يتعامل تحويل تلقائياً مع حدود معدل Google API بتأخير تصاعدي. إذا استمرت المشاكل، جرّب تقليل التزامن:</p>
442
+
443
+ ```bash
444
+ tahweel documents/ -F 2 -O 6
445
+ ```
446
+
447
+ <h3 dir="rtl">Poppler غير موجود</h3>
448
+
449
+ <p dir="rtl">تأكد من تثبيت Poppler وأنه في مسار PATH:</p>
450
+
451
+ ```bash
452
+ which pdftoppm # Should return a path
453
+ ```
454
+
455
+ <h2 dir="rtl">المساهمة</h2>
456
+
457
+ <p dir="rtl">تقارير الأخطاء وطلبات السحب مرحب بها على GitHub في https://github.com/ieasybooks/tahweel.rb.</p>
458
+
459
+ <ol dir="rtl">
460
+ <li>انسخ المستودع (Fork)</li>
461
+ <li>أنشئ فرع الميزة (<code dir="ltr">git checkout -b feature/amazing-feature</code>)</li>
462
+ <li>ثبّت تغييراتك (<code dir="ltr">git commit -am 'Add amazing feature'</code>)</li>
463
+ <li>ادفع إلى الفرع (<code dir="ltr">git push origin feature/amazing-feature</code>)</li>
464
+ <li>افتح طلب سحب (Pull Request)</li>
465
+ </ol>
466
+
467
+ <h3 dir="rtl">التطوير</h3>
468
+
469
+ <p dir="rtl">بعد استنساخ المستودع:</p>
470
+
471
+ ```bash
472
+ bin/setup # Install dependencies
473
+ rake spec # Run tests
474
+ bin/console # Interactive prompt
475
+ ```
32
476
 
33
- ## Contributing
477
+ <h2 dir="rtl">الرخصة</h2>
34
478
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tahweel. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/tahweel/blob/main/CODE_OF_CONDUCT.md).
479
+ <p dir="rtl">هذه الأداة متاحة كمصدر مفتوح بموجب شروط <a href="https://opensource.org/licenses/MIT">رخصة MIT</a>.</p>
36
480
 
37
- ## License
481
+ <h2 dir="rtl">قواعد السلوك</h2>
38
482
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
483
+ <p dir="rtl">يُتوقع من جميع المتفاعلين في مشروع تحويل اتباع <a href="https://github.com/ieasybooks/tahweel.rb/blob/main/CODE_OF_CONDUCT.md">قواعد السلوك</a>.</p>
40
484
 
41
- ## Code of Conduct
485
+ ---
42
486
 
43
- Everyone interacting in the Tahweel project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/tahweel/blob/main/CODE_OF_CONDUCT.md).
487
+ <p dir="rtl" align="center">صُنع بـ ❤️ بواسطة <a href="https://github.com/ieasybooks">iEasyBooks</a></p>
data/assets/logo.png ADDED
Binary file
Binary file
data/bin/tahweel CHANGED
@@ -11,10 +11,15 @@ require "tahweel/cli/progress_renderer"
11
11
  begin
12
12
  soft, hard = Process.getrlimit(:NOFILE)
13
13
  Process.setrlimit(:NOFILE, [4096, hard].min) if soft < 4096
14
- rescue StandardError
15
- puts "\e[31mTahweel failed to increase the soft limit of file descriptors to 4096."
16
- puts "If you faced connection errors or the CLI froze, try running `ulimit -n 4096` in your terminal."
17
- puts "If you still face issues, please report them at https://github.com/ieasybooks/tahweel.rb/issues.\e[0m"
14
+ rescue Exception # rubocop:disable Lint/RescueException
15
+ if Gem.win_platform?
16
+ puts "\e[33mWarning: Could not adjust file descriptor limit on Windows. Proceeding with default limits."
17
+ puts "If you faced connection errors or the CLI froze, please report at https://github.com/ieasybooks/tahweel.rb/issues.\e[0m"
18
+ else
19
+ puts "\e[33mWarning: Tahweel failed to increase the soft limit of file descriptors to 4096."
20
+ puts "If you faced connection errors or the CLI froze, try running `ulimit -n 4096` in your terminal."
21
+ puts "If you still face issues, please report them at https://github.com/ieasybooks/tahweel.rb/issues.\e[0m"
22
+ end
18
23
  end
19
24
 
20
25
  begin
@@ -27,7 +32,7 @@ begin
27
32
  exit 0
28
33
  end
29
34
 
30
- Tahweel::Authorizer.authorize if options[:file_concurrency] > 1 && options[:processor] == :google_drive
35
+ Tahweel::Authorizer.authorize if options[:processor] == :google_drive
31
36
 
32
37
  base_path = File.directory?(input_path) ? input_path : File.dirname(input_path)
33
38