problem_child 0.1.0 → 0.2.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/.travis.yml +3 -1
- data/README.md +8 -0
- data/lib/problem_child/memcache.rb +22 -0
- data/lib/problem_child/version.rb +1 -1
- data/lib/problem_child.rb +7 -0
- data/problem_child.gemspec +1 -0
- data/spec/problem_child_memcache_spec.rb +35 -0
- data/spec/problem_child_spec.rb +24 -3
- data/spec/spec_helper.rb +3 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e83ecc3d971edca9afa09d88616214477ad6674
|
4
|
+
data.tar.gz: 2a7a552a65d5457ec6d2008e647226e18f7a050f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17b494db5c8b46d04004377e62845dc8ba1cfffbeb004331acb9d1cf119a061d1bd4c8330bc798d5b4b4f122ebbd7bb053c691e94ed25ee6766936d4628abdbe
|
7
|
+
data.tar.gz: ebd5fecb4ed6e22c5522d678fdafc6ba5fd332849f8abdf7121ccc333d4364a9499aec40069c74ba5fbdf75f4e2906db7fb9775e9bcec9951765d12b92660187
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -20,6 +20,14 @@ Allows authenticated or anonymous users to fill out a standard web form to creat
|
|
20
20
|
```
|
21
21
|
3. Follow the configuration options below
|
22
22
|
|
23
|
+
## Requirements
|
24
|
+
|
25
|
+
You'll need to have [Memcache](http://memcached.org/) running.
|
26
|
+
|
27
|
+
On OS X, run `brew install memcached` to install, followed by `memcached` to run the memcache server.
|
28
|
+
|
29
|
+
On Heroku you'll want to run `heroku addons:add memcachier:dev` to add a free Memecache instance to your app.
|
30
|
+
|
23
31
|
## Configuring
|
24
32
|
|
25
33
|
You must set the following as environmental variables:
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ProblemChild
|
2
|
+
class Memcache
|
3
|
+
|
4
|
+
def self.client
|
5
|
+
Dalli::Client.new(server, options)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.options
|
9
|
+
{
|
10
|
+
:username => ENV["MEMCACHIER_USERNAME"],
|
11
|
+
:password => ENV["MEMCACHIER_PASSWORD"],
|
12
|
+
:failover => true,
|
13
|
+
:socket_timeout => 1.5,
|
14
|
+
:socket_failure_delay => 0.2
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.server
|
19
|
+
ENV["MEMCACHIER_SERVERS"].split(",") unless ENV["MEMCACHIER_SERVERS"].to_s.blank?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/problem_child.rb
CHANGED
@@ -3,10 +3,13 @@ require 'sinatra'
|
|
3
3
|
require 'sinatra_auth_github'
|
4
4
|
require 'dotenv'
|
5
5
|
require 'json'
|
6
|
+
require 'dalli'
|
7
|
+
require 'rack/session/dalli'
|
6
8
|
require 'active_support'
|
7
9
|
require 'active_support/core_ext/string'
|
8
10
|
require "problem_child/version"
|
9
11
|
require "problem_child/helpers"
|
12
|
+
require "problem_child/memcache"
|
10
13
|
|
11
14
|
module ProblemChild
|
12
15
|
|
@@ -26,6 +29,10 @@ module ProblemChild
|
|
26
29
|
|
27
30
|
include ProblemChild::Helpers
|
28
31
|
|
32
|
+
configure do
|
33
|
+
use Rack::Session::Dalli, cache: ProblemChild::Memcache.client
|
34
|
+
end
|
35
|
+
|
29
36
|
set :github_options, {
|
30
37
|
:scopes => "repo,read:org"
|
31
38
|
}
|
data/problem_child.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency "sinatra_auth_github", "~> 1.0"
|
25
25
|
spec.add_dependency "activesupport", "~> 4.2"
|
26
26
|
spec.add_dependency "rack", "1.5.2"
|
27
|
+
spec.add_dependency "dalli", "~> 2.7"
|
27
28
|
|
28
29
|
spec.add_development_dependency "rspec", "~> 3.1"
|
29
30
|
spec.add_development_dependency "rack-test", "~> 0.6"
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "ProblemChild::MemcacheHelper" do
|
4
|
+
|
5
|
+
it "knows the server" do
|
6
|
+
with_env "MEMCACHIER_SERVERS", "localhost:1234" do
|
7
|
+
expect(ProblemChild::Memcache.server).to eql(["localhost:1234"])
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "can process multiple servers" do
|
12
|
+
with_env "MEMCACHIER_SERVERS", "localhost:1234, localhost:4567" do
|
13
|
+
expect(ProblemChild::Memcache.server).to eql(["localhost:1234", " localhost:4567"])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "pulls the username and password" do
|
18
|
+
with_env "MEMCACHIER_USERNAME", "user" do
|
19
|
+
with_env "MEMCACHIER_PASSWORD", "pass" do
|
20
|
+
expected = {
|
21
|
+
:username => "user",
|
22
|
+
:password => "pass",
|
23
|
+
:failover => true,
|
24
|
+
:socket_timeout => 1.5,
|
25
|
+
:socket_failure_delay => 0.2
|
26
|
+
}
|
27
|
+
expect(ProblemChild::Memcache.options).to eql(expected)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns the client" do
|
33
|
+
expect(ProblemChild::Memcache.client.class).to eql(Dalli::Client)
|
34
|
+
end
|
35
|
+
end
|
data/spec/problem_child_spec.rb
CHANGED
@@ -107,9 +107,11 @@ describe "logged out user" do
|
|
107
107
|
|
108
108
|
it "asks the user to log in" do
|
109
109
|
with_env "GITHUB_ORG_ID", "balter-test-org" do
|
110
|
-
|
111
|
-
|
112
|
-
|
110
|
+
with_env "GITHUB_TOKEN", nil do
|
111
|
+
get "/"
|
112
|
+
expect(last_response.status).to eql(302)
|
113
|
+
expect(last_response.headers['Location']).to match(%r{^https://github\.com/login/oauth/authorize})
|
114
|
+
end
|
113
115
|
end
|
114
116
|
end
|
115
117
|
|
@@ -137,4 +139,23 @@ describe "logged out user" do
|
|
137
139
|
end
|
138
140
|
end
|
139
141
|
end
|
142
|
+
|
143
|
+
it "supports submissions > 4k" do
|
144
|
+
with_env "GITHUB_TOKEN", "1234" do
|
145
|
+
with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
|
146
|
+
long_string = "0" * 5000
|
147
|
+
|
148
|
+
stub_request(:post, "https://api.github.com/repos/benbalter/test-repo-ignore-me/issues").
|
149
|
+
with(:body => "{\"labels\":[],\"title\":\"title\",\"body\":\"* **Foo**: #{long_string}\"}").
|
150
|
+
to_return(:status => 200)
|
151
|
+
|
152
|
+
|
153
|
+
post "/", :title => "title", :foo => long_string
|
154
|
+
follow_redirect!
|
155
|
+
|
156
|
+
expect(last_response.status).to eql(200)
|
157
|
+
expect(last_response.body).to match(/Your issue was successfully submitted/)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
140
161
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: problem_child
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 1.5.2
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: dalli
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.7'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '2.7'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: rspec
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -225,6 +239,7 @@ files:
|
|
225
239
|
- config.ru
|
226
240
|
- lib/problem_child.rb
|
227
241
|
- lib/problem_child/helpers.rb
|
242
|
+
- lib/problem_child/memcache.rb
|
228
243
|
- lib/problem_child/public/vendor/bootstrap/.bower.json
|
229
244
|
- lib/problem_child/public/vendor/bootstrap/Gruntfile.js
|
230
245
|
- lib/problem_child/public/vendor/bootstrap/LICENSE
|
@@ -278,6 +293,7 @@ files:
|
|
278
293
|
- script/release
|
279
294
|
- script/server
|
280
295
|
- spec/problem_child_helpers_spec.rb
|
296
|
+
- spec/problem_child_memcache_spec.rb
|
281
297
|
- spec/problem_child_spec.rb
|
282
298
|
- spec/spec_helper.rb
|
283
299
|
homepage: https://github.com/benbalter/problem_child
|
@@ -307,5 +323,6 @@ summary: Allows authenticated or anonymous users to fill out a standard web form
|
|
307
323
|
creat GitHub issues.
|
308
324
|
test_files:
|
309
325
|
- spec/problem_child_helpers_spec.rb
|
326
|
+
- spec/problem_child_memcache_spec.rb
|
310
327
|
- spec/problem_child_spec.rb
|
311
328
|
- spec/spec_helper.rb
|