Skip to content

Commit e70ac10

Browse files
Merge pull request #1 from boost/configuration
Setup Configuration
2 parents 628eca3 + db41db1 commit e70ac10

File tree

5 files changed

+46
-5
lines changed

5 files changed

+46
-5
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ Style/StringLiteralsInInterpolation:
1111

1212
Layout/LineLength:
1313
Max: 120
14+
15+
Style/Documentation:
16+
Enabled: false

Gemfile.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ GEM
4949
unicode-display_width (2.3.0)
5050

5151
PLATFORMS
52+
ruby
5253
x86_64-darwin-19
5354

5455
DEPENDENCIES

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,25 @@ NOTE: similar code will only work correctly if you run a diff on all the files i
101101
```
102102
4. Now you have time to fix the issues yay!
103103
104+
## Configuration
105+
106+
Example:
107+
108+
```rb
109+
CodeclimateDiff.configure do |config|
110+
config.gitlab = {
111+
main_branch_name: "main", # Required. Defaults to "main"
112+
project_id: 123, # Required. Gitlab's Project ID. Defaults nil.
113+
host: "https://org.gitlab.org", # Required. Gitlab's Host. e.g. https://org.gitlab.org. Defaults nil.
114+
personal_access_token: ENV["GITLAB_PERSONAL_ACCESS_TOKEN"] # Required. Your personal access token. Defaults nil.
115+
}
116+
117+
config.github = {
118+
# TODO: Add GitHub requirements
119+
}
120+
end
121+
```
122+
104123
## Development
105124

106125
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

lib/codeclimate_diff.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# frozen_string_literal: true
22

33
require_relative "codeclimate_diff/version"
4+
require_relative "codeclimate_diff/configuration"
45

56
module CodeclimateDiff
7+
class << self
8+
def configuration
9+
@configuration ||= Configuration.new
10+
end
11+
12+
def configure
13+
yield(configuration)
14+
end
15+
end
616
end

lib/codeclimate_diff/configuration.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22

33
module CodeclimateDiff
44
class Configuration
5-
attr_accessor :main_branch_name
5+
attr_accessor :gitlab,
6+
:github
67

7-
# using_gitlab: true
8+
def initialize
9+
@gitlab = {
10+
main_branch_name: "main",
11+
project_id: nil,
12+
host: nil,
13+
personal_access_token: nil
14+
}
815

9-
# gitlab host
10-
11-
# project id
16+
@github = {
17+
# TODO: Add GitHub requirements
18+
}
19+
end
1220
end
1321
end

0 commit comments

Comments
 (0)