File tree 10 files changed +51
-82
lines changed
10 files changed +51
-82
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,17 @@ WORKDIR /usr/src/app
4
4
COPY Gemfile /usr/src/app/
5
5
COPY Gemfile.lock /usr/src/app/
6
6
7
- RUN apk --update add ruby ruby-dev ruby-bundler build-base && \
7
+ RUN apk --update add ruby ruby-dev ruby-bundler build-base git && \
8
8
bundle install -j 4 && \
9
9
apk del build-base && rm -fr /usr/share/ri
10
10
11
11
RUN adduser -u 9000 -D app
12
+ COPY . /usr/src/app
13
+ RUN chown -R app:app /usr/src/app
14
+
12
15
USER app
13
16
14
- COPY . /usr/src/app
17
+ RUN cd /usr/src/app && \
18
+ rake docs:scrape
15
19
16
20
CMD ["/usr/src/app/bin/codeclimate-rubocop" ]
Original file line number Diff line number Diff line change @@ -59,6 +59,3 @@ DEPENDENCIES
59
59
rake
60
60
rubocop
61
61
rubocop-rspec
62
-
63
- BUNDLED WITH
64
- 1.10.6
Original file line number Diff line number Diff line change 1
1
require 'rake/testtask'
2
2
3
+ Rake . add_rakelib 'lib/tasks'
4
+
3
5
Rake ::TestTask . new do |t |
4
6
t . test_files = Dir . glob ( 'spec/**/*_spec.rb' )
5
7
t . libs = %w[ lib spec ]
Original file line number Diff line number Diff line change 7
7
8
8
test :
9
9
override :
10
- - bundle exec rake
11
10
- docker build -t=$PRIVATE_REGISTRY/$CIRCLE_PROJECT_REPONAME:b$CIRCLE_BUILD_NUM .
11
+ - docker run $PRIVATE_REGISTRY/$CIRCLE_PROJECT_REPONAME:b$CIRCLE_BUILD_NUM bundle exec rake
12
12
13
13
deployment :
14
14
registry :
Original file line number Diff line number Diff line change
1
+ * .md
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ namespace :docs do
2
+ desc "Scrapes documentation from the rubocop gem"
3
+ task :scrape do
4
+ TAG = "v0.34.2"
5
+ COP_FOLDERS = %w[ lint metrics performance rails style ]
6
+
7
+ %x{git clone https://github.com/bbatsov/rubocop.git rubocop-git}
8
+ %x{cd rubocop-git && git checkout tags/#{ TAG } }
9
+
10
+ files = Dir . glob ( "./rubocop-git/lib/rubocop/cop/{#{ COP_FOLDERS . join ( ',' ) } }/**.rb" )
11
+
12
+ documentation = files . each_with_object ( { } ) do |file , hash |
13
+ content = File . read ( file )
14
+ class_doc = content . match ( /(\s +#.*)+/ ) . to_s
15
+ doc_lines = class_doc .
16
+ gsub ( /^\n / , "" ) .
17
+ split ( "\n " ) .
18
+ map { |line | line . gsub ( /\s +#\s ?/ , "" ) } .
19
+ join ( "\n " )
20
+ hash [ file ] = doc_lines
21
+ end
22
+
23
+ documentation . each do |file_path , documentation |
24
+ namespace = file_path . split ( '/' ) . slice ( -2 , 1 ) . join ( '/' )
25
+ file_name = File . basename ( file_path , '.rb' )
26
+
27
+ folder_path = "./config/contents/#{ namespace } "
28
+ write_path = "#{ folder_path } /#{ file_name } .md"
29
+
30
+ puts "Writing documentation to #{ write_path } "
31
+
32
+
33
+ FileUtils . mkdir_p ( folder_path )
34
+ File . open ( write_path , 'w' ) do |file |
35
+ file . write ( documentation )
36
+ end
37
+ end
38
+
39
+ %x{rm -rf rubocop-git}
40
+ end
41
+ end
You can’t perform that action at this time.
0 commit comments