tech_radar 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12c5a51e4ba45174512792a3392836535cc46d2d
4
- data.tar.gz: 827dd7cace04d49531c568cb16a9b17005d19b04
3
+ metadata.gz: 017f7f9db5644c8fef87cc38ec4b447b60277a8f
4
+ data.tar.gz: 15926f574b2fdddb449f128db0fe1be0cccf1557
5
5
  SHA512:
6
- metadata.gz: 20905adc6a36a6f4091ba81b3549f253888bb666cfb21e5f14428b133fdfdeac86195f4f77ea7e65edb0d3a905e9f03afef2057acbdf8a97704347837d24232a
7
- data.tar.gz: 72b927aa902313753ffa53b6b2c2fc6218d1ba21d23f0560d4a10bd4f385127132b6b74f71828264f40a1dceaa066383e25808eeca8956ea1928b8da89987e8d
6
+ metadata.gz: cec199461227239004563f3c70bd7c3ada6a29f1c63640b2846d1806349ebf41362cc48a2308db38ccf49372895fd4d4cc3f7c7cd72ed802cf6fd24c3f0a8152
7
+ data.tar.gz: 8e87e6566033cc82957d4eb42e776ba486874340450e9a5398731286f8de085ac206dbe3fee4d165f298e4e4a6365bfe84a1c03dfd7447c3fb54fdad787842cb
@@ -22,5 +22,9 @@ module TechRadar
22
22
  technology.ring != 'Adopt' && technology.ring != 'Trial'
23
23
  end
24
24
 
25
+ def render_summary(summary_text)
26
+ TechRadar::Rendering.renderer.render_text(summary_text)
27
+ end
28
+
25
29
  end
26
30
  end
@@ -0,0 +1,28 @@
1
+ module TechRadar
2
+ module Rendering
3
+ class Markdown
4
+ def initialize
5
+ require 'redcarpet'
6
+ renderer = Redcarpet::Render::HTML.new(
7
+ filter_html: true,
8
+ no_styles: true,
9
+ safe_links_only: true
10
+ )
11
+ @markdown = Redcarpet::Markdown.new(renderer,
12
+ no_intra_emphasis: true,
13
+ tables: true,
14
+ fenced_code_blocks: true,
15
+ autolink: true,
16
+ disable_indented_code_blocks: true,
17
+ strikethrough: true,
18
+ superscript: true)
19
+ rescue LoadError => ex
20
+ raise "Since you speecified markdown rendering, you must include the redcarpet gem in your app: #{ex.message}"
21
+ end
22
+
23
+ def render_text(text)
24
+ @markdown.render(text).html_safe
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,9 @@
1
+ module TechRadar
2
+ module Rendering
3
+ class Plaintext
4
+ def render_text(text)
5
+ text
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module TechRadar
2
+ module Rendering
3
+ def self.renderer
4
+ @renderers ||= {}
5
+ @renderers[TechRadar.summary_format] ||= "tech_radar/rendering/#{TechRadar.summary_format}".classify.constantize.new
6
+ @renderers[TechRadar.summary_format]
7
+ end
8
+ end
9
+ end
@@ -14,7 +14,7 @@
14
14
  </p>
15
15
  <% else %>
16
16
  <% if @technology.more_details_summary.present? %>
17
- <p><%= @technology.more_details_summary %></p>
17
+ <p class="text-muted"><%= render_summary(@technology.more_details_summary) %></p>
18
18
  <% end %>
19
19
  <p>
20
20
  <%= link_to t("tech_radar.radar.technologies.more_details_url.link"), @technology.more_details_url, class: "btn btn-default" %>
@@ -26,7 +26,7 @@
26
26
  <% if @technology.why_summary.present? %>
27
27
  <p>
28
28
  <span class="text-muted">
29
- <%= @technology.why_summary %>
29
+ <%= render_summary(@technology.why_summary) %>
30
30
  </span>
31
31
  <% if @technology.why_url.present? %>
32
32
  <%= link_to t("tech_radar.radar.technologies.why_summary.link"), @technology.why_url %>
@@ -1,3 +1,3 @@
1
1
  module TechRadar
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/tech_radar.rb CHANGED
@@ -8,4 +8,8 @@ module TechRadar
8
8
  mattr_accessor :warn_on_missing_why_summary
9
9
 
10
10
  TechRadar.warn_on_missing_why_summary = Hash.new(true)
11
+
12
+ mattr_accessor :summary_format
13
+
14
+ TechRadar.summary_format = :plaintext
11
15
  end
@@ -4,6 +4,7 @@ module TechRadar
4
4
  class TechnologiesControllerTest < ActionController::TestCase
5
5
  setup do
6
6
  @routes = Engine.routes
7
+ TechRadar.summary_format = :markdown
7
8
  end
8
9
 
9
10
  test "index" do
@@ -46,7 +47,7 @@ module TechRadar
46
47
  assert_response :success
47
48
  assert response.body.include?("Ruby"),"Expected #{response.body} to include 'Ruby'"
48
49
  refute response.body.include?("Google"),"Expected #{response.body} NOT to include a link to a Google search"
49
- assert response.body.include?("object-oriented"),"Expected #{response.body} to include Ruby's summary"
50
+ assert response.body.include?("<em>object-oriented</em>"),"Expected #{response.body} to include Ruby's summary, parsed as markdown"
50
51
  end
51
52
 
52
53
  test "show with more_details_url" do
@@ -8,7 +8,6 @@
8
8
  "Trial":
9
9
  ElasticSearch:
10
10
  purpose: "Indexed Search"
11
- more_details_url:
12
11
  why_summary: "Erch and CXE using"
13
12
  HumbleKit:
14
13
  purpose: "CSS Framework"
@@ -77,7 +76,7 @@
77
76
  Ruby:
78
77
  purpose: Middleware Programming
79
78
  more_details_url: https://www.ruby-lang.org/en/
80
- more_details_summary: "Ruby is a dynamic, object-oriented programming language that combines ideas from Smalltalk, Perl, and others"
79
+ more_details_summary: "Ruby is a dynamic, _object-oriented_ programming language that combines ideas from Smalltalk, Perl, and others"
81
80
  "Trial":
82
81
  CoffeeScript:
83
82
  purpose: Browser Programming
@@ -45,7 +45,7 @@ module TechRadar
45
45
  technology = @radar.technology("Ruby")
46
46
  assert_equal "Ruby" , technology.name
47
47
  assert_equal "https://www.ruby-lang.org/en/" , technology.more_details_url
48
- assert_equal "Ruby is a dynamic, object-oriented programming language that combines ideas from Smalltalk, Perl, and others",
48
+ assert_equal "Ruby is a dynamic, _object-oriented_ programming language that combines ideas from Smalltalk, Perl, and others",
49
49
  technology.more_details_summary
50
50
  assert_equal nil , technology.why_url
51
51
  assert_equal nil , technology.why_summary
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ module TechRadar
4
+ class RenderingTest < ActiveSupport::TestCase
5
+
6
+ test "plaintext" do
7
+ TechRadar.summary_format = :plaintext
8
+ renderer = Rendering.renderer
9
+
10
+ assert_equal TechRadar::Rendering::Plaintext,renderer.class
11
+ end
12
+
13
+ test "markdown" do
14
+ TechRadar.summary_format = :markdown
15
+ renderer = Rendering.renderer
16
+
17
+ assert_equal TechRadar::Rendering::Markdown,renderer.class
18
+ end
19
+
20
+ end
21
+ end
data/test/test_helper.rb CHANGED
@@ -3,7 +3,6 @@ ENV["RAILS_ENV"] = "test"
3
3
 
4
4
  require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
5
5
  require "rails/test_help"
6
- require "mocha/test_unit"
7
6
 
8
7
  # Filter out Minitest backtrace while allowing backtrace from other libraries
9
8
  # to be shown.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tech_radar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stitch Fix Engineering
@@ -54,7 +54,7 @@ dependencies:
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
- name: mocha
57
+ name: redcarpet
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - ">="
@@ -87,6 +87,9 @@ files:
87
87
  - app/helpers/tech_radar/application_helper.rb
88
88
  - app/models/tech_radar/quadrant.rb
89
89
  - app/models/tech_radar/radar.rb
90
+ - app/models/tech_radar/rendering.rb
91
+ - app/models/tech_radar/rendering/Markdown.rb
92
+ - app/models/tech_radar/rendering/Plaintext.rb
90
93
  - app/models/tech_radar/ring.rb
91
94
  - app/models/tech_radar/technology.rb
92
95
  - app/views/layouts/tech_radar/application.html.erb
@@ -177,6 +180,7 @@ files:
177
180
  - test/dummy/tmp/cache/assets/test/sprockets/v3.0/wjc4fxI0T-E_AMREBsqAzcOoJVLQ2XmN8ybSXr2sA1c.cache
178
181
  - test/integration/navigation_test.rb
179
182
  - test/models/tech_radar/radar_test.rb
183
+ - test/models/tech_radar/rendering_test.rb
180
184
  - test/test_helper.rb
181
185
  homepage: https://github.com/stitchfix/tech_radar
182
186
  licenses:
@@ -278,4 +282,5 @@ test_files:
278
282
  - test/dummy/tmp/cache/assets/test/sprockets/v3.0/ZWMSse5xwAn4lVdnOdzP7aamfJLIIJ3tgM_K6QgcID8.cache
279
283
  - test/integration/navigation_test.rb
280
284
  - test/models/tech_radar/radar_test.rb
285
+ - test/models/tech_radar/rendering_test.rb
281
286
  - test/test_helper.rb