Class: PlatformosCheck::Corrector
- Inherits:
-
Object
- Object
- PlatformosCheck::Corrector
show all
- Includes:
- JsonHelpers
- Defined in:
- lib/platformos_check/corrector.rb
Instance Method Summary
collapse
-
#add_translation(json_file, path, value) ⇒ Object
def rename(storage, old_path, new_path) storage.rename(old_path, new_path) end.
-
#create_file(storage, relative_path, content) ⇒ Object
-
#initialize(app_file:) ⇒ Corrector
constructor
A new instance of Corrector.
-
#insert_after(node, content, character_range = nil) ⇒ Object
-
#insert_before(node, content, character_range = nil) ⇒ Object
-
#mkdir(storage, relative_path) ⇒ Object
-
#remove(node) ⇒ Object
-
#remove_file(storage, relative_path) ⇒ Object
-
#remove_translation(json_file, path) ⇒ Object
-
#replace(node, content, character_range = nil) ⇒ Object
-
#replace_inner_json(node, json) ⇒ Object
-
#replace_inner_markup(node, content) ⇒ Object
-
#wrap(node, insert_before, insert_after) ⇒ Object
#format_json_parse_error, #pretty_json
Constructor Details
#initialize(app_file:) ⇒ Corrector
Returns a new instance of Corrector.
7
8
9
|
# File 'lib/platformos_check/corrector.rb', line 7
def initialize(app_file:)
@app_file = app_file
end
|
Instance Method Details
#add_translation(json_file, path, value) ⇒ Object
def rename(storage, old_path, new_path)
storage.rename(old_path, new_path)
end
56
57
58
59
60
|
# File 'lib/platformos_check/corrector.rb', line 56
def add_translation(json_file, path, value)
hash = json_file.content
JsonHelper.set(hash, path, value)
json_file.update_contents(hash)
end
|
#create_file(storage, relative_path, content) ⇒ Object
40
41
42
|
# File 'lib/platformos_check/corrector.rb', line 40
def create_file(storage, relative_path, content)
storage.write(relative_path, content)
end
|
#insert_after(node, content, character_range = nil) ⇒ Object
11
12
13
|
# File 'lib/platformos_check/corrector.rb', line 11
def insert_after(node, content, character_range = nil)
@app_file.rewriter.insert_after(node, content, character_range)
end
|
#insert_before(node, content, character_range = nil) ⇒ Object
15
16
17
|
# File 'lib/platformos_check/corrector.rb', line 15
def insert_before(node, content, character_range = nil)
@app_file.rewriter.insert_before(node, content, character_range)
end
|
#mkdir(storage, relative_path) ⇒ Object
48
49
50
|
# File 'lib/platformos_check/corrector.rb', line 48
def mkdir(storage, relative_path)
storage.mkdir(relative_path)
end
|
#remove(node) ⇒ Object
19
20
21
|
# File 'lib/platformos_check/corrector.rb', line 19
def remove(node)
@app_file.rewriter.remove(node)
end
|
#remove_file(storage, relative_path) ⇒ Object
44
45
46
|
# File 'lib/platformos_check/corrector.rb', line 44
def remove_file(storage, relative_path)
storage.remove(relative_path)
end
|
#remove_translation(json_file, path) ⇒ Object
62
63
64
65
66
|
# File 'lib/platformos_check/corrector.rb', line 62
def remove_translation(json_file, path)
hash = json_file.content
JsonHelper.delete(hash, path)
json_file.update_contents(hash)
end
|
#replace(node, content, character_range = nil) ⇒ Object
23
24
25
26
|
# File 'lib/platformos_check/corrector.rb', line 23
def replace(node, content, character_range = nil)
@app_file.rewriter.replace(node, content, character_range)
node.markup = content
end
|
#replace_inner_json(node, json) ⇒ Object
32
33
34
|
# File 'lib/platformos_check/corrector.rb', line 32
def replace_inner_json(node, json, **)
replace_inner_markup(node, pretty_json(json, **))
end
|
#replace_inner_markup(node, content) ⇒ Object
28
29
30
|
# File 'lib/platformos_check/corrector.rb', line 28
def replace_inner_markup(node, content)
@app_file.rewriter.replace_inner_markup(node, content)
end
|
#wrap(node, insert_before, insert_after) ⇒ Object
36
37
38
|
# File 'lib/platformos_check/corrector.rb', line 36
def wrap(node, insert_before, insert_after)
@app_file.rewriter.wrap(node, insert_before, insert_after)
end
|