Last active
May 18, 2018 11:05
-
-
Save sevab/497ead350f25e82c5034686c6b163192 to your computer and use it in GitHub Desktop.
Emebr Services Feature Analyzer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just drop the file at the root of the project and run with
ruby service_analyzer.rb
.