Class: I18nFlow::Configuration
- Inherits:
-
Object
- Object
- I18nFlow::Configuration
show all
- Includes:
- Validation
- Defined in:
- lib/i18n_flow/configuration.rb,
lib/i18n_flow/configuration.rb
Defined Under Namespace
Modules: Validation
Classes: NoConfigurationFileFoundError, ValueError
Constant Summary
collapse
- CONFIG_FILES =
[
'i18n_flow.yml',
'i18n_flow.yaml',
].freeze
- LINTERS =
i[
file_scope
symmetry
].freeze
Instance Method Summary
collapse
Methods included from Validation
included
Constructor Details
Returns a new instance of Configuration.
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/i18n_flow/configuration.rb', line 113
def initialize
update(validate: false) do |c|
c.base_path = File.expand_path('.')
c.glob_patterns = ['*.en.yml']
c.valid_locales = %w[en]
c.locale_pairs = []
c.linters = LINTERS
c.split_max_level = 3
c.split_line_threshold = 50
end
end
|
Instance Method Details
177
178
179
180
|
# File 'lib/i18n_flow/configuration.rb', line 177
def auto_configure!
load_from_file!
update
end
|
#base_path=(path) ⇒ Object
125
126
127
128
129
|
# File 'lib/i18n_flow/configuration.rb', line 125
def base_path=(path)
@base_path = path&.tap do |v|
break Pathname.new(v)
end
end
|
#glob_patterns=(patterns) ⇒ Object
131
132
133
134
135
136
|
# File 'lib/i18n_flow/configuration.rb', line 131
def glob_patterns=(patterns)
@glob_patterns = patterns&.tap do |v|
break unless v.is_a?(Array)
break v.map(&:to_s)
end
end
|
#linters=(linters) ⇒ Object
153
154
155
156
157
158
|
# File 'lib/i18n_flow/configuration.rb', line 153
def linters=(linters)
@linters = linters&.tap do |v|
break unless v.is_a?(Array)
break v.map(&:to_sym)
end
end
|
#locale_pairs=(pairs) ⇒ Object
138
139
140
141
142
143
144
|
# File 'lib/i18n_flow/configuration.rb', line 138
def locale_pairs=(pairs)
@locale_pairs = pairs&.tap do |v|
break unless v.is_a?(Array)
break unless v.all? { |e| e.size == 2 }
break v.map { |e| e.map(&:to_s) }
end
end
|
#split_line_threshold=(threshold) ⇒ Object
166
167
168
169
170
|
# File 'lib/i18n_flow/configuration.rb', line 166
def split_line_threshold=(threshold)
@split_line_threshold = threshold&.tap do |v|
break unless v.is_a?(Integer)
end
end
|
#split_max_level=(level) ⇒ Object
160
161
162
163
164
|
# File 'lib/i18n_flow/configuration.rb', line 160
def split_max_level=(level)
@split_max_level = level&.tap do |v|
break unless v.is_a?(Integer)
end
end
|
#update(validate: true) {|_self| ... } ⇒ Object
172
173
174
175
|
# File 'lib/i18n_flow/configuration.rb', line 172
def update(validate: true)
yield self if block_given?
validate! if validate
end
|
#valid_locales=(locales) ⇒ Object
146
147
148
149
150
151
|
# File 'lib/i18n_flow/configuration.rb', line 146
def valid_locales=(locales)
@valid_locales = locales&.tap do |v|
break unless v.is_a?(Array)
break v.map(&:to_s)
end
end
|