Class: ShellAdapter
- Inherits:
-
Object
- Object
- ShellAdapter
- Defined in:
- lib/git_survey/shell_adapter.rb
Overview
Adapter which handles shell access.
Class Method Summary collapse
- .activity_interval(directory) ⇒ Object
-
.authors(anonymized, directory) ⇒ Object
git shortlog -s -n.
-
.hot_files(anonymized, directory, number) ⇒ Object
git log –pretty=format: –name-only | sort | uniq -c | sort -rg | head -10.
-
.init_date(directory) ⇒ Object
git log –date=iso8601-strict –reverse |head -3 |grep “Date”.
-
.latest_activity_date(directory) ⇒ Object
git log –date=iso8601-strict |head -3 |grep “Date”.
-
.number_of_branches(directory) ⇒ Object
git branch | wc -l.
-
.number_of_commits(directory, branch) ⇒ Object
git rev-list –count <revision>.
-
.number_of_files(directory) ⇒ Object
git ls-files | wc -l.
-
.repo_name(anonimize, directory) ⇒ Object
basename ‘git rev-parse –show-toplevel`.
Class Method Details
.activity_interval(directory) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/git_survey/shell_adapter.rb', line 67 def self.activity_interval(directory) earliest = init_date(directory).to_f latest = latest_activity_date(directory).to_f diff = latest - earliest (diff / (365 * 24 * 60 * 60)).round(2) end |
.authors(anonymized, directory) ⇒ Object
git shortlog -s -n
91 92 93 |
# File 'lib/git_survey/shell_adapter.rb', line 91 def self.(anonymized, directory) hash_from_line_with_delimiter(anonymized, directory, COMMAND_AUTHORS, "\t") end |
.hot_files(anonymized, directory, number) ⇒ Object
git log –pretty=format: –name-only | sort | uniq -c | sort -rg | head -10
96 97 98 99 100 |
# File 'lib/git_survey/shell_adapter.rb', line 96 def self.hot_files(anonymized, directory, number) number_with_empty_lines = number.to_i + 1 command = COMMAND_FILES_HOT + number_with_empty_lines.to_s hash_from_line_with_delimiter(anonymized, directory, command, ' ') end |
.init_date(directory) ⇒ Object
git log –date=iso8601-strict –reverse |head -3 |grep “Date”
56 57 58 59 |
# File 'lib/git_survey/shell_adapter.rb', line 56 def self.init_date(directory) string = run_shell_command(directory, COMMAND_REPO_INIT_DATE) Time.iso8601(date_at_the_end_of_line(string)) end |
.latest_activity_date(directory) ⇒ Object
git log –date=iso8601-strict |head -3 |grep “Date”
62 63 64 65 |
# File 'lib/git_survey/shell_adapter.rb', line 62 def self.latest_activity_date(directory) string = run_shell_command(directory, COMMAND_LATEST_ACTIVITY_DATE) Time.iso8601(date_at_the_end_of_line(string)) end |
.number_of_branches(directory) ⇒ Object
git branch | wc -l
86 87 88 |
# File 'lib/git_survey/shell_adapter.rb', line 86 def self.number_of_branches(directory) run_shell_command(directory, COMMAND_BRANCHES_NUMBER).to_i end |
.number_of_commits(directory, branch) ⇒ Object
git rev-list –count <revision>
76 77 78 |
# File 'lib/git_survey/shell_adapter.rb', line 76 def self.number_of_commits(directory, branch) run_shell_command(directory, COMMAND_COMMITS_NUMBER + branch).to_i end |
.number_of_files(directory) ⇒ Object
git ls-files | wc -l
81 82 83 |
# File 'lib/git_survey/shell_adapter.rb', line 81 def self.number_of_files(directory) run_shell_command(directory, COMMAND_FILES_NUMBER).to_i end |
.repo_name(anonimize, directory) ⇒ Object
basename ‘git rev-parse –show-toplevel`
50 51 52 53 |
# File 'lib/git_survey/shell_adapter.rb', line 50 def self.repo_name(anonimize, directory) name = run_shell_command(directory, COMMAND_REPO_NAME).strip Helpers.anonymized(anonimize, name) end |