diff options
author | Alberto Almagro <albertoalmagro@gmail.com> | 2018-11-22 20:48:25 +0100 |
---|---|---|
committer | Alberto Almagro <albertoalmagro@gmail.com> | 2018-11-22 22:39:13 +0100 |
commit | 5020c2e3022ad9f07c29679f489cdb836425c552 (patch) | |
tree | 2162eebeaf3c55b6df97af843d0ec1f980f66759 /guides | |
parent | 1b68ead8f8cb0d7a1771ab82ab20bd79857b40ee (diff) | |
download | rails-5020c2e3022ad9f07c29679f489cdb836425c552.tar.gz rails-5020c2e3022ad9f07c29679f489cdb836425c552.tar.bz2 rails-5020c2e3022ad9f07c29679f489cdb836425c552.zip |
Use direction instead of rtl flag.
Improve readability by using `direction` as CSS does.
More info: https://developer.mozilla.org/en-US/docs/Web/CSS/direction
Continues: #34486
[Alberto Almagro + Ufuk Kayserilioglu]
Diffstat (limited to 'guides')
-rw-r--r-- | guides/rails_guides.rb | 14 | ||||
-rw-r--r-- | guides/rails_guides/generator.rb | 25 |
2 files changed, 21 insertions, 18 deletions
diff --git a/guides/rails_guides.rb b/guides/rails_guides.rb index b24c0205d5..28a7c94ca9 100644 --- a/guides/rails_guides.rb +++ b/guides/rails_guides.rb @@ -20,11 +20,11 @@ version = env_value["RAILS_VERSION"] edge = `git rev-parse HEAD`.strip unless version RailsGuides::Generator.new( - edge: edge, - version: version, - all: env_flag["ALL"], - only: env_value["ONLY"], - kindle: env_flag["KINDLE"], - language: env_value["GUIDES_LANGUAGE"], - rtl: env_value["RTL"] + edge: edge, + version: version, + all: env_flag["ALL"], + only: env_value["ONLY"], + kindle: env_flag["KINDLE"], + language: env_value["GUIDES_LANGUAGE"], + direction: env_value["DIRECTION"].to_sym ).generate diff --git a/guides/rails_guides/generator.rb b/guides/rails_guides/generator.rb index 3d8f54ab34..1f0a2063f2 100644 --- a/guides/rails_guides/generator.rb +++ b/guides/rails_guides/generator.rb @@ -17,14 +17,14 @@ module RailsGuides class Generator GUIDES_RE = /\.(?:erb|md)\z/ - def initialize(edge:, version:, all:, only:, kindle:, language:, rtl: false) - @edge = edge - @version = version - @all = all - @only = only - @kindle = kindle - @language = language - @rtl = rtl + def initialize(edge:, version:, all:, only:, kindle:, language:, direction: :ltr) + @edge = edge + @version = version + @all = all + @only = only + @kindle = kindle + @language = language + @direction = direction if @kindle check_for_kindlegen @@ -118,12 +118,15 @@ module RailsGuides def copy_assets FileUtils.cp_r(Dir.glob("#{@guides_dir}/assets/*"), @output_dir) - if @rtl - FileUtils.rm(Dir.glob("#{@output_dir}/stylesheets/main.css")) - FileUtils.mv("#{@output_dir}/stylesheets/main.rtl.css", "#{@output_dir}/stylesheets/main.css") + if @direction == :rtl + overwrite_css_with_right_to_left_direction end end + def overwrite_css_with_right_to_left_direction + FileUtils.mv("#{@output_dir}/stylesheets/main.rtl.css", "#{@output_dir}/stylesheets/main.css") + end + def output_file_for(guide) if guide.end_with?(".md") guide.sub(/md\z/, "html") |