wahy 1.3.8 → 2.0.4
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 +4 -4
- data/.rubocop.yml +8 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +7 -71
- data/LICENSE.txt +1 -1
- data/README.md +72 -47
- data/Rakefile +9 -7
- data/bin/wahy +7 -2
- data/exe/wahy +0 -2
- data/lib/wahy/cli.rb +89 -0
- data/lib/wahy/parser.rb +56 -0
- data/lib/wahy/version.rb +3 -1
- data/lib/wahy.rb +6 -152
- data/sig/wahy.rbs +4 -0
- data/wahy.gemspec +34 -33
- metadata +17 -53
- data/.gitignore +0 -9
- data/.rbenv-gemsets +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -5
- data/Gemfile +0 -6
- data/Screenshot_2017-08-17_16-23-15.png +0 -0
- data/bin/console +0 -14
- data/bin/setup +0 -8
- /data/lib/{data → wahy/data}/config_en.xml +0 -0
- /data/lib/{data → wahy/data}/config_tr.xml +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d8992df63d738bc270dcef57c353356f80792df9c04da329e0fe9bb678f819b7
|
|
4
|
+
data.tar.gz: d0c95b7f8fa2183d3d8fa46de749934d3f856f9311302296817c2b7efdb3475b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f305f0f9dae0d31b680b570541d4e8362953206d9683875e0c6dfbbaeab6d360bd79e046de03d14e0a5bc90094cb01f48e5d6e5506d39530c24b77581ce9ba41
|
|
7
|
+
data.tar.gz: e607ee3f7b4ac2d97e08d41e061f418879b977b89282b737e52597ce6c5b71abce84e0f7394d5c97fb13d90cee68245176d47d9415fceac94050c54e86f5a4c3
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
CHANGED
|
@@ -1,74 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Code of Conduct
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
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
data/README.md
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
# Wahy
|
|
2
2
|
|
|
3
|
-
|
|
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,71 +27,81 @@ gem 'wahy'
|
|
|
12
27
|
|
|
13
28
|
And then execute:
|
|
14
29
|
|
|
15
|
-
|
|
30
|
+
```bash
|
|
31
|
+
bundle install
|
|
32
|
+
```
|
|
16
33
|
|
|
17
34
|
Or install it yourself as:
|
|
18
35
|
|
|
19
|
-
|
|
36
|
+
```bash
|
|
37
|
+
gem install wahy
|
|
38
|
+
```
|
|
20
39
|
|
|
21
|
-
|
|
40
|
+
Or install it directly via terminal:
|
|
22
41
|
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
wahy -h
|
|
42
|
+
```bash
|
|
43
|
+
gem install wahy
|
|
44
|
+
```
|
|
27
45
|
|
|
28
|
-
|
|
29
|
-
# If you want to see English results you don't need to call -l argument (English is default)
|
|
30
|
-
# -l => to pick language ('eng'|'tur') # Default: (English)
|
|
31
|
-
# -s => to pick scripture (also can use scripture's number) # between 1-114 # Default: 1
|
|
32
|
-
# -a => to pick sign number (also can use all) # Default: all
|
|
46
|
+
## CLI Usage
|
|
33
47
|
|
|
34
|
-
|
|
48
|
+
You can use the wahy command directly in your terminal. By default, it displays the 1st chapter in English.
|
|
35
49
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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 | - |
|
|
39
56
|
|
|
40
|
-
|
|
41
|
-
wahy -l 'eng' -s 'The Cow' -a 2
|
|
42
|
-
wahy -l 'tur' -s 'The Cow' -a 2
|
|
57
|
+
Examples
|
|
43
58
|
|
|
44
|
-
|
|
45
|
-
wahy -l 'eng' -s 'The Cow' > fileName.txt # :)
|
|
59
|
+
View the entire chapter in English:
|
|
46
60
|
|
|
47
|
-
|
|
61
|
+
```bash
|
|
62
|
+
wahy
|
|
63
|
+
```
|
|
48
64
|
|
|
49
|
-
|
|
50
|
-
require 'wahy'
|
|
65
|
+
View a specific chapter in Turkish:
|
|
51
66
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
# Gem includes two XML data
|
|
61
|
-
# English Quran Tranlation(/lib/data/config_en.xml): Written by Yusuf Ali
|
|
62
|
-
# Turkish Quran Tranlation(/lib/data/config_tr.xml): Written by Elmalılı Hamdi Yazır
|
|
63
|
-
# Special Thanks to: http://www.qurandatabase.org/Database.aspx
|
|
67
|
+
```bash
|
|
68
|
+
wahy -l tur -s <chapter_name_or_number>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
View a specific verse:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
wahy -l tur -s <chapter_name_or_number> -a <verse_number>
|
|
64
75
|
```
|
|
65
76
|
|
|
66
|
-
|
|
77
|
+
Save output to a file:
|
|
67
78
|
|
|
68
|
-
|
|
79
|
+
```bash
|
|
80
|
+
wahy -l tur -s <chapter_name_or_number> -a <verse_number> > output.txt
|
|
81
|
+
```
|
|
69
82
|
|
|
70
|
-
|
|
83
|
+
## Library (API) Usage
|
|
71
84
|
|
|
72
|
-
|
|
85
|
+
You can require wahy in your own Ruby projects to parse and manipulate Quranic data programmatically:
|
|
73
86
|
|
|
74
|
-
|
|
87
|
+
```ruby
|
|
88
|
+
require 'wahy'
|
|
75
89
|
|
|
76
|
-
|
|
90
|
+
# 1. Load data for a specific language
|
|
91
|
+
data = Wahy.new_data 'tur'
|
|
77
92
|
|
|
78
|
-
|
|
93
|
+
# 2. Extract chapters
|
|
94
|
+
quran = Wahy.chapters_data data
|
|
95
|
+
|
|
96
|
+
# 3. Get a specific chapter node
|
|
97
|
+
the_opening = Wahy.scripture_data quran, 'the opening'
|
|
98
|
+
|
|
99
|
+
# 4. Extract verses as an array of strings
|
|
100
|
+
signs = Wahy.sign_data the_opening
|
|
79
101
|
|
|
80
|
-
|
|
102
|
+
# 5. Get a specific sign
|
|
103
|
+
sign_two = Wahy.take_specific_sign signs, 1
|
|
104
|
+
```
|
|
105
|
+
## License
|
|
81
106
|
|
|
82
|
-
|
|
107
|
+
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 "
|
|
4
|
+
require "minitest/test_task"
|
|
5
|
+
|
|
6
|
+
Minitest::TestTask.create
|
|
7
|
+
|
|
8
|
+
require "rubocop/rake_task"
|
|
3
9
|
|
|
4
|
-
|
|
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 :
|
|
12
|
+
task default: %i[test rubocop]
|
data/bin/wahy
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
7
|
+
require 'wahy'
|
|
8
|
+
|
|
9
|
+
# CLI sınıfınızı başlatın
|
|
10
|
+
Wahy::CLI.start(ARGV)
|
data/exe/wahy
CHANGED
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
|
data/lib/wahy/parser.rb
ADDED
|
@@ -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
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
|
-
|
|
5
|
-
|
|
6
|
-
require 'colorize'
|
|
7
|
-
|
|
2
|
+
require_relative "wahy/parser"
|
|
3
|
+
require_relative "wahy/cli"
|
|
8
4
|
|
|
9
5
|
module Wahy
|
|
10
|
-
|
|
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
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
data/wahy.gemspec
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
|
-
#
|
|
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
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
spec.name = "wahy"
|
|
8
|
-
spec.version = Wahy::VERSION
|
|
9
|
-
spec.authors = ["Gökhan Çağlar"]
|
|
10
|
-
spec.email = ["caglar.gokhan@gmail.com"]
|
|
3
|
+
require_relative "lib/wahy/version"
|
|
11
4
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
spec.
|
|
16
|
-
|
|
17
|
-
it and take Quran data with helpfull and easy to use methods.}
|
|
18
|
-
spec.homepage = "https://github.com/cptangry/wahy"
|
|
19
|
-
spec.license = "MIT"
|
|
20
|
-
spec.executables << "wahy"
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "wahy"
|
|
7
|
+
spec.version = Wahy::VERSION
|
|
8
|
+
spec.authors = ["cptangry"]
|
|
9
|
+
spec.email = ["caglar.gokhan@gmail.com"]
|
|
21
10
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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."
|
|
13
|
+
spec.homepage = "https://github.com/username/wahy"
|
|
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
|
-
|
|
32
|
-
|
|
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
|
|
35
|
-
spec.executables
|
|
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
|
-
spec.add_development_dependency
|
|
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:
|
|
4
|
+
version: 2.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
7
|
+
- cptangry
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
@@ -29,14 +29,14 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '13.4'
|
|
33
33
|
type: :development
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '
|
|
39
|
+
version: '13.4'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: minitest
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -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
|
-
|
|
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,30 +88,26 @@ executables:
|
|
|
118
88
|
extensions: []
|
|
119
89
|
extra_rdoc_files: []
|
|
120
90
|
files:
|
|
121
|
-
- ".
|
|
122
|
-
-
|
|
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
|
-
- Screenshot_2017-08-17_16-23-15.png
|
|
131
|
-
- bin/console
|
|
132
|
-
- bin/setup
|
|
133
97
|
- bin/wahy
|
|
134
98
|
- exe/wahy
|
|
135
|
-
- lib/data/config_en.xml
|
|
136
|
-
- lib/data/config_tr.xml
|
|
137
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
|
|
138
104
|
- lib/wahy/version.rb
|
|
105
|
+
- sig/wahy.rbs
|
|
139
106
|
- wahy.gemspec
|
|
140
|
-
homepage: https://github.com/
|
|
107
|
+
homepage: https://github.com/username/wahy
|
|
141
108
|
licenses:
|
|
142
109
|
- MIT
|
|
143
|
-
metadata:
|
|
144
|
-
allowed_push_host: https://rubygems.org/
|
|
110
|
+
metadata: {}
|
|
145
111
|
rdoc_options: []
|
|
146
112
|
require_paths:
|
|
147
113
|
- lib
|
|
@@ -149,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
149
115
|
requirements:
|
|
150
116
|
- - ">="
|
|
151
117
|
- !ruby/object:Gem::Version
|
|
152
|
-
version:
|
|
118
|
+
version: 4.0.2
|
|
153
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
120
|
requirements:
|
|
155
121
|
- - ">="
|
|
@@ -158,7 +124,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
158
124
|
requirements: []
|
|
159
125
|
rubygems_version: 4.0.6
|
|
160
126
|
specification_version: 4
|
|
161
|
-
summary:
|
|
162
|
-
fixed. It can run as a terminal command. Default Lang is English now. Also you can
|
|
163
|
-
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.
|
|
164
128
|
test_files: []
|
data/.gitignore
DELETED
data/.rbenv-gemsets
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
wahy
|
data/.ruby-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4.0.2
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
|
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
|
File without changes
|
|
File without changes
|