ellen-github 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/ellen-github.gemspec +1 -1
- data/lib/ellen/github/actions/base.rb +4 -5
- data/lib/ellen/github/actions/create_issue.rb +6 -6
- data/lib/ellen/github/actions/remember.rb +1 -8
- data/lib/ellen/github/version.rb +1 -1
- data/lib/ellen/handlers/github.rb +2 -2
- data/spec/ellen/handlers/github_spec.rb +53 -26
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9daee4e66e51d6e4a8f8e7faba35609ca088e7ea
|
4
|
+
data.tar.gz: f6dc855d733ecaba80492406a3ef3c23ecd260ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e23e91b34ae15f824f162ceadc9e8633adb3d621ca86c1c553c6476094bcb70e879f685e277a98eb5393582bd1bd0022956ccb588ecb1296d09b0fb58688cbc
|
7
|
+
data.tar.gz: 8f47fb7aee9b2990a732fa2f1088cb12a7c3105d6e75ed3355e7b212614837843e2c41856a7905517348d009ea4e9ce0107bbaa823d5c9957b7e8a3b3f0c5584
|
data/CHANGELOG.md
CHANGED
data/ellen-github.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.add_dependency "ellen", ">= 0.
|
19
|
+
spec.add_dependency "ellen", ">= 0.2.0"
|
20
20
|
spec.add_dependency "octokit"
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
22
|
spec.add_development_dependency "rake"
|
@@ -6,17 +6,16 @@ module Ellen
|
|
6
6
|
class Base
|
7
7
|
NAMESPACE = "github"
|
8
8
|
|
9
|
-
attr_reader :message
|
9
|
+
attr_reader :message
|
10
10
|
|
11
|
-
def initialize(
|
12
|
-
@message =
|
13
|
-
@robot = options[:robot]
|
11
|
+
def initialize(message)
|
12
|
+
@message = message
|
14
13
|
end
|
15
14
|
|
16
15
|
private
|
17
16
|
|
18
17
|
def access_tokens
|
19
|
-
robot.brain.data[NAMESPACE] ||= {}
|
18
|
+
message.robot.brain.data[NAMESPACE] ||= {}
|
20
19
|
end
|
21
20
|
|
22
21
|
def sender_name
|
@@ -15,21 +15,21 @@ module Ellen
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def require_access_token
|
18
|
-
|
18
|
+
message.reply("I don't know your github access token")
|
19
19
|
end
|
20
20
|
|
21
21
|
def created
|
22
|
-
|
22
|
+
message.reply("Created a new Issue")
|
23
23
|
end
|
24
24
|
|
25
25
|
def create
|
26
|
-
|
26
|
+
message.reply("Created #{issue.html_url}")
|
27
27
|
rescue Octokit::Unauthorized
|
28
|
-
|
28
|
+
message.reply("Failed in authentication (401)")
|
29
29
|
rescue Octokit::NotFound
|
30
|
-
|
30
|
+
message.reply("Could not find that repository")
|
31
31
|
rescue => exception
|
32
|
-
|
32
|
+
message.reply("Failed by #{exception.class}")
|
33
33
|
end
|
34
34
|
|
35
35
|
def issue
|
@@ -2,13 +2,6 @@ module Ellen
|
|
2
2
|
module Github
|
3
3
|
module Actions
|
4
4
|
class Remember < Base
|
5
|
-
attr_reader :message, :robot
|
6
|
-
|
7
|
-
def initialize(options)
|
8
|
-
@message = options[:message]
|
9
|
-
@robot = options[:robot]
|
10
|
-
end
|
11
|
-
|
12
5
|
def call
|
13
6
|
remember
|
14
7
|
report
|
@@ -17,7 +10,7 @@ module Ellen
|
|
17
10
|
private
|
18
11
|
|
19
12
|
def report
|
20
|
-
|
13
|
+
message.reply("Remembered #{sender_name}'s github access token")
|
21
14
|
end
|
22
15
|
|
23
16
|
def remember
|
data/lib/ellen/github/version.rb
CHANGED
@@ -6,11 +6,11 @@ module Ellen
|
|
6
6
|
on(/remember my github token (?<token>.+)\z/, name: "remember", description: "Remember sender's GitHub access token")
|
7
7
|
|
8
8
|
def create_issue(message)
|
9
|
-
Ellen::Github::Actions::CreateIssue.new(message
|
9
|
+
Ellen::Github::Actions::CreateIssue.new(message).call
|
10
10
|
end
|
11
11
|
|
12
12
|
def remember(message)
|
13
|
-
Ellen::Github::Actions::Remember.new(message
|
13
|
+
Ellen::Github::Actions::Remember.new(message).call
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -2,14 +2,6 @@ require "spec_helper"
|
|
2
2
|
require "json"
|
3
3
|
|
4
4
|
describe Ellen::Handlers::Github do
|
5
|
-
before do
|
6
|
-
ENV["GITHUB_ACCESS_TOKEN"] = github_access_token
|
7
|
-
end
|
8
|
-
|
9
|
-
after do
|
10
|
-
ENV["GITHUB_ACCESS_TOKEN"] = nil
|
11
|
-
end
|
12
|
-
|
13
5
|
let(:robot) do
|
14
6
|
Ellen::Robot.new
|
15
7
|
end
|
@@ -18,28 +10,21 @@ describe Ellen::Handlers::Github do
|
|
18
10
|
"dummy"
|
19
11
|
end
|
20
12
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
nil
|
25
|
-
end
|
13
|
+
let(:sender) do
|
14
|
+
"bob"
|
15
|
+
end
|
26
16
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
17
|
+
let(:channel) do
|
18
|
+
"#general"
|
19
|
+
end
|
32
20
|
|
33
|
-
|
34
|
-
|
35
|
-
Ellen.should_not_receive(:die)
|
36
|
-
described_class.new(robot)
|
37
|
-
end
|
38
|
-
end
|
21
|
+
let(:access_tokens) do
|
22
|
+
robot.brain.data[Ellen::Github::Actions::Base::NAMESPACE] ||= {}
|
39
23
|
end
|
40
24
|
|
41
25
|
describe "#create_issue" do
|
42
26
|
before do
|
27
|
+
Ellen.logger.stub(:info)
|
43
28
|
stub_request(:post, "https://api.github.com/repos/#{user}/#{repository}/issues").
|
44
29
|
with(
|
45
30
|
body: {
|
@@ -65,8 +50,50 @@ describe Ellen::Handlers::Github do
|
|
65
50
|
"This is a test issue"
|
66
51
|
end
|
67
52
|
|
68
|
-
|
69
|
-
|
53
|
+
let(:body) do
|
54
|
+
%<ellen create issue "#{title}" on #{user}/#{repository}>
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when access token for the sender is remembered" do
|
58
|
+
before do
|
59
|
+
access_tokens.merge!(sender => github_access_token)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "creates a new issue with given title on given repository" do
|
63
|
+
robot.receive(
|
64
|
+
body: body,
|
65
|
+
from: sender,
|
66
|
+
to: channel,
|
67
|
+
)
|
68
|
+
a_request(:any, //).should have_been_made
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "when access token for the sender is not remembered" do
|
73
|
+
it "does not create a new issue" do
|
74
|
+
robot.receive(
|
75
|
+
body: body,
|
76
|
+
from: sender,
|
77
|
+
to: channel,
|
78
|
+
)
|
79
|
+
a_request(:any, //).should_not have_been_made
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#remember" do
|
85
|
+
let(:body) do
|
86
|
+
"@ellen remember my github token #{github_access_token}"
|
87
|
+
end
|
88
|
+
|
89
|
+
it "remembers sender's access token in its brain" do
|
90
|
+
Ellen.logger.should_receive(:info).with("Remembered #{sender}'s github access token")
|
91
|
+
robot.receive(
|
92
|
+
body: body,
|
93
|
+
from: sender,
|
94
|
+
to: channel,
|
95
|
+
)
|
96
|
+
access_tokens[sender].should == github_access_token
|
70
97
|
end
|
71
98
|
end
|
72
99
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ellen-github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ellen
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: octokit
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|