<commit_before>Skeets
=====

![skeets](http://img1.wikia.nocookie.net/__cb20110522030251/marvel_dc/images/2/2b/Skeets_JLU_1.jpg)

Skeets is a networking image library that fetches, caches, and displays images via HTTP in Swift. It is built off [SwiftHTTP](https://github.com/daltoniam/SwiftHTTP).

## Features

- Multi level cache. In-memory and disk caching.
- Nonblocking IO. All HTTP and disk IO happen in the background, thanks to GCD.
- Simple one method to load a remote image.
- Robust, fast, and customizable caching.
- Simple concise codebase at just a few hundred LOC.
- handles redundant image requests, so only one request is sent for multiple queries

Full article here: [Vluxe](http://vluxe.io/skeets.html)

## Example

First thing is to import the framework. See the Installation instructions, on how to add the framework to your project.

```swift
//iOS
import Skeets
//OS X
import SkeetsOSX
```

Once imported, you can start requesting images.

```swift
//create a imageView
let imageView = UIImageView(frame: CGRectMake(0, 60, 200, 200))
self.view.addSubview(imageView)

//set the cache directory. Only have to do this once since `sharedManager` is a singleton
let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
ImageManager.sharedManager.cache.diskDirectory = "\(paths[0])/ImageCache"

//for OSX
//let paths = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true)
//ImageManager.sharedManager.cache.diskDirectory = "\(paths[0])/\(NSBundle.mainBundle().bundleIdentifier!)/ImageCache"

ImageManager.sharedManager.cache.cleanDisk()

//fetch the image
ImageManager.sharedManager.fetch("http://vluxe.io/assets/images/logo.png",
    progress: { (status: Double) in
        println("updating some UI for this: \(status)") //useful if you have some kind of progress dialog as the image loads
    },success: { (data: NSData) in
        println("got an image!")
        imageView.image = UIImage(data: data) //set the image data
    }, failure: { (error: NSError) in
        println("failed to get an image: \(error)")
})
```

## Custom Cache

Skeets also supports customized caching and protocols. It is possible to implement your own custom cache by implementing the `CacheProtocol`. There is also a powerful default cache provided with a few customization options.

```swift
let c = ImageManager.sharedManager.cache as? ImageCache
if let cache = c {
    cache.diskAge = 60 * 60 //360 seconds or 1 hour (Default is 1 day).
    cache.imageCount = 10 //only 10 images will be stored in memory (Default is 50).
}
```

The cache can also be manually purged (e.g. memory warning is received).

```swift
ImageManager.sharedManager.cache.clearCache()
```

The disk can also be clean for possibly stale entries as well.

```swift
ImageManager.sharedManager.cache.cleanDisk()
```

## Requirements

Skeets requires at least iOS 8/OSX 10.10 or above.

Skeets depends on [SwiftHTTP](https://github.com/daltoniam/SwiftHTTP). Make sure to import that framework as well before using Skeets.

## Installation

### Cocoapods

```
Coming soon...(Hopefully!)
```

### Carthage

Check out the [Carthage](https://github.com/Carthage/Carthage) docs on how to add a install. The `Skeets` framework is already setup with shared schemes.

[Carthage Install](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application)

### Rogue

First see the [installation docs](https://github.com/acmacalister/Rogue) for how to install Rogue.

To install Skeets run the command below in the directory you created the rogue file.

```
rogue add https://github.com/daltoniam/Skeets
```

Next open the `libs` folder and add the `Skeets.xcodeproj` to your Xcode project. Once that is complete, in your "Build Phases" add the `Skeets.framework` to your "Link Binary with Libraries" phase. Make sure to add the `libs` folder to your `.gitignore` file.

### Other<commit_msg>README update<commit_after>Skeets
=====

![skeets](http://img1.wikia.nocookie.net/__cb20110522030251/marvel_dc/images/2/2b/Skeets_JLU_1.jpg)

Skeets is a networking image library that fetches, caches, and displays images via HTTP in Swift. It is built off [SwiftHTTP](https://github.com/daltoniam/SwiftHTTP).

## Features

- Multi level cache. In-memory and disk caching.
- Nonblocking IO. All HTTP and disk IO happen in the background, thanks to GCD.
- Simple one method to load a remote image.
- Robust, fast, and customizable caching.
- Simple concise codebase at just a few hundred LOC.
- handles redundant image requests, so only one request is sent for multiple queries

Full article here: [Vluxe](http://vluxe.io/skeets.html)

## Example

First thing is to import the framework. See the Installation instructions, on how to add the framework to your project.

```swift
//iOS
import Skeets
//OS X
import SkeetsOSX
```

Once imported, you can start requesting images.

```swift
//create a imageView
let imageView = UIImageView(frame: CGRectMake(0, 60, 200, 200))
self.view.addSubview(imageView)

//set the cache directory. Only have to do this once since `sharedManager` is a singleton
let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
ImageManager.sharedManager.cache.diskDirectory = "\(paths[0])/ImageCache"

//for OSX
//let paths = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true)
//ImageManager.sharedManager.cache.diskDirectory = "\(paths[0])/\(NSBundle.mainBundle().bundleIdentifier!)/ImageCache"

ImageManager.sharedManager.cache.cleanDisk()

//fetch the image
ImageManager.sharedManager.fetch("http://vluxe.io/assets/images/logo.png",
    progress: { (status: Double) in
        println("updating some UI for this: \(status)") //useful if you have some kind of progress dialog as the image loads
    },success: { (data: NSData) in
        println("got an image!")
        imageView.image = UIImage(data: data) //set the image data
    }, failure: { (error: NSError) in
        println("failed to get an image: \(error)")
})
```

## Custom Cache

Skeets also supports customized caching and protocols. It is possible to implement your own custom cache by implementing the `CacheProtocol`. There is also a powerful default cache provided with a few customization options.

```swift
let c = ImageManager.sharedManager.cache as? ImageCache
if let cache = c {
    cache.diskAge = 60 * 60 //360 seconds or 1 hour (Default is 1 day).
    cache.imageCount = 10 //only 10 images will be stored in memory (Default is 50).
}
```

The cache can also be manually purged (e.g. memory warning is received).

```swift
ImageManager.sharedManager.cache.clearCache()
```

The disk can also be clean for possibly stale entries as well.

```swift
ImageManager.sharedManager.cache.cleanDisk()
```

## Requirements

Skeets requires at least iOS 8/OSX 10.10 or above.

Skeets depends on [SwiftHTTP](https://github.com/daltoniam/SwiftHTTP). Make sure to import that framework as well before using Skeets.

## Installation

### Cocoapods

### [CocoaPods](http://cocoapods.org/) 
At this time, Cocoapods support for Swift frameworks is supported in a [pre-release](http://blog.cocoapods.org/Pod-Authors-Guide-to-CocoaPods-Frameworks/).

To use Skeets in your project add the following 'Podfile' to your project

    source 'https://github.com/CocoaPods/Specs.git'

    xcodeproj 'YourProjectName.xcodeproj'
    platform :ios, '8.0'

    pod 'Skeets', :git => "https://github.com/daltoniam/skeets.git", :branch => "cocoapods"

    target 'YourProjectNameTests' do
        pod 'Skeets', :git => "https://github.com/daltoniam/skeets.git", :branch => "cocoapods"
    end

Then run:

    pod install

#### Updating the Cocoapod
You can validate Skeets.podspec using:

    pod spec lint Skeets.podspec

This should be tested with a sample project before releasing it. This can be done by adding the following line to a ```Podfile```:
    
    pod 'Skeets', :git => 'https://github.com/username/skeets.git'

Then run:
    
    pod install

If all goes well you are ready to release. First, create a tag and push:

    git tag 'version'
    git push --tags

Once the tag is available you can send the library to the Specs repo. For this you'll have to follow the instructions in [Getting Setup with Trunk](http://guides.cocoapods.org/making/getting-setup-with-trunk.html).

    pod trunk push Skeets.podspec



### Carthage

Check out the [Carthage](https://github.com/Carthage/Carthage) docs on how to add a install. The `Skeets` framework is already setup with shared schemes.

[Carthage Install](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application)

### Rogue

First see the [installation docs](https://github.com/acmacalister/Rogue) for how to install Rogue.

To install Skeets run the command below in the directory you created the rogue file.

```
rogue add https://github.com/daltoniam/Skeets
```

Next open the `libs` folder and add the `Skeets.xcodeproj` to your Xcode project. Once that is complete, in your "Build Phases" add the `Skeets.framework` to your "Link Binary with Libraries" phase. Make sure to add the `libs` folder to your `.gitignore` file.

### Other
{'fraction_non_alphanumeric': 0.106756904268093, 'fraction_numerical': 0.010915838882218098, 'mean_word_length': 4.179197286602601, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '994922', 'n_tokens_mistral': 2945, 'n_tokens_neox': 2729, 'n_words': 1021}