Skip to content

iOS Mobile Coding Challenge #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Xcode
xcuserdata/
project.xcworkspace/
Pods/
21 changes: 21 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'mobile-coding-challenge' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

# Pods for mobile-coding-challenge
pod 'Moya'
pod 'SwiftyJSON'
pod 'Kingfisher'

end

target 'mobile-coding-challenge-unit-tests' do
inherit! :search_paths

pod 'Moya'
pod 'SwiftyJSON'

end
32 changes: 32 additions & 0 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
PODS:
- Alamofire (5.2.2)
- Kingfisher (5.15.0):
- Kingfisher/Core (= 5.15.0)
- Kingfisher/Core (5.15.0)
- Moya (14.0.0):
- Moya/Core (= 14.0.0)
- Moya/Core (14.0.0):
- Alamofire (~> 5.0)
- SwiftyJSON (5.0.0)

DEPENDENCIES:
- Kingfisher
- Moya
- SwiftyJSON

SPEC REPOS:
trunk:
- Alamofire
- Kingfisher
- Moya
- SwiftyJSON

SPEC CHECKSUMS:
Alamofire: 814429acc853c6c54ff123fc3d2ef66803823ce0
Kingfisher: 1acb67597a520c2d0310677e66d6e0af455ef757
Moya: 5b45dacb75adb009f97fde91c204c1e565d31916
SwiftyJSON: 36413e04c44ee145039d332b4f4e2d3e8d6c4db7

PODFILE CHECKSUM: 9a7dc13e8ed477ab04dc26d1d80a1fa72dece796

COCOAPODS: 1.9.3
59 changes: 12 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,18 @@
# Mobile Coding Challenge
# Mobile Coding Challenge by [Gemography](https://github.com/gemography)

## Idea of the App
The task is to implement a small app that will list the most starred Github repos that were created in the last 30 days.
You'll be fetching the sorted JSON data directly from the Github API (Github API explained down below).
## Idea of the App

## Features
* As a User I should be able to list the most starred Github repos that were created in the last 30 days.
* As a User I should see the results as a list. One repository per row.
* As a User I should be able to see for each repo/row the following details :
* Repository name
* Repository description
* Numbers of stars for the repo.
* Username and avatar of the owner.
* [BONUS] As a User I should be able to keep scrolling and new results should appear (pagination).
The task is just to implement a small app that will list the most starred Github repos that were created in the last 30 days.

## Things to keep in mind 🚨
* Features are less important than code quality. Put more focus on code quality and less on speed and number of features implemented.
* Your code will be evaluated based on: code structure, programming best practices, legibility (and not number of features implemented or speed).
* The git commit history (and git commit messages) will be also evaluated.
* Do not forget to include few details about the project in the README (e.g explain choice of libraries, how to run it ...)
## How to run the challenge project?

## How to get the data from Github
To get the most starred Github repos created in the last 30 days (relative to 2017-11-22), you'll need to call the following endpoint :

`https://api.github.com/search/repositories?q=created:>2017-10-22&sort=stars&order=desc`

The JSON data from Github will be paginated (you'll receive around 100 repos per JSON page).

To get the 2nd page, you add `&page=2` to the end of your API request :

`https://api.github.com/search/repositories?q=created:>2017-10-22&sort=stars&order=desc&page=2`

To get the 3rd page, you add `&page=3` ... etc

You can read more about the Github API over [here](https://developer.github.com/v3/search/#search-repositories
).

## Mockups
![alt text](https://raw.githubusercontent.com/hiddenfounders/mobile-coding-challenge/master/mockup.png)

Here's what each element represents :

![alt text](https://raw.githubusercontent.com/hiddenfounders/mobile-coding-challenge/master/row-explained.png)


## Technologies to use
Choose whatever mobile platform you're most familiar with.

* For iOS, feel free to use Swift or Objective-C.
* For Android, feel free to use Kotlin or Java.
1. Clone this repo.
2. Open shell window and navigate to project folder.
3. Run
```bash
pod install
```
4. Open mobile-coding-challenge.xcworkspace and run the project on selected device or simulator.


Good luck!
22 changes: 22 additions & 0 deletions mobile-coding-challenge-unit-tests/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
//
// MostStarredGithubReposJSONTests.swift
// mobile-coding-challenge-unit-tests
//
// Created by Mobile on 9/20/20.
// Copyright © 2020 Zakariae. All rights reserved.
//

import XCTest
import Moya
import SwiftyJSON

class MostStarredGithubReposJSONTests: XCTestCase {

override func setUp() {
super.setUp()

self.continueAfterFailure = false

}

func testForIsTheMostStarredGithubReposJSONCorrect(){

let expectation = self.expectation(description: "theMostStarredGithubReposJSONExpectation")

var previousMonthDate: Date?

if let _previousMonthDate = Calendar.current.date(byAdding: .month, value: -1, to: Date()){

previousMonthDate = _previousMonthDate

let requestProvider = MoyaProvider<RequestHandler>()

requestProvider.request(.getMostGithubRepos(created_at: previousMonthDate!.formattedDate(using: "YYYY-MM-dd"), page: 1)) { result in

switch result {
case let .success(moyaResponse):

let responseJSON = JSON(moyaResponse.data)

var mostStarredGithubRepos: [JSON]?
var totalCount : Int?

if moyaResponse.statusCode == 200{

if let _mostStarredGithubRepos = responseJSON["items"].array{

if let _totalCount = responseJSON["total_count"].int{

mostStarredGithubRepos = _mostStarredGithubRepos

totalCount = _totalCount

var totalChecks: Int = 0

for _mostStarredGithubRepo in mostStarredGithubRepos!{

let mostStarredGithubRepo = GithubRepositoryEntity(from: _mostStarredGithubRepo)

XCTAssertNotNil(mostStarredGithubRepo, "TEST: IS THE MOST STARRED GITHUB REPOS JSON CORRECT => Response JSON is not fit : Something missed from GithubRepositoryEntity")

totalChecks += 1

}

XCTAssertEqual(totalChecks, mostStarredGithubRepos!.count)
expectation.fulfill()

return

}

XCTAssertNotNil(totalCount, "TEST: IS THE MOST STARRED GITHUB REPOS JSON CORRECT => Response JSON is not fit : (total_count => Int) is not exists or is not an integer.")

return

}

XCTAssertNotNil(mostStarredGithubRepos, "TEST: IS THE MOST STARRED GITHUB REPOS JSON CORRECT => Response JSON is not fit : [items] is not exists or is not an array.")

return

}

XCTAssertEqual(moyaResponse.statusCode, 200, "TEST: IS THE MOST STARRED GITHUB REPOS JSON CORRECT => Created_at is not fit")
expectation.fulfill()


default:
expectation.fulfill()

}

}

self.wait(for: [expectation], timeout: 10.0)

return

}

XCTAssertNotNil(previousMonthDate, "TEST: IS THE MOST STARRED GITHUB REPOS JSON CORRECT => Previous month date is incorrect")

}

}
23 changes: 23 additions & 0 deletions mobile-coding-challenge-unit-tests/ShortValueOfIntTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// ShortValueOfIntTests.swift
// mobile-coding-challenge-unit-tests
//
// Created by Mobile on 9/20/20.
// Copyright © 2020 Zakariae. All rights reserved.
//

import XCTest

class ShortValueOfIntTests: XCTestCase {

func testForIsShortValueOfIntCorrect(){

XCTAssertEqual(100.shortValue, "100")
XCTAssertEqual((-800).shortValue, "-800")
XCTAssertEqual(8000.shortValue, "8.0K")
XCTAssertEqual(2000000.shortValue, "2.0M")
XCTAssertEqual(100000000000.shortValue, "+100...")

}

}
Loading