faussaire 0.1.1

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/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "rubocop/rake_task"
6
+
7
+ # Define the RSpec task for running tests
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.pattern = 'spec/**/*_spec.rb'
10
+ end
11
+
12
+ RuboCop::RakeTask.new
13
+
14
+ # Default task to run specs and RuboCop
15
+ task default: %i[spec rubocop]
data/bonjour.png ADDED
Binary file
data/faussaire.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/faussaire/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "faussaire"
7
+ spec.version = Faussaire::VERSION
8
+ spec.authors = ["ikramagix"]
9
+ spec.email = ["hello@ikramagix.com"]
10
+
11
+ spec.summary = "Generate a wide range of fake data in French and Greek"
12
+ spec.description = "Faussaire is a Ruby gem that allows you to effortlessly generate a diverse set of fake data in multiple languages, including French and Greek. Whether you're developing and testing applications or need placeholder content for design mockups, Faussaire provides a simple and flexible way to create realistic-looking data on demand."
13
+ spec.homepage = "https://github.com/ikramagix/faussaire"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/ikramagix/faussaire"
19
+ spec.metadata["changelog_uri"] = "https://github.com/ikramagix/faussaire/blob/main/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (File.expand_path(f) == __FILE__) ||
26
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ # Uncomment to register a new dependency of your gem
34
+ # spec.add_dependency "example-gem", "~> 1.0"
35
+
36
+ # For more information and examples about making a new gem, check out our
37
+ # guide at: https://bundler.io/guides/creating_gem.html
38
+ end
data/hello.png ADDED
Binary file
data/jadore-rire.gif ADDED
Binary file
@@ -0,0 +1,192 @@
1
+ require 'yaml'
2
+
3
+ module Faussaire
4
+ class Address
5
+ DATA_PATH = File.expand_path('../../locale/fr.yml', __dir__)
6
+
7
+ class << self
8
+ def initialize_data
9
+ @data = YAML.load_file(DATA_PATH)
10
+ end
11
+
12
+ ##
13
+ # Produces a random city name.
14
+ #
15
+ # @return [String]
16
+ #
17
+ # @example
18
+ # Faussaire::Address.city #=> "Paris"
19
+ #
20
+ def city
21
+ fetch('fr.faussaire.address.city')
22
+ end
23
+
24
+ ##
25
+ # Produces a random street number up to 99.
26
+ #
27
+ # @return [String]
28
+ #
29
+ # @example
30
+ # Faussaire::Address.street_number_99 #=> "42"
31
+ #
32
+ def street_number_99
33
+ fetch('fr.faussaire.address.street_number_99')
34
+ end
35
+
36
+ ##
37
+ # Produces a random street number up to 999.
38
+ #
39
+ # @return [String]
40
+ #
41
+ # @example
42
+ # Faussaire::Address.street_number_999 #=> "123"
43
+ #
44
+ def street_number_999
45
+ fetch('fr.faussaire.address.street_number_999')
46
+ end
47
+
48
+ ##
49
+ # Produces a random street number up to 9999.
50
+ #
51
+ # @return [String]
52
+ #
53
+ # @example
54
+ # Faussaire::Address.street_number_9999 #=> "1234"
55
+ #
56
+ def street_number_9999
57
+ fetch('fr.faussaire.address.street_number_9999')
58
+ end
59
+
60
+ ##
61
+ # Produces a random street type.
62
+ #
63
+ # @return [String]
64
+ #
65
+ # @example
66
+ # Faussaire::Address.street_type #=> "Avenue"
67
+ #
68
+ def street_type
69
+ fetch('fr.faussaire.address.street_type')
70
+ end
71
+
72
+ ##
73
+ # Produces a random street name.
74
+ #
75
+ # @return [String]
76
+ #
77
+ # @example
78
+ # Faussaire::Address.street_name #=> "Champs-Élysées"
79
+ #
80
+ def street_name
81
+ fetch('fr.faussaire.address.street_name')
82
+ end
83
+
84
+ ##
85
+ # Produces a random department name.
86
+ #
87
+ # @return [String]
88
+ #
89
+ # @example
90
+ # Faussaire::Address.dpt_name #=> "Yvelines"
91
+ #
92
+ def dpt_name
93
+ fetch('fr.faussaire.address.dpt_name')
94
+ end
95
+
96
+ ##
97
+ # Produces a random department number for metropolitan France.
98
+ #
99
+ # @return [String]
100
+ #
101
+ # @example
102
+ # Faussaire::Address.dpt_number #=> "78"
103
+ #
104
+ def dpt_number
105
+ fetch('fr.faussaire.address.dpt_number_metropolis')
106
+ end
107
+
108
+ ##
109
+ # Produces a random department number for overseas departments.
110
+ #
111
+ # @return [String]
112
+ #
113
+ # @example
114
+ # Faussaire::Address.dpt_number_other #=> "971"
115
+ #
116
+ def dpt_number_other
117
+ fetch('fr.faussaire.address.dpt_number_overseas')
118
+ end
119
+
120
+ ##
121
+ # Produces a random postal code, formatted to five digits.
122
+ #
123
+ # @return [String]
124
+ #
125
+ # @example
126
+ # Faussaire::Address.postal_code #=> "75001"
127
+ #
128
+ def postal_code
129
+ code = fetch('fr.faussaire.address.postal_code')
130
+ code.to_s.rjust(5, '0')
131
+ end
132
+
133
+ ##
134
+ # Produces a random region name.
135
+ #
136
+ # @return [String]
137
+ #
138
+ # @example
139
+ # Faussaire::Address.region #=> "Île-de-France"
140
+ #
141
+ def region
142
+ fetch('fr.faussaire.address.region')
143
+ end
144
+
145
+ ##
146
+ # Generates a complete address using various components such as street number,
147
+ # street type, street name, postal code, city, and region.
148
+ #
149
+ # @return [String] The full address in a standard format.
150
+ #
151
+ # @example
152
+ # Faussaire::Address.full_address #=> "3 Rue du Bac, 75007 Paris, Tarn (44), Région Nouvelle-Aquitaine"
153
+ #
154
+ def full_address
155
+ number = random_street_number
156
+ type = street_type
157
+ name = street_name
158
+ postal = postal_code
159
+ city_name = city
160
+ department_name = dpt_name
161
+ department_number = department_number_select
162
+ reg = region
163
+
164
+
165
+ "#{number} #{type} #{name}, #{postal} #{city_name}, #{department_name} (#{department_number}), Région #{reg}"
166
+ end
167
+
168
+ private
169
+
170
+ def random_street_number
171
+ [
172
+ method(:street_number_99),
173
+ method(:street_number_999),
174
+ method(:street_number_9999)
175
+ ].sample.call
176
+ end
177
+
178
+ def department_number_select
179
+ [dpt_number, dpt_number_other].sample
180
+ end
181
+
182
+ def fetch(key)
183
+ return nil if data.nil? || data.dig(*key.split('.')).nil?
184
+ data.dig(*key.split('.')).sample
185
+ end
186
+
187
+ def data
188
+ @data ||= initialize_data
189
+ end
190
+ end
191
+ end
192
+ end
@@ -0,0 +1,56 @@
1
+ require 'yaml'
2
+
3
+ module Faussaire
4
+ class Ancien
5
+ DATA_PATH = File.expand_path('../../../locale/fr.yml', __FILE__)
6
+
7
+ ##
8
+ # Fetches and samples data based on the provided key. If the fetched data is an array,
9
+ # it samples a single item, otherwise returns the data directly.
10
+ #
11
+ # @param key [String] The dot-separated key used to access the data.
12
+ # @return [Object, nil] The data fetched and optionally sampled.
13
+ #
14
+ def self.fetch(key)
15
+ data = YAML.load_file(DATA_PATH)
16
+ result = data.dig(*key.split('.'))
17
+ result.is_a?(Array) ? result.sample : result
18
+ end
19
+
20
+ ##
21
+ # Produces a random mythical creature name.
22
+ #
23
+ # @return [String]
24
+ #
25
+ # @example
26
+ # Faussaire::Ancien.creature #=> "Dragon"
27
+ #
28
+ def self.creature
29
+ fetch('fr.faussaire.ancien.creature')
30
+ end
31
+
32
+ ##
33
+ # Produces a random historic figure name.
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @example
38
+ # Faussaire::Ancien.historic_figure #=> "Napoléon Bonaparte"
39
+ #
40
+ def self.historic_figure
41
+ fetch('fr.faussaire.ancien.historic_figure')
42
+ end
43
+
44
+ ##
45
+ # Retrieves a random word.
46
+ #
47
+ # @return [String]
48
+ #
49
+ # @example
50
+ # Faussaire::Ancien.words #=> "torteleresse"
51
+ #
52
+ def self.words
53
+ fetch('fr.faussaire.ancien.words')
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,6 @@
1
+ # lib/faussaire/base.rb
2
+ module Faussaire
3
+ class Base
4
+ end
5
+ end
6
+
@@ -0,0 +1,72 @@
1
+ require 'yaml'
2
+
3
+ module Faussaire
4
+ class Bizness
5
+ DATA_PATH = File.expand_path('../../../locale/fr.yml', __FILE__)
6
+
7
+ ##
8
+ # Fetches and optionally samples data based on the provided key.
9
+ # If the fetched data is an array, it samples a single item,
10
+ # otherwise returns the data directly.
11
+ #
12
+ # @param key [String] The dot-separated key used to access the data.
13
+ # @return [Object, nil] The data fetched and optionally sampled.
14
+ #
15
+ def self.fetch(key)
16
+ data = YAML.load_file(DATA_PATH)
17
+ result = data.dig(*key.split('.'))
18
+ result.is_a?(Array) ? result.sample : result
19
+ end
20
+
21
+ ##
22
+ # Produces a random brand name.
23
+ #
24
+ # @return [String]
25
+ #
26
+ # @example
27
+ # Faussaire::Bizness.brands #=> "Apple"
28
+ #
29
+ def self.brands
30
+ fetch('fr.faussaire.bizness.brands')
31
+ end
32
+
33
+ def self.load_dico
34
+ data = YAML.load_file(DATA_PATH)
35
+ dico = data.dig('fr', 'faussaire', 'bizness', 'pipotronics')
36
+ dico
37
+ end
38
+
39
+ def self.pipotronic
40
+ dico = load_dico
41
+ selected_phrases = dico.map { |category| category.sample }
42
+ format(selected_phrases)
43
+ end
44
+
45
+ def self.format(arr)
46
+ vowels = "aeiouyhéèà"
47
+ arr.each_with_index do |phrase, i|
48
+ # Identifier si le mot actuel se termine par '#' et le traiter.
49
+ if phrase[-1] == '#'
50
+ phrase.chop! # Supprimer le dernier caractère '#'
51
+ next_phrase_starts_with_vowel = i < arr.size - 1 && vowels.include?(arr[i + 1][0].downcase)
52
+ arr[i] += next_phrase_starts_with_vowel ? 'e ' : "'"
53
+ end
54
+
55
+ # Traiter les cas où le mot se termine par '\'' ou contient 'de ' nécessitant une décision sur l'ajout de 'e ' ou de ''.
56
+ if phrase[-1] == '\'' || (phrase.include?('de') && phrase[-3..] == "de ")
57
+ # Aucun besoin de couper le mot ici; ajustez simplement pour le suivant.
58
+ next_phrase_starts_with_vowel = i < arr.size - 1 && vowels.include?(arr[i + 1][0].downcase)
59
+ arr[i] += next_phrase_starts_with_vowel ? 'e ' : ""
60
+ end
61
+
62
+ # Ajouter un espace si nécessaire.
63
+ arr[i] += ' ' unless arr[i].end_with?(' ', "'") || i == arr.size - 1
64
+ # Traitement spécial pour le sixième élément, si nécessaire.
65
+ arr[i] = 'les ' + arr[i] if i == 5
66
+ end
67
+ # Construire la phrase et ajouter un point à la fin.
68
+ sentence = arr.join.squeeze(' ').strip + '.'
69
+ sentence
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,40 @@
1
+ require 'yaml'
2
+
3
+ module Faussaire
4
+ class Citation
5
+ DATA_PATH = File.expand_path('./../../locale/fr.yml', __dir__)
6
+
7
+ class << self
8
+ ##
9
+ # Produces a random philosopher quote.
10
+ #
11
+ # @return [String]
12
+ #
13
+ # @example
14
+ # Faussaire::Citation.philo #=> "Homère a dit un jour : Le sommeil et la mort sont des frères jumeaux."
15
+ #
16
+ def philo
17
+ fetch('fr.faussaire.citation.philosophy').sample
18
+ end
19
+
20
+ ##
21
+ # Produces a random french proverb.
22
+ #
23
+ # @return [String]
24
+ #
25
+ # @example
26
+ # Faussaire::Citation.proverbe #=> "Pense deux fois avant de parler, tu en parleras deux fois mieux."
27
+ #
28
+ def proverbe
29
+ fetch('fr.faussaire.citation.proverbe').sample
30
+ end
31
+
32
+ private
33
+
34
+ def fetch(key)
35
+ data = YAML.load_file(DATA_PATH)
36
+ data.dig(*key.split('.'))
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,72 @@
1
+ require 'yaml'
2
+
3
+ module Faussaire
4
+ class Cosmos
5
+ DATA_PATH = File.expand_path('../../locale/fr.yml', __dir__)
6
+
7
+ class << self
8
+ def initialize_data
9
+ @data = YAML.load_file(DATA_PATH)
10
+ end
11
+
12
+ ##
13
+ # Produces a random planet name.
14
+ #
15
+ # @return [String]
16
+ #
17
+ # @example
18
+ # Faussaire::Cosmos.planet #=> "Mars"
19
+ #
20
+ def planet
21
+ fetch('fr.faussaire.cosmos.planet')
22
+ end
23
+
24
+ ##
25
+ # Produces a random cosmic event.
26
+ #
27
+ # @return [String]
28
+ #
29
+ # @example
30
+ # Faussaire::Cosmos.event #=> "Éclipse solaire"
31
+ #
32
+ def event
33
+ fetch('fr.faussaire.cosmos.event')
34
+ end
35
+
36
+ ##
37
+ # Produces a random neighborhood in the cosmos (like a galaxy or nebula).
38
+ #
39
+ # @return [String]
40
+ #
41
+ # @example
42
+ # Faussaire::Cosmos.neighborhood #=> "Voie lactée"
43
+ #
44
+ def neighborhood
45
+ fetch('fr.faussaire.cosmos.neighborhood')
46
+ end
47
+
48
+ ##
49
+ # Produces a random space exploration name.
50
+ #
51
+ # @return [String]
52
+ #
53
+ # @example
54
+ # Faussaire::Cosmos.exploration #=> "Voyager"
55
+ #
56
+ def exploration
57
+ fetch('fr.faussaire.cosmos.exploration')
58
+ end
59
+
60
+ private
61
+
62
+ def fetch(key)
63
+ return nil if data.nil? || data.dig(*key.split('.')).nil?
64
+ data.dig(*key.split('.')).sample
65
+ end
66
+
67
+ def data
68
+ @data ||= initialize_data
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,79 @@
1
+ require 'yaml'
2
+
3
+ module Faussaire
4
+ class Creamerie
5
+ DATA_PATH = File.expand_path('../../locale/fr.yml', __dir__)
6
+
7
+ class << self
8
+ ##
9
+ # Produces a random milk type.
10
+ #
11
+ # @return [String]
12
+ #
13
+ # @example
14
+ # Faussaire::Creamerie.milk_type #=> "de vache"
15
+ def milk_type
16
+ fetch('fr.faussaire.creamerie.milk_type')
17
+ end
18
+
19
+ ##
20
+ # Produces a random butter.
21
+ #
22
+ # @return [Hash]
23
+ #
24
+ # @example
25
+ # Faussaire::Creamerie.butter #=> { name: ..., type: ... }
26
+ def butter
27
+ {
28
+ name: fetch('fr.faussaire.creamerie.butter.name'),
29
+ type: fetch('fr.faussaire.creamerie.butter.type')
30
+ }
31
+ end
32
+
33
+ ##
34
+ # Produces information about top butter producers.
35
+ #
36
+ # @return [String]
37
+ #
38
+ # @example
39
+ # Faussaire::Creamerie.butter_producers #=> "N°1: États-Unis (892,801 t)"
40
+ def butter_producers
41
+ fetch('fr.faussaire.creamerie.butter.top_producers')
42
+ end
43
+
44
+ ##
45
+ # Produces a random cheese.
46
+ #
47
+ # @return [Hash]
48
+ #
49
+ # @example
50
+ # Faussaire::Creamerie.cheese #=> { type: ..., name: ..., region: ... }
51
+ def cheese
52
+ {
53
+ type: fetch('fr.faussaire.creamerie.cheese.type'),
54
+ name: fetch('fr.faussaire.creamerie.cheese.name'),
55
+ region: fetch('fr.faussaire.creamerie.cheese.region')
56
+ }
57
+ end
58
+
59
+ private
60
+
61
+ def fetch(key)
62
+ data = YAML.load_file(DATA_PATH)
63
+ data.dig(*key.split('.')).sample
64
+ end
65
+
66
+ def cheese_type
67
+ fetch('creamerie.cheese.type')
68
+ end
69
+
70
+ def cheese_name
71
+ fetch('creamerie.cheese.name')
72
+ end
73
+
74
+ def cheese_region
75
+ fetch('creamerie.cheese.region')
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,76 @@
1
+ require 'yaml'
2
+
3
+ module Faussaire
4
+ class Gardinerie
5
+ DATA_PATH = File.expand_path('./../../locale/fr.yml', __dir__)
6
+
7
+ class << self
8
+ ##
9
+ # Produces a random vegetable name and its ideal consumption month in France.
10
+ #
11
+ # @return [String]
12
+ #
13
+ # @example
14
+ # Faussaire::Gardinerie.vegetable #=> "Carotte (Mars)"
15
+ #
16
+ def vegetable
17
+ fetch('fr.faussaire.gardinerie.potager').sample
18
+ end
19
+
20
+ ##
21
+ # Produces a random fruit name and its ideal consumption month in France.
22
+ #
23
+ # @return [String]
24
+ #
25
+ # @example
26
+ # Faussaire::Gardinerie.fruit #=> "Pomme (Janvier)"
27
+ #
28
+ def fruit
29
+ fetch('fr.faussaire.gardinerie.verger').sample
30
+ end
31
+
32
+ ##
33
+ # Produces a random name of a harmful weed (harmful for agriculture).
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @example
38
+ # Faussaire::Gardinerie.rival_plant #=> "Cuscuta campestris de la famille des Convolvulaceae, parasite sur diverses plantes cultivées, notamment les Fabaceae, répartition cosmopolite"
39
+ #
40
+ def rival_plant
41
+ fetch('fr.faussaire.gardinerie.rival_plant').sample
42
+ end
43
+
44
+ ##
45
+ # Produces a random name of a carnivorous plant.
46
+ #
47
+ # @return [String]
48
+ #
49
+ # @example
50
+ # Faussaire::Gardinerie.bang_bang_plant #=> "Drosera : pièges à mucilage avec feuilles et poils qui s'enroulent autour des proies"
51
+ #
52
+ def bang_bang_plant
53
+ fetch('fr.faussaire.gardinerie.bang_bang_plant').sample
54
+ end
55
+
56
+ ##
57
+ # Produces a random psychotropic plant name.
58
+ #
59
+ # @return [String]
60
+ #
61
+ # @example
62
+ # Faussaire::Gardinerie.very_naughty_plant #=> "Cannabis sativa ssp. indica : Chanvre, source de substances psychotropes de la famille des Cannabaceae"
63
+ #
64
+ def very_naughty_plant
65
+ fetch('fr.faussaire.gardinerie.very_naughty_plant').sample
66
+ end
67
+
68
+ private
69
+
70
+ def fetch(key)
71
+ data = YAML.load_file(DATA_PATH)
72
+ data.dig(*key.split('.'))
73
+ end
74
+ end
75
+ end
76
+ end