<commit_before># Correspondence Tools - Staff
[![Build Status](https://travis-ci.org/ministryofjustice/correspondence_tool_staff.svg?branch=develop)](https://travis-ci.org/ministryofjustice/correspondence_tool_staff)
[![Code Climate](https://codeclimate.com/github/ministryofjustice/correspondence_tool_staff/badges/gpa.svg)](https://codeclimate.com/github/ministryofjustice/correspondence_tool_staff)
[![Test Coverage](https://codeclimate.com/github/ministryofjustice/correspondence_tool_staff/badges/coverage.svg)](https://codeclimate.com/github/ministryofjustice/correspondence_tool_staff/coverage)
[![Issue Count](https://codeclimate.com/github/ministryofjustice/correspondence_tool_staff/badges/issue_count.svg)](https://codeclimate.com/github/ministryofjustice/correspondence_tool_staff)
[![Build Status](https://semaphoreci.com/api/v1/aliuk2012/correspondence_tool_staff/branches/ct-1778-ico-filter/badge.svg)](https://semaphoreci.com/aliuk2012/correspondence_tool_staff)

A simple application to allow internal staff users to answer correspondence.

## Development

### Working on the Code

Work should be based off of, and PRed to, the master branch. We use the GitHub
PR approval process so once your PR is ready you'll need to have one person
approve it, and the CI tests passing, before it can be merged. Feel free to use
the issue tags on your PR to indicate if it is a WIP or if it is ready for
reviewing.


### Basic Setup

#### Cloning This Repository

Clone this repository change to the new directory

```bash
$ git clone <EMAIL>:ministryofjustice/correspondence_tool_staff.git
$ cd correspondence_tool_staff
```

#### Building with Docker Compose

This project is buildable with `docker-compose`. Install [Docker for
Mac](https://docs.docker.com/docker-for-mac/) and then run this in the
repository directory:

```
$ docker-compose up
```

This will build and run all the Docker containers locally and publish port 3000
from the web container locally. The application will be available on
http://localhost:3000/


#### Installing Dependencies

**NB**: The instructions below are only required if you want to run the application
natively without Docker. Only use if necessary, otherwise use the "Building with
Docker Compose" instructions above.

<details>
<summary>Latest Version of Ruby</summary>

Install the latest version of ruby as defined in `.ruby-version`.

With rbenv (make sure you are in the repo path):

```
$ rbenv install
$ gem install bundler
```
</details>

<details>
<summary>Installing Postgres 9.5.x</summary>

We use version 9.5.x of PostgreSQL to match what we have in the deployed
environments, and also because the `structure.sql` file generated by PostgreSQL
can change with every different version.

```
$ brew install postgresql@9.5
```
</details>

<details>
<summary>Installing Latest XCode Stand-Alone Command-Line Tools</summary>

May be necessary to ensure that libraries are available for gems, for example
Nokogiri can have problems with `libiconv` and `libxml`.

```
$ xcode-select --install
```
</details>

<details>
<summary>Browser testing</summary>

We use [headless chrome](https://developers.google.com/web/updates/2017/04/headless-chrome)
for Capybara tests, which require JavaScript. You will need to install Chrome >= 59. 
Where we don't require JavaScript to test a feature we use Capybara's default driver 
[RackTest](https://github.com/teamcapybara/capybara#racktest) which is ruby based 
and much faster as it does not require a server to be started.

**Debugging:**

To debug a spec that requires JavaScript, you need to set a environment variable called CHROME_DEBUG.
It can be set to any value you like.

Examples:

```
$ CHROME_BEBUG=1 bundle exec rspec
```

When you have set `CHROME_DEBUG`, you should notice chrome start up and appear on your
taskbar/Docker. You can now click on chrome and watch it run through your tests.
If you have a `binding.pry`  in your tests the browser will stop at that point.<commit_msg>fix readme typo<commit_after># Correspondence Tools - Staff
[![Build Status](https://travis-ci.org/ministryofjustice/correspondence_tool_staff.svg?branch=develop)](https://travis-ci.org/ministryofjustice/correspondence_tool_staff)
[![Code Climate](https://codeclimate.com/github/ministryofjustice/correspondence_tool_staff/badges/gpa.svg)](https://codeclimate.com/github/ministryofjustice/correspondence_tool_staff)
[![Test Coverage](https://codeclimate.com/github/ministryofjustice/correspondence_tool_staff/badges/coverage.svg)](https://codeclimate.com/github/ministryofjustice/correspondence_tool_staff/coverage)
[![Issue Count](https://codeclimate.com/github/ministryofjustice/correspondence_tool_staff/badges/issue_count.svg)](https://codeclimate.com/github/ministryofjustice/correspondence_tool_staff)
[![Build Status](https://semaphoreci.com/api/v1/aliuk2012/correspondence_tool_staff/branches/ct-1778-ico-filter/badge.svg)](https://semaphoreci.com/aliuk2012/correspondence_tool_staff)

A simple application to allow internal staff users to answer correspondence.

## Development

### Working on the Code

Work should be based off of, and PRed to, the master branch. We use the GitHub
PR approval process so once your PR is ready you'll need to have one person
approve it, and the CI tests passing, before it can be merged. Feel free to use
the issue tags on your PR to indicate if it is a WIP or if it is ready for
reviewing.


### Basic Setup

#### Cloning This Repository

Clone this repository change to the new directory

```bash
$ git clone <EMAIL>:ministryofjustice/correspondence_tool_staff.git
$ cd correspondence_tool_staff
```

#### Building with Docker Compose

This project is buildable with `docker-compose`. Install [Docker for
Mac](https://docs.docker.com/docker-for-mac/) and then run this in the
repository directory:

```
$ docker-compose up
```

This will build and run all the Docker containers locally and publish port 3000
from the web container locally. The application will be available on
http://localhost:3000/


#### Installing Dependencies

**NB**: The instructions below are only required if you want to run the application
natively without Docker. Only use if necessary, otherwise use the "Building with
Docker Compose" instructions above.

<details>
<summary>Latest Version of Ruby</summary>

Install the latest version of ruby as defined in `.ruby-version`.

With rbenv (make sure you are in the repo path):

```
$ rbenv install
$ gem install bundler
```
</details>

<details>
<summary>Installing Postgres 9.5.x</summary>

We use version 9.5.x of PostgreSQL to match what we have in the deployed
environments, and also because the `structure.sql` file generated by PostgreSQL
can change with every different version.

```
$ brew install postgresql@9.5
```
</details>

<details>
<summary>Installing Latest XCode Stand-Alone Command-Line Tools</summary>

May be necessary to ensure that libraries are available for gems, for example
Nokogiri can have problems with `libiconv` and `libxml`.

```
$ xcode-select --install
```
</details>

<details>
<summary>Browser testing</summary>

We use [headless chrome](https://developers.google.com/web/updates/2017/04/headless-chrome)
for Capybara tests, which require JavaScript. You will need to install Chrome >= 59. 
Where we don't require JavaScript to test a feature we use Capybara's default driver 
[RackTest](https://github.com/teamcapybara/capybara#racktest) which is ruby based 
and much faster as it does not require a server to be started.

**Debugging:**

To debug a spec that requires JavaScript, you need to set a environment variable called CHROME_DEBUG.
It can be set to any value you like.

Examples:

```
$ CHROME_DEBUG=1 bundle exec rspec
```

When you have set `CHROME_DEBUG`, you should notice chrome start up and appear on your
taskbar/Docker. You can now click on chrome and watch it run through your tests.
If you have a `binding.pry`  in your tests the browser will stop at that point.
{'fraction_non_alphanumeric': 0.09378134403209629, 'fraction_numerical': 0.009027081243731194, 'mean_word_length': 5.236903831118061, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 37, 'https://': 26, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2664780', 'n_tokens_mistral': 2461, 'n_tokens_neox': 2326, 'n_words': 851}