• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Devex / article_json / 318
100%

Build:
DEFAULT BRANCH: master
Ran 20 Nov 2017 06:32PM UTC
Jobs 2
Files 171
Run time 36s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
318

push

travis-ci

nicolas-fricke
Rework algorithm to place additional elements

While the previous algorithm was better in saturating articles with
additional elements it did not perform well when placing a single
additional element into an article, this was always placed at the end.

Considering the known use-cases of this algorithm (placing ads or CTA
forms within an article), it seems more common that single elements are
placed than that the article is being saturated with additional
elements.

Outline of the new algorithm:
1. It calculates every how many characters (only considering paragraphs)
   an additional element should be inserted, given the number of
   additional elements provided
2. It then iterates over the existing elements within the article,
   inserting them into the resulting, merged article
3. As soon as it has passed the right amount characters, it checks if
   the current position is eligible for inserting an additional element
   (the previous element needs to be a paragraph and the following needs
   to be either a paragraph or a headline)
    a) If so, it inserts the additional element and recalculates in how
       many characters the next element should be inserted, based on the
       remaining number of characters and remaining additional elements
    b) If not, it keeps iterating over the article until it finds an
       eligible position and only then inserts the additional element
       and recalculates the number of characters until the next
       insertion
4. If there are still additional elements remaining which couldn't be
   inserted (due to not finding enough eligible positions), they are
   appended to the end of the article

4250 of 4250 relevant lines covered (100.0%)

38.11 hits per line

Jobs
ID Job ID Ran Files Coverage
1 318.1 (2.3) 20 Nov 2017 06:32PM UTC 0
100.0
Travis Job 318.1
2 318.2 (ruby-head) 20 Nov 2017 06:32PM UTC 0
100.0
Travis Job 318.2
Source Files on build 318
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #318
  • 3be44e0b on github
  • Prev Build on master (#316)
  • Next Build on master (#320)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc