Class: InchCI::Worker::Build::BadgeDetector
- Inherits:
-
Object
- Object
- InchCI::Worker::Build::BadgeDetector
- Defined in:
- lib/inch_ci/worker/build/badge_detector.rb
Class Method Summary collapse
Instance Method Summary collapse
- #detected? ⇒ Boolean
-
#initialize(contents, info) ⇒ BadgeDetector
constructor
A new instance of BadgeDetector.
Constructor Details
#initialize(contents, info) ⇒ BadgeDetector
21 22 23 24 |
# File 'lib/inch_ci/worker/build/badge_detector.rb', line 21 def initialize(contents, info) @contents = contents @pattern = Regexp.escape("inch-ci.org/#{info.service_name}/#{info.user_name}/#{info.repo_name}") end |
Class Method Details
.find_readme(repo) ⇒ String
15 16 17 18 19 |
# File 'lib/inch_ci/worker/build/badge_detector.rb', line 15 def self.find_readme(repo) Dir[File.join(repo.path, '*.*')].sort.detect do |f| File.basename(f) =~ /\Areadme\./i end end |
.in_readme?(repo, info) ⇒ Boolean
5 6 7 8 9 10 11 12 |
# File 'lib/inch_ci/worker/build/badge_detector.rb', line 5 def self.in_readme?(repo, info) if filename = find_readme(repo) contents = File.read(filename, :encoding => 'utf-8') new(contents, info).detected? else false end end |
Instance Method Details
#detected? ⇒ Boolean
26 27 28 |
# File 'lib/inch_ci/worker/build/badge_detector.rb', line 26 def detected? !!( @contents =~ /#{@pattern}/mi ) end |