github-nippou 3.0.0.beta1 → 3.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/Gemfile.lock +24 -17
- data/README.md +9 -4
- data/Rakefile +4 -0
- data/github-nippou.gemspec +2 -0
- data/lib/github/nippou.rb +1 -0
- data/lib/github/nippou/commands.rb +34 -46
- data/lib/github/nippou/format.rb +13 -8
- data/lib/github/nippou/settings.rb +110 -0
- data/lib/github/nippou/version.rb +1 -1
- data/spec/fixtures/settings-invalid.yml +7 -0
- data/spec/fixtures/settings-valid.yml +7 -0
- data/spec/github/nippou/settings_spec.rb +96 -0
- data/spec/spec_helper.rb +12 -6
- data/spec/support/load_fixture.rb +5 -0
- metadata +40 -4
- data/spec/github/nippou/commands_spec.rb +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b2635f8f5c14d8ecf0f10ffa0595d01a8b3a6a2
|
4
|
+
data.tar.gz: 394c46d23a5672976d245179a8cbcee420a8f92f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97396ec2e51a931f4124c6b48e0b917d1fb14c11653ea551d3a0bf9c65b98d49259882043228c4d365458dd7642a559afbcfb6b9fd5f1f5ef7f1ab08bc9a5d17
|
7
|
+
data.tar.gz: 2309f8a4184accc68c906c6328e8d7bba76839c8aad9df220b7a6bf53d6ac7ca7725c59c62807efbe44178c1e946620f5e38f7cda6a225e25bddc98f6d0ee891
|
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
github-nippou (3.0.0.
|
4
|
+
github-nippou (3.0.0.beta2)
|
5
5
|
activesupport
|
6
|
+
highline
|
7
|
+
launchy
|
6
8
|
octokit
|
7
9
|
parallel
|
8
10
|
thor
|
@@ -10,23 +12,28 @@ PATH
|
|
10
12
|
GEM
|
11
13
|
remote: https://rubygems.org/
|
12
14
|
specs:
|
13
|
-
activesupport (5.
|
15
|
+
activesupport (5.1.3)
|
14
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
17
|
i18n (~> 0.7)
|
16
18
|
minitest (~> 5.1)
|
17
19
|
tzinfo (~> 1.1)
|
18
|
-
addressable (2.
|
19
|
-
|
20
|
+
addressable (2.5.1)
|
21
|
+
public_suffix (~> 2.0, >= 2.0.2)
|
22
|
+
concurrent-ruby (1.0.5)
|
20
23
|
diff-lcs (1.3)
|
21
|
-
faraday (0.
|
24
|
+
faraday (0.12.2)
|
22
25
|
multipart-post (>= 1.2, < 3)
|
23
|
-
|
24
|
-
|
26
|
+
highline (1.7.8)
|
27
|
+
i18n (0.8.6)
|
28
|
+
launchy (2.4.3)
|
29
|
+
addressable (~> 2.3)
|
30
|
+
minitest (5.10.3)
|
25
31
|
multipart-post (2.0.0)
|
26
|
-
octokit (4.
|
27
|
-
sawyer (~> 0.
|
28
|
-
parallel (1.
|
29
|
-
|
32
|
+
octokit (4.7.0)
|
33
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
34
|
+
parallel (1.12.0)
|
35
|
+
public_suffix (2.0.5)
|
36
|
+
rake (12.0.0)
|
30
37
|
rspec (3.6.0)
|
31
38
|
rspec-core (~> 3.6.0)
|
32
39
|
rspec-expectations (~> 3.6.0)
|
@@ -40,12 +47,12 @@ GEM
|
|
40
47
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
48
|
rspec-support (~> 3.6.0)
|
42
49
|
rspec-support (3.6.0)
|
43
|
-
sawyer (0.
|
44
|
-
addressable (>= 2.3.5, < 2.
|
45
|
-
faraday (~> 0.8, < 0
|
46
|
-
thor (0.19.
|
47
|
-
thread_safe (0.3.
|
48
|
-
tzinfo (1.2.
|
50
|
+
sawyer (0.8.1)
|
51
|
+
addressable (>= 2.3.5, < 2.6)
|
52
|
+
faraday (~> 0.8, < 1.0)
|
53
|
+
thor (0.19.4)
|
54
|
+
thread_safe (0.3.6)
|
55
|
+
tzinfo (1.2.3)
|
49
56
|
thread_safe (~> 0.1)
|
50
57
|
|
51
58
|
PLATFORMS
|
data/README.md
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
-
# Github::Nippou
|
1
|
+
# Github::Nippou
|
2
|
+
|
3
|
+
[![Travis Status](https://img.shields.io/travis/masutaka/github-nippou.svg?style=flat-square)][travisci]
|
4
|
+
[![License](https://img.shields.io/github/license/masutaka/github-nippou.svg?style=flat-square)][license]
|
5
|
+
[![Gem](https://img.shields.io/gem/v/github-nippou.svg?style=flat-square)][gem-link]
|
6
|
+
|
7
|
+
[travisci]: https://travis-ci.org/masutaka/github-nippou
|
8
|
+
[license]: https://github.com/masutaka/github-nippou/blob/master/LICENSE.txt
|
9
|
+
[gem-link]: http://badge.fury.io/rb/github-nippou
|
2
10
|
|
3
11
|
Displays today's your GitHub action.
|
4
12
|
|
@@ -70,6 +78,3 @@ You can omit the sub command `list`.
|
|
70
78
|
In Japanese
|
71
79
|
|
72
80
|
[github-nippou - GitHubから日報を作成 MOONGIFT](http://www.moongift.jp/2016/06/github-nippou-github%E3%81%8B%E3%82%89%E6%97%A5%E5%A0%B1%E3%82%92%E4%BD%9C%E6%88%90/)
|
73
|
-
|
74
|
-
[gem-badge]: https://badge.fury.io/rb/github-nippou.svg
|
75
|
-
[gem-link]: http://badge.fury.io/rb/github-nippou
|
data/Rakefile
CHANGED
data/github-nippou.gemspec
CHANGED
@@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
23
|
spec.add_dependency 'activesupport'
|
24
|
+
spec.add_dependency 'highline'
|
25
|
+
spec.add_dependency 'launchy'
|
24
26
|
spec.add_dependency 'octokit'
|
25
27
|
spec.add_dependency 'parallel'
|
26
28
|
spec.add_dependency 'thor'
|
data/lib/github/nippou.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'highline/import'
|
2
|
+
require 'launchy'
|
1
3
|
require 'parallel'
|
2
4
|
require 'thor'
|
3
5
|
require 'yaml'
|
@@ -14,7 +16,7 @@ module Github
|
|
14
16
|
aliases: :u, desc: 'Retrieves GitHub user_events until the date'
|
15
17
|
class_option :debug, type: :boolean, default: false, aliases: :d, desc: 'Debug mode'
|
16
18
|
|
17
|
-
desc 'list', "Displays today's GitHub events formatted for Nippou"
|
19
|
+
desc 'list', "Displays today's GitHub events formatted for Nippou (Default)"
|
18
20
|
def list
|
19
21
|
lines = []
|
20
22
|
mutex = Mutex.new
|
@@ -36,35 +38,48 @@ module Github
|
|
36
38
|
puts <<~MESSAGE
|
37
39
|
** Gist scope required.
|
38
40
|
|
39
|
-
You need personal access token which has gist scope.
|
40
|
-
Please add gist scope
|
41
|
+
You need personal access token which has `gist` scope.
|
42
|
+
Please add `gist` scope to your personal access token, visit
|
43
|
+
https://github.com/settings/tokens
|
41
44
|
MESSAGE
|
42
45
|
exit!
|
43
46
|
end
|
44
|
-
|
47
|
+
|
48
|
+
if settings.gist_id.present?
|
45
49
|
puts <<~MESSAGE
|
46
50
|
** Already initialized.
|
47
51
|
|
48
|
-
|
52
|
+
Your `~/.gitconfig` already has gist_id as `github-nippou.settings-gist-id`.
|
49
53
|
MESSAGE
|
50
|
-
exit
|
54
|
+
exit
|
55
|
+
end
|
56
|
+
|
57
|
+
puts 'This command will create a gist and update your `~/.gitconfig`.'
|
58
|
+
|
59
|
+
unless HighLine.agree('Are you sure? [y/n] ')
|
60
|
+
puts 'Canceled.'
|
61
|
+
abort
|
51
62
|
end
|
52
63
|
|
53
|
-
|
54
|
-
|
55
|
-
public: true,
|
56
|
-
files: { 'settings.yml' => { content: settings.to_yaml }}
|
57
|
-
).to_h
|
58
|
-
`git config --global github-nippou.settings-gist-id #{result[:id]}`
|
64
|
+
gist = settings.create_gist
|
65
|
+
`git config --global github-nippou.settings-gist-id #{gist.id}`
|
59
66
|
|
60
67
|
puts <<~MESSAGE
|
61
|
-
The github-nippou settings was created on
|
62
|
-
|
63
|
-
|
68
|
+
The github-nippou settings was created on #{gist.html_url}
|
69
|
+
|
70
|
+
And the gist_id was appended to your `~/.gitconfig`. You can
|
71
|
+
check the gist_id with following command.
|
72
|
+
|
64
73
|
$ git config --global github-nippou.settings-gist-id
|
65
74
|
MESSAGE
|
66
75
|
end
|
67
76
|
|
77
|
+
desc 'open-settings', 'Open settings url with web browser'
|
78
|
+
def open_settings
|
79
|
+
puts "Open #{settings.url}"
|
80
|
+
Launchy.open(settings.url)
|
81
|
+
end
|
82
|
+
|
68
83
|
desc 'version', 'Displays version'
|
69
84
|
def version
|
70
85
|
puts VERSION
|
@@ -93,7 +108,7 @@ module Github
|
|
93
108
|
puts <<~MESSAGE
|
94
109
|
** User required.
|
95
110
|
|
96
|
-
Please set github-nippou.user to your
|
111
|
+
Please set github-nippou.user to your `~/.gitconfig`.
|
97
112
|
$ git config --global github-nippou.user [Your GitHub account]
|
98
113
|
MESSAGE
|
99
114
|
exit!
|
@@ -111,10 +126,10 @@ module Github
|
|
111
126
|
puts <<~MESSAGE
|
112
127
|
** Authorization required.
|
113
128
|
|
114
|
-
Please set github-nippou.token to your
|
129
|
+
Please set github-nippou.token to your `~/.gitconfig`.
|
115
130
|
$ git config --global github-nippou.token [Your GitHub access token]
|
116
131
|
|
117
|
-
To get new token with `repo` scope, visit
|
132
|
+
To get new token with `repo` and `gist` scope, visit
|
118
133
|
https://github.com/settings/tokens/new
|
119
134
|
MESSAGE
|
120
135
|
exit!
|
@@ -122,34 +137,7 @@ module Github
|
|
122
137
|
end
|
123
138
|
|
124
139
|
def settings
|
125
|
-
|
126
|
-
|
127
|
-
yaml_data =
|
128
|
-
case
|
129
|
-
when ENV['GITHUB_NIPPOU_SETTINGS']
|
130
|
-
ENV['GITHUB_NIPPOU_SETTINGS'].chomp
|
131
|
-
when !`git config github-nippou.settings`.chomp.empty?
|
132
|
-
`git config github-nippou.settings`.chomp
|
133
|
-
when !`git config github-nippou.settings-gist-id`.chomp.empty?
|
134
|
-
gist_id = `git config github-nippou.settings-gist-id`.chomp
|
135
|
-
gist = client.gist(gist_id)
|
136
|
-
gist[:files][:'settings.yml'][:content]
|
137
|
-
end
|
138
|
-
|
139
|
-
@settings =
|
140
|
-
if yaml_data
|
141
|
-
YAML.load(yaml_data).deep_symbolize_keys
|
142
|
-
else
|
143
|
-
YAML.load_file(File.expand_path('../../../config/settings.yml', __dir__)).deep_symbolize_keys
|
144
|
-
end
|
145
|
-
rescue Psych::SyntaxError => e
|
146
|
-
puts <<~MESSAGE
|
147
|
-
** YAML syntax error.
|
148
|
-
|
149
|
-
#{e.message}
|
150
|
-
#{yaml_data}
|
151
|
-
MESSAGE
|
152
|
-
exit
|
140
|
+
@settings ||= Settings.new(client: client)
|
153
141
|
end
|
154
142
|
|
155
143
|
def thread_num
|
data/lib/github/nippou/format.rb
CHANGED
@@ -4,8 +4,10 @@ module Github
|
|
4
4
|
using SawyerResourceGithub
|
5
5
|
using StringMarkdown
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
# @param client [Octokit::Client]
|
8
|
+
# @param thread_num [Integer]
|
9
|
+
# @param settings [Settings]
|
10
|
+
# @param debug [Boolean]
|
9
11
|
def initialize(client, thread_num, settings, debug)
|
10
12
|
@client = client
|
11
13
|
@thread_num = thread_num
|
@@ -55,6 +57,8 @@ module Github
|
|
55
57
|
|
56
58
|
private
|
57
59
|
|
60
|
+
attr_reader :settings
|
61
|
+
|
58
62
|
def issue(user_event)
|
59
63
|
case
|
60
64
|
when user_event.payload.pull_request
|
@@ -71,23 +75,24 @@ module Github
|
|
71
75
|
lines.sort { |a, b| a[:url] <=> b[:url] }
|
72
76
|
end
|
73
77
|
|
74
|
-
def format_status(status)
|
75
|
-
settings[:dictionary][:status][status]
|
76
|
-
end
|
77
|
-
|
78
78
|
def format_subject(subject)
|
79
|
-
sprintf(settings
|
79
|
+
sprintf(settings.format.subject, subject: subject)
|
80
80
|
end
|
81
81
|
|
82
82
|
def format_line(line)
|
83
83
|
sprintf(
|
84
|
-
settings
|
84
|
+
settings.format.line,
|
85
85
|
title: line[:title].markdown_escape,
|
86
86
|
url: line[:url],
|
87
87
|
user: line[:user],
|
88
88
|
status: format_status(line[:status])
|
89
89
|
).strip
|
90
90
|
end
|
91
|
+
|
92
|
+
def format_status(status)
|
93
|
+
return nil if status.nil?
|
94
|
+
settings.dictionary.status.send(status)
|
95
|
+
end
|
91
96
|
end
|
92
97
|
end
|
93
98
|
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module Github
|
5
|
+
module Nippou
|
6
|
+
class Settings
|
7
|
+
# @param client [Octokit::Client]
|
8
|
+
def initialize(client:)
|
9
|
+
@client = client
|
10
|
+
end
|
11
|
+
|
12
|
+
# Getting gist id which has settings.yml
|
13
|
+
#
|
14
|
+
# @return [String] gist id
|
15
|
+
def gist_id
|
16
|
+
@gist_id ||=
|
17
|
+
begin
|
18
|
+
ENV['GITHUB_NIPPOU_SETTINGS_GIST_ID'] ||
|
19
|
+
begin
|
20
|
+
git_config = `git config github-nippou.settings-gist-id`.chomp
|
21
|
+
git_config.present? ? git_config : nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Create gist with config/settings.yml
|
27
|
+
#
|
28
|
+
# @return [Sawyer::Resource]
|
29
|
+
def create_gist
|
30
|
+
client.create_gist(
|
31
|
+
description: 'github-nippou settings',
|
32
|
+
public: true,
|
33
|
+
files: { 'settings.yml' => { content: default_settings.to_yaml }}
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Getting settings url
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
def url
|
41
|
+
@url ||=
|
42
|
+
if gist_id
|
43
|
+
client.gist(gist_id).html_url
|
44
|
+
else
|
45
|
+
"https://github.com/masutaka/github-nippou/blob/v#{VERSION}/config/settings.yml"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Getting format settings
|
50
|
+
#
|
51
|
+
# @return [OpenStruct]
|
52
|
+
def format
|
53
|
+
open_struct(data[:format])
|
54
|
+
end
|
55
|
+
|
56
|
+
# Getting dictionary settings
|
57
|
+
#
|
58
|
+
# @return [OpenStruct]
|
59
|
+
def dictionary
|
60
|
+
open_struct(data[:dictionary])
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
attr_reader :client
|
66
|
+
|
67
|
+
# Getting default settings.yml as Hash
|
68
|
+
#
|
69
|
+
# return [Hash]
|
70
|
+
def default_settings
|
71
|
+
@default_settings ||=
|
72
|
+
YAML.load_file(
|
73
|
+
File.expand_path('../../../config/settings.yml', __dir__)
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Getting settings data as Hash
|
78
|
+
#
|
79
|
+
# return [Hash]
|
80
|
+
def data
|
81
|
+
@data ||=
|
82
|
+
begin
|
83
|
+
if gist_id.present?
|
84
|
+
gist = client.gist(gist_id)
|
85
|
+
yaml_data = gist[:files][:'settings.yml'][:content]
|
86
|
+
YAML.load(yaml_data).deep_symbolize_keys
|
87
|
+
else
|
88
|
+
default_settings.deep_symbolize_keys
|
89
|
+
end
|
90
|
+
rescue Psych::SyntaxError
|
91
|
+
puts <<~MESSAGE
|
92
|
+
** YAML syntax error.
|
93
|
+
|
94
|
+
#{$!.message}
|
95
|
+
#{yaml_data}
|
96
|
+
MESSAGE
|
97
|
+
raise $!
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Cast to OpenStruct
|
102
|
+
#
|
103
|
+
# @param hash [Hash]
|
104
|
+
# @return [OpenStruct]
|
105
|
+
def open_struct(hash)
|
106
|
+
JSON.parse(hash.to_json, object_class: OpenStruct)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
describe Github::Nippou::Settings do
|
2
|
+
let(:client) { Octokit::Client.new(login: 'taro', access_token: '1234abcd') }
|
3
|
+
let(:settings) { described_class.new(client: client) }
|
4
|
+
|
5
|
+
after { ENV['GITHUB_NIPPOU_SETTINGS_GIST_ID'] = nil }
|
6
|
+
|
7
|
+
describe '#gist_id' do
|
8
|
+
before { ENV['GITHUB_NIPPOU_SETTINGS_GIST_ID'] = '0123456789' }
|
9
|
+
|
10
|
+
it 'is valid' do
|
11
|
+
expect(settings.gist_id).to eq '0123456789'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#create_gist' do
|
16
|
+
it 'responds to #create_gist' do
|
17
|
+
expect(settings).to respond_to :create_gist
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#url' do
|
22
|
+
context 'given gist_id' do
|
23
|
+
let(:gist_id) { '0123456789' }
|
24
|
+
|
25
|
+
before do
|
26
|
+
ENV['GITHUB_NIPPOU_SETTINGS_GIST_ID'] = gist_id
|
27
|
+
response = OpenStruct.new(html_url: "https://gist.github.com/#{gist_id}")
|
28
|
+
allow(client).to receive(:gist).and_return(response)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'is gist url' do
|
32
|
+
expect(settings.url).to eq "https://gist.github.com/#{gist_id}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'given no gist_id' do
|
37
|
+
it 'is github url' do
|
38
|
+
expect(settings.url).to eq "https://github.com/masutaka/github-nippou/blob/v#{Github::Nippou::VERSION}/config/settings.yml"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#format' do
|
44
|
+
before do
|
45
|
+
ENV['GITHUB_NIPPOU_SETTINGS_GIST_ID'] = '12345'
|
46
|
+
allow(client).to receive(:gist).and_return( files: { 'settings.yml': { content: settings_yaml } } )
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'given valid settings' do
|
50
|
+
let(:settings_yaml) { load_fixture('settings-valid.yml') }
|
51
|
+
|
52
|
+
it 'is valid `subject`' do
|
53
|
+
expect(settings.format.subject).to eq '### %{subject}'
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'is valid `line`' do
|
57
|
+
expect(settings.format.line).to eq '* [%{title}](%{url}) by %{user} %{status}'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'given invalid settings' do
|
62
|
+
let(:settings_yaml) { load_fixture('settings-invalid.yml') }
|
63
|
+
|
64
|
+
it 'outputs YAML syntax error message' do
|
65
|
+
expect { settings.format }.to raise_error Psych::SyntaxError
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#dictionary' do
|
71
|
+
before do
|
72
|
+
ENV['GITHUB_NIPPOU_SETTINGS_GIST_ID'] = '12345'
|
73
|
+
allow(client).to receive(:gist).and_return( files: { 'settings.yml': { content: settings_yaml } } )
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'given valid settings' do
|
77
|
+
let(:settings_yaml) { load_fixture('settings-valid.yml') }
|
78
|
+
|
79
|
+
it 'is valid `status.merged`' do
|
80
|
+
expect(settings.dictionary.status.merged).to eq '**merged!**'
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'is valid `status.closed`' do
|
84
|
+
expect(settings.dictionary.status.closed).to eq '**closed!**'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'given invalid settings' do
|
89
|
+
let(:settings_yaml) { load_fixture('settings-invalid.yml') }
|
90
|
+
|
91
|
+
it 'outputs YAML syntax error message' do
|
92
|
+
expect { settings.dictionary }.to raise_error Psych::SyntaxError
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -14,8 +14,14 @@
|
|
14
14
|
|
15
15
|
require 'github/nippou'
|
16
16
|
|
17
|
+
Dir[File.expand_path('support/**/*.rb', __dir__)].each do |f|
|
18
|
+
require f
|
19
|
+
end
|
20
|
+
|
17
21
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
18
22
|
RSpec.configure do |config|
|
23
|
+
config.include LoadFixtureHelper
|
24
|
+
|
19
25
|
# rspec-expectations config goes here. You can use an alternate
|
20
26
|
# assertion/expectation library such as wrong or the stdlib/minitest
|
21
27
|
# assertions if you prefer.
|
@@ -46,6 +52,12 @@ RSpec.configure do |config|
|
|
46
52
|
# triggering implicit auto-inclusion in groups with matching metadata.
|
47
53
|
config.shared_context_metadata_behavior = :apply_to_host_groups
|
48
54
|
|
55
|
+
# Run specs in random order to surface order dependencies. If you find an
|
56
|
+
# order dependency and want to debug it, you can fix the order by providing
|
57
|
+
# the seed, which is printed after each run.
|
58
|
+
# --seed 1234
|
59
|
+
config.order = :random
|
60
|
+
|
49
61
|
# The settings below are suggested to provide a good initial experience
|
50
62
|
# with RSpec, but feel free to customize to your heart's content.
|
51
63
|
=begin
|
@@ -87,12 +99,6 @@ RSpec.configure do |config|
|
|
87
99
|
# particularly slow.
|
88
100
|
config.profile_examples = 10
|
89
101
|
|
90
|
-
# Run specs in random order to surface order dependencies. If you find an
|
91
|
-
# order dependency and want to debug it, you can fix the order by providing
|
92
|
-
# the seed, which is printed after each run.
|
93
|
-
# --seed 1234
|
94
|
-
config.order = :random
|
95
|
-
|
96
102
|
# Seed global randomization in this process using the `--seed` CLI option.
|
97
103
|
# Setting this allows you to use `--seed` to deterministically reproduce
|
98
104
|
# test failures related to randomization by passing the same `--seed` value
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-nippou
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.
|
4
|
+
version: 3.0.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Masuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07
|
11
|
+
date: 2017-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: highline
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: launchy
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: octokit
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,6 +148,7 @@ extra_rdoc_files: []
|
|
120
148
|
files:
|
121
149
|
- ".gitignore"
|
122
150
|
- ".rspec"
|
151
|
+
- ".travis.yml"
|
123
152
|
- Gemfile
|
124
153
|
- Gemfile.lock
|
125
154
|
- LICENSE.txt
|
@@ -133,10 +162,14 @@ files:
|
|
133
162
|
- lib/github/nippou/concerns/sawyer_resource_github.rb
|
134
163
|
- lib/github/nippou/concerns/string_markdown.rb
|
135
164
|
- lib/github/nippou/format.rb
|
165
|
+
- lib/github/nippou/settings.rb
|
136
166
|
- lib/github/nippou/user_events.rb
|
137
167
|
- lib/github/nippou/version.rb
|
138
|
-
- spec/
|
168
|
+
- spec/fixtures/settings-invalid.yml
|
169
|
+
- spec/fixtures/settings-valid.yml
|
170
|
+
- spec/github/nippou/settings_spec.rb
|
139
171
|
- spec/spec_helper.rb
|
172
|
+
- spec/support/load_fixture.rb
|
140
173
|
homepage: https://github.com/masutaka/github-nippou
|
141
174
|
licenses:
|
142
175
|
- MIT
|
@@ -162,5 +195,8 @@ signing_key:
|
|
162
195
|
specification_version: 4
|
163
196
|
summary: Print today's your GitHub action.
|
164
197
|
test_files:
|
165
|
-
- spec/
|
198
|
+
- spec/fixtures/settings-invalid.yml
|
199
|
+
- spec/fixtures/settings-valid.yml
|
200
|
+
- spec/github/nippou/settings_spec.rb
|
166
201
|
- spec/spec_helper.rb
|
202
|
+
- spec/support/load_fixture.rb
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Github::Nippou::Commands do
|
4
|
-
let(:commands) { described_class.new }
|
5
|
-
|
6
|
-
describe '#settings' do
|
7
|
-
subject(:execute) { commands.send(:settings) }
|
8
|
-
|
9
|
-
let(:settings) do
|
10
|
-
{
|
11
|
-
format: {
|
12
|
-
subject: '### %{subject}',
|
13
|
-
line: '* [%{title}](%{url}) by %{user} %{status}',
|
14
|
-
},
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
let(:yaml) { settings.to_yaml }
|
19
|
-
|
20
|
-
context "when ENV['GITHUB_NIPPOU_SETTINGS'] present" do
|
21
|
-
before { ENV['GITHUB_NIPPOU_SETTINGS'] = yaml }
|
22
|
-
|
23
|
-
context 'given valid YAML syntax' do
|
24
|
-
it 'should set YAML value to @settings' do
|
25
|
-
expect { execute }
|
26
|
-
.to change { commands.instance_variable_get(:@settings) }
|
27
|
-
.to settings
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'given invalid YAML syntax' do
|
32
|
-
before do
|
33
|
-
ENV['GITHUB_NIPPOU_SETTINGS'] = <<~INVALID_YAML
|
34
|
-
format:
|
35
|
-
**!!invalid!!**
|
36
|
-
line: '* [%{title}](%{url}) by %{user} %{status}'
|
37
|
-
INVALID_YAML
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should output YAML syntax error message' do
|
41
|
-
expect {
|
42
|
-
begin
|
43
|
-
execute
|
44
|
-
rescue SystemExit
|
45
|
-
nil
|
46
|
-
end
|
47
|
-
}.to output(<<~ERROR).to_stdout
|
48
|
-
** YAML syntax error.
|
49
|
-
|
50
|
-
(<unknown>): did not find expected alphabetic or numeric character while scanning an alias at line 2 column 3
|
51
|
-
format:
|
52
|
-
**!!invalid!!**
|
53
|
-
line: '* [%{title}](%{url}) by %{user} %{status}'
|
54
|
-
ERROR
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|