organo 0.3.5 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/doc/anime.md +30 -8
  3. data/doc/readme.md +2 -2
  4. data/lib/organo/commands/anime/anime_add.rb +27 -24
  5. data/lib/organo/commands/anime/anime_find_broken_links.rb +31 -0
  6. data/lib/organo/commands/anime/anime_remove.rb +10 -14
  7. data/lib/organo/commands/anime/anime_set_sequel.rb +49 -0
  8. data/lib/organo/commands/anime/anime_show.rb +9 -15
  9. data/lib/organo/commands/anime/anime_update_image.rb +16 -35
  10. data/lib/organo/commands/anime/anime_update_query.rb +16 -21
  11. data/lib/organo/commands/api/api_get_anime.rb +3 -6
  12. data/lib/organo/commands/api/api_get_season.rb +3 -4
  13. data/lib/organo/commands/api/api_get_sequels.rb +1 -3
  14. data/lib/organo/commands/init.rb +30 -8
  15. data/lib/organo/commands/remote/remote_add.rb +6 -10
  16. data/lib/organo/commands/remote/remote_download.rb +5 -6
  17. data/lib/organo/commands/remote/remote_remove.rb +0 -2
  18. data/lib/organo/commands/remote/remote_upload.rb +1 -2
  19. data/lib/organo/commands/statistics.rb +6 -21
  20. data/lib/organo/query.rb +0 -1
  21. data/lib/organo/tools/string_utils.rb +28 -0
  22. data/lib/organo/tools/writer.rb +0 -5
  23. data/lib/organo/version.rb +1 -1
  24. data/lib/organo.rb +34 -43
  25. metadata +36 -17
  26. data/lib/organo/commands/anime/anime_add_sequel.rb +0 -52
  27. data/lib/organo/commands/anime/anime_get_broken_links.rb +0 -32
  28. data/lib/organo/commands/anime/anime_search.rb +0 -25
  29. data/lib/organo/commands/api/api_search_anime.rb +0 -29
  30. data/lib/organo/commands/merge.rb +0 -24
  31. data/lib/organo/model/search_show.rb +0 -58
  32. data/lib/organo/model/sequel.rb +0 -39
  33. data/lib/organo/model/show.rb +0 -36
  34. data/lib/organo/show_list.rb +0 -32
  35. data/lib/organo/tools/check.rb +0 -12
  36. data/lib/organo/tools/local_search.rb +0 -49
  37. data/lib/organo/tools/reader.rb +0 -38
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
- require_relative 'reader'
5
-
6
- module Organo
7
- class LocalSearch
8
-
9
- def self.find_anime_by_id(mal_id)
10
- anime_list = Reader.read_all_files
11
- get_anime_obj(mal_id, anime_list)
12
- end
13
-
14
- def self.get_anime_obj(mal_id, anime_list)
15
- return_value = nil
16
- anime_list.each do |anime|
17
- if anime.id == mal_id.to_i || anime.sequels.find { |sequel| sequel['id'] == mal_id.to_i }
18
- return_value = anime
19
- break
20
- end
21
- end
22
- return_value
23
- end
24
-
25
- def self.find_file_by_anime_id(mal_id)
26
- return_value = nil
27
- Dir["#{Config::DEFAULT_DIR}/*.json"].each do |file_path|
28
- anime_list = Reader.read_file(file_path)
29
- unless get_anime_obj(mal_id, anime_list).nil?
30
- return_value = file_path
31
- break
32
- end
33
- end
34
- return_value
35
- end
36
-
37
- def self.find_anime_by_query(query)
38
- anime_list = Reader.read_all_files
39
- return_value = []
40
- anime_list.each do |anime|
41
- if (anime.title.downcase.include? query.downcase) ||
42
- (anime.sequels.find { |sequel| sequel['title'].downcase.include? query.downcase })
43
- return_value.push(anime)
44
- end
45
- end
46
- return_value
47
- end
48
- end
49
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
- require_relative '../config'
5
- require_relative '../model/show'
6
-
7
- module Organo
8
- class Reader
9
- def self.read_all_files
10
- shows = []
11
- Dir["#{Config::DEFAULT_DIR}/*.json"].each do |file_path|
12
- shows = shows.union(Reader.read_file(file_path))
13
- end
14
- shows.sort_by(&:title)
15
- end
16
-
17
- def self.read_file(file_path)
18
- shows = []
19
- file = File.read(file_path)
20
- data = JSON.parse(file)
21
- data.each do |show|
22
- shows.push(
23
- Show.new(
24
- show['id'],
25
- show['slug'],
26
- show['title'],
27
- show['image_url'],
28
- show['search_query'],
29
- show['links'],
30
- show['sequels']
31
- )
32
- )
33
- end
34
- shows
35
- end
36
-
37
- end
38
- end