Skip to content

Commit

Permalink
Initial skeleton with subscription support.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Aug 16, 2017
0 parents commit 99fd14b
Show file tree
Hide file tree
Showing 112 changed files with 3,375 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env.sample
@@ -0,0 +1,4 @@
SLACK_CLIENT_ID=
SLACK_CLIENT_SECRET=
STRIPE_API_PUBLISHABLE_KEY=
STRIPE_API_KEY=
6 changes: 6 additions & 0 deletions .gitignore
@@ -0,0 +1,6 @@
.DS_Store
.rvmrc
.irbrc
.bundle
log
.env
3 changes: 3 additions & 0 deletions .rspec
@@ -0,0 +1,3 @@
--color
--format=documentation

5 changes: 5 additions & 0 deletions .rubocop.yml
@@ -0,0 +1,5 @@
Style/FrozenStringLiteralComment:
Enabled: false

inherit_from: .rubocop_todo.yml

57 changes: 57 additions & 0 deletions .rubocop_todo.yml
@@ -0,0 +1,57 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-08-16 12:45:08 -0400 using RuboCop version 0.49.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
Lint/UselessAssignment:
Exclude:
- 'slack-sup/commands/subscription.rb'

# Offense count: 6
Metrics/AbcSize:
Max: 36

# Offense count: 29
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 71

# Offense count: 2
Metrics/CyclomaticComplexity:
Max: 11

# Offense count: 115
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 242

# Offense count: 5
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 23

# Offense count: 2
Metrics/PerceivedComplexity:
Max: 11

# Offense count: 26
Style/Documentation:
Enabled: false

# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Style/FileName:
Exclude:
- 'slack-sup.rb'

# Offense count: 3
Style/MultilineBlockChain:
Exclude:
- 'spec/api/endpoints/credit_cards_endpoint_spec.rb'
- 'spec/api/endpoints/subscriptions_endpoint_spec.rb'
1 change: 1 addition & 0 deletions .ruby-version
@@ -0,0 +1 @@
2.4.1
20 changes: 20 additions & 0 deletions .travis.yml
@@ -0,0 +1,20 @@
rvm:
- 2.3.1

language: ruby

cache: bundler

services:
- mongodb

addons:
firefox: 54.0

before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- wget https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz
- mkdir geckodriver
- tar -xzf geckodriver-v0.18.0-linux64.tar.gz -C geckodriver
- export PATH=$PATH:$PWD/geckodriver
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,3 @@
### Changelog

* 8/16/2017: Initial public release, Artsy hackathon 2017 - [@dblock](https://github.com/dblock).
125 changes: 125 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,125 @@
# Contributing to SlackSup

This project is work of [many contributors](https://github.com/dblock/slack-sup/graphs/contributors).

You're encouraged to submit [pull requests](https://github.com/dblock/slack-sup/pulls), [propose features and discuss issues](https://github.com/dblock/slack-sup/issues).

In the examples below, substitute your Github username for `contributor` in URLs.

## Fork the Project

Fork the [project on Github](https://github.com/dblock/slack-sup) and check out your copy.

```
git clone https://github.com/contributor/slack-sup.git
cd slack-sup
git remote add upstream https://github.com/dblock/slack-sup.git
```

## Create a Topic Branch

Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.

```
git checkout master
git pull upstream master
git checkout -b my-feature-branch
```

## Bundle Install and Test

Ensure that you can build the project and run tests.

```
bundle install
bundle exec rake
```

## Write Tests

Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build.
Add to [spec](spec).

We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.

## Write Code

Implement your feature or bug fix.

Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop).
Run `bundle exec rubocop` and fix any style issues highlighted.

Make sure that `bundle exec rake` completes without errors.

## Write Documentation

Document any external behavior in the [README](README.md).

## Update Changelog

Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*.
Make it look like every other line, including your name and link to your Github account.

## Commit Changes

Make sure git knows your name and email address:

```
git config --global user.name "Your Name"
git config --global user.email "contributor@example.com"
```

Writing good commit logs is important. A commit log should describe what changed and why.

```
git add ...
git commit
```

## Push

```
git push origin my-feature-branch
```

## Make a Pull Request

Go to https://github.com/contributor/slack-sup and select your feature branch.
Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.

## Rebase

If you've been working on a change for a while, rebase with upstream/master.

```
git fetch upstream
git rebase upstream/master
git push origin my-feature-branch -f
```

## Update CHANGELOG Again

Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.

```
* [#123](https://github.com/dblock/slack-sup/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
```

Amend your previous commit and force push the changes.

```
git commit --amend
git push origin my-feature-branch -f
```

## Check on Your Pull Request

Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.

## Be Patient

It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!

## Thank You

Please do know that we really appreciate and value your time and work. We love you, really.
25 changes: 25 additions & 0 deletions DEBUGGING.md
@@ -0,0 +1,25 @@
## Debugging

### Locally

You can debug your instance of slack-sup with a built-in `script/console`.

### Silence Mongoid Logger

If Mongoid logging is annoying you.

```ruby
Mongoid.logger.level = Logger::INFO
Mongo::Logger.logger.level = Logger::INFO
```

### Heroku

```
heroku run script/console --app=...
Running `script/console` attached to terminal... up, run.7593
2.2.1 > Team.count
=> 3
```
60 changes: 60 additions & 0 deletions DEV.md
@@ -0,0 +1,60 @@
## Development Environment

You may want to watch [Your First Slack Bot Service video](http://code.dblock.org/2016/03/11/your-first-slack-bot-service-video.html) first.

### Prerequisites

Ensure that you can build the project and run tests. You will need these.

- [MongoDB](https://docs.mongodb.com/manual/installation/)
- [Firefox](https://www.mozilla.org/firefox/new/)
- [Geckodriver](https://github.com/mozilla/geckodriver), download, `tar vfxz` and move to `/usr/local/bin`
- Ruby 2.3.1

```
bundle install
bundle exec rake
```

### Slack Team

Create a Slack team [here](https://slack.com/create).

### Slack App

Create a test app [here](https://api.slack.com/apps). This gives you a client ID and a client secret.

Under _Features/OAuth & Permissions_, configure the redirect URL to `http://localhost:5000`.

Add the following Permission Scope.

* Add a bot user with the username @bot.

### Slack Keys

Create a `.env` file.

```
SLACK_CLIENT_ID=slack_client_id
SLACK_CLIENT_SECRET=slack_client_secret
```

### Stripe Keys

If you want to test paid features or payment-related functions you need a [Stripe](https://www.stripe.com) account and test keys. Add to `.env` file.

```
STRIPE_API_PUBLISHABLE_KEY=pk_test_key
STRIPE_API_KEY=sk_test_key
```

### Start the Bot

```
$ foreman start
08:54:07 web.1 | started with pid 32503
08:54:08 web.1 | I, [2017-08-04T08:54:08.138999 #32503] INFO -- : listening on addr=0.0.0.0:5000 fd=11
```

Navigate to [localhost:5000](http://localhost:5000).
36 changes: 36 additions & 0 deletions Gemfile
@@ -0,0 +1,36 @@
source 'http://rubygems.org'

ruby '2.4.1'

gem 'mongoid'
gem 'mongoid-scroll'
gem 'newrelic_rpm'
gem 'rack-robotz'
gem 'rack-server-pages'
gem 'slack-ruby-bot-server'
gem 'slack-ruby-client'
gem 'stripe', '~> 1.58.0'

group :development, :test do
gem 'foreman'
gem 'rake', '~> 10.4'
gem 'rubocop', '0.49.1'
end

group :development do
gem 'mongoid-shell'
end

group :test do
gem 'capybara'
gem 'database_cleaner'
gem 'fabrication'
gem 'faker'
gem 'hyperclient'
gem 'rack-test'
gem 'rspec'
gem 'selenium-webdriver'
gem 'stripe-ruby-mock', '~> 2.4.1', require: 'stripe_mock'
gem 'vcr'
gem 'webmock'
end

0 comments on commit 99fd14b

Please sign in to comment.