File tree Expand file tree Collapse file tree 10 files changed +51
-82
lines changed Expand file tree Collapse file tree 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
44COPY Gemfile /usr/src/app/
55COPY Gemfile.lock /usr/src/app/
66
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 && \
88 bundle install -j 4 && \
99 apk del build-base && rm -fr /usr/share/ri
1010
1111RUN adduser -u 9000 -D app
12+ COPY . /usr/src/app
13+ RUN chown -R app:app /usr/src/app
14+
1215USER app
1316
14- COPY . /usr/src/app
17+ RUN cd /usr/src/app && \
18+ rake docs:scrape
1519
1620CMD ["/usr/src/app/bin/codeclimate-rubocop" ]
Original file line number Diff line number Diff line change @@ -59,6 +59,3 @@ DEPENDENCIES
5959 rake
6060 rubocop
6161 rubocop-rspec
62-
63- BUNDLED WITH
64- 1.10.6
Original file line number Diff line number Diff line change 11require 'rake/testtask'
22
3+ Rake . add_rakelib 'lib/tasks'
4+
35Rake ::TestTask . new do |t |
46 t . test_files = Dir . glob ( 'spec/**/*_spec.rb' )
57 t . libs = %w[ lib spec ]
Original file line number Diff line number Diff line change 77
88test :
99 override :
10- - bundle exec rake
1110 - 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
1212
1313deployment :
1414 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