Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Ruby
on:
push:
branches:
- master
- main

pull_request:

Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.6
TargetRubyVersion: 2.7

Style/StringLiterals:
Enabled: true
Expand Down
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,23 @@

- **Ruby Version Update**:
- Adjusted the required Ruby version to address a `rubocop` PR conflict issue.
- Standardized capitalization in the `license.txt` file.
- Standardized capitalization in the `license.txt` file.

## [1.0.1] - 2026-02-12
### Added
- **New `Faussaire::So.mething` Method**:
- Generates a random ...
- Example: `Faussaire::So.mething` => `"Wiser"`

### Enhancements
- **W...**:
- A...
- S..

- **W...**:
- A...
- S..

- **W...**:
- A...
- S..
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ If you’ve got something cool to add, don’t be shy! Well-documented pull requ
> </a>
> <br>
> <a href="#Français" style="text-decoration:none;">
> Évidemment, vous pouvez aussi me lire en français. On est là pour ça, non ?
> Lisez-moi en français.
> </a>
> </p>

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ gem "rake", "~> 13.0"

gem "rspec", "~> 3.0"

gem "rubocop", "~> 1.21"
gem "rubocop", "~> 1.21"
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
faussaire (0.1.6)
faussaire (1.0.2)

GEM
remote: https://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require "rubocop/rake_task"

# Define the RSpec task for running tests
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'spec/**/*_spec.rb'
t.pattern = "spec/**/*_spec.rb"
end

RuboCop::RakeTask.new
Expand Down
23 changes: 11 additions & 12 deletions lib/faussaire.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
require_relative "faussaire/version"
require_relative "faussaire/base"
require_relative "faussaire/name"
require_relative 'faussaire/address'
require_relative 'faussaire/ancien'
require_relative 'faussaire/bizness'
require_relative 'faussaire/tv'
require_relative 'faussaire/wine'
require_relative 'faussaire/creamerie'
require_relative 'faussaire/gardinerie'
require_relative 'faussaire/citation'
require_relative 'faussaire/cosmos'
require_relative 'faussaire/music'
require_relative 'faussaire/piraterie'

require_relative "faussaire/address"
require_relative "faussaire/ancien"
require_relative "faussaire/bizness"
require_relative "faussaire/tv"
require_relative "faussaire/wine"
require_relative "faussaire/creamerie"
require_relative "faussaire/gardinerie"
require_relative "faussaire/citation"
require_relative "faussaire/cosmos"
require_relative "faussaire/music"
require_relative "faussaire/piraterie"

module Faussaire
class Error < StandardError; end
Expand Down
36 changes: 19 additions & 17 deletions lib/faussaire/address.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
require 'yaml'
# frozen_string_literal: true

require "yaml"

module Faussaire
class Address
DATA_PATH = File.expand_path('../../locale/fr.yml', __dir__)
DATA_PATH = File.expand_path("../../locale/fr.yml", __dir__)

class << self
def initialize_data
Expand All @@ -18,7 +20,7 @@ def initialize_data
# Faussaire::Address.city #=> "Paris"
#
def city
fetch('fr.faussaire.address.city')
fetch("fr.faussaire.address.city")
end

##
Expand All @@ -30,7 +32,7 @@ def city
# Faussaire::Address.street_number_99 #=> "42"
#
def street_number_99
fetch('fr.faussaire.address.street_number_99')
fetch("fr.faussaire.address.street_number_99")
end

##
Expand All @@ -42,7 +44,7 @@ def street_number_99
# Faussaire::Address.street_number_999 #=> "123"
#
def street_number_999
fetch('fr.faussaire.address.street_number_999')
fetch("fr.faussaire.address.street_number_999")
end

##
Expand All @@ -54,7 +56,7 @@ def street_number_999
# Faussaire::Address.street_number_9999 #=> "1234"
#
def street_number_9999
fetch('fr.faussaire.address.street_number_9999')
fetch("fr.faussaire.address.street_number_9999")
end

##
Expand All @@ -66,7 +68,7 @@ def street_number_9999
# Faussaire::Address.street_type #=> "Avenue"
#
def street_type
fetch('fr.faussaire.address.street_type')
fetch("fr.faussaire.address.street_type")
end

##
Expand All @@ -78,7 +80,7 @@ def street_type
# Faussaire::Address.street_name #=> "Champs-Élysées"
#
def street_name
fetch('fr.faussaire.address.street_name')
fetch("fr.faussaire.address.street_name")
end

##
Expand All @@ -90,7 +92,7 @@ def street_name
# Faussaire::Address.dpt_name #=> "Yvelines"
#
def dpt_name
fetch('fr.faussaire.address.dpt_name')
fetch("fr.faussaire.address.dpt_name")
end

##
Expand All @@ -102,7 +104,7 @@ def dpt_name
# Faussaire::Address.dpt_number #=> "78"
#
def dpt_number
fetch('fr.faussaire.address.dpt_number_metropolis')
fetch("fr.faussaire.address.dpt_number_metropolis")
end

##
Expand All @@ -114,7 +116,7 @@ def dpt_number
# Faussaire::Address.dpt_number_other #=> "971"
#
def dpt_number_other
fetch('fr.faussaire.address.dpt_number_overseas')
fetch("fr.faussaire.address.dpt_number_overseas")
end

##
Expand All @@ -126,8 +128,8 @@ def dpt_number_other
# Faussaire::Address.postal_code #=> "75001"
#
def postal_code
code = fetch('fr.faussaire.address.postal_code')
code.to_s.rjust(5, '0')
code = fetch("fr.faussaire.address.postal_code")
code.to_s.rjust(5, "0")
end

##
Expand All @@ -139,7 +141,7 @@ def postal_code
# Faussaire::Address.region #=> "Île-de-France"
#
def region
fetch('fr.faussaire.address.region')
fetch("fr.faussaire.address.region")
end

##
Expand All @@ -161,7 +163,6 @@ def full_address
department_number = department_number_select
reg = region


"#{number} #{type} #{name}, #{postal} #{city_name}, #{department_name} (#{department_number}), Région #{reg}"
end

Expand All @@ -180,8 +181,9 @@ def department_number_select
end

def fetch(key)
return nil if data.nil? || data.dig(*key.split('.')).nil?
data.dig(*key.split('.')).sample
return nil if data.nil? || data.dig(*key.split(".")).nil?

data.dig(*key.split(".")).sample
end

def data
Expand Down
14 changes: 8 additions & 6 deletions lib/faussaire/ancien.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
require 'yaml'
# frozen_string_literal: true

require "yaml"

module Faussaire
class Ancien
DATA_PATH = File.expand_path('../../../locale/fr.yml', __FILE__)
DATA_PATH = File.expand_path("../../locale/fr.yml", __dir__)

##
# Fetches and samples data based on the provided key. If the fetched data is an array,
Expand All @@ -13,7 +15,7 @@ class Ancien
#
def self.fetch(key)
data = YAML.load_file(DATA_PATH)
result = data.dig(*key.split('.'))
result = data.dig(*key.split("."))
result.is_a?(Array) ? result.sample : result
end

Expand All @@ -26,7 +28,7 @@ def self.fetch(key)
# Faussaire::Ancien.creature #=> "Dragon"
#
def self.creature
fetch('fr.faussaire.ancien.creature')
fetch("fr.faussaire.ancien.creature")
end

##
Expand All @@ -38,7 +40,7 @@ def self.creature
# Faussaire::Ancien.historic_figure #=> "Napoléon Bonaparte"
#
def self.historic_figure
fetch('fr.faussaire.ancien.historic_figure')
fetch("fr.faussaire.ancien.historic_figure")
end

##
Expand All @@ -50,7 +52,7 @@ def self.historic_figure
# Faussaire::Ancien.words #=> "torteleresse"
#
def self.words
fetch('fr.faussaire.ancien.words')
fetch("fr.faussaire.ancien.words")
end
end
end
7 changes: 4 additions & 3 deletions lib/faussaire/base.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

# lib/faussaire/base.rb
module Faussaire
class Base
end
class Base
end
end
36 changes: 18 additions & 18 deletions lib/faussaire/bizness.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
require 'yaml'
# frozen_string_literal: true

require "yaml"

module Faussaire
class Bizness
DATA_PATH = File.expand_path('../../../locale/fr.yml', __FILE__)
DATA_PATH = File.expand_path("../../locale/fr.yml", __dir__)

##
# Fetches and optionally samples data based on the provided key.
Expand All @@ -14,7 +16,7 @@ class Bizness
#
def self.fetch(key)
data = YAML.load_file(DATA_PATH)
result = data.dig(*key.split('.'))
result = data.dig(*key.split("."))
result.is_a?(Array) ? result.sample : result
end

Expand All @@ -27,46 +29,44 @@ def self.fetch(key)
# Faussaire::Bizness.brands #=> "Apple"
#
def self.brands
fetch('fr.faussaire.bizness.brands')
fetch("fr.faussaire.bizness.brands")
end

def self.load_dico
data = YAML.load_file(DATA_PATH)
dico = data.dig('fr', 'faussaire', 'bizness', 'pipotronics')
dico
data.dig("fr", "faussaire", "bizness", "pipotronics")
end

def self.pipotronic
dico = load_dico
selected_phrases = dico.map { |category| category.sample }
selected_phrases = dico.map(&:sample)
format(selected_phrases)
end

def self.format(arr)
vowels = "aeiouyhéèà"
arr.each_with_index do |phrase, i|
# Identifier si le mot actuel se termine par '#' et le traiter.
if phrase[-1] == '#'
if phrase[-1] == "#"
phrase.chop! # Supprimer le dernier caractère '#'
next_phrase_starts_with_vowel = i < arr.size - 1 && vowels.include?(arr[i + 1][0].downcase)
arr[i] += next_phrase_starts_with_vowel ? 'e ' : "'"
arr[i] += next_phrase_starts_with_vowel ? "e " : "'"
end

# Traiter les cas où le mot se termine par '\'' ou contient 'de ' nécessitant une décision sur l'ajout de 'e ' ou de ''.
if phrase[-1] == '\'' || (phrase.include?('de') && phrase[-3..] == "de ")
if phrase[-1] == "'" || (phrase.include?("de") && phrase[-3..] == "de ")
# Aucun besoin de couper le mot ici; ajustez simplement pour le suivant.
next_phrase_starts_with_vowel = i < arr.size - 1 && vowels.include?(arr[i + 1][0].downcase)
arr[i] += next_phrase_starts_with_vowel ? 'e ' : ""
arr[i] += next_phrase_starts_with_vowel ? "e " : ""
end

# Ajouter un espace si nécessaire.
arr[i] += ' ' unless arr[i].end_with?(' ', "'") || i == arr.size - 1
arr[i] += " " unless arr[i].end_with?(" ", "'") || i == arr.size - 1
# Traitement spécial pour le sixième élément, si nécessaire.
arr[i] = 'les ' + arr[i] if i == 5
arr[i] = "les #{arr[i]}" if i == 5
end
# Construire la phrase et ajouter un point à la fin.
sentence = arr.join.squeeze(' ').strip + '.'
sentence
"#{arr.join.squeeze(" ").strip}."
end
end
end
end
Loading