conjugate_french 0.1.3 → 0.1.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/:courir +2 -0
- data/Gemfile.lock +1 -1
- data/bin/conjugate_french +4 -3
- data/courir +2 -0
- data/lib/conjugate/tense.rb +63 -0
- data/lib/conjugate_french.rb +4 -54
- data/lib/conjugate_french/version.rb +1 -1
- metadata +5 -3
- data/conjugate_french-0.1.2.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7a75418e3191ca82ce1e4aa723e0d23b44d69934a7059ec4f3ec66a029b8786
|
4
|
+
data.tar.gz: 5c65f09fd4a7e504e76b211adb15836d368f1801e960a9f196bd648a1b7ff090
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 832b04e130dc3f9db126dc28bf55f838f8ac29f9a27095e5c8b2bebf8f69688c7177e2b67699aca27b3942c1521bacc39e7a72b2f41667a6c1659893ac3a6522
|
7
|
+
data.tar.gz: beabba716afb2ad5600482dccb98adaa865488e5378309423707e410f4a29902fd3361c30b0d437ee944b60e25f99bc301268e748b167a39f8977156691052fa
|
data/:courir
ADDED
data/Gemfile.lock
CHANGED
data/bin/conjugate_french
CHANGED
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'conjugate_french'
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
case ARGV.size
|
6
|
+
when 1
|
7
|
+
raise ArgumentError, 'please add a correct verb after the conjugate method call'
|
7
8
|
else
|
8
|
-
ConjugateFrench::ConjugateCLI.start(ARGV)
|
9
|
+
puts ConjugateFrench::ConjugateCLI.start(ARGV)
|
9
10
|
end
|
data/courir
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'terminal-table'
|
3
|
+
|
4
|
+
module ConjugateFrench
|
5
|
+
class Tense
|
6
|
+
TENSES = %w[indicatif subjonctif conditionnel impératif participe].freeze
|
7
|
+
VERB_ERROR = "The verb you've entered can not be conjugated".freeze
|
8
|
+
TENSE_ERROR = "The verb can not be conjugated at the tense you've entered".freeze
|
9
|
+
|
10
|
+
def self.conjugate(verb, tense)
|
11
|
+
build_tables(get_verbe(verb), tense)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.build_tables(full_verb, specific_tense)
|
15
|
+
raise ArgumentError, VERB_ERROR if full_verb.nil?
|
16
|
+
|
17
|
+
if specific_tense.nil?
|
18
|
+
TENSES.map { |tense| table(tense, full_verb) }
|
19
|
+
else
|
20
|
+
table(specific_tense, full_verb)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.get_verbe(verb)
|
25
|
+
file = File.read('lib/verbs.json')
|
26
|
+
parsed_file = JSON.parse(file)
|
27
|
+
@get_verbe ||= parsed_file.select do |verb_list|
|
28
|
+
verb_list['infinitif']['présent'][0] == verb
|
29
|
+
end[0]
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.headings(tense, full_verb)
|
33
|
+
raise ArgumentError, TENSE_ERROR unless TENSES.include?(tense)
|
34
|
+
|
35
|
+
[nil, full_verb[tense].keys]
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.table(tense, full_verb)
|
39
|
+
tense_rows = persons(tense)
|
40
|
+
verb = full_verb['infinitif']['présent'].first
|
41
|
+
|
42
|
+
tense_rows.each_with_index do |person, index|
|
43
|
+
full_verb[tense].each { |row| person << row[1][index] }
|
44
|
+
end
|
45
|
+
|
46
|
+
tense = Terminal::Table.new(
|
47
|
+
title: "Verbe #{verb.capitalize} #{tense.capitalize}",
|
48
|
+
rows: tense_rows,
|
49
|
+
headings: headings(tense, full_verb).flatten
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.persons(tense)
|
54
|
+
if tense == 'impératif'
|
55
|
+
[[nil], [nil], [nil]]
|
56
|
+
elsif tense == 'participe'
|
57
|
+
[[nil], [nil]]
|
58
|
+
else
|
59
|
+
[['Je'], ['Tu'], ['Il'], ['Nous'], ['Vous'], ['Ils']]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/conjugate_french.rb
CHANGED
@@ -1,64 +1,14 @@
|
|
1
1
|
require 'conjugate_french/version'
|
2
2
|
require 'thor'
|
3
|
-
|
4
|
-
require 'terminal-table'
|
3
|
+
require_relative './conjugate/tense'
|
5
4
|
|
6
5
|
module ConjugateFrench
|
7
6
|
class ConjugateCLI < Thor
|
8
7
|
desc 'verbe VERB', 'finally know how to write french VERBS'
|
9
|
-
|
8
|
+
argument :opts, optional: true, type: :hash
|
10
9
|
|
11
|
-
def
|
12
|
-
|
13
|
-
parsed_file = JSON.parse(file)
|
14
|
-
|
15
|
-
full_verb = parsed_file.select do |verb_list|
|
16
|
-
verb_list['infinitif']['présent'][0] == verb
|
17
|
-
end
|
18
|
-
|
19
|
-
final_output = output(full_verb, verb)
|
20
|
-
puts final_output
|
21
|
-
final_output
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def table(tense, full_verb, verb)
|
27
|
-
tense_rows = persons(tense)
|
28
|
-
|
29
|
-
tense_headings = headings(tense, full_verb)
|
30
|
-
|
31
|
-
tense_rows.each_with_index do |person, index|
|
32
|
-
full_verb[0][tense].each { |row| person << row[1][index] }
|
33
|
-
end
|
34
|
-
|
35
|
-
tense = Terminal::Table.new(
|
36
|
-
title: "Verbe #{verb.capitalize} #{tense.capitalize}",
|
37
|
-
rows: tense_rows,
|
38
|
-
headings: tense_headings.flatten
|
39
|
-
)
|
40
|
-
end
|
41
|
-
|
42
|
-
def persons(tense)
|
43
|
-
if tense == 'impératif'
|
44
|
-
[[nil], [nil], [nil]]
|
45
|
-
elsif tense == 'participe'
|
46
|
-
[[nil], [nil]]
|
47
|
-
else
|
48
|
-
[['Je'], ['Tu'], ['Il'], ['Nous'], ['Vous'], ['Ils']]
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def headings(tense, full_verb)
|
53
|
-
[nil, full_verb[0][tense].keys]
|
54
|
-
end
|
55
|
-
|
56
|
-
def output(full_verb, verb)
|
57
|
-
if full_verb.empty?
|
58
|
-
'The verb you entered was not found. There is probably a typo or the verb is not in the infinitive.'
|
59
|
-
else
|
60
|
-
TENSES.map { |tense| table(tense, full_verb, verb) }
|
61
|
-
end
|
10
|
+
def conjugate
|
11
|
+
ConjugateFrench::Tense.conjugate(opts['verb'], opts['tense'])
|
62
12
|
end
|
63
13
|
end
|
64
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conjugate_french
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martfed
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- ".gitignore"
|
80
80
|
- ".rspec"
|
81
81
|
- ".travis.yml"
|
82
|
+
- ":courir"
|
82
83
|
- Gemfile
|
83
84
|
- Gemfile.lock
|
84
85
|
- LICENSE
|
@@ -88,8 +89,9 @@ files:
|
|
88
89
|
- bin/conjugate_french
|
89
90
|
- bin/console
|
90
91
|
- bin/setup
|
91
|
-
- conjugate_french-0.1.2.gem
|
92
92
|
- conjugate_french.gemspec
|
93
|
+
- courir
|
94
|
+
- lib/conjugate/tense.rb
|
93
95
|
- lib/conjugate_french.rb
|
94
96
|
- lib/conjugate_french/version.rb
|
95
97
|
- lib/verbs.json
|
data/conjugate_french-0.1.2.gem
DELETED
Binary file
|