Skip to content

Instantly share code, notes, and snippets.

@sevab
Last active May 18, 2018 11:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sevab/497ead350f25e82c5034686c6b163192 to your computer and use it in GitHub Desktop.
Emebr Services Feature Analyzer
services_dir_name = './app/services'
servise_dir = Dir.glob(File.join(services_dir_name, '**', '*'))
object_proxy_tests = [/ObjectProxy/, /_ProxyMixin/]
service_inject_tests = [/inject as service/]
alias_tests = [/alias/]
readonly_tests = [/readonly/]
observer_tests = [/observer/]
actions_tests = [/actions/]
exrtended_mixin_tests = [/EventedMixin/]
number_of_services = servise_dir.select { |file| File.file?(file) }.count
proxy_extends = 0
service_injects = 0
aliases = 0
readonlies = 0
observers = 0
actions = 0
extended_mixins = 0
non_volatile_cp = 0
servise_dir.each do |file|
file_contents = File.readlines(file)
object_proxy_tests.each do |regex|
!file_contents.grep(regex).empty? && (proxy_extends += 1)
end
service_inject_tests.each do |regex|
!file_contents.grep(regex).empty? && (service_injects += 1)
end
alias_tests.each do |regex|
!file_contents.grep(regex).empty? && (aliases += 1)
end
readonly_tests.each do |regex|
!file_contents.grep(regex).empty? && (readonlies += 1)
end
observer_tests.each do |regex|
!file_contents.grep(regex).empty? && (observers += 1)
end
actions_tests.each do |regex|
!file_contents.grep(regex).empty? && (actions += 1)
end
exrtended_mixin_tests.each do |regex|
!file_contents.grep(regex).empty? && (extended_mixins += 1)
end
if !file_contents.grep(/computed/).empty? && file_contents.grep(/volatile/).empty?
non_volatile_cp += 1
end
end
puts "Total services: #{number_of_services}"
puts "injects another service: #{service_injects}"
puts "is an object proxy: #{proxy_extends}"
puts "aliases: #{aliases}"
puts "readonly: #{readonlies}"
puts "non-volatile computed properties: #{non_volatile_cp}"
puts "observers: #{observers}"
puts "concatenated or merged properties: (0)"
puts "actions: #{actions}"
puts "EventedMixin: #{extended_mixins}"
@sevab
Copy link
Author

sevab commented May 18, 2018

Just drop the file at the root of the project and run with ruby service_analyzer.rb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment