GitHub PullRequestReviewCommentEvent at 2014-07-31 22:50:21
Repository: adl-utils
Actor: houndci
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/aldogroup/adl-utils/pulls/comments/15675017","id":15675017,"diff_hunk":"@@ -0,0 +1,378 @@\n+require 'adl-utils/version'\n+require 'expanded_date'\n+\n+module Middleman\n+  class ScheduledImpexExtension < Cli:Impex\n+\n+    def initialize(app, options_hash={}, &block)\n+      super\n+    end\n+\n+    include Thor::Actions\n+\n+    check_unknown_options!\n+\n+    namespace :impex\n+\n+    # Tell Thor to exit with a nonzero exit code on failure\n+    def self.exit_on_failure?\n+      true\n+    end\n+\n+    desc \"impex\", Middleman::ADLUTILS::IMPEX_DESC\n+\n+    def impex_scheduled\n+      build_before()\n+      mm_var()\n+    end\n+\n+    protected\n+\n+    def mm_var\n+      extend Middleman\n+\n+      mm = ::Middleman::Application.server.inst do\n+        config[:environment] = :build\n+      end\n+\n+      mm_config = {\n+        'season' => mm.config.season,\n+        'campaign' => mm.config.campaign,\n+        'week' => mm.config.campaign.upcase.gsub(/[\\`\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\-\\=\\_\\+\\[\\]\\\\\\;\\'\\,\\.\\/\\{\\}\\|\\:\\\"\\<\\>\\?]/,''),\n+        'previous_campaign' => mm.config.previous_campaign.upcase.gsub(/[\\`\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\-\\=\\_\\+\\[\\]\\\\\\;\\'\\,\\.\\/\\{\\}\\|\\:\\\"\\<\\>\\?]/,''),\n+        'campaign_start' => mm.config.campaign_start,\n+        'special_event' => mm.config.special_event\n+      }\n+\n+      generate(mm_config)\n+    end\n+\n+    def generate(mm_config={})\n+      impexer_config = {\n+        'revision' => ENV['REV'],\n+        'locales' => %w(ca_en ca_fr uk_en_UK us_en_US),\n+        'source_root' => File.dirname(__FILE__),\n+        'usage_path' => File.join(File.dirname(__FILE__), '/data/'),\n+        'impex_data_file' => File.join(File.dirname(__FILE__), '/data/') + 'impex_data.yml',\n+        'impex_data' => File.read(File.join(File.dirname(__FILE__), '/data/') + 'impex_data.yml'),\n+        'impex_pages' => YAML.load(File.read(File.join(File.dirname(__FILE__), '/data/') + 'impex_data.yml'))\n+      }\n+\n+      generate_config(mm_config)\n+      # binding.pry\n+      impexer_config['locales'].each do |loc|\n+        generate_content(mm_config,impexer_config,loc)\n+      end\n+\n+    end\n+\n+    def build_before\n+      if yes?(\"== Do you want to build your project first ?\")\n+        # http://forum.middlemanapp.com/t/problem-with-the-build-task-in-an-extension\n+        run(\"VER=hybris REV=#{ENV['REV']} middleman build --clean\") || exit(1)\n+      end\n+    end\n+\n+    def generate_config(mm_config={})\n+      create_file \"build/impex/#{ENV['REV']}/1-#{mm_config['season']}-#{mm_config['campaign']}_config-#{Time.now.strftime('%y%m%d-%H%M')}.impex\", :verbose => false\n+      impex_config_file = \"build/impex/#{ENV['REV']}/1-#{mm_config['season']}-#{mm_config['campaign']}_config-#{Time.now.strftime('%y%m%d-%H%M')}.impex\"\n+      say(\"\\n░▒▓ Starting ImpEx Builder Tool ▓▒░\\n\", :green)\n+\n+      append_to_file impex_config_file, :verbose => false do\n+        \"\\n####################################################\\n#                    WCMS CONFIG                   #\\n####################################################\\n\\n#### DO NOT MODIFY ####\\n# Macros / Replacement Parameter definitions\\n$contentCatalog=aldoCommerceContentCatalog\\n$caProductCatalog=caAldoProductCatalog\\n$ukProductCatalog=ukAldoProductCatalog\\n$usProductCatalog=usAldoProductCatalog\\n\\n$contentCV=catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalog]),CatalogVersion.version[default=Staged])[default=$contentCatalog:Staged]\\n$caProductCV=catalogVersion(catalog(id[default=$caProductCatalog]),version[default='Staged'])[unique=true,default=$caProductCatalog:Staged]\\n$ukProductCV=catalogVersion(catalog(id[default=$ukProductCatalog]),version[default='Staged'])[unique=true,default=$ukProductCatalog:Staged]\\n$usProductCV=catalogVersion(catalog(id[default=$usProductCatalog]),version[default='Staged'])[unique=true,default=$usProductCatalog:Staged]\\n$siteResource=jar:com.aldo.hybris.initialdata.setup.InitialDataSystemSetup&/aldoinitialdata/import/contentCatalogs/$contentCatalog\\n\\n#### END DO NOT MODIFY ####\\n\\n#### CREATE COMPONENTS FOR HOME PAGE (header, content & footer) ####\\n# CMS Paragraph Components\\nINSERT_UPDATE CMSParagraphComponent;$contentCV[unique=true];uid[unique=true];name;&componentRef\\n;;HomepageComponent#{mm_config['previous_campaign']};Home Page Component for #{mm_config['previous_campaign']};HomepageComponent#{mm_config['previous_campaign']};\\n;;HTMLHeaderComponent#{mm_config['previous_campaign']};HTML Header Component for #{mm_config['previous_campaign']};HTMLHeaderComponent#{mm_config['previous_campaign']};\\n;;HTMLFooterComponent#{mm_config['previous_campaign']};HTML Footer Component for #{mm_config['previous_campaign']};HTMLFooterComponent#{mm_config['previous_campaign']};\\n;;PermanentFooterComponent; Permanent Footer Component;PermanentFooterComponent;\\n\\n;;HomepageComponent#{mm_config['week']};Home Page Component for #{mm_config['week']};HomepageComponent#{mm_config['week']};\\n;;HTMLHeaderComponent#{mm_config['week']};HTML Header Component for #{mm_config['week']};HTMLHeaderComponent#{mm_config['week']};\\n;;HTMLFooterComponent#{mm_config['week']};HTML Footer Component for #{mm_config['week']};HTMLFooterComponent#{mm_config['week']};\\n\\n\\n#### ADD THE ABOVE COMPONENTS TO THE RIGHT HOME PAGE PLACEHOLDERS ####\\n# Once you create the new paragraph component above, add it to the component list separated by a comma like I did with MegaPromoBanner2 below\\nINSERT_UPDATE ContentSlot;$contentCV[unique=true];uid[unique=true];name;active;cmsComponents(&componentRef)\\n;;HTMLHeaderSlot;HTML Header Slot;true;HTMLHeaderComponent#{mm_config['previous_campaign']},HTMLHeaderComponent#{mm_config['week']};\\n;;FooterSlot;Footer;true;PermanentFooterComponent,HTMLFooterComponent#{mm_config['previous_campaign']},HTMLFooterComponent#{mm_config['week']};\\n;;Section1Slot-Homepage;Section1 Slot for Homepage;true;HomepageComponent#{mm_config['previous_campaign']},HomepageComponent#{mm_config['week']};\"\n+      end\n+\n+      say(\"\\n☑ Finished generating config file\", :green)\n+\n+    end\n+\n+    def generate_content(mm_config={},impexer_config={},locale)\n+      FileUtils.rm(\"build/impex/#{ENV['REV']}/#{locale}.impex\") if options[:force]\n+\n+      create_file \"build/impex/#{ENV['REV']}/#{mm_config['season']}-#{mm_config['campaign']}_#{locale}-#{Time.now.strftime('%y%m%d-%H%M')}.impex\", :verbose => false\n+      impex_content_file = \"build/impex/#{ENV['REV']}/#{mm_config['season']}-#{mm_config['campaign']}_#{locale}-#{Time.now.strftime('%y%m%d-%H%M')}.impex\"\n+\n+      # =>  Setup the working directory\n+      build_dir = Pathname.new(\"build/#{impexer_config['revision']}/hybris/\" + locale)\n+\n+      # =>  Setup locale & country_code for impex file generation\n+      mm_campaign_start = mm_config['campaign_start']\n+      if locale == 'ca_en' || locale == 'ca_fr'\n+        country_code = 'ca'\n+        date_hour = \"#{mm_campaign_start['ca'][0]} #{mm_campaign_start['ca'][1]}\"\n+        campaign_start = DateTime.parse(date_hour).strftime('%d.%m.%Y %H:%M:%S')\n+        if locale == 'ca_en'\n+          lang = 'en'\n+        else\n+          lang = 'fr'\n+        end\n+      end\n+      if locale == 'uk_en_UK'\n+        lang = 'en_UK'\n+        country_code = 'uk'\n+        date_hour = \"#{mm_campaign_start['uk'][0]} #{mm_campaign_start['uk'][1]}\"\n+        campaign_start = DateTime.parse(date_hour).strftime('%d.%m.%Y %H:%M:%S')\n+      end\n+      if locale == 'us_en_US'\n+        lang = 'en_US'\n+        country_code = 'us'\n+        date_hour = \"#{mm_campaign_start['us'][0]} #{mm_campaign_start['us'][1]}\"\n+        campaign_start = DateTime.parse(date_hour).strftime('%d.%m.%Y %H:%M:%S')\n+      end\n+\n+      # =>  Create an array with all the directories inside the working dir\n+      @content_dir = Dir.glob('*')\n+\n+      say(\"\\n\\n✪ Generating impex content files for #{locale}\", :blue)\n+\n+      ########################\n+      #### Hybris ImpEx Header\n+      ########################\n+      append_to_file impex_content_file, :verbose => false do\n+        \"#Hybris Header\\n$contentCatalog=aldoCommerceContentCatalog\\n$contentCV=catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalog]),CatalogVersion.version[default=Staged])[default=$contentCatalog:Staged]\\n$picture=media(code, $contentCV);\\n$siteResource=jar:com.aldo.hybris.initialdata.setup.InitialDataSystemSetup&/aldoinitialdata/import/contentCatalogs/$contentCatalog\\n$lang=#{lang}\\n$countryCode=#{country_code}\\n$siteResource_content=$countryCode!!$lang!!jar:com.aldo.hybris.initialdata.setup.InitialDataSystemSetup&/aldoinitialdata/import/contentCatalogs/$contentCatalog\\n\"\n+      end\n+      ###############################\n+      #### End Of Hybris ImpEx Header\n+      ###############################\n+\n+      ##############################\n+      #### Start Of Time Restriction\n+      ##############################\n+      campaign_end = (DateTime.parse(campaign_start).end_of_next_month + 1).strftime('%d.%m.%Y %H:%M:%S')\n+      # binding.pry\n+      previous_campaign_start = (DateTime.parse(campaign_start) - 10).strftime('%d.%m.%Y %H:%M:%S')\n+      previous_campaign_end = (DateTime.parse(campaign_start) - ((0.01 / 24)/36)).strftime('%d.%m.%Y %H:%M:%S')\n+\n+      append_to_file impex_content_file, :verbose => false do\n+        \"\\n####################################################\\n\"\n+      end\n+      append_to_file impex_content_file, :verbose => false do\n+        \"#                TIME RESTRICTIONS                 #\\n\"\n+      end\n+      append_to_file impex_content_file, :verbose => false do\n+        \"####################################################\\n\"\n+      end\n+      append_to_file impex_content_file, :verbose => false do\n+        \"#Create time restrictions here then add time restriction name to the end of each component\\n\"\n+      end\n+      append_to_file impex_content_file, :verbose => false do\n+        \"INSERT_UPDATE CMSTimeRestriction;$contentCV[unique=true];uid[unique=true];name;activeFrom[dateformat=dd.MM.yyyy HH:mm:ss];activeUntil[dateformat=dd.MM.yyyy HH:mm:ss]\\n\"\n+      end\n+      append_to_file impex_content_file, :verbose => false do\n+        \";;Time-Restriction-#{mm_config['previous_campaign']};Time Restriction #{mm_config['previous_campaign']};#{previous_campaign_start};#{previous_campaign_end};\\n\"\n+      end\n+      append_to_file impex_content_file, :verbose => false do\n+        \";;Time-Restriction-#{mm_config['week']};Time Restriction #{mm_config['week']};#{campaign_start};#{campaign_end};\\n\"\n+      end\n+\n+      #### End Of Time Restriction\n+\n+      # =>  Read page and get content\n+      impexer_config['impex_pages'].each do |impex_page|\n+\n+        content = File.join(build_dir, impex_page['page_file'])\n+        content_page = File.read(content).gsub(' \"', '\"').gsub('\"', '\"\"').gsub(/\\n/, '').force_encoding(\"ASCII-8BIT\")\n+\n+        if content.include?('ca_en')\n+          content_fr = content.gsub('ca_en', 'ca_fr')\n+          content_fr_page = File.read(content_fr).gsub(' \"', '\"').gsub('\"', '\"\"').gsub(/\\n/, '').force_encoding(\"ASCII-8BIT\")\n+\n+        elsif content.include?('ca_fr')\n+          content_en = content.gsub('ca_fr', 'ca_en')\n+          content_en_page = File.read(content_en).gsub(' \"', '\"').gsub('\"', '\"\"').gsub(/\\n/, '').force_encoding(\"ASCII-8BIT\")\n+        end\n+\n+\n+\n+        if impex_page['page_title'] == 'homepage'\n+          append_to_file impex_content_file, :verbose => false do\n+            \"\\n# Homepage \\nINSERT_UPDATE CMSParagraphComponent;$contentCV[unique=true];uid[unique=true];content[lang=$lang];restrictions(name)\\n;;HomepageComponent#{mm_config['week']};\\\"#{content_page}\\\";Time Restriction #{mm_config['week']};\\n\"\n+          end\n+        end\n+\n+        if mm_config['special_event']\n+          append_to_file impex_content_file, :verbose => false do\n+              \"\\n;;HeaderPromotionalBannerComponent;\\\"<p><img src=\"\"//media.aldoshoes.com/content/uat/black-friday-1/images/freeshipping-blackfriday.gif\"\" width=\"\"752\"\" height=\"\"77\"\" alt=\"\"\"\" /></p>\\\";Time Restriction #{mm_config['week']};\\n\"\n+          end\n+        end\n+\n+        head_content_path = File.join(build_dir, '/head.html')\n+        head_content = File.read(head_content_path).gsub(' \"', '\"').gsub('\"', '\"\"').force_encoding(\"ASCII-8BIT\")\n+\n+        append_to_file impex_content_file, :verbose => false do\n+            \"\\n# Header Component\\n;;HTMLHeaderComponent#{mm_config['week']};\\\"#{head_content}\\\";Time Restriction #{mm_config['week']};\\n\"\n+        end\n+        footer_content_path = File.join(build_dir, '/footer.html')\n+        footer_content = File.read(footer_content_path).gsub(' \"', '\"').gsub('\"', '\"\"').force_encoding(\"ASCII-8BIT\")\n+\n+        append_to_file impex_content_file, :verbose => false do\n+            \"\\n# Footer Component\\n;;HTMLFooterComponent#{mm_config['week']};\\\"#{footer_content}\\\";Time Restriction #{mm_config['week']};\\n\"\n+        end\n+\n+        # Generate the rest of the content\n+        unless content.include?('ca_en') || content.include?('ca_fr')\n+          append_to_file impex_content_file, :verbose => false do\n+              \"\\n# Landing Pages & Category Banner\\n$productCatalog=#{country_code}AldoProductCatalog\\n$catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]\\nUPDATE Category;$catalogVersion;code[unique=true];landingPage[lang=$lang];categoryBanner[lang=$lang]\\n\\n#In this section you add the time restriction and the content tied to that time restriction\\nINSERT_UPDATE ScheduledCategoryContent;&Item;pk[unique=true];$catalogVersion;contentType(code);startDate[dateformat=dd.MM.yyyy hh:mm:ss];endDate[dateformat=dd.MM.yyyy hh:mm:ss];bannerContent[lang=$lang]\\n\\n\"\n+          end\n+        else\n+          #binding.pry\n+          if content.include?('ca_en')\n+            append_to_file impex_content_file, :verbose => false do\n+              \"\\n# Landing Pages & Category Banner\\n$productCatalog=#{country_code}AldoProductCatalog\\n$catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]\\nUPDATE Category;$catalogVersion;code[unique=true];landingPage[lang=$lang];categoryBanner[lang=$lang]\\n\\n#In this section you add the time restriction and the content tied to that time restriction\\nINSERT_UPDATE ScheduledCategoryContent;&Item;pk[unique=true];$catalogVersion;contentType(code);startDate[dateformat=dd.MM.yyyy hh:mm:ss];endDate[dateformat=dd.MM.yyyy hh:mm:ss];bannerContent[lang=$lang];bannerContent[lang=fr]\\n\\n\"\n+            end\n+          elsif content.include?('ca_fr')\n+            append_to_file impex_content_file, :verbose => false do\n+              \"\\n# Landing Pages & Category Banner\\n$productCatalog=#{country_code}AldoProductCatalog\\n$catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]\\nUPDATE Category;$catalogVersion;code[unique=true];landingPage[lang=$lang];categoryBanner[lang=$lang]\\n\\n#In this section you add the time restriction and the content tied to that time restriction\\nINSERT_UPDATE ScheduledCategoryContent;&Item;pk[unique=true];$catalogVersion;contentType(code);startDate[dateformat=dd.MM.yyyy hh:mm:ss];endDate[dateformat=dd.MM.yyyy hh:mm:ss];bannerContent[lang=$lang];bannerContent[lang=en]\\n\\n\"\n+            end\n+          end\n+        end\n+        # binding.pry\n+        unless impex_page['type'] == 'homepage'\n+\n+          apply_restriction_config = \"\\n\\n#In this section you are tying your time restricted content to a category id. You can also put in a current (not time restricted) landing page or banner\\nUPDATE Category;$catalogVersion;code[unique=true];landingPage[lang=$lang];categoryBanner[lang=$lang];scheduledContent(&Item)\\n\\n\"\n+\n+          append_to_file impex_content_file, :verbose => false do\n+              apply_restriction_config\n+          end\n+\n+          unless locale == 'ca_en' || locale == 'ca_fr'\n+            insert_into_file impex_content_file, :before => apply_restriction_config, :verbose => false do\n+                \"\\n##{impex_page['page_title']}\\n;#{impex_page['page_title']}#{mm_config['previous_campaign']};<ignore>;;#{impex_page['type']};#{previous_campaign_start};#{previous_campaign_end};<ignore>\\n;#{impex_page['page_title']}#{mm_config['week']};<ignore>;;#{impex_page['type']};#{campaign_start};#{campaign_end};\\\"#{content_page}\\\"\\n\"\n+            end\n+          end\n+\n+          if content.include?('ca_en')\n+            #binding.pry\n+            insert_into_file impex_content_file, :before => apply_restriction_config, :verbose => false do\n+                \"\\n##{impex_page['page_title']}\\n;#{impex_page['page_title']}#{mm_config['previous_campaign']};<ignore>;;#{impex_page['type']};#{previous_campaign_start};#{previous_campaign_end};<ignore>\\n;#{impex_page['page_title']}#{mm_config['week']};<ignore>;;#{impex_page['type']};#{campaign_start};#{campaign_end};\\\"#{content_page}\\\";\\\"#{content_fr_page}\\\"\\n\"\n+            end\n+          elsif content.include?('ca_fr')\n+            insert_into_file impex_content_file, :before => apply_restriction_config, :verbose => false do\n+                \"\\n##{impex_page['page_title']}\\n;#{impex_page['page_title']}#{mm_config['previous_campaign']};<ignore>;;#{impex_page['type']};#{previous_campaign_start};#{previous_campaign_end};<ignore>\\n;#{impex_page['page_title']}#{mm_config['week']};<ignore>;;#{impex_page['type']};#{campaign_start};#{campaign_end};\\\"#{content_page}\\\";\\\"#{content_en_page}\\\"\\n\"\n+            end\n+          end\n+\n+          insert_into_file impex_content_file, :after => apply_restriction_config, :verbose => false do\n+              \"##{impex_page['page_title']}\\n;;\\\"#{impex_page['hybris_id']}\\\";\"\";\"\";#{impex_page['page_title']}#{mm_config['previous_campaign']},#{impex_page['page_title']}#{mm_config['week']};\\n\"\n+          end\n+\n+          if impex_page.include?(\"sub_pages\")\n+            if File.exist?(File.join(build_dir.to_s, impex_page['sub_pages'][0]['page_file']))\n+              impex_page['sub_pages'].each do |sub_page|\n+                sub_content = File.join(build_dir, sub_page['page_file'])\n+                sub_content_page = File.read(sub_content).gsub(' \"', '\"').gsub('\"', '\"\"').force_encoding(\"ASCII-8BIT\") unless File.file?(sub_content)\n+\n+                previous_sublp = \"##{sub_page['page_title']}\\n;#{sub_page['page_title'].capitalize.gsub(' ','')}#{mm_config['previous_campaign']};<ignore>;;#{sub_page['type']};#{previous_campaign_start};#{previous_campaign_end};<ignore>\\n\"\n+                current_sublp = \";#{sub_page['page_title'].capitalize.gsub(' ','')}#{mm_config['week']};<ignore>;;#{sub_page['type']};#{campaign_start};#{campaign_end};\\\"#{sub_content_page}\\\"\\n\"\n+\n+                insert_into_file impex_content_file, :before => apply_restriction_config, :verbose => false do\n+                  \"#{previous_sublp}#{current_sublp}\"\n+                end\n+\n+                insert_into_file impex_content_file, :after => apply_restriction_config, :verbose => false do\n+                  \"##{sub_page['page_title']}\\n;;\\\"#{sub_page['hybris_id']}\\\";\"\";\"\";#{impex_page['page_title']}#{mm_config['previous_campaign']},#{sub_page['page_title'].capitalize.gsub(' ','')}#{mm_config['week']};\\n\"\n+                end\n+\n+              end # End of sub_pages generator loop\n+            else\n+              say(\"\\s\\sError: #{File.join(build_dir, impex_page['sub_pages'][0]['page_file'])} Not found\", :red)\n+              say(\"\\s\\s⚠ Ignoring #{impex_page['sub_pages'][0]['page_title']}, because the file is missing.\\n\\n\", :magenta)\n+            end\n+          end # End of sub_pages conditional check\n+        end\n+\n+      end # End of impex_pages loop\n+      append_to_file(impex_content_file, \"\\n#end of Landing Pages and Children Pages\\n\\n#L3 Pages\\n\\n#End of L3\")\n+\n+      apply_restriction_l3 = \"\\n\\n#In this section you are tying your time restricted L3 to a category id.\\nUPDATE Category;$catalogVersion;code[unique=true];landingPage[lang=$lang];categoryBanner[lang=$lang];scheduledContent(&Item)\\n\\n\"\n+\n+      insert_into_file impex_content_file, :before => \"#End of L3\", :verbose => false do\n+        apply_restriction_l3\n+      end\n+\n+      @l3_build_dir = build_dir + '/l3'\n+\n+      l3_content_dir = Dir.glob(build_dir + 'l3/*')\n+\n+      l3_content_dir.each do |l3_content|\n+          l3_hybris_page_name = l3_content.to_s.gsub(/\\d{3,}-/, '').gsub(/\\-/,' ').strip\n+          l3_hybris_id = l3_content.match(/\\d{3,}/).to_s\n+          l3_title = l3_hybris_page_name.gsub(build_dir.to_s, '').gsub('/l3/', '').lstrip\n+          #binding.pry\n+\n+          if l3_content.include?('ca_en')\n+            l3_header = \"\\n$productCatalog=#{country_code}AldoProductCatalog\\n$catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]\\nUPDATE Category;$catalogVersion;code[unique=true];landingPage[lang=$lang];categoryBanner[lang=$lang]\\n\\n#In this section you add the time restriction and the content tied to that time restriction\\nINSERT_UPDATE ScheduledCategoryContent;&Item;pk[unique=true];$catalogVersion;contentType(code);startDate[dateformat=dd.MM.yyyy hh:mm:ss];endDate[dateformat=dd.MM.yyyy hh:mm:ss];bannerContent[lang=$lang];bannerContent[lang=fr]\\n\\n#l3\"\n+            insert_into_file impex_content_file, :after => \"#L3 Pages\", :verbose => false do\n+              l3_header\n+            end\n+          elsif l3_content.include?('ca_fr')\n+\n+            l3_header = \"\\n$productCatalog=#{country_code}AldoProductCatalog\\n$catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]\\nUPDATE Category;$catalogVersion;code[unique=true];landingPage[lang=$lang];categoryBanner[lang=$lang]\\n\\n#In this section you add the time restriction and the content tied to that time restriction\\nINSERT_UPDATE ScheduledCategoryContent;&Item;pk[unique=true];$catalogVersion;contentType(code);startDate[dateformat=dd.MM.yyyy hh:mm:ss];endDate[dateformat=dd.MM.yyyy hh:mm:ss];bannerContent[lang=$lang];bannerContent[lang=en]\\n\\n#l3\"\n+\n+            insert_into_file impex_content_file, :after => \"#L3 Pages\", :verbose => false do\n+              l3_header\n+            end\n+          else\n+\n+            l3_header = \"\\n$productCatalog=#{country_code}AldoProductCatalog\\n$catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]\\nUPDATE Category;$catalogVersion;code[unique=true];landingPage[lang=$lang];categoryBanner[lang=$lang]\\n\\n#In this section you add the time restriction and the content tied to that time restriction\\nINSERT_UPDATE ScheduledCategoryContent;&Item;pk[unique=true];$catalogVersion;contentType(code);startDate[dateformat=dd.MM.yyyy hh:mm:ss];endDate[dateformat=dd.MM.yyyy hh:mm:ss];bannerContent[lang=$lang]\\n\\n#l3\"\n+\n+            insert_into_file impex_content_file, :after => \"#L3 Pages\", :verbose => false do\n+              l3_header\n+            end\n+\n+          end\n+          unless l3_hybris_id.empty?\n+\n+              l3_content_page = File.read(\"#{l3_content}/index.html\").gsub(' \"', '\"').gsub('\"', '\"\"').force_encoding(\"ASCII-8BIT\")\n+\n+              if mm_config['special_event']\n+                previous_l3 = \"\\n##{l3_title}\\n;#{l3_hybris_id}#{mm_config['previous_campaign']};<ignore>;;CATEGORY_BANNER;#{previous_campaign_start};#{previous_campaign_end};<ignore>\\n\"\n+\n+                if l3_content.include?('ca_en')\n+                  l3_content_page_fr = File.read(\"#{l3_content.gsub('ca_en', 'ca_fr')}/index.html\").gsub(' \"', '\"').gsub('\"', '\"\"').force_encoding(\"ASCII-8BIT\")\n+                  current_l3 = \";#{l3_hybris_id}#{mm_config['week']};<ignore>;;CATEGORY_BANNER;#{campaign_start};#{campaign_end};\\\"#{l3_content_page}\\\";\\\"#{l3_content_page_fr}\\\"\\n\"\n+                elsif l3_content.include?('ca_fr')\n+                  l3_content_page_en = File.read(\"#{l3_content.gsub('ca_fr', 'ca_en')}/index.html\").gsub(' \"', '\"').gsub('\"', '\"\"').force_encoding(\"ASCII-8BIT\")\n+                  current_l3 = \";#{l3_hybris_id}#{mm_config['week']};<ignore>;;CATEGORY_BANNER;#{campaign_start};#{campaign_end};\\\"#{l3_content_page}\\\";\\\"#{l3_content_page_en}\\\"\\n\"\n+                else\n+                  current_l3 = \";#{l3_hybris_id}#{mm_config['week']};<ignore>;;CATEGORY_BANNER;#{campaign_start};#{campaign_end};\\\"#{l3_content_page}\\\"\\n\"\n+                end\n+\n+                insert_into_file impex_content_file, :after => l3_header, :verbose => false do\n+                  \"#{previous_l3}#{current_l3}\"\n+                end\n+\n+                insert_into_file impex_content_file, :after => apply_restriction_l3, :verbose => false do\n+                  \"\\n##{l3_title}\\n;;\\\"#{l3_hybris_id}\\\";\"\";\"\";#{l3_hybris_id}#{mm_config['previous_campaign']},#{l3_hybris_id}#{mm_config['week']};\\n\"\n+                end\n+\n+              else\n+                append_to_file(impex_content_file, \"##{l3_hybris_page_name}\\n;;\\\"#{l3_hybris_id}\\\";;\\\"#{l3_content_page}\\\"\\n\", :verbose => false)\n+              end\n+\n+          end\n+      end\n+      say(\"\\s\\s☑ Finished to generate the impex content files for #{locale}\", :green)","path":"lib/adl-utils/impex/impex_scheduled.rb","position":355,"original_position":355,"commit_id":"1e19ba23117ba1b9a8f05f69b89cc61c7cf91f1b","original_commit_id":"1e19ba23117ba1b9a8f05f69b89cc61c7cf91f1b","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=1","gravatar_id":"38d9cefd9971a05bf447f07c6cd332cc","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Line is too long. [87/80]","created_at":"2014-07-31T22:50:21Z","updated_at":"2014-07-31T22:50:21Z","html_url":"https://github.com/aldogroup/adl-utils/pull/2#discussion_r15675017","pull_request_url":"https://api.github.com/repos/aldogroup/adl-utils/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/aldogroup/adl-utils/pulls/comments/15675017"},"html":{"href":"https://github.com/aldogroup/adl-utils/pull/2#discussion_r15675017"},"pull_request":{"href":"https://api.github.com/repos/aldogroup/adl-utils/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/aldogroup/adl-utils/pulls/2","id":19184014,"html_url":"https://github.com/aldogroup/adl-utils/pull/2","diff_url":"https://github.com/aldogroup/adl-utils/pull/2.diff","patch_url":"https://github.com/aldogroup/adl-utils/pull/2.patch","issue_url":"https://api.github.com/repos/aldogroup/adl-utils/issues/2","number":2,"state":"closed","title":"Merging Working Time Restriction from Testing to Master","user":{"login":"blabassi","id":6494631,"avatar_url":"https://avatars.githubusercontent.com/u/6494631?v=1","gravatar_id":"5b5e83859650f06643840130efa4f32d","url":"https://api.github.com/users/blabassi","html_url":"https://github.com/blabassi","followers_url":"https://api.github.com/users/blabassi/followers","following_url":"https://api.github.com/users/blabassi/following{/other_user}","gists_url":"https://api.github.com/users/blabassi/gists{/gist_id}","starred_url":"https://api.github.com/users/blabassi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blabassi/subscriptions","organizations_url":"https://api.github.com/users/blabassi/orgs","repos_url":"https://api.github.com/users/blabassi/repos","events_url":"https://api.github.com/users/blabassi/events{/privacy}","received_events_url":"https://api.github.com/users/blabassi/received_events","type":"User","site_admin":false},"body":"## Impex Generator\r\nTested on UAT (Still needs works on L3)\r\n\r\n## All other modules hasn't been touched","created_at":"2014-07-31T22:48:58Z","updated_at":"2014-07-31T22:50:21Z","closed_at":"2014-07-31T22:49:08Z","merged_at":"2014-07-31T22:49:08Z","merge_commit_sha":"2223fbd6865876c5d0c11ebbae13e8b1c6e85f76","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aldogroup/adl-utils/pulls/2/commits","review_comments_url":"https://api.github.com/repos/aldogroup/adl-utils/pulls/2/comments","review_comment_url":"https://api.github.com/repos/aldogroup/adl-utils/pulls/comments/{number}","comments_url":"https://api.github.com/repos/aldogroup/adl-utils/issues/2/comments","statuses_url":"https://api.github.com/repos/aldogroup/adl-utils/statuses/1e19ba23117ba1b9a8f05f69b89cc61c7cf91f1b","head":{"label":"aldogroup:testing","ref":"testing","sha":"1e19ba23117ba1b9a8f05f69b89cc61c7cf91f1b","user":{"login":"aldogroup","id":3799865,"avatar_url":"https://avatars.githubusercontent.com/u/3799865?v=1","gravatar_id":null,"url":"https://api.github.com/users/aldogroup","html_url":"https://github.com/aldogroup","followers_url":"https://api.github.com/users/aldogroup/followers","following_url":"https://api.github.com/users/aldogroup/following{/other_user}","gists_url":"https://api.github.com/users/aldogroup/gists{/gist_id}","starred_url":"https://api.github.com/users/aldogroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aldogroup/subscriptions","organizations_url":"https://api.github.com/users/aldogroup/orgs","repos_url":"https://api.github.com/users/aldogroup/repos","events_url":"https://api.github.com/users/aldogroup/events{/privacy}","received_events_url":"https://api.github.com/users/aldogroup/received_events","type":"Organization","site_admin":false},"repo":{"id":18847281,"name":"adl-utils","full_name":"aldogroup/adl-utils","owner":{"login":"aldogroup","id":3799865,"avatar_url":"https://avatars.githubusercontent.com/u/3799865?v=1","gravatar_id":null,"url":"https://api.github.com/users/aldogroup","html_url":"https://github.com/aldogroup","followers_url":"https://api.github.com/users/aldogroup/followers","following_url":"https://api.github.com/users/aldogroup/following{/other_user}","gists_url":"https://api.github.com/users/aldogroup/gists{/gist_id}","starred_url":"https://api.github.com/users/aldogroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aldogroup/subscriptions","organizations_url":"https://api.github.com/users/aldogroup/orgs","repos_url":"https://api.github.com/users/aldogroup/repos","events_url":"https://api.github.com/users/aldogroup/events{/privacy}","received_events_url":"https://api.github.com/users/aldogroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aldogroup/adl-utils","description":"A set of tools that we use at the ALDO Group for our Middleman applications.","fork":false,"url":"https://api.github.com/repos/aldogroup/adl-utils","forks_url":"https://api.github.com/repos/aldogroup/adl-utils/forks","keys_url":"https://api.github.com/repos/aldogroup/adl-utils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aldogroup/adl-utils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aldogroup/adl-utils/teams","hooks_url":"https://api.github.com/repos/aldogroup/adl-utils/hooks","issue_events_url":"https://api.github.com/repos/aldogroup/adl-utils/issues/events{/number}","events_url":"https://api.github.com/repos/aldogroup/adl-utils/events","assignees_url":"https://api.github.com/repos/aldogroup/adl-utils/assignees{/user}","branches_url":"https://api.github.com/repos/aldogroup/adl-utils/branches{/branch}","tags_url":"https://api.github.com/repos/aldogroup/adl-utils/tags","blobs_url":"https://api.github.com/repos/aldogroup/adl-utils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aldogroup/adl-utils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aldogroup/adl-utils/git/refs{/sha}","trees_url":"https://api.github.com/repos/aldogroup/adl-utils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aldogroup/adl-utils/statuses/{sha}","languages_url":"https://api.github.com/repos/aldogroup/adl-utils/languages","stargazers_url":"https://api.github.com/repos/aldogroup/adl-utils/stargazers","contributors_url":"https://api.github.com/repos/aldogroup/adl-utils/contributors","subscribers_url":"https://api.github.com/repos/aldogroup/adl-utils/subscribers","subscription_url":"https://api.github.com/repos/aldogroup/adl-utils/subscription","commits_url":"https://api.github.com/repos/aldogroup/adl-utils/commits{/sha}","git_commits_url":"https://api.github.com/repos/aldogroup/adl-utils/git/commits{/sha}","comments_url":"https://api.github.com/repos/aldogroup/adl-utils/comments{/number}","issue_comment_url":"https://api.github.com/repos/aldogroup/adl-utils/issues/comments/{number}","contents_url":"https://api.github.com/repos/aldogroup/adl-utils/contents/{+path}","compare_url":"https://api.github.com/repos/aldogroup/adl-utils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aldogroup/adl-utils/merges","archive_url":"https://api.github.com/repos/aldogroup/adl-utils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aldogroup/adl-utils/downloads","issues_url":"https://api.github.com/repos/aldogroup/adl-utils/issues{/number}","pulls_url":"https://api.github.com/repos/aldogroup/adl-utils/pulls{/number}","milestones_url":"https://api.github.com/repos/aldogroup/adl-utils/milestones{/number}","notifications_url":"https://api.github.com/repos/aldogroup/adl-utils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aldogroup/adl-utils/labels{/name}","releases_url":"https://api.github.com/repos/aldogroup/adl-utils/releases{/id}","created_at":"2014-04-16T16:35:52Z","updated_at":"2014-07-25T13:48:50Z","pushed_at":"2014-07-31T22:49:08Z","git_url":"git://github.com/aldogroup/adl-utils.git","ssh_url":"git@github.com:aldogroup/adl-utils.git","clone_url":"https://github.com/aldogroup/adl-utils.git","svn_url":"https://github.com/aldogroup/adl-utils","homepage":"","size":311,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"aldogroup:master","ref":"master","sha":"c82532a62a917c6252c95d2f9d7a0c031c867555","user":{"login":"aldogroup","id":3799865,"avatar_url":"https://avatars.githubusercontent.com/u/3799865?v=1","gravatar_id":null,"url":"https://api.github.com/users/aldogroup","html_url":"https://github.com/aldogroup","followers_url":"https://api.github.com/users/aldogroup/followers","following_url":"https://api.github.com/users/aldogroup/following{/other_user}","gists_url":"https://api.github.com/users/aldogroup/gists{/gist_id}","starred_url":"https://api.github.com/users/aldogroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aldogroup/subscriptions","organizations_url":"https://api.github.com/users/aldogroup/orgs","repos_url":"https://api.github.com/users/aldogroup/repos","events_url":"https://api.github.com/users/aldogroup/events{/privacy}","received_events_url":"https://api.github.com/users/aldogroup/received_events","type":"Organization","site_admin":false},"repo":{"id":18847281,"name":"adl-utils","full_name":"aldogroup/adl-utils","owner":{"login":"aldogroup","id":3799865,"avatar_url":"https://avatars.githubusercontent.com/u/3799865?v=1","gravatar_id":null,"url":"https://api.github.com/users/aldogroup","html_url":"https://github.com/aldogroup","followers_url":"https://api.github.com/users/aldogroup/followers","following_url":"https://api.github.com/users/aldogroup/following{/other_user}","gists_url":"https://api.github.com/users/aldogroup/gists{/gist_id}","starred_url":"https://api.github.com/users/aldogroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aldogroup/subscriptions","organizations_url":"https://api.github.com/users/aldogroup/orgs","repos_url":"https://api.github.com/users/aldogroup/repos","events_url":"https://api.github.com/users/aldogroup/events{/privacy}","received_events_url":"https://api.github.com/users/aldogroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aldogroup/adl-utils","description":"A set of tools that we use at the ALDO Group for our Middleman applications.","fork":false,"url":"https://api.github.com/repos/aldogroup/adl-utils","forks_url":"https://api.github.com/repos/aldogroup/adl-utils/forks","keys_url":"https://api.github.com/repos/aldogroup/adl-utils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aldogroup/adl-utils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aldogroup/adl-utils/teams","hooks_url":"https://api.github.com/repos/aldogroup/adl-utils/hooks","issue_events_url":"https://api.github.com/repos/aldogroup/adl-utils/issues/events{/number}","events_url":"https://api.github.com/repos/aldogroup/adl-utils/events","assignees_url":"https://api.github.com/repos/aldogroup/adl-utils/assignees{/user}","branches_url":"https://api.github.com/repos/aldogroup/adl-utils/branches{/branch}","tags_url":"https://api.github.com/repos/aldogroup/adl-utils/tags","blobs_url":"https://api.github.com/repos/aldogroup/adl-utils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aldogroup/adl-utils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aldogroup/adl-utils/git/refs{/sha}","trees_url":"https://api.github.com/repos/aldogroup/adl-utils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aldogroup/adl-utils/statuses/{sha}","languages_url":"https://api.github.com/repos/aldogroup/adl-utils/languages","stargazers_url":"https://api.github.com/repos/aldogroup/adl-utils/stargazers","contributors_url":"https://api.github.com/repos/aldogroup/adl-utils/contributors","subscribers_url":"https://api.github.com/repos/aldogroup/adl-utils/subscribers","subscription_url":"https://api.github.com/repos/aldogroup/adl-utils/subscription","commits_url":"https://api.github.com/repos/aldogroup/adl-utils/commits{/sha}","git_commits_url":"https://api.github.com/repos/aldogroup/adl-utils/git/commits{/sha}","comments_url":"https://api.github.com/repos/aldogroup/adl-utils/comments{/number}","issue_comment_url":"https://api.github.com/repos/aldogroup/adl-utils/issues/comments/{number}","contents_url":"https://api.github.com/repos/aldogroup/adl-utils/contents/{+path}","compare_url":"https://api.github.com/repos/aldogroup/adl-utils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aldogroup/adl-utils/merges","archive_url":"https://api.github.com/repos/aldogroup/adl-utils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aldogroup/adl-utils/downloads","issues_url":"https://api.github.com/repos/aldogroup/adl-utils/issues{/number}","pulls_url":"https://api.github.com/repos/aldogroup/adl-utils/pulls{/number}","milestones_url":"https://api.github.com/repos/aldogroup/adl-utils/milestones{/number}","notifications_url":"https://api.github.com/repos/aldogroup/adl-utils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aldogroup/adl-utils/labels{/name}","releases_url":"https://api.github.com/repos/aldogroup/adl-utils/releases{/id}","created_at":"2014-04-16T16:35:52Z","updated_at":"2014-07-25T13:48:50Z","pushed_at":"2014-07-31T22:49:08Z","git_url":"git://github.com/aldogroup/adl-utils.git","ssh_url":"git@github.com:aldogroup/adl-utils.git","clone_url":"https://github.com/aldogroup/adl-utils.git","svn_url":"https://github.com/aldogroup/adl-utils","homepage":"","size":311,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aldogroup/adl-utils/pulls/2"},"html":{"href":"https://github.com/aldogroup/adl-utils/pull/2"},"issue":{"href":"https://api.github.com/repos/aldogroup/adl-utils/issues/2"},"comments":{"href":"https://api.github.com/repos/aldogroup/adl-utils/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/aldogroup/adl-utils/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/aldogroup/adl-utils/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/aldogroup/adl-utils/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/aldogroup/adl-utils/statuses/1e19ba23117ba1b9a8f05f69b89cc61c7cf91f1b"}}}}