Class: MultiRepo::Helpers::ReadmeBadges
- Inherits:
-
Object
- Object
- MultiRepo::Helpers::ReadmeBadges
- Defined in:
- lib/multi_repo/helpers/readme_badges.rb
Instance Attribute Summary collapse
-
#badges ⇒ Object
Returns the value of attribute badges.
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(repo, dry_run: false) ⇒ ReadmeBadges
constructor
A new instance of ReadmeBadges.
- #save! ⇒ Object
Constructor Details
#initialize(repo, dry_run: false) ⇒ ReadmeBadges
Returns a new instance of ReadmeBadges.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/multi_repo/helpers/readme_badges.rb', line 8 def initialize(repo, dry_run: false, **) @repo = repo @dry_run = dry_run if repo.dry_run != dry_run raise ArgumentError, "expected repo.dry_run (#{repo.dry_run}) to match dry_run (#{dry_run})" end reload end |
Instance Attribute Details
#badges ⇒ Object
Returns the value of attribute badges.
6 7 8 |
# File 'lib/multi_repo/helpers/readme_badges.rb', line 6 def badges @badges end |
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run.
5 6 7 |
# File 'lib/multi_repo/helpers/readme_badges.rb', line 5 def dry_run @dry_run end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
5 6 7 |
# File 'lib/multi_repo/helpers/readme_badges.rb', line 5 def repo @repo end |
Instance Method Details
#content ⇒ Object
34 35 36 37 |
# File 'lib/multi_repo/helpers/readme_badges.rb', line 34 def content return "" unless @file File.read(repo.path.join(@file)) end |
#save! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/multi_repo/helpers/readme_badges.rb', line 19 def save! lines = content.lines apply_badges!(lines) save_contents!(lines.join) if dry_run reload(lines) else reload end true end |