Skip to content

Commit eea07aa

Browse files
committed
feat: Setup configuration
1 parent 8fdbab9 commit eea07aa

File tree

5 files changed

+38
-8
lines changed

5 files changed

+38
-8
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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,21 @@ 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+
end
117+
```
118+
104119
## Development
105120

106121
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
# frozen_string_literal: true
22

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

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

lib/codeclimate_diff/configuration.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
module CodeclimateDiff
44
class Configuration
5-
attr_accessor :main_branch_name
6-
7-
#using_gitlab: true
8-
9-
# gitlab host
10-
11-
# project id
5+
attr_accessor :gitlab
126

7+
def initialize
8+
@gitlab = {
9+
main_branch_name: "main",
10+
project_id: nil,
11+
host: nil,
12+
personal_access_token: nil
13+
}
14+
end
1315
end
1416
end

0 commit comments

Comments
 (0)