Commits

Shrikant Sharat Kandula committed 3feef98

Sample test case and combining now works fine.

Comments (0)

Files changed (6)

+def:
+	ruby main.rb
+	cat all-scripts.js
+(function () {
+    alert("here's script1.js");
+})();
+(function () {
+    alert("here's script2.js");
+})();
+<!doctype html>
+<html>
+    <head>
+        <meta charset=utf-8>
+        <title>woohoo</title>
+
+    <body>
+        <p>Hello there</p>
+
+        <script src=script1.js></script>
+        <script src=script2.js></script>
+require 'rubygems'
+require 'bundler/setup'
+
+require 'nokogiri'
+
+f = File.open 'index.html'
+doc = Nokogiri::HTML f
+f.close
+
+scripts = doc.css 'script'
+
+File.open 'all-scripts.js', 'w' do |outfile|
+  scripts.each do |script|
+    filename = script[:src]
+    File.open filename do |f|
+      outfile.write f.reduce { |acc, line| acc + line }
+    end
+  end
+end
+
+puts 'Done'
+(function () {
+    alert("here's script1.js");
+})();
+(function () {
+    alert("here's script2.js");
+})();