rails-scope 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +0 -0
- data/README.md +11 -0
- data/bin/rails-scope +7 -0
- data/lib/complexity/flay.rb +9 -0
- data/lib/complexity/flog.rb +9 -0
- data/lib/count/code_count.rb +80 -0
- data/lib/count/gemfile.rb +10 -0
- data/lib/rails-scope.rb +68 -0
- data/lib/security/brakeman.rb +9 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8b86cb25451385c0e092d33d553dad6d8866bdf7
|
4
|
+
data.tar.gz: b7dddadbc5448dde588b1b9bf3ee5c4cdd09adb6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 20889f4050d824f74d6b1b3e2d15c078ff17031609de6d8fd4b6a435dcc36f11e7ceccfa433867eca89d340b56a677cc0f1754bcf27ff6dc51170ce6aac49071
|
7
|
+
data.tar.gz: 19867ec4ca2e8b49beaa87cdd630cac59f993b5460b1ea0d42c93dad56da081931f80783641ad9df442566d05304f2027ef588a55eed293dc74216abb5523c38
|
data/LICENSE.txt
ADDED
File without changes
|
data/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# rails-scope
|
2
|
+
Ruby gem that allows nVisium to accurately and automatically scope a Ruby on Rails application for assessment purposes.
|
3
|
+
|
4
|
+
# Output will consist of
|
5
|
+
|
6
|
+
- Code complexity
|
7
|
+
- Routes
|
8
|
+
- Number of Controller, Views, and Models
|
9
|
+
- Lines of code within Controller, Views, and Models
|
10
|
+
- # and names of RubyGems in use
|
11
|
+
- brakeman output (--summary)
|
data/bin/rails-scope
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
class CodeCount
|
2
|
+
|
3
|
+
attr_accessor :directories, :files, :entries
|
4
|
+
attr_reader :target_dir
|
5
|
+
|
6
|
+
def self.kick_off
|
7
|
+
@directories = []
|
8
|
+
@files = []
|
9
|
+
# We need to get the line of code_count, directory count, file count, and
|
10
|
+
# ...names from the app dir
|
11
|
+
@target_dir = "#{$path}/app"
|
12
|
+
if Dir.exist?(@target_dir)
|
13
|
+
create_count
|
14
|
+
else
|
15
|
+
$output_file.puts("We weren't able to find the app/ directory looking here: #{@target_dir}")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.uninteresting_directories
|
20
|
+
%w{ . .. assets }
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# This method is just hideous but... hackathon = mvp
|
25
|
+
def self.collect_assets
|
26
|
+
@entries = Dir.entries @target_dir
|
27
|
+
@entries.delete_if {|dir| uninteresting_directories.include? dir }
|
28
|
+
@entries.each do |top_level_dir|
|
29
|
+
files_and_folders = Dir.glob("#{@target_dir}/#{top_level_dir}/**/*")
|
30
|
+
assets = files_and_folders.each do |file_or_fold|
|
31
|
+
if File.directory?(file_or_fold)
|
32
|
+
@directories << file_or_fold
|
33
|
+
elsif File.file?(file_or_fold)
|
34
|
+
@files << file_or_fold
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.print_out_info
|
41
|
+
['directories', 'files'].each_with_index do |item, idx|
|
42
|
+
$output_file.puts("The following are the names of the #{item.capitalize}: ")
|
43
|
+
$output_file.puts("-" * 30)
|
44
|
+
instance_variable_get("@#{item}").each do |asset|
|
45
|
+
$output_file.puts asset
|
46
|
+
end
|
47
|
+
$output_file.puts("\n")
|
48
|
+
end
|
49
|
+
|
50
|
+
# Being Duplication that really should be fixed
|
51
|
+
$output_file.puts("The following is the individual file LoC: ")
|
52
|
+
$output_file.puts("-" * 30)
|
53
|
+
$output_file.puts("\n")
|
54
|
+
@files.each do |file|
|
55
|
+
$output_file.puts(loc_in_file(file))
|
56
|
+
end
|
57
|
+
$output_file.puts("\n")
|
58
|
+
$output_file.puts("The following is the LoC for folders under the app directory: ")
|
59
|
+
$output_file.puts("-" * 30)
|
60
|
+
$output_file.puts("\n")
|
61
|
+
@entries.each do |entry|
|
62
|
+
$output_file.puts("#{loc_in_dir(entry)[/(\d+ total)/]}: #{entry}")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.loc_in_file(file)
|
67
|
+
%x{wc -l #{file} }
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.loc_in_dir(dir)
|
71
|
+
%x{find . #{@target_dir}/#{dir} |xargs wc -l }
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
def self.create_count
|
76
|
+
collect_assets
|
77
|
+
print_out_info
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
data/lib/rails-scope.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'security/brakeman'
|
4
|
+
require 'complexity/flog'
|
5
|
+
require 'complexity/flay'
|
6
|
+
require 'count/code_count'
|
7
|
+
require 'count/gemfile'
|
8
|
+
|
9
|
+
class RailsScope
|
10
|
+
|
11
|
+
attr_reader :options
|
12
|
+
|
13
|
+
def self.run
|
14
|
+
@options = {}
|
15
|
+
OptionParser.new do |opts|
|
16
|
+
opts.banner = "Usage: rails-scope [options]"
|
17
|
+
|
18
|
+
opts.on("-p", "--path /var/app/current", "Path to your application directory") do |p|
|
19
|
+
@options[:path] = p
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on("-o", "--path /my/dir", "The location you would like the scope.nv file stored") do |o|
|
23
|
+
@options[:output] = o
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on("-h", "--help", "Displays help information") do
|
27
|
+
puts opts
|
28
|
+
exit
|
29
|
+
end
|
30
|
+
end.parse!
|
31
|
+
start
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.klasses
|
35
|
+
%w{ Brakeman Flog Flay CodeCount Gemfile}
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.separator(tool_name='')
|
39
|
+
sep = tool_name == klasses.first ? "" : "\n"
|
40
|
+
sep << "=" * 15
|
41
|
+
sep << tool_name
|
42
|
+
sep << "=" * 15
|
43
|
+
sep << "\n\n"
|
44
|
+
$output_file.puts sep
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.start
|
48
|
+
$path = @options[:path] ? @options[:path] : Dir.pwd
|
49
|
+
$output_path = @options[:output] ? @options[:output] : Dir.pwd
|
50
|
+
$output_file = File.new("#{$output_path}/scope.nv", "w")
|
51
|
+
$tmpdir = Dir.mktmpdir
|
52
|
+
klasses.each do |klass|
|
53
|
+
separator(klass.to_s)
|
54
|
+
obj = Object.const_get(klass)
|
55
|
+
obj.kick_off
|
56
|
+
end
|
57
|
+
ensure
|
58
|
+
clean_up
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.clean_up
|
62
|
+
puts "#{$output_file}"
|
63
|
+
$output_file.close
|
64
|
+
ensure
|
65
|
+
FileUtils.remove_entry_secure $tmpdir if !$tmpdir.nil? && Dir.exists?($tmpdir)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails-scope
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ken Johnson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: brakeman
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: slim
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: flog
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: flay
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.6'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.6'
|
83
|
+
description: "\n \t\t\t\t\t\tRuby gem that allows nVisium to accurately and automatically
|
84
|
+
scope a Ruby on Rails application for assessment purposes.\n "
|
85
|
+
email:
|
86
|
+
- contact@nvisium.com
|
87
|
+
executables:
|
88
|
+
- rails-scope
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- bin/rails-scope
|
95
|
+
- lib/complexity/flay.rb
|
96
|
+
- lib/complexity/flog.rb
|
97
|
+
- lib/count/code_count.rb
|
98
|
+
- lib/count/gemfile.rb
|
99
|
+
- lib/rails-scope.rb
|
100
|
+
- lib/security/brakeman.rb
|
101
|
+
homepage: https://github.com/nVisium/rails-scope
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- "."
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.4.3
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Assists nVisium in scoping and pricing Rails assessments for our clients.
|
125
|
+
test_files: []
|