nexus_mods 0.1.1 → 0.3.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/nexus_mods/api/api_limits.rb +64 -0
- data/lib/nexus_mods/api/category.rb +54 -0
- data/lib/nexus_mods/api/game.rb +106 -0
- data/lib/nexus_mods/api/mod.rb +141 -0
- data/lib/nexus_mods/api/mod_file.rb +116 -0
- data/lib/nexus_mods/api/user.rb +55 -0
- data/lib/nexus_mods/api_client.rb +182 -0
- data/lib/nexus_mods/cacheable_api.rb +52 -0
- data/lib/nexus_mods/cacheable_with_expiry.rb +70 -0
- data/lib/nexus_mods/core_extensions/cacheable/cache_adapters/persistent_json_adapter.rb +62 -0
- data/lib/nexus_mods/core_extensions/cacheable/method_generator.rb +62 -0
- data/lib/nexus_mods/file_cache.rb +71 -0
- data/lib/nexus_mods/version.rb +1 -1
- data/lib/nexus_mods.rb +32 -86
- data/spec/nexus_mods_test/factories/games.rb +135 -0
- data/spec/nexus_mods_test/factories/mod_files.rb +113 -0
- data/spec/nexus_mods_test/factories/mods.rb +144 -0
- data/spec/nexus_mods_test/helpers.rb +39 -14
- data/spec/nexus_mods_test/scenarios/nexus_mods/{api_limits_spec.rb → api/api_limits_spec.rb} +10 -3
- data/spec/nexus_mods_test/scenarios/nexus_mods/api/game_spec.rb +93 -0
- data/spec/nexus_mods_test/scenarios/nexus_mods/api/mod_file_spec.rb +73 -0
- data/spec/nexus_mods_test/scenarios/nexus_mods/api/mod_spec.rb +62 -0
- data/spec/nexus_mods_test/scenarios/nexus_mods_caching_spec.rb +88 -0
- metadata +37 -13
- data/lib/nexus_mods/api_limits.rb +0 -44
- data/lib/nexus_mods/category.rb +0 -37
- data/lib/nexus_mods/game.rb +0 -78
- data/lib/nexus_mods/mod.rb +0 -106
- data/lib/nexus_mods/mod_file.rb +0 -86
- data/lib/nexus_mods/user.rb +0 -37
- data/spec/nexus_mods_test/scenarios/nexus_mods/game_spec.rb +0 -180
- data/spec/nexus_mods_test/scenarios/nexus_mods/mod_file_spec.rb +0 -140
- data/spec/nexus_mods_test/scenarios/nexus_mods/mod_spec.rb +0 -185
    
        data/lib/nexus_mods/game.rb
    DELETED
    
    | @@ -1,78 +0,0 @@ | |
| 1 | 
            -
            class NexusMods
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              # A NexusMods game.
         | 
| 4 | 
            -
              # Attributes info can be taken from there:
         | 
| 5 | 
            -
              # * https://github.com/Nexus-Mods/node-nexus-api/blob/master/docs/interfaces/_types_.igameinfo.md
         | 
| 6 | 
            -
              class Game
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                attr_reader(
         | 
| 9 | 
            -
                  *%i[
         | 
| 10 | 
            -
                    id
         | 
| 11 | 
            -
                    name
         | 
| 12 | 
            -
                    forum_url
         | 
| 13 | 
            -
                    nexusmods_url
         | 
| 14 | 
            -
                    genre
         | 
| 15 | 
            -
                    domain_name
         | 
| 16 | 
            -
                    approved_date
         | 
| 17 | 
            -
                    files_count
         | 
| 18 | 
            -
                    files_views
         | 
| 19 | 
            -
                    files_endorsements
         | 
| 20 | 
            -
                    downloads_count
         | 
| 21 | 
            -
                    authors_count
         | 
| 22 | 
            -
                    mods_count
         | 
| 23 | 
            -
                    categories
         | 
| 24 | 
            -
                  ]
         | 
| 25 | 
            -
                )
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                # Constructor
         | 
| 28 | 
            -
                #
         | 
| 29 | 
            -
                # Parameters::
         | 
| 30 | 
            -
                # * *id* (Integer): The game's id
         | 
| 31 | 
            -
                # * *name* (String): The game's name
         | 
| 32 | 
            -
                # * *forum_url* (String): The game's forum's URL
         | 
| 33 | 
            -
                # * *nexusmods_url* (String): The game's NexusMods' URL
         | 
| 34 | 
            -
                # * *genre* (String): The game's genre
         | 
| 35 | 
            -
                # * *domain_name* (String): The game's domain's name
         | 
| 36 | 
            -
                # * *approved_date* (Time): The game's approved date (time when the game was added)
         | 
| 37 | 
            -
                # * *files_count* (Integer): The game's files' count [default: 0]
         | 
| 38 | 
            -
                # * *files_views* (Integer): The game's files' views [default: 0]
         | 
| 39 | 
            -
                # * *files_endorsements* (Integer): The game's files' endorsements [default: 0]
         | 
| 40 | 
            -
                # * *downloads_count* (Integer): The game's downloads' count [default: 0]
         | 
| 41 | 
            -
                # * *authors_count* (Integer): The game's authors's count [default: 0]
         | 
| 42 | 
            -
                # * *mods_count* (Integer): The game's mods' count [default: 0]
         | 
| 43 | 
            -
                # * *categories* (Array<Category>): The list of game's categories [default: []]
         | 
| 44 | 
            -
                def initialize(
         | 
| 45 | 
            -
                  id:,
         | 
| 46 | 
            -
                  name:,
         | 
| 47 | 
            -
                  forum_url:,
         | 
| 48 | 
            -
                  nexusmods_url:,
         | 
| 49 | 
            -
                  genre:,
         | 
| 50 | 
            -
                  domain_name:,
         | 
| 51 | 
            -
                  approved_date:,
         | 
| 52 | 
            -
                  files_count: 0,
         | 
| 53 | 
            -
                  files_views: 0,
         | 
| 54 | 
            -
                  files_endorsements: 0,
         | 
| 55 | 
            -
                  downloads_count: 0,
         | 
| 56 | 
            -
                  authors_count: 0,
         | 
| 57 | 
            -
                  mods_count: 0,
         | 
| 58 | 
            -
                  categories: []
         | 
| 59 | 
            -
                )
         | 
| 60 | 
            -
                  @id = id
         | 
| 61 | 
            -
                  @name = name
         | 
| 62 | 
            -
                  @forum_url = forum_url
         | 
| 63 | 
            -
                  @nexusmods_url = nexusmods_url
         | 
| 64 | 
            -
                  @genre = genre
         | 
| 65 | 
            -
                  @domain_name = domain_name
         | 
| 66 | 
            -
                  @approved_date = approved_date
         | 
| 67 | 
            -
                  @files_count = files_count
         | 
| 68 | 
            -
                  @files_views = files_views
         | 
| 69 | 
            -
                  @files_endorsements = files_endorsements
         | 
| 70 | 
            -
                  @downloads_count = downloads_count
         | 
| 71 | 
            -
                  @authors_count = authors_count
         | 
| 72 | 
            -
                  @mods_count = mods_count
         | 
| 73 | 
            -
                  @categories = categories
         | 
| 74 | 
            -
                end
         | 
| 75 | 
            -
             | 
| 76 | 
            -
              end
         | 
| 77 | 
            -
             | 
| 78 | 
            -
            end
         | 
    
        data/lib/nexus_mods/mod.rb
    DELETED
    
    | @@ -1,106 +0,0 @@ | |
| 1 | 
            -
            class NexusMods
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              # A NexusMods mod.
         | 
| 4 | 
            -
              # Attributes info can be taken from there:
         | 
| 5 | 
            -
              # * https://github.com/Nexus-Mods/node-nexus-api/blob/master/docs/interfaces/_types_.imodinfo.md
         | 
| 6 | 
            -
              class Mod
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                attr_reader(
         | 
| 9 | 
            -
                  *%i[
         | 
| 10 | 
            -
                    uid
         | 
| 11 | 
            -
                    mod_id
         | 
| 12 | 
            -
                    game_id
         | 
| 13 | 
            -
                    allow_rating
         | 
| 14 | 
            -
                    domain_name
         | 
| 15 | 
            -
                    category_id
         | 
| 16 | 
            -
                    version
         | 
| 17 | 
            -
                    created_time
         | 
| 18 | 
            -
                    updated_time
         | 
| 19 | 
            -
                    author
         | 
| 20 | 
            -
                    contains_adult_content
         | 
| 21 | 
            -
                    status
         | 
| 22 | 
            -
                    available
         | 
| 23 | 
            -
                    uploader
         | 
| 24 | 
            -
                    name
         | 
| 25 | 
            -
                    summary
         | 
| 26 | 
            -
                    description
         | 
| 27 | 
            -
                    picture_url
         | 
| 28 | 
            -
                    downloads_count
         | 
| 29 | 
            -
                    unique_downloads_count
         | 
| 30 | 
            -
                    endorsements_count
         | 
| 31 | 
            -
                  ]
         | 
| 32 | 
            -
                )
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                # Constructor
         | 
| 35 | 
            -
                #
         | 
| 36 | 
            -
                # Parameters::
         | 
| 37 | 
            -
                # * *uid* (Integer): The mod's uid
         | 
| 38 | 
            -
                # * *mod_id* (Integer): The mod's id
         | 
| 39 | 
            -
                # * *game_id* (Integer): The mod's game id
         | 
| 40 | 
            -
                # * *allow_rating* (Boolean): Does this mod allow endorsements?
         | 
| 41 | 
            -
                # * *domain_name* (String): The mod's domain name
         | 
| 42 | 
            -
                # * *category_id* (String): The mod's category id
         | 
| 43 | 
            -
                # * *version* (String): The mod's version
         | 
| 44 | 
            -
                # * *created_time* (Time): The mod's creation time
         | 
| 45 | 
            -
                # * *updated_time* (Time): The mod's update time
         | 
| 46 | 
            -
                # * *author* (String): The mod's author
         | 
| 47 | 
            -
                # * *contains_adult_content* (Boolean): Does this mod contain adult content?
         | 
| 48 | 
            -
                # * *status* (String): The mod's status
         | 
| 49 | 
            -
                # * *available* (Boolean): Is the mod publicly available?
         | 
| 50 | 
            -
                # * *uploader* (User): The mod's uploader information
         | 
| 51 | 
            -
                # * *name* (String or nil): The mod's name, or nil if under moderation [default: nil]
         | 
| 52 | 
            -
                # * *summary* (String or nil): The mod's summary, or nil if none [default: nil]
         | 
| 53 | 
            -
                # * *description* (String or nil): The mod's description, or nil if none [default: nil]
         | 
| 54 | 
            -
                # * *picture_url* (String): The mod's picture_url [default: nil]
         | 
| 55 | 
            -
                # * *downloads_count* (Integer): The mod's downloads' count [default: 0]
         | 
| 56 | 
            -
                # * *unique_downloads_count* (Integer): The mod's unique downloads' count [default: 0]
         | 
| 57 | 
            -
                # * *endorsements_count* (Integer): The mod's endorsements' count [default: 0]
         | 
| 58 | 
            -
                def initialize(
         | 
| 59 | 
            -
                  uid:,
         | 
| 60 | 
            -
                  mod_id:,
         | 
| 61 | 
            -
                  game_id:,
         | 
| 62 | 
            -
                  allow_rating:,
         | 
| 63 | 
            -
                  domain_name:,
         | 
| 64 | 
            -
                  category_id:,
         | 
| 65 | 
            -
                  version:,
         | 
| 66 | 
            -
                  created_time:,
         | 
| 67 | 
            -
                  updated_time:,
         | 
| 68 | 
            -
                  author:,
         | 
| 69 | 
            -
                  contains_adult_content:,
         | 
| 70 | 
            -
                  status:,
         | 
| 71 | 
            -
                  available:,
         | 
| 72 | 
            -
                  uploader:,
         | 
| 73 | 
            -
                  name: nil,
         | 
| 74 | 
            -
                  summary: nil,
         | 
| 75 | 
            -
                  description: nil,
         | 
| 76 | 
            -
                  picture_url: nil,
         | 
| 77 | 
            -
                  downloads_count: 0,
         | 
| 78 | 
            -
                  unique_downloads_count: 0,
         | 
| 79 | 
            -
                  endorsements_count: 0
         | 
| 80 | 
            -
                )
         | 
| 81 | 
            -
                  @uid = uid
         | 
| 82 | 
            -
                  @mod_id = mod_id
         | 
| 83 | 
            -
                  @game_id = game_id
         | 
| 84 | 
            -
                  @allow_rating = allow_rating
         | 
| 85 | 
            -
                  @domain_name = domain_name
         | 
| 86 | 
            -
                  @category_id = category_id
         | 
| 87 | 
            -
                  @version = version
         | 
| 88 | 
            -
                  @created_time = created_time
         | 
| 89 | 
            -
                  @updated_time = updated_time
         | 
| 90 | 
            -
                  @author = author
         | 
| 91 | 
            -
                  @contains_adult_content = contains_adult_content
         | 
| 92 | 
            -
                  @status = status
         | 
| 93 | 
            -
                  @available = available
         | 
| 94 | 
            -
                  @uploader = uploader
         | 
| 95 | 
            -
                  @name = name
         | 
| 96 | 
            -
                  @summary = summary
         | 
| 97 | 
            -
                  @description = description
         | 
| 98 | 
            -
                  @picture_url = picture_url
         | 
| 99 | 
            -
                  @downloads_count = downloads_count
         | 
| 100 | 
            -
                  @unique_downloads_count = unique_downloads_count
         | 
| 101 | 
            -
                  @endorsements_count = endorsements_count
         | 
| 102 | 
            -
                end
         | 
| 103 | 
            -
             | 
| 104 | 
            -
              end
         | 
| 105 | 
            -
             | 
| 106 | 
            -
            end
         | 
    
        data/lib/nexus_mods/mod_file.rb
    DELETED
    
    | @@ -1,86 +0,0 @@ | |
| 1 | 
            -
            class NexusMods
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              # A NexusMods file.
         | 
| 4 | 
            -
              # Attributes info can be taken from there:
         | 
| 5 | 
            -
              # * https://github.com/Nexus-Mods/node-nexus-api/blob/master/docs/interfaces/_types_.ifileinfo.md
         | 
| 6 | 
            -
              class ModFile
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                attr_reader(
         | 
| 9 | 
            -
                  *%i[
         | 
| 10 | 
            -
                    ids
         | 
| 11 | 
            -
                    uid
         | 
| 12 | 
            -
                    id
         | 
| 13 | 
            -
                    name
         | 
| 14 | 
            -
                    version
         | 
| 15 | 
            -
                    category_id
         | 
| 16 | 
            -
                    category_name
         | 
| 17 | 
            -
                    is_primary
         | 
| 18 | 
            -
                    size
         | 
| 19 | 
            -
                    file_name
         | 
| 20 | 
            -
                    uploaded_time
         | 
| 21 | 
            -
                    mod_version
         | 
| 22 | 
            -
                    external_virus_scan_url
         | 
| 23 | 
            -
                    description
         | 
| 24 | 
            -
                    changelog_html
         | 
| 25 | 
            -
                    content_preview_url
         | 
| 26 | 
            -
                  ]
         | 
| 27 | 
            -
                )
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                # Constructor
         | 
| 30 | 
            -
                #
         | 
| 31 | 
            -
                # Parameters::
         | 
| 32 | 
            -
                # * *ids* (Array<Integer>): The file's list of IDs
         | 
| 33 | 
            -
                # * *uid* (Integer): The file's UID
         | 
| 34 | 
            -
                # * *id* (Integer): The file's main ID
         | 
| 35 | 
            -
                # * *name* (String): The file's name
         | 
| 36 | 
            -
                # * *version* (String): The file's version
         | 
| 37 | 
            -
                # * *category_id* (Symbol): The file's category's ID
         | 
| 38 | 
            -
                # * *category_name* (String): The file's category_name
         | 
| 39 | 
            -
                # * *is_primary* (String): Is this file the primary download one?
         | 
| 40 | 
            -
                # * *size* (Integer): The file's size (in bytes)
         | 
| 41 | 
            -
                # * *file_name* (String): The file's exact file name
         | 
| 42 | 
            -
                # * *uploaded_time* (Time): The file's uploaded time
         | 
| 43 | 
            -
                # * *mod_version* (String): The file's mod version
         | 
| 44 | 
            -
                # * *external_virus_scan_url* (String): The URL of virus scan for this file
         | 
| 45 | 
            -
                # * *description* (String): The file's description
         | 
| 46 | 
            -
                # * *changelog_html* (String): The file's change log in HTML
         | 
| 47 | 
            -
                # * *content_preview_url* (String): URL to a JSON that gives info on the file's content
         | 
| 48 | 
            -
                def initialize(
         | 
| 49 | 
            -
                  ids:,
         | 
| 50 | 
            -
                  uid:,
         | 
| 51 | 
            -
                  id:,
         | 
| 52 | 
            -
                  name:,
         | 
| 53 | 
            -
                  version:,
         | 
| 54 | 
            -
                  category_id:,
         | 
| 55 | 
            -
                  category_name:,
         | 
| 56 | 
            -
                  is_primary:,
         | 
| 57 | 
            -
                  size:,
         | 
| 58 | 
            -
                  file_name:,
         | 
| 59 | 
            -
                  uploaded_time:,
         | 
| 60 | 
            -
                  mod_version:,
         | 
| 61 | 
            -
                  external_virus_scan_url:,
         | 
| 62 | 
            -
                  description:,
         | 
| 63 | 
            -
                  changelog_html:,
         | 
| 64 | 
            -
                  content_preview_url:
         | 
| 65 | 
            -
                )
         | 
| 66 | 
            -
                  @ids = ids
         | 
| 67 | 
            -
                  @uid = uid
         | 
| 68 | 
            -
                  @id = id
         | 
| 69 | 
            -
                  @name = name
         | 
| 70 | 
            -
                  @version = version
         | 
| 71 | 
            -
                  @category_id = category_id
         | 
| 72 | 
            -
                  @category_name = category_name
         | 
| 73 | 
            -
                  @is_primary = is_primary
         | 
| 74 | 
            -
                  @size = size
         | 
| 75 | 
            -
                  @file_name = file_name
         | 
| 76 | 
            -
                  @uploaded_time = uploaded_time
         | 
| 77 | 
            -
                  @mod_version = mod_version
         | 
| 78 | 
            -
                  @external_virus_scan_url = external_virus_scan_url
         | 
| 79 | 
            -
                  @description = description
         | 
| 80 | 
            -
                  @changelog_html = changelog_html
         | 
| 81 | 
            -
                  @content_preview_url = content_preview_url
         | 
| 82 | 
            -
                end
         | 
| 83 | 
            -
             | 
| 84 | 
            -
              end
         | 
| 85 | 
            -
             | 
| 86 | 
            -
            end
         | 
    
        data/lib/nexus_mods/user.rb
    DELETED
    
    | @@ -1,37 +0,0 @@ | |
| 1 | 
            -
            class NexusMods
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              # A user on NExusMods.
         | 
| 4 | 
            -
              # Mainly used for uploaders information.
         | 
| 5 | 
            -
              class User
         | 
| 6 | 
            -
             | 
| 7 | 
            -
                attr_reader(
         | 
| 8 | 
            -
                  *%i[
         | 
| 9 | 
            -
                    member_id
         | 
| 10 | 
            -
                    member_group_id
         | 
| 11 | 
            -
                    name
         | 
| 12 | 
            -
                    profile_url
         | 
| 13 | 
            -
                  ]
         | 
| 14 | 
            -
                )
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                # Constructor
         | 
| 17 | 
            -
                #
         | 
| 18 | 
            -
                # Parameters::
         | 
| 19 | 
            -
                # * *member_id* (Integer): The user's member id
         | 
| 20 | 
            -
                # * *member_group_id* (Integer): The user's member group id
         | 
| 21 | 
            -
                # * *name* (String): The user's name
         | 
| 22 | 
            -
                # * *profile_url* (String): The user's profile URL
         | 
| 23 | 
            -
                def initialize(
         | 
| 24 | 
            -
                  member_id:,
         | 
| 25 | 
            -
                  member_group_id:,
         | 
| 26 | 
            -
                  name:,
         | 
| 27 | 
            -
                  profile_url:
         | 
| 28 | 
            -
                )
         | 
| 29 | 
            -
                  @member_id = member_id
         | 
| 30 | 
            -
                  @member_group_id = member_group_id
         | 
| 31 | 
            -
                  @name = name
         | 
| 32 | 
            -
                  @profile_url = profile_url
         | 
| 33 | 
            -
                end
         | 
| 34 | 
            -
             | 
| 35 | 
            -
              end
         | 
| 36 | 
            -
             | 
| 37 | 
            -
            end
         | 
| @@ -1,180 +0,0 @@ | |
| 1 | 
            -
            describe NexusMods::Game do
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              context 'when testing games' do
         | 
| 4 | 
            -
             | 
| 5 | 
            -
                it 'returns the games list' do
         | 
| 6 | 
            -
                  expect_validate_user
         | 
| 7 | 
            -
                  expect_http_call_to(
         | 
| 8 | 
            -
                    path: '/v1/games.json',
         | 
| 9 | 
            -
                    json: [
         | 
| 10 | 
            -
                      {
         | 
| 11 | 
            -
                        'id' => 100,
         | 
| 12 | 
            -
                        'name' => 'Morrowind',
         | 
| 13 | 
            -
                        'forum_url' => 'https://forums.nexusmods.com/index.php?/forum/111-morrowind/',
         | 
| 14 | 
            -
                        'nexusmods_url' => 'http://www.nexusmods.com/morrowind',
         | 
| 15 | 
            -
                        'genre' => 'RPG',
         | 
| 16 | 
            -
                        'file_count' => 14_143,
         | 
| 17 | 
            -
                        'downloads' => 20_414_985,
         | 
| 18 | 
            -
                        'domain_name' => 'morrowind',
         | 
| 19 | 
            -
                        'approved_date' => 1,
         | 
| 20 | 
            -
                        'file_views' => 100_014_750,
         | 
| 21 | 
            -
                        'authors' => 2062,
         | 
| 22 | 
            -
                        'file_endorsements' => 719_262,
         | 
| 23 | 
            -
                        'mods' => 6080,
         | 
| 24 | 
            -
                        'categories' => [
         | 
| 25 | 
            -
                          {
         | 
| 26 | 
            -
                            'category_id' => 1,
         | 
| 27 | 
            -
                            'name' => 'Morrowind',
         | 
| 28 | 
            -
                            'parent_category' => false
         | 
| 29 | 
            -
                          },
         | 
| 30 | 
            -
                          {
         | 
| 31 | 
            -
                            'category_id' => 2,
         | 
| 32 | 
            -
                            'name' => 'Buildings',
         | 
| 33 | 
            -
                            'parent_category' => 1
         | 
| 34 | 
            -
                          }
         | 
| 35 | 
            -
                        ]
         | 
| 36 | 
            -
                      },
         | 
| 37 | 
            -
                      {
         | 
| 38 | 
            -
                        'id' => 101,
         | 
| 39 | 
            -
                        'name' => 'Oblivion',
         | 
| 40 | 
            -
                        'forum_url' => 'https://forums.nexusmods.com/index.php?/forum/131-oblivion/',
         | 
| 41 | 
            -
                        'nexusmods_url' => 'http://www.nexusmods.com/oblivion',
         | 
| 42 | 
            -
                        'genre' => 'RPG',
         | 
| 43 | 
            -
                        'file_count' => 52_775,
         | 
| 44 | 
            -
                        'downloads' => 187_758_634,
         | 
| 45 | 
            -
                        'domain_name' => 'oblivion',
         | 
| 46 | 
            -
                        'approved_date' => 1,
         | 
| 47 | 
            -
                        'file_views' => 880_508_188,
         | 
| 48 | 
            -
                        'authors' => 10_673,
         | 
| 49 | 
            -
                        'file_endorsements' => 4_104_067,
         | 
| 50 | 
            -
                        'mods' => 29_220,
         | 
| 51 | 
            -
                        'categories' => [
         | 
| 52 | 
            -
                          {
         | 
| 53 | 
            -
                            'category_id' => 20,
         | 
| 54 | 
            -
                            'name' => 'Oblivion',
         | 
| 55 | 
            -
                            'parent_category' => false
         | 
| 56 | 
            -
                          },
         | 
| 57 | 
            -
                          {
         | 
| 58 | 
            -
                            'category_id' => 22,
         | 
| 59 | 
            -
                            'name' => 'New structures - Buildings',
         | 
| 60 | 
            -
                            'parent_category' => 20
         | 
| 61 | 
            -
                          }
         | 
| 62 | 
            -
                        ]
         | 
| 63 | 
            -
                      }
         | 
| 64 | 
            -
                    ]
         | 
| 65 | 
            -
                  )
         | 
| 66 | 
            -
                  games = nexus_mods.games.sort_by(&:id)
         | 
| 67 | 
            -
                  expect(games.size).to eq 2
         | 
| 68 | 
            -
                  first_game = games.first
         | 
| 69 | 
            -
                  expect(first_game.id).to eq 100
         | 
| 70 | 
            -
                  expect(first_game.name).to eq 'Morrowind'
         | 
| 71 | 
            -
                  expect(first_game.forum_url).to eq 'https://forums.nexusmods.com/index.php?/forum/111-morrowind/'
         | 
| 72 | 
            -
                  expect(first_game.nexusmods_url).to eq 'http://www.nexusmods.com/morrowind'
         | 
| 73 | 
            -
                  expect(first_game.genre).to eq 'RPG'
         | 
| 74 | 
            -
                  expect(first_game.files_count).to eq 14_143
         | 
| 75 | 
            -
                  expect(first_game.downloads_count).to eq 20_414_985
         | 
| 76 | 
            -
                  expect(first_game.domain_name).to eq 'morrowind'
         | 
| 77 | 
            -
                  expect(first_game.approved_date).to eq Time.parse('1970-01-01 00:00:01 +0000')
         | 
| 78 | 
            -
                  expect(first_game.files_views).to eq 100_014_750
         | 
| 79 | 
            -
                  expect(first_game.authors_count).to eq 2062
         | 
| 80 | 
            -
                  expect(first_game.files_endorsements).to eq 719_262
         | 
| 81 | 
            -
                  expect(first_game.mods_count).to eq 6080
         | 
| 82 | 
            -
                  first_game_categories = first_game.categories
         | 
| 83 | 
            -
                  expect(first_game_categories.size).to eq 2
         | 
| 84 | 
            -
                  expect(first_game_categories.first.id).to eq 1
         | 
| 85 | 
            -
                  expect(first_game_categories.first.name).to eq 'Morrowind'
         | 
| 86 | 
            -
                  expect(first_game_categories.first.parent_category).to be_nil
         | 
| 87 | 
            -
                  expect(first_game_categories[1].id).to eq 2
         | 
| 88 | 
            -
                  expect(first_game_categories[1].name).to eq 'Buildings'
         | 
| 89 | 
            -
                  expect(first_game_categories[1].parent_category).not_to be_nil
         | 
| 90 | 
            -
                  expect(first_game_categories[1].parent_category.id).to eq 1
         | 
| 91 | 
            -
                  expect(first_game_categories[1].parent_category.name).to eq 'Morrowind'
         | 
| 92 | 
            -
                  expect(first_game_categories[1].parent_category.parent_category).to be_nil
         | 
| 93 | 
            -
                  second_game = games[1]
         | 
| 94 | 
            -
                  expect(second_game.id).to eq 101
         | 
| 95 | 
            -
                  expect(second_game.name).to eq 'Oblivion'
         | 
| 96 | 
            -
                  expect(second_game.forum_url).to eq 'https://forums.nexusmods.com/index.php?/forum/131-oblivion/'
         | 
| 97 | 
            -
                  expect(second_game.nexusmods_url).to eq 'http://www.nexusmods.com/oblivion'
         | 
| 98 | 
            -
                  expect(second_game.genre).to eq 'RPG'
         | 
| 99 | 
            -
                  expect(second_game.files_count).to eq 52_775
         | 
| 100 | 
            -
                  expect(second_game.downloads_count).to eq 187_758_634
         | 
| 101 | 
            -
                  expect(second_game.domain_name).to eq 'oblivion'
         | 
| 102 | 
            -
                  expect(second_game.approved_date).to eq Time.parse('1970-01-01 00:00:01 +0000')
         | 
| 103 | 
            -
                  expect(second_game.files_views).to eq 880_508_188
         | 
| 104 | 
            -
                  expect(second_game.authors_count).to eq 10_673
         | 
| 105 | 
            -
                  expect(second_game.files_endorsements).to eq 4_104_067
         | 
| 106 | 
            -
                  expect(second_game.mods_count).to eq 29_220
         | 
| 107 | 
            -
                  second_game_categories = second_game.categories
         | 
| 108 | 
            -
                  expect(second_game_categories.size).to eq 2
         | 
| 109 | 
            -
                  expect(second_game_categories.first.id).to eq 20
         | 
| 110 | 
            -
                  expect(second_game_categories.first.name).to eq 'Oblivion'
         | 
| 111 | 
            -
                  expect(second_game_categories.first.parent_category).to be_nil
         | 
| 112 | 
            -
                  expect(second_game_categories[1].id).to eq 22
         | 
| 113 | 
            -
                  expect(second_game_categories[1].name).to eq 'New structures - Buildings'
         | 
| 114 | 
            -
                  expect(second_game_categories[1].parent_category).not_to be_nil
         | 
| 115 | 
            -
                  expect(second_game_categories[1].parent_category.id).to eq 20
         | 
| 116 | 
            -
                  expect(second_game_categories[1].parent_category.name).to eq 'Oblivion'
         | 
| 117 | 
            -
                  expect(second_game_categories[1].parent_category.parent_category).to be_nil
         | 
| 118 | 
            -
                end
         | 
| 119 | 
            -
             | 
| 120 | 
            -
                it 'returns a game having missing parent category' do
         | 
| 121 | 
            -
                  expect_validate_user
         | 
| 122 | 
            -
                  expect_http_call_to(
         | 
| 123 | 
            -
                    path: '/v1/games.json',
         | 
| 124 | 
            -
                    json: [
         | 
| 125 | 
            -
                      {
         | 
| 126 | 
            -
                        'id' => 100,
         | 
| 127 | 
            -
                        'name' => 'Morrowind',
         | 
| 128 | 
            -
                        'forum_url' => 'https://forums.nexusmods.com/index.php?/forum/111-morrowind/',
         | 
| 129 | 
            -
                        'nexusmods_url' => 'http://www.nexusmods.com/morrowind',
         | 
| 130 | 
            -
                        'genre' => 'RPG',
         | 
| 131 | 
            -
                        'file_count' => 14_143,
         | 
| 132 | 
            -
                        'downloads' => 20_414_985,
         | 
| 133 | 
            -
                        'domain_name' => 'morrowind',
         | 
| 134 | 
            -
                        'approved_date' => 1,
         | 
| 135 | 
            -
                        'file_views' => 100_014_750,
         | 
| 136 | 
            -
                        'authors' => 2062,
         | 
| 137 | 
            -
                        'file_endorsements' => 719_262,
         | 
| 138 | 
            -
                        'mods' => 6080,
         | 
| 139 | 
            -
                        'categories' => [
         | 
| 140 | 
            -
                          {
         | 
| 141 | 
            -
                            'category_id' => 1,
         | 
| 142 | 
            -
                            'name' => 'Morrowind',
         | 
| 143 | 
            -
                            'parent_category' => false
         | 
| 144 | 
            -
                          },
         | 
| 145 | 
            -
                          {
         | 
| 146 | 
            -
                            'category_id' => 2,
         | 
| 147 | 
            -
                            'name' => 'Buildings',
         | 
| 148 | 
            -
                            'parent_category' => 3
         | 
| 149 | 
            -
                          }
         | 
| 150 | 
            -
                        ]
         | 
| 151 | 
            -
                      }
         | 
| 152 | 
            -
                    ]
         | 
| 153 | 
            -
                  )
         | 
| 154 | 
            -
                  game = nexus_mods.games.first
         | 
| 155 | 
            -
                  expect(game.id).to eq 100
         | 
| 156 | 
            -
                  expect(game.name).to eq 'Morrowind'
         | 
| 157 | 
            -
                  expect(game.forum_url).to eq 'https://forums.nexusmods.com/index.php?/forum/111-morrowind/'
         | 
| 158 | 
            -
                  expect(game.nexusmods_url).to eq 'http://www.nexusmods.com/morrowind'
         | 
| 159 | 
            -
                  expect(game.genre).to eq 'RPG'
         | 
| 160 | 
            -
                  expect(game.files_count).to eq 14_143
         | 
| 161 | 
            -
                  expect(game.downloads_count).to eq 20_414_985
         | 
| 162 | 
            -
                  expect(game.domain_name).to eq 'morrowind'
         | 
| 163 | 
            -
                  expect(game.approved_date).to eq Time.parse('1970-01-01 00:00:01 +0000')
         | 
| 164 | 
            -
                  expect(game.files_views).to eq 100_014_750
         | 
| 165 | 
            -
                  expect(game.authors_count).to eq 2062
         | 
| 166 | 
            -
                  expect(game.files_endorsements).to eq 719_262
         | 
| 167 | 
            -
                  expect(game.mods_count).to eq 6080
         | 
| 168 | 
            -
                  game_categories = game.categories
         | 
| 169 | 
            -
                  expect(game_categories.size).to eq 2
         | 
| 170 | 
            -
                  expect(game_categories.first.id).to eq 1
         | 
| 171 | 
            -
                  expect(game_categories.first.name).to eq 'Morrowind'
         | 
| 172 | 
            -
                  expect(game_categories.first.parent_category).to be_nil
         | 
| 173 | 
            -
                  expect(game_categories[1].id).to eq 2
         | 
| 174 | 
            -
                  expect(game_categories[1].name).to eq 'Buildings'
         | 
| 175 | 
            -
                  expect(game_categories[1].parent_category).to be_nil
         | 
| 176 | 
            -
                end
         | 
| 177 | 
            -
             | 
| 178 | 
            -
              end
         | 
| 179 | 
            -
             | 
| 180 | 
            -
            end
         | 
| @@ -1,140 +0,0 @@ | |
| 1 | 
            -
            describe NexusMods::ModFile do
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              context 'when testing mod files' do
         | 
| 4 | 
            -
             | 
| 5 | 
            -
                # Example of JSON object returned by the API for a mod files list
         | 
| 6 | 
            -
                let(:json_example_mod_files) do
         | 
| 7 | 
            -
                  [
         | 
| 8 | 
            -
                    {
         | 
| 9 | 
            -
                      'id' => [
         | 
| 10 | 
            -
                        2472,
         | 
| 11 | 
            -
                        1704
         | 
| 12 | 
            -
                      ],
         | 
| 13 | 
            -
                      'uid' => 7_318_624_274_856,
         | 
| 14 | 
            -
                      'file_id' => 2472,
         | 
| 15 | 
            -
                      'name' => 'ApachiiSkyHair_v_1_6_Full',
         | 
| 16 | 
            -
                      'version' => '1.6.Full',
         | 
| 17 | 
            -
                      'category_id' => 4,
         | 
| 18 | 
            -
                      'category_name' => 'OLD_VERSION',
         | 
| 19 | 
            -
                      'is_primary' => false,
         | 
| 20 | 
            -
                      'file_name' => 'ApachiiSkyHair_v_1_6_Full-2014-1-6-Full.7z',
         | 
| 21 | 
            -
                      'uploaded_timestamp' => 1_477_967_645,
         | 
| 22 | 
            -
                      'uploaded_time' => '2016-11-01T02:34:05.000+00:00',
         | 
| 23 | 
            -
                      'mod_version' => '1.6.Full',
         | 
| 24 | 
            -
                      'external_virus_scan_url' => 'https://www.virustotal.com/file/3dcc96dce0b846ea643d626c48bd6ad08752da8232f3d29be644d36e1fd627cf/analysis/1477978674/',
         | 
| 25 | 
            -
                      'description' => '[b][color=orange] NOT optimized meshes. Standalone. Adds 42 new hairstyles for females, 21 hair for males and 5 hairs for Female Khajiit- 2 hairs for Male Khajiit[/color][/b]  ',
         | 
| 26 | 
            -
                      'size' => 304_347,
         | 
| 27 | 
            -
                      'size_kb' => 304_347,
         | 
| 28 | 
            -
                      'size_in_bytes' => 309_251_227,
         | 
| 29 | 
            -
                      'changelog_html' => nil,
         | 
| 30 | 
            -
                      'content_preview_link' => 'https://file-metadata.nexusmods.com/file/nexus-files-meta/1704/2014/ApachiiSkyHair_v_1_6_Full-2014-1-6-Full.7z.json'
         | 
| 31 | 
            -
                    },
         | 
| 32 | 
            -
                    {
         | 
| 33 | 
            -
                      'id' => [
         | 
| 34 | 
            -
                        2487,
         | 
| 35 | 
            -
                        1705
         | 
| 36 | 
            -
                      ],
         | 
| 37 | 
            -
                      'uid' => 7_318_624_274_857,
         | 
| 38 | 
            -
                      'file_id' => 2487,
         | 
| 39 | 
            -
                      'name' => 'ApachiiSkyHairMale_v_1_2',
         | 
| 40 | 
            -
                      'version' => '1.2',
         | 
| 41 | 
            -
                      'category_id' => 4,
         | 
| 42 | 
            -
                      'category_name' => 'OLD_VERSION',
         | 
| 43 | 
            -
                      'is_primary' => false,
         | 
| 44 | 
            -
                      'file_name' => 'ApachiiSkyHairMale_v_1_2-2014-1-2.7z',
         | 
| 45 | 
            -
                      'uploaded_timestamp' => 1_477_968_373,
         | 
| 46 | 
            -
                      'uploaded_time' => '2016-11-01T02:46:13.000+00:00',
         | 
| 47 | 
            -
                      'mod_version' => '1.2',
         | 
| 48 | 
            -
                      'external_virus_scan_url' => 'https://www.virustotal.com/file/3e86106233499ac43383c32ce4a2d8e162dc6e940b4d228f649a701b71ee5676/analysis/1477979366/',
         | 
| 49 | 
            -
                      'description' => 'NOT optimezed meshes. Standalone 55 Male hairs -  Not included in ApachiiSkyHair v_1_6_Full ',
         | 
| 50 | 
            -
                      'size' => 204_347,
         | 
| 51 | 
            -
                      'size_kb' => 204_347,
         | 
| 52 | 
            -
                      'size_in_bytes' => 209_251_227,
         | 
| 53 | 
            -
                      'changelog_html' => nil,
         | 
| 54 | 
            -
                      'content_preview_link' => 'https://file-metadata.nexusmods.com/file/nexus-files-meta/1704/2014/ApachiiSkyHairMale_v_1_2-2014-1-2.7z.json'
         | 
| 55 | 
            -
                    }
         | 
| 56 | 
            -
                  ]
         | 
| 57 | 
            -
                end
         | 
| 58 | 
            -
             | 
| 59 | 
            -
                # Expect a mod's files to be the example ones
         | 
| 60 | 
            -
                #
         | 
| 61 | 
            -
                # Parameters::
         | 
| 62 | 
            -
                # * *mod_files* (Array<NexusMods::File>): List of files to validate
         | 
| 63 | 
            -
                def expect_mod_files_to_be_example(mod_files)
         | 
| 64 | 
            -
                  expect(mod_files.size).to eq 2
         | 
| 65 | 
            -
                  sorted_mod_files = mod_files.sort_by(&:id)
         | 
| 66 | 
            -
                  first_mod_file = sorted_mod_files.first
         | 
| 67 | 
            -
                  expect(first_mod_file.ids).to eq [2472, 1704]
         | 
| 68 | 
            -
                  expect(first_mod_file.uid).to eq 7_318_624_274_856
         | 
| 69 | 
            -
                  expect(first_mod_file.id).to eq 2472
         | 
| 70 | 
            -
                  expect(first_mod_file.name).to eq 'ApachiiSkyHair_v_1_6_Full'
         | 
| 71 | 
            -
                  expect(first_mod_file.version).to eq '1.6.Full'
         | 
| 72 | 
            -
                  expect(first_mod_file.category_id).to eq :old
         | 
| 73 | 
            -
                  expect(first_mod_file.category_name).to eq 'OLD_VERSION'
         | 
| 74 | 
            -
                  expect(first_mod_file.is_primary).to be false
         | 
| 75 | 
            -
                  expect(first_mod_file.size).to eq 309_251_227
         | 
| 76 | 
            -
                  expect(first_mod_file.file_name).to eq 'ApachiiSkyHair_v_1_6_Full-2014-1-6-Full.7z'
         | 
| 77 | 
            -
                  expect(first_mod_file.uploaded_time).to eq Time.parse('2016-11-01T02:34:05.000+00:00')
         | 
| 78 | 
            -
                  expect(first_mod_file.mod_version).to eq '1.6.Full'
         | 
| 79 | 
            -
                  expect(first_mod_file.external_virus_scan_url).to eq 'https://www.virustotal.com/file/3dcc96dce0b846ea643d626c48bd6ad08752da8232f3d29be644d36e1fd627cf/analysis/1477978674/'
         | 
| 80 | 
            -
                  expect(first_mod_file.description).to eq '[b][color=orange] NOT optimized meshes. Standalone. Adds 42 new hairstyles for females, 21 hair for males and 5 hairs for Female Khajiit- 2 hairs for Male Khajiit[/color][/b]  '
         | 
| 81 | 
            -
                  expect(first_mod_file.changelog_html).to be_nil
         | 
| 82 | 
            -
                  expect(first_mod_file.content_preview_url).to eq 'https://file-metadata.nexusmods.com/file/nexus-files-meta/1704/2014/ApachiiSkyHair_v_1_6_Full-2014-1-6-Full.7z.json'
         | 
| 83 | 
            -
                  second_mod_file = sorted_mod_files[1]
         | 
| 84 | 
            -
                  expect(second_mod_file.ids).to eq [2487, 1705]
         | 
| 85 | 
            -
                  expect(second_mod_file.uid).to eq 7_318_624_274_857
         | 
| 86 | 
            -
                  expect(second_mod_file.id).to eq 2487
         | 
| 87 | 
            -
                  expect(second_mod_file.name).to eq 'ApachiiSkyHairMale_v_1_2'
         | 
| 88 | 
            -
                  expect(second_mod_file.version).to eq '1.2'
         | 
| 89 | 
            -
                  expect(second_mod_file.category_id).to eq :old
         | 
| 90 | 
            -
                  expect(second_mod_file.category_name).to eq 'OLD_VERSION'
         | 
| 91 | 
            -
                  expect(second_mod_file.is_primary).to be false
         | 
| 92 | 
            -
                  expect(second_mod_file.size).to eq 209_251_227
         | 
| 93 | 
            -
                  expect(second_mod_file.file_name).to eq 'ApachiiSkyHairMale_v_1_2-2014-1-2.7z'
         | 
| 94 | 
            -
                  expect(second_mod_file.uploaded_time).to eq Time.parse('2016-11-01T02:46:13.000+00:00')
         | 
| 95 | 
            -
                  expect(second_mod_file.mod_version).to eq '1.2'
         | 
| 96 | 
            -
                  expect(second_mod_file.external_virus_scan_url).to eq 'https://www.virustotal.com/file/3e86106233499ac43383c32ce4a2d8e162dc6e940b4d228f649a701b71ee5676/analysis/1477979366/'
         | 
| 97 | 
            -
                  expect(second_mod_file.description).to eq 'NOT optimezed meshes. Standalone 55 Male hairs -  Not included in ApachiiSkyHair v_1_6_Full '
         | 
| 98 | 
            -
                  expect(second_mod_file.changelog_html).to be_nil
         | 
| 99 | 
            -
                  expect(second_mod_file.content_preview_url).to eq 'https://file-metadata.nexusmods.com/file/nexus-files-meta/1704/2014/ApachiiSkyHairMale_v_1_2-2014-1-2.7z.json'
         | 
| 100 | 
            -
                end
         | 
| 101 | 
            -
             | 
| 102 | 
            -
                it 'returns a mod files list' do
         | 
| 103 | 
            -
                  expect_validate_user
         | 
| 104 | 
            -
                  expect_http_call_to(
         | 
| 105 | 
            -
                    path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
         | 
| 106 | 
            -
                    json: { files: json_example_mod_files }
         | 
| 107 | 
            -
                  )
         | 
| 108 | 
            -
                  expect_mod_files_to_be_example(nexus_mods.mod_files(game_domain_name: 'skyrimspecialedition', mod_id: 2014))
         | 
| 109 | 
            -
                end
         | 
| 110 | 
            -
             | 
| 111 | 
            -
                it 'returns the default mod files list' do
         | 
| 112 | 
            -
                  expect_validate_user
         | 
| 113 | 
            -
                  expect_http_call_to(
         | 
| 114 | 
            -
                    path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
         | 
| 115 | 
            -
                    json: { files: json_example_mod_files }
         | 
| 116 | 
            -
                  )
         | 
| 117 | 
            -
                  expect_mod_files_to_be_example(nexus_mods(mod_id: 2014).mod_files(game_domain_name: 'skyrimspecialedition'))
         | 
| 118 | 
            -
                end
         | 
| 119 | 
            -
             | 
| 120 | 
            -
                it 'returns mod files list for the default game' do
         | 
| 121 | 
            -
                  expect_validate_user
         | 
| 122 | 
            -
                  expect_http_call_to(
         | 
| 123 | 
            -
                    path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
         | 
| 124 | 
            -
                    json: { files: json_example_mod_files }
         | 
| 125 | 
            -
                  )
         | 
| 126 | 
            -
                  expect_mod_files_to_be_example(nexus_mods(game_domain_name: 'skyrimspecialedition').mod_files(mod_id: 2014))
         | 
| 127 | 
            -
                end
         | 
| 128 | 
            -
             | 
| 129 | 
            -
                it 'returns mod files list for the default game and mod' do
         | 
| 130 | 
            -
                  expect_validate_user
         | 
| 131 | 
            -
                  expect_http_call_to(
         | 
| 132 | 
            -
                    path: '/v1/games/skyrimspecialedition/mods/2014/files.json',
         | 
| 133 | 
            -
                    json: { files: json_example_mod_files }
         | 
| 134 | 
            -
                  )
         | 
| 135 | 
            -
                  expect_mod_files_to_be_example(nexus_mods(game_domain_name: 'skyrimspecialedition', mod_id: 2014).mod_files)
         | 
| 136 | 
            -
                end
         | 
| 137 | 
            -
             | 
| 138 | 
            -
              end
         | 
| 139 | 
            -
             | 
| 140 | 
            -
            end
         |