wahy 1.3.9 → 2.0.5

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: b2c5edeafe373e9b29f6d0eda1be6525157fb7a354928b4532bb7b640c61fa81
4
- data.tar.gz: 137d031f2a2041be1448d1dcf9a3672a8c01eb119ff57fa16fb447c602c03bc0
3
+ metadata.gz: 5d853de63838d3a32095161363dd188cb718bd98e1e7b8ac44db9d31b768210a
4
+ data.tar.gz: 921a91ff83817d791b6a393531fe8da4abd0349689ecdc307aa57016d5630be2
5
5
  SHA512:
6
- metadata.gz: 1bba452aefb20adc5e41d2cd159b7e4ecb1c89b25cde4d804e4639090ad7333522038afc5048b63add6ae802baf158df458707badae322955b42fc43bbb1cba4
7
- data.tar.gz: abd708538ed84996ca8bbb7499bd6cfd8b5a072e1ae7b69f02232aa31151420fdef3d5ee762f7d4eac7304be48532a11b58f2f58fa1f71fa2626268b4cd71b44
6
+ metadata.gz: 224f3ad775efc37663370d8669c47f1a44e925159fb12cdd46239348a3babf09557c78231b55bc34bfd6a503fc7a5b15ab475c2b2bd9c23a590056004f205603
7
+ data.tar.gz: cd8cf7d256f9c7a76ff01600dea4e96750e1b10eed9da5cada6ccae8ad45d9ad7524b4a217b128575ffc6f0cd186dbbdfd45a1d66d8483b3ca5316d8328210a9
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.2
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-05-26
4
+
5
+ - Initial release
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,74 +1,10 @@
1
- # Contributor Covenant Code of Conduct
1
+ # Code of Conduct
2
2
 
3
- ## Our Pledge
3
+ "wahy" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
4
4
 
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
5
+ * Participants will be tolerant of opposing views.
6
+ * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
7
+ * When interpreting the words and actions of others, participants should always assume good intentions.
8
+ * Behaviour which can be reasonably considered harassment will not be tolerated.
11
9
 
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at TODO: Write your email address. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
10
+ If you have any concerns about behaviour within this project, please contact us at ["caglar.gokhan@gmail.com"](mailto:"caglar.gokhan@gmail.com").
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 Gökhan ÇAĞLAR
3
+ Copyright (c) 2026 cptangry
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,10 +1,25 @@
1
1
  # Wahy
2
2
 
3
- Welcome to my Wahy gem repo! 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/wahy`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Wahy is a powerful Ruby-based tool designed to query, read, and display Quran chapters and verses directly from your terminal. It offers a clean, colorized CLI interface for quick lookup and a modular structure that allows you to use it as a library (API) in your own Ruby projects.
4
+
5
+ ## Features
6
+
7
+ - **Dual Language Support:** Easily query and read verses in Turkish (`tur`) or English (`eng`).
8
+ - **Flexible Queries:** Search chapters by their number (e.g., `2`) or their names (e.g., `"Bakara"` or `"The Cow"`).
9
+ - **Verse Filtering:** Retrieve an entire chapter or a specific verse (e.g., `-a 5`) with ease.
10
+ - **Colorized Terminal UI:** Optimized reading experience with automatic text centering and highlighted verse indicators.
11
+ - **Modular Library:** Easily integrate the data parsing logic into other Ruby applications.
12
+
13
+ ## Prerequisites
14
+
15
+ - Ruby 2.5 or higher
16
+ - The project expects XML data files to be located in the `lib/wahy/data/` directory:
17
+ - `config_en.xml`
18
+ - `config_tr.xml`
4
19
 
5
20
  ## Installation
6
21
 
7
- Add this line to your application's Gemfile:
22
+ Add this line to your application's `Gemfile`:
8
23
 
9
24
  ```ruby
10
25
  gem 'wahy'
@@ -12,73 +27,84 @@ gem 'wahy'
12
27
 
13
28
  And then execute:
14
29
 
15
- $ bundle
30
+ ```bash
31
+ bundle install
32
+ ```
16
33
 
17
34
  Or install it yourself as:
18
35
 
19
- $ gem install wahy
36
+ ```bash
37
+ gem install wahy
38
+ ```
20
39
 
21
- ## Usage
40
+ Or install it directly via terminal:
22
41
 
23
- ![Ekran Görüntüsü](Screenshot_2017-08-17_16-23-15.png)
42
+ ```bash
43
+ gem install wahy
44
+ ```
24
45
 
25
- ```shell
26
- # Just install gem and use wahy command
27
- # For help:
28
- wahy -h
46
+ ## CLI Usage
29
47
 
30
- There is the argument's options:
31
- # If you want to see English results you don't need to call -l argument (English is default)
32
- # -l => to pick language ('eng'|'tur') # Default: (English)
33
- # -s => to pick scripture (also can use scripture's number) # between 1-114 # Default: 1
34
- # -a => to pick sign number (also can use all) # Default: all
48
+ You can use the wahy command directly in your terminal. By default, it displays the 1st chapter in English.
35
49
 
36
- # User can call only wahy command then will see all sings of first scripture in Engish.
50
+ | Option | Long Option | Description | Default |
51
+ | :--- | :--- | :--- | :--- |
52
+ | `-l` | `--lang` | Language selection (`tur` or `eng`) | `eng` |
53
+ | `-s` | `--scripture` | Chapter name or number (1-114) | `1` |
54
+ | `-a` | `--ayah` | Specific verse number or 'all' | `all` |
55
+ | `-h` | `--help` | Show help menu | - |
37
56
 
38
- # The Cow Scripture and its all signs
39
- wahy -l 'eng' -s 'The Cow' # alias to: wahy -l 'eng' -s 'The Cow' -a 'all'
40
- wahy -l 'tur' -s 'The Cow' # alias to: wahy -l 'eng' -s 'The Cow' -a 'all'
57
+ Examples
41
58
 
42
- # The Cow Scripture and its 2nd sign
43
- wahy -l 'eng' -s 'The Cow' -a 2
44
- wahy -l 'tur' -s 'The Cow' -a 2
59
+ View the entire chapter in English:
45
60
 
46
- # There is a little terminal trick to save output to a file:
47
- wahy -l 'eng' -s 'The Cow' > fileName.txt # :)
61
+ ```bash
62
+ wahy
63
+ ```
48
64
 
49
- # Also in lib directory : wahy.rb is a executable file
65
+ View a specific chapter in Turkish:
50
66
 
51
- # Also you can use that gem as source of your own project
52
- require 'wahy'
67
+ ```bash
68
+ wahy -l tur -s <chapter_number> # If you know name of Chapter, you don't need to use -l --lang parameter.
69
+ # With -l (`tur` or `eng`) always use -s <Chapter number>
70
+ ```
53
71
 
54
- data = Wahy.new_data 'tur' # or data = Wahy.new_data 'eng'
55
- quran = Wahy.chapters_data data
56
- the_opening = Wahy.scripture_data quran, 'the opening' # a nokogiri object
57
- signs = Wahy.sign_data the_opening # an array
58
- sign_one = signs[0] # or sign_one = signs.first # it's array
59
- # OR
60
- sing_two = Wahy.take_specific_sign signs, 1
61
-
62
- # Gem includes two XML data
63
- # English Quran Tranlation(/lib/data/config_en.xml): Written by Yusuf Ali
64
- # Turkish Quran Tranlation(/lib/data/config_tr.xml): Written by Elmalılı Hamdi Yazır
65
- # Special Thanks to: http://www.qurandatabase.org/Database.aspx
72
+ View a specific verse:
73
+
74
+ ```bash
75
+ wahy -l tur -s <chapter_number> -a <verse_number>
76
+
77
+ wahy -s <chapter_mame_or_number> -a <verse_number>
66
78
  ```
67
79
 
68
- ## Development
80
+ Save output to a file:
69
81
 
70
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
82
+ ```bash
83
+ wahy -s <chapter_name_or_number> -a <verse_number> > output.txt
84
+ ```
71
85
 
72
- 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
86
+ ## Library (API) Usage
73
87
 
74
- ## Contributing
88
+ You can require wahy in your own Ruby projects to parse and manipulate Quranic data programmatically:
75
89
 
76
- Bug reports and pull requests are welcome on GitHub at https://github.com/cptangry/wahy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
90
+ ```ruby
91
+ require 'wahy'
77
92
 
78
- ## License
93
+ # 1. Load data for a specific language
94
+ data = Wahy.new_data 'tur'
79
95
 
80
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
96
+ # 2. Extract chapters
97
+ quran = Wahy.chapters_data data
98
+
99
+ # 3. Get a specific chapter node
100
+ the_opening = Wahy.scripture_data quran, 'the opening'
101
+
102
+ # 4. Extract verses as an array of strings
103
+ signs = Wahy.sign_data the_opening
81
104
 
82
- ## Code of Conduct
105
+ # 5. Get a specific sign
106
+ sign_two = Wahy.take_specific_sign signs, 1
107
+ ```
108
+ ## License
83
109
 
84
- Everyone interacting in the Wahy project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/cptangry/wahy/blob/master/CODE_OF_CONDUCT.md).
110
+ This project is licensed under the MIT License.
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
- require "rake/testtask"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "rubocop/rake_task"
3
9
 
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
8
- end
10
+ RuboCop::RakeTask.new
9
11
 
10
- task :default => :test
12
+ task default: %i[test rubocop]
data/bin/wahy CHANGED
@@ -1,5 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "wahy"
3
+ # Bu satır, projenin 'lib' klasörünü LOAD_PATH'e ekler
4
+ # böylece gem'i yerel olarak geliştirirken kodlarınız birbirini görür.
5
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
4
6
 
5
- Wahy.show_wahy
7
+ require 'wahy'
8
+
9
+ # CLI sınıfınızı başlatın
10
+ Wahy::CLI.start(ARGV)
data/exe/wahy CHANGED
@@ -1,5 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "wahy"
4
-
5
- Wahy.show_wahy
data/lib/wahy/cli.rb ADDED
@@ -0,0 +1,89 @@
1
+ require 'optparse'
2
+ require 'colorize'
3
+
4
+ module Wahy
5
+ class CLI
6
+ def self.start(args)
7
+ # Set default options
8
+ options = { lang: 'eng', scripture: '1', ayah: 'all' }
9
+
10
+ opt_parser = OptionParser.new do |opts|
11
+ opts.banner = "Usage: wahy [options]"
12
+
13
+ opts.on("-l", "--lang LANGUAGE", "Language selection ('tur' or 'eng') - Default: eng") do |l|
14
+ options[:lang] = l
15
+ end
16
+
17
+ opts.on("-s", "--scripture SCRIPTURE", "Chapter name or ID (1-114) - Default: 1") do |s|
18
+ options[:scripture] = s
19
+ end
20
+
21
+ opts.on("-a", "--ayah AYAH", "Sign/Verse number or 'all' - Default: all") do |a|
22
+ options[:ayah] = a
23
+ end
24
+
25
+ opts.on("-h", "--help", "Prints this help") do
26
+ puts opts
27
+ exit
28
+ end
29
+ end
30
+
31
+ opt_parser.parse!(args)
32
+
33
+ begin
34
+ # Fetch Data
35
+ doc = Wahy.new_data(options[:lang])
36
+ chapters = Wahy.chapters_data(doc)
37
+ chapter = Wahy.scripture_data(chapters, options[:scripture])
38
+
39
+ if chapter.nil?
40
+ puts "Error: Scripture '#{options[:scripture]}' not found.".colorize(:red)
41
+ exit 1
42
+ end
43
+
44
+ # Header preparation
45
+ chapter_id = chapter['ChapterID']
46
+ chapter_name = chapter['ChapterName']
47
+ title = "#{chapter_id}. #{chapter_name}"
48
+
49
+ # Get terminal width for centering (fallback to 80 if it fails)
50
+ term_width = `tput cols`.to_i rescue 80
51
+ term_width = 80 if term_width == 0
52
+
53
+ # Print centered and colored header
54
+ puts "\n"
55
+ puts title.center(term_width).colorize(:green).bold
56
+ puts ("=" * title.length).center(term_width).colorize(:green)
57
+ puts "\n"
58
+
59
+ signs = Wahy.sign_data(chapter)
60
+
61
+ # Print verses
62
+ if options[:ayah].to_s.downcase == 'all'
63
+ signs.each { |sign| print_sign(sign) }
64
+ else
65
+ sign = Wahy.take_specific_sign(signs, options[:ayah])
66
+ if sign.nil?
67
+ puts "Error: Ayah '#{options[:ayah]}' not found in this scripture.".colorize(:red)
68
+ else
69
+ print_sign(sign)
70
+ end
71
+ end
72
+ puts "\n"
73
+ rescue => e
74
+ puts "An error occurred: #{e.message}".colorize(:red)
75
+ exit 1
76
+ end
77
+ end
78
+
79
+ private
80
+
81
+ # Helper method to print a single verse
82
+ def self.print_sign(sign)
83
+ verse_id = sign['VerseID']
84
+ # CDATA text parsing and whitespace stripping
85
+ text = sign.text.strip
86
+ puts "[#{verse_id}] ".colorize(:cyan).bold + text
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,56 @@
1
+ require "nokogiri"
2
+
3
+ module Wahy
4
+ module Parser
5
+ # Returns the parsed Nokogiri document for the specified language
6
+ # @param lang [String] 'eng' or 'tur'
7
+ def new_data(lang = "eng")
8
+ filename = lang.to_s.downcase == "tur" ? "config_tr.xml" : "config_en.xml"
9
+ filepath = File.join(__dir__, "data", filename)
10
+
11
+ raise "Data file not found: #{filepath}" unless File.exist?(filepath)
12
+
13
+ Nokogiri::XML(File.read(filepath))
14
+ end
15
+
16
+ # Returns the list of Chapter nodes
17
+ # @param doc [Nokogiri::XML::Document]
18
+ def chapters_data(doc)
19
+ doc.xpath("//Chapter")
20
+ end
21
+
22
+ # Finds a specific chapter by ID or Name (case-insensitive)
23
+ # @param chapters [Nokogiri::XML::NodeSet]
24
+ # @param identifier [String, Integer]
25
+ def scripture_data(chapters, identifier)
26
+ # Eğer identifier bir sayı ise direkt ID ile eşleştir
27
+ return chapters.find { |c| c["ChapterID"] == identifier.to_s } if identifier.to_s =~ /^\d+$/
28
+
29
+ # Sayı değilse hem Türkçe hem İngilizce isimle eşleştirmeye çalış
30
+ # Bunun için hem TR hem EN datasına ihtiyacımız olacak
31
+ tr_doc = new_data("tur")
32
+ en_doc = new_data("eng")
33
+
34
+ tr_chapter = tr_doc.xpath("//Chapter").find { |c| c["ChapterName"].downcase == identifier.downcase }
35
+ return chapters_data(tr_doc).find { |c| c["ChapterID"] == tr_chapter["ChapterID"] } if tr_chapter
36
+
37
+ en_chapter = en_doc.xpath("//Chapter").find { |c| c["ChapterName"].downcase == identifier.downcase }
38
+ return chapters_data(en_doc).find { |c| c["ChapterID"] == en_chapter["ChapterID"] } if en_chapter
39
+
40
+ nil
41
+ end
42
+
43
+ # Returns an array of Verse nodes for a given chapter
44
+ # @param chapter [Nokogiri::XML::Node]
45
+ def sign_data(chapter)
46
+ chapter.xpath("Verse").to_a
47
+ end
48
+
49
+ # Returns a specific verse from the signs array
50
+ # @param signs [Array<Nokogiri::XML::Node>]
51
+ # @param verse_number [String, Integer]
52
+ def take_specific_sign(signs, verse_number)
53
+ signs.find { |verse| verse["VerseID"] == verse_number.to_s }
54
+ end
55
+ end
56
+ end
data/lib/wahy/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Wahy
2
- VERSION = "1.3.9"
4
+ VERSION = "2.0.5"
3
5
  end
data/lib/wahy.rb CHANGED
@@ -1,157 +1,11 @@
1
- #!/usr/bin/env ruby
2
- # coding: utf-8
3
1
  require_relative "wahy/version"
4
- require 'nokogiri'
5
- require 'optparse'
6
- require 'colorize'
7
-
2
+ require_relative "wahy/parser"
3
+ require_relative "wahy/cli"
8
4
 
9
5
  module Wahy
10
- class Parser
11
- def self.load_xml
12
- # İşletim sistemine uygun mutlak yolu güvenli şekilde oluşturuyoruz
13
- en_xml_yolu = File.expand_path('data/config_en.xml', __dir__)
14
- tr_xml_yolu = File.expand_path('data/config_tr.xml', __dir__)
15
-
16
- # Dosyaları okuyoruz (Karakter sorunu yaşamamak için UTF-8 belirterek)
17
- en_xml_verisi = File.read(en_xml_yolu, encoding: 'UTF-8')
18
- tr_xml_verisi = File.read(tr_xml_yolu, encoding: 'UTF-8')
19
-
20
- # wahy.rb betiğinde verileri kolayca çağırabilmek için Hash döndürüyoruz
21
- {
22
- en: en_xml_verisi,
23
- tr: tr_xml_verisi
24
- }
25
- end
26
- end
27
- XML_DATA = Wahy::Parser.load_xml
28
- ENGLISH = XML_DATA[:en]
29
- TUR = XML_DATA[:tr]
30
-
31
- SURELER = {
32
- :tur => ["Fatiha", "Bakara", "Ali İmran", "Nisa", "Maide", "Enam", "Araf", "Enfal", "Tevbe", "Yunus", "Hud", "Yusuf", "Rad", "İbrahim", "Hicr", "Nahl", "Isra", "Kehf", "Meryem", "Taha", "Enbiya", "Hac", "Muminun", "Nur", "Furkan", "Suara", "Neml", "Kasas", "Ankebut", "Rum", "Lukman", "Secde", "Ahzab", "Sebe", "Fatir", "Yasin", "Saffat", "Sad", "Zümer", "Mumin", "Fussilet", "Sura", "Zuhruf", "Duhan", "Casiye", "Ahkaf", "Muhammed", "Fetih", "Hucurat", "Kaf", "Zariyat", "Tur", "Necm", "Kamer", "Rahman", "Vakia", "Hadid", "Mücadele", "Hasr", "Mümtahine", "Saf", "Cuma", "Münafikun", "Tegabun", "Talak", "Tahrim", "Mülk", "Kalem", "Hakka", "Mearic", "Nuh", "Cin", "Müzzemmil", "Müddessir", "Kıyamet", "İnsan", "Murselat", "Nebe", "Naziat", "Abese", "Tekvir", "İnfitar", "Mutaffifin", "İnsikak", "Buruc", "Tarik", "Ala", "Gasiye", "Fecr", "Beled", "Şems", "Leyl", "Duha", "İnşirah", "Tin", "Alak", "Kadir", "Beyyine", "Zilzal", "Adiyat", "Karia", "Tekasür", "Asr", "Hümeze", "Fil", "Kureyş", "Maun", "Kevser", "Kafirun", "Nasr", "Leheb", "İhlas", "Felak", "Nas"],
33
- :eng => ["The Opening", "The Cow", "The Family Of Imran", "Women", "The Food", "The Cattle", "The Elevated Place", "The Spoils Of War", "Repentance", "Yunus", "Hud", "Yusuf", "The Thunder", "Ibrahim", "The Rock", "The Bee", "The Israelites", "The Cave", "Marium", "Ta Ha", "The Prophets", "The Pilgrimage", "The Believers", "The Light", "The Criterion", "The Poets", "The Ant", "The Narrative", "The Spider", "The Romans", "Luqman", "The Adoration", "The Allies", "Saba", "The Originator", "Ya Seen", "The Rangers", "Suad", "The Companies", "The Believer", "Ha Mim", "The Counsel", "The Embellishment", "The Evident Smoke", "The Kneeling", "The Sandhills", "Muhammad", "The Victory", "The Chambers", "Qaf", "The Scatterers", "The Mountain", "The Star", "The Moon", "The Beneficient", "The Great Event", "The Iron", "The Pleading One", "The Banishment", "The Examined One", "The Ranks", "Friday", "The Hypocrites", "Loss And Gain", "The Divorce", "The Prohibition", "The Kingdom", "The Pen", "The Sure Calamity", "The Ways Of Ascent", "Nuh", "The Jinn", "The Wrapped Up", "The Clothe Done", "The Resurrection", "The Man", "The Emissaries", "The Great Event", "Those Who Pull Out", "He Frowned", "The Covering Up", "The Cleaving Asund", "The Defrauders", "The Bursting Asund", "The Mansions Of The Stars", "The Night-Comer", "The Most High", "The Overwhelming", "The Daybreak", "The City", "The Sun", "The Night", "The Early Hours", "The Expansion", "The Fig", "The Clot", "The Majesty", "The Clear Evidence", "The Shaking", "The Assaulters", "The Terrible Calam", "The Multiplicatio", "Time", "The Slanderer", "The Elephant", "The Qureaish", "The Daily Necessar", "The Heavenly Fount", "The Unbelievers", "The Help", "The Flame", "The Unity", "The Dawn", "The Men"]
34
- }
35
-
36
- module Opt_PARSER
37
-
38
-
39
-
40
- def self.opsiyonlar opts
41
- options = {}
42
- parser = OptionParser.new do |o|
43
- o.banner = "Usage: wahy [options]"
44
-
45
-
46
- o.on("-lLANG", "--lang=LANGUAGE", "Which language that you want to read signs?") do |l|
47
- options[:lang] = l
48
- end
49
-
50
- o.on("-sSCRIPTURE", "--scripture=SCRIPTURE", "Scripture name or number") do |s|
51
- if s =~ /[[:digit:]]/
52
- options[:scripture] = s.to_i - 1
53
- elsif s == 'all'
54
- options[:scripture] = s
55
- else
56
- scr = s.include?(" ") ? s.split(" ").map {|i| i = i.capitalize}.join(" ") : s.capitalize
57
- SURELER.values.each do |v|
58
- options[:scripture] = v.index(scr) if v.include? scr
59
- end
60
- end
61
- end
62
-
63
- o.on("-asign", "--ayah=SIGN", "Sign number") do |a|
64
- a = a.to_i - 1 unless a == 'all'
65
- options[:sign] = a
66
- end
67
-
68
- o.on("-h", "--help", "Prints this help") do
69
- puts o
70
- exit
71
- end
72
- end
73
-
74
- parser.parse!(opts)
75
- options
76
- end
77
- end
78
-
79
- args = ARGV
80
-
81
- OPTIONS = Opt_PARSER.opsiyonlar args
82
- LANG = OPTIONS[:lang]
83
- SCRIPTURE = OPTIONS[:scripture] || 0
84
- SIGN = OPTIONS[:sign] || 'all'
85
-
86
- Doc = Nokogiri::XML(LANG == 'tur' ? TUR : ENGLISH) do |config|
87
- config.strict.noblanks
88
- end
89
-
90
- Elements = Doc.xpath("//*[@ChapterName]")
91
-
92
- def self.show_wahy
93
- var = Elements[SCRIPTURE]
94
- puts var.attr('ChapterName').upcase.center(40, "*")
95
-
96
- if SIGN == 'all'
97
- var.css('Verse').each_with_index do |v, i|
98
- print "[#{i + 1}]: ".red, "#{v.text}".green, "\n"
99
- end
100
- else
101
- print "[#{SIGN + 1}]: ".red, "#{var.css('Verse')[SIGN].text}".green, "\n"
102
- end
103
- end
104
-
105
- def self.new_data lang
106
- if lang == 'tur'
107
- doc = Nokogiri::XML(TUR)
108
- elsif lang == 'eng'
109
- doc = Nokogiri::XML(ENGLISH)
110
- else
111
- print 'Please, select a correct option ("tur" or "eng"): '
112
- selection = gets.chomp
113
- new_data selection
114
- end
115
- doc
116
- end
117
-
118
- def self.chapters_data parsed_xml_data
119
- elements = parsed_xml_data.xpath("//*[@ChapterName]")
120
- elements
121
- end
122
-
123
- def self.scripture_data parsed_chapter_data, scripture_name
124
- s_data = nil
125
- if scripture_name =~ /[[:digit:]]/
126
- s_data = parsed_chapter_data[scripture_name]
127
- else
128
- sc = scripture_name.include?(" ") ? scripture_name.split(" ").map {|i| i = i.capitalize}.join(" ") : scripture_name.capitalize
129
- SURELER.values.each do |v|
130
- s_data = v.index(sc) if v.include? sc
131
- end
132
- end
133
- scripture = parsed_chapter_data[(s_data || 0)]
134
- scripture
135
- end
136
-
137
- def self.sign_data scripture_data
138
- sign = []
139
- scripture_data.css('Verse').each do |v|
140
- sign << v.text
141
- end
142
- sign
143
- end
144
-
145
- def self.sign_data_object scripture_data
146
- scripture_data.css('Verse')
147
- end
148
-
149
- def self.take_specific_sign sign_data, sign_number
150
- sign = sign_data[sign_number]
151
- sign
152
- end
6
+ class Error < StandardError; end
153
7
 
154
- def self.specific_sign_object scripture_data, sign_number
155
- sign = scripture_data.css('Verse')[sign_number]
156
- end
8
+ # Extend the parser methods so they can be called directly on Wahy module
9
+ # e.g. Wahy.new_data('eng')
10
+ extend Parser
157
11
  end
data/sig/wahy.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Wahy
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
data/wahy.gemspec CHANGED
@@ -1,45 +1,46 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "./lib/wahy/version.rb"
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/wahy/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "wahy"
8
- spec.version = Wahy::VERSION
9
- spec.authors = ["Gökhan Çağlar"]
10
- spec.email = ["caglar.gokhan@gmail.com"]
6
+ spec.name = "wahy"
7
+ spec.version = Wahy::VERSION
8
+ spec.authors = ["cptangry"]
9
+ spec.email = ["caglar.gokhan@gmail.com"]
11
10
 
12
- spec.summary = %q{You can read Quran's scriptures or signs from terminal. Executable path issues fixed. It can run as a
13
- terminal command. Default Lang is English now. Also you can require
14
- it and take Quran data with helpfull and easy to use methods.}
15
- spec.description = %q{You can read Quran's scriptures or signs from terminal. Executable path issues fixed. It can run as a
16
- terminal command. Default Lang is English now. Also you can require
17
- it and take Quran data with helpfull and easy to use methods.}
11
+ spec.summary = "A CLI tool and library to query the Holy Quran in TR/ENG."
12
+ spec.description = "Query and read the Holy Quran chapters and verses in the terminal with colored output. Includes both English and Turkish support."
18
13
  spec.homepage = "https://github.com/cptangry/wahy"
19
- spec.license = "MIT"
20
- spec.executables << "wahy"
21
-
22
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
23
- # to allow pushing to a single host or delete this section to allow pushing to any host.
24
- if spec.respond_to?(:metadata)
25
- spec.metadata["allowed_push_host"] = "https://rubygems.org/"
26
- else
27
- raise "RubyGems 2.0 or newer is required to protect against " \
28
- "public gem pushes."
29
- end
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 4.0.2"
16
+ # Uncomment the line below to require MFA for gem pushes.
17
+ # This helps protect your gem from supply chain attacks by ensuring
18
+ # no one can publish a new version without multi-factor authentication.
19
+ # See: https://guides.rubygems.org/mfa-requirement-opt-in/
20
+ # spec.metadata["rubygems_mfa_required"] = "true"
30
21
 
31
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
32
- f.match(%r{^(test|spec|features)/})
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ gemspec = File.basename(__FILE__)
25
+ spec.files = Dir.chdir(__dir__) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (File.expand_path(f) == __FILE__) ||
28
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
29
+ end
33
30
  end
34
- spec.bindir = "bin"
35
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.bindir = "bin"
32
+ spec.executables = ["wahy"]
36
33
  spec.require_paths = ["lib"]
37
34
 
38
35
  spec.add_development_dependency "bundler", "~> 4.0.12"
39
36
  spec.add_development_dependency 'rake', '~> 13.4'
40
37
  spec.add_development_dependency "minitest", "~> 5.0"
41
- spec.add_development_dependency 'nokogiri', '~> 1.8'
42
- spec.add_development_dependency 'colorize', '~> 0.8.1'
43
38
  spec.add_runtime_dependency 'nokogiri', '~> 1.8'
44
39
  spec.add_runtime_dependency 'colorize', '~> 0.8.1'
40
+
41
+ # Uncomment to register a new dependency of your gem
42
+ # spec.add_dependency "example-gem", "~> 1.0"
43
+
44
+ # For more information and examples about making a new gem, check out our
45
+ # guide at: https://guides.rubygems.org/make-your-own-gem/
45
46
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wahy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.9
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
- - Gökhan Çağlar
7
+ - cptangry
8
8
  bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
@@ -51,34 +51,6 @@ dependencies:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '5.0'
54
- - !ruby/object:Gem::Dependency
55
- name: nokogiri
56
- requirement: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '1.8'
61
- type: :development
62
- prerelease: false
63
- version_requirements: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '1.8'
68
- - !ruby/object:Gem::Dependency
69
- name: colorize
70
- requirement: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: 0.8.1
75
- type: :development
76
- prerelease: false
77
- version_requirements: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: 0.8.1
82
54
  - !ruby/object:Gem::Dependency
83
55
  name: nokogiri
84
56
  requirement: !ruby/object:Gem::Requirement
@@ -107,10 +79,8 @@ dependencies:
107
79
  - - "~>"
108
80
  - !ruby/object:Gem::Version
109
81
  version: 0.8.1
110
- description: |-
111
- You can read Quran's scriptures or signs from terminal. Executable path issues fixed. It can run as a
112
- terminal command. Default Lang is English now. Also you can require
113
- it and take Quran data with helpfull and easy to use methods.
82
+ description: Query and read the Holy Quran chapters and verses in the terminal with
83
+ colored output. Includes both English and Turkish support.
114
84
  email:
115
85
  - caglar.gokhan@gmail.com
116
86
  executables:
@@ -118,31 +88,26 @@ executables:
118
88
  extensions: []
119
89
  extra_rdoc_files: []
120
90
  files:
121
- - ".gitignore"
122
- - ".rbenv-gemsets"
123
- - ".ruby-version"
124
- - ".travis.yml"
91
+ - ".rubocop.yml"
92
+ - CHANGELOG.md
125
93
  - CODE_OF_CONDUCT.md
126
- - Gemfile
127
94
  - LICENSE.txt
128
95
  - README.md
129
96
  - Rakefile
130
- - SECURITY.md
131
- - Screenshot_2017-08-17_16-23-15.png
132
- - bin/console
133
- - bin/setup
134
97
  - bin/wahy
135
98
  - exe/wahy
136
- - lib/data/config_en.xml
137
- - lib/data/config_tr.xml
138
99
  - lib/wahy.rb
100
+ - lib/wahy/cli.rb
101
+ - lib/wahy/data/config_en.xml
102
+ - lib/wahy/data/config_tr.xml
103
+ - lib/wahy/parser.rb
139
104
  - lib/wahy/version.rb
105
+ - sig/wahy.rbs
140
106
  - wahy.gemspec
141
107
  homepage: https://github.com/cptangry/wahy
142
108
  licenses:
143
109
  - MIT
144
- metadata:
145
- allowed_push_host: https://rubygems.org/
110
+ metadata: {}
146
111
  rdoc_options: []
147
112
  require_paths:
148
113
  - lib
@@ -150,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
150
115
  requirements:
151
116
  - - ">="
152
117
  - !ruby/object:Gem::Version
153
- version: '0'
118
+ version: 4.0.2
154
119
  required_rubygems_version: !ruby/object:Gem::Requirement
155
120
  requirements:
156
121
  - - ">="
@@ -159,7 +124,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
124
  requirements: []
160
125
  rubygems_version: 4.0.6
161
126
  specification_version: 4
162
- summary: You can read Quran's scriptures or signs from terminal. Executable path issues
163
- fixed. It can run as a terminal command. Default Lang is English now. Also you can
164
- require it and take Quran data with helpfull and easy to use methods.
127
+ summary: A CLI tool and library to query the Holy Quran in TR/ENG.
165
128
  test_files: []
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
data/.rbenv-gemsets DELETED
@@ -1 +0,0 @@
1
- wahy
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 4.0.2
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rbenv:
4
- - 4.0.2
5
- before_install: gem install bundler
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in wahy.gemspec
6
- gemspec
data/SECURITY.md DELETED
@@ -1,21 +0,0 @@
1
- # Security Policy
2
-
3
- ## Supported Versions
4
-
5
- Use this section to tell people about which versions of your project are
6
- currently being supported with security updates.
7
-
8
- | Version | Supported |
9
- | ------- | ------------------ |
10
- | 5.1.x | :white_check_mark: |
11
- | 5.0.x | :x: |
12
- | 4.0.x | :white_check_mark: |
13
- | < 4.0 | :x: |
14
-
15
- ## Reporting a Vulnerability
16
-
17
- Use this section to tell people how to report a vulnerability.
18
-
19
- Tell them where to go, how often they can expect to get an update on a
20
- reported vulnerability, what to expect if the vulnerability is accepted or
21
- declined, etc.
Binary file
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "wahy"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
File without changes
File without changes