How to use script method of JSHelper Package

Best Site_prism code snippet using JSHelper.script

Rakefile

Source:Rakefile Github

copy

Full Screen

1require 'rubygems'2require 'vendor/sprockets/lib/sprockets'3require 'rake'4require 'rake/packagetask'5require 'yaml'6require 'fileutils'7module ActiveJSHelper8 ROOT_DIR = File.expand_path(File.dirname(__FILE__))9 10 ASSETS_DIR = File.join(ROOT_DIR, 'assets')11 SRC_DIR = File.join(ROOT_DIR, 'src')12 DIST_DIR = File.join(ROOT_DIR, 'assets/downloads')13 DOCS_DIR = File.join(ROOT_DIR, 'docs')14 TEST_DIR = File.join(ROOT_DIR, 'test')15 VENDOR_DIR = File.join(ROOT_DIR, 'vendor')16 17 VERSION = YAML.load(IO.read(File.join(SRC_DIR, 'constants.yml')))['VERSION']18 19 SOURCE_FILE_FOR_DOCS = File.join(DIST_DIR, 'source_for_docs.js')20 21 INCLUDES = {22 :swfaddress => [23 File.join(VENDOR_DIR,'swfaddress/swfaddress.js')24 ],25 :active_support_extensions => [26 File.join(SRC_DIR,'dom.js'),27 File.join(SRC_DIR,'active_support/inflector.js'),28 File.join(SRC_DIR,'active_support/date.js'),29 File.join(SRC_DIR,'active_support/json.js'),30 File.join(SRC_DIR,'active_support/callback_queue.js'),31 File.join(SRC_DIR,'active_support/request.js'),32 File.join(SRC_DIR,'active_support/initializer.js')33 ]34 }35 36 DISTRIBUTION_FOR_DOC_GENERATION = [37 File.join(SRC_DIR,'active_support.js'),38 File.join(SRC_DIR,'builder.js'),39 INCLUDES[:active_support_extensions],40 File.join(SRC_DIR,'active_event.js'),41 File.join(SRC_DIR,'active_routes.js'),42 File.join(SRC_DIR,'active_record.js'),43 File.join(SRC_DIR,'active_view.js')44 ]45 46 DISTRIBUTIONS = {47 'dom.js' => [48 File.join(SRC_DIR,'dom.js')49 ],50 'builder.js' => [51 File.join(SRC_DIR,'dom.js')52 ],53 'active_support.js' => [54 File.join(SRC_DIR,'active_support.js'),55 INCLUDES[:active_support_extensions]56 ],57 'active_event.js' => [58 File.join(SRC_DIR,'active_support.js'),59 File.join(SRC_DIR,'active_event.js')60 ],61 'active_view.js' => [62 File.join(SRC_DIR,'active_support.js'),63 File.join(SRC_DIR,'dom.js'),64 File.join(SRC_DIR,'builder.js'),65 File.join(SRC_DIR,'active_event.js'),66 File.join(SRC_DIR,'active_view.js')67 ],68 'active_routes.js' => [69 File.join(SRC_DIR,'active_support.js'),70 File.join(SRC_DIR,'active_event.js'),71 File.join(SRC_DIR,'active_routes.js')72 ],73 'active_record.js' => [74 File.join(SRC_DIR,'active_support.js'),75 INCLUDES[:active_support_extensions],76 File.join(SRC_DIR,'active_event.js'),77 File.join(SRC_DIR,'active_record.js')78 ],79 'active.js' => [80 File.join(SRC_DIR,'active_support.js'),81 INCLUDES[:active_support_extensions],82 File.join(SRC_DIR,'builder.js'),83 File.join(SRC_DIR,'active_event.js'),84 File.join(SRC_DIR,'active_routes.js'),85 File.join(SRC_DIR,'active_view.js'),86 File.join(SRC_DIR,'active_record.js'),87 INCLUDES[:swfaddress]88 ], 89 #ActiveJS combined tests90 File.join('..','..','test','test.js') => [91 Dir[File.join(TEST_DIR,'**/setup.js')],92 Dir[File.join(TEST_DIR,'**/*.js')].reject{|item| item.match(/setup\.js$/)}93 ].flatten.reject{|item| item.match(/\/test.js$/)}94 }95 #individual test building96 [97 'active_event',98 'active_view',99 'active_routes',100 'active_record',101 'active_support'102 ].each do |group|103 DISTRIBUTIONS[File.join('..','..','test',group,'test.js')] = [104 Dir[File.join(TEST_DIR,group + '/setup.js')],105 Dir[File.join(TEST_DIR,group + '/*.js')].reject{|item| item.match(/setup\.js$/)}106 ].flatten.reject{|item| item.match(/\/test.js$/)}107 end108 109 def self.sprocketize110 load_path = [SRC_DIR]111 DISTRIBUTIONS.each_pair do |distribution_name,source_files|112 flattened_source_files = source_files.clone.flatten113 flattened_source_files.unshift('LICENSE')114 secretary = Sprockets::Secretary.new(115 :root => ROOT_DIR,116 :load_path => load_path,117 :source_files => flattened_source_files,118 :strip_comments => false119 )120 secretary.concatenation.save_to(File.join(DIST_DIR, distribution_name))121 end122 end123 124 def self.sprocketize_for_docs125 flattened_source_files = DISTRIBUTION_FOR_DOC_GENERATION.clone.flatten126 secretary = Sprockets::Secretary.new(127 :root => ROOT_DIR,128 :load_path => [SRC_DIR],129 :source_files => flattened_source_files,130 :strip_comments => false131 )132 secretary.concatenation.save_to(SOURCE_FILE_FOR_DOCS)133 end134end135desc "Builds the distribution."136task :dist, :copy_locations do |task,arguments|137 puts "Building ActiveJS distributions with Sprockets"138 ActiveJSHelper.sprocketize139 ActiveJSHelper::DISTRIBUTIONS.each_pair do |target,payload|140 puts "Built #{File.expand_path(File.join(ActiveJSHelper::DIST_DIR,target))}"141 end 142 copy_locations = (arguments[:copy_locations] || '').split(',')143 copy_locations.each do |location_pair|144 source, target = location_pair.split(':')145 source = File.expand_path(File.join(ActiveJSHelper::DIST_DIR,source))146 target = File.expand_path(target)147 FileUtils.copy(148 source,149 target150 )151 puts "Copied #{source} to #{target}"152 end153 puts "Task complete."154end155desc "Builds the documentation"156task :docs do157 require 'vendor/pdoc/lib/pdoc'158 rm_rf Dir.glob(File.join(ActiveJSHelper::DOCS_DIR, "*"))159 ActiveJSHelper.sprocketize_for_docs160 PDoc.run({161 :source_files => [ActiveJSHelper::SOURCE_FILE_FOR_DOCS],162 :destination => ActiveJSHelper::DOCS_DIR,163 :syntax_highlighter => :pygments,164 :markdown_parser => :bluecloth,165 :src_code_href => proc { |doc|166 "http://github.com/aptana/activejs/blob/#{hash}/#{doc.file}#LID#{doc.line_number}"167 },168 :pretty_urls => false,169 :bust_cache => false,170 :name => 'ActiveJS',171 :short_name => 'ActiveJS',172 :home_url => 'http://activejs.org',173 :doc_url => 'http://activejs.org',174 :version => ActiveJSHelper::VERSION,175 :index_title => 'ActiveJS: JavaScript Application Framework',176 :index_page => 'README.markdown',177 :index_header => '<a href="http://activejs.org/downloads/active.js" id="header_logo"><img src="http://activejs.org/images/activejs.gif"/></a>',178 :footer => '<div id="footer_logos"><a href="http://syntacticx.com"><img src="http://activejs.org/images/syntacticx.gif" style="border:none;"/></a><a href="http://aptana.org/"><img src="http://activejs.org/images/aptana.gif" style="border:none;"/></a><a href="http://dashwire.com/"><img src="http://activejs.org/images/dashwire.gif" style="border:none;"/></a></div>',179 :stylesheets => ['docs']180 })181 FileUtils.rm(ActiveJSHelper::SOURCE_FILE_FOR_DOCS)182 FileUtils.cp_r(Dir.glob(File.join(ActiveJSHelper::ASSETS_DIR,"**")), ActiveJSHelper::DOCS_DIR)183end184desc "Builds the distributions, and documentation, and copies the generated docs to a location of your choosing"185task :deploy, :target do |task,arguments|186 Rake::Task["dist"].reenable187 Rake::Task["dist"].invoke188 Rake::Task["docs"].reenable189 Rake::Task["docs"].invoke190 rm_rf Dir.glob(File.join(arguments[:target],"*"))191 FileUtils.cp_r(Dir.glob(File.join(ActiveJSHelper::DOCS_DIR,"*")),File.join(arguments[:target]))192end193task :compress do194 require 'yui/compressor'195 compressor = YUI::JavaScriptCompressor.new(:munge => true)196 ActiveJSHelper::DISTRIBUTIONS.each_pair do |name,payload|197 src = File.read(File.join(ActiveJSHelper::DIST_DIR,name))198 File.open(File.join(ActiveJSHelper::DIST_DIR,name.gsub(/\.js$/,'.min.js')),'w') do |file|199 file.write(compressor.compress(src))200 end201 end202end...

Full Screen

Full Screen

js_helper_spec.rb

Source:js_helper_spec.rb Github

copy

Full Screen

...29 describe "#js_configuration" do30 it 'output nil without configuration' do31 helper.js_configuration().should be_nil32 end33 it "output a script tag" do34 helper.configure_js('foo', {:bar=>'bizz'})35 helper.configure_js('bot', {:lot=>'op'})36 helper.js_configuration.should match(/script/)37 helper.js_configuration.should eq "<script>\n//<![CDATA[\nfunction extend(a,b){a=a||{};for(var c in b)\"object\"==typeof b[c]&&null!==b[c]&&b[c].constructor==Array?a[c]=b[c]:\"object\"==typeof b[c]?a[c]=extend(a[c],b[c]):a[c]=b[c];return a}window.lp = window.lp || {}; window.lp.foo=window.lp.foo||{}; extend(window.lp.foo, {\"bar\":\"bizz\"}); window.lp.bot=window.lp.bot||{}; extend(window.lp.bot, {\"lot\":\"op\"});\n//]]>\n</script>"38 end39 end40 describe "#js_hash" do41 it "sets values on the window object" do42 helper.js_hash({'aaa' => 'bbb', 'ccc' => 'ddd'}).should == 'window.aaa = "bbb";window.ccc = "ddd";'43 end44 it "checks sets values on nested objects" do45 helper.js_hash({'aaa' => 'bbb', 'ccc' => {'ddd' => 'eee'}}).should == "window.aaa = \"bbb\";if (!window.hasOwnProperty('ccc')) window.ccc = {};window.ccc.ddd = \"eee\";"46 end47 it "sanitizes the keys" do48 helper.js_hash({'<script>aaa</script>' => "<script>foo</script>"}).should == "window.aaa = \"foo\";"49 end50 end51 describe ::JsHelper::Config do52 let(:configuration) { { :foo => :bar }}53 subject { JsHelper::Config.new(nil) }54 describe "#initialize" do55 it "stores the root namespace on the root_namespace attribute" do56 JsHelper::Config.new("foo").root_namespace.should eq "foo"57 end58 end59 describe "#configurations" do60 it "by default, returns a an empty hash for any key" do61 subject.configurations[:some_key].should eq({})62 end...

Full Screen

Full Screen

script

Using AI Code Generation

copy

Full Screen

1script 'alert("Hello World")'2script 'alert("Hello World")'3script 'alert("Hello World")'4script 'alert("Hello World")'5script 'alert("Hello World")'6script 'alert("Hello World")'7script 'alert("Hello World")'8script 'alert("Hello World")'9script 'alert("Hello World")'10script 'alert("Hello World")'11script 'alert("Hello World")'12script 'alert("Hello World")'13script 'alert("Hello World")'14script 'alert("Hello World")'

Full Screen

Full Screen

script

Using AI Code Generation

copy

Full Screen

1JSHelper.script('alert("Hello from Ruby");')2JSHelper.script('alert("Hello from Ruby");', 'alert("Hello from Ruby");')3JSHelper.script('alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");')4JSHelper.script('alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");')5JSHelper.script('alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");')6JSHelper.script('alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");')7JSHelper.script('alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");')8JSHelper.script('alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");', 'alert("Hello from Ruby");')

Full Screen

Full Screen

script

Using AI Code Generation

copy

Full Screen

1js.script("alert('Hello World!')")2js.script("alert('Hello World!')")3js.script("alert('Hello World!')")4js.script("alert('Hello World!')")

Full Screen

Full Screen

script

Using AI Code Generation

copy

Full Screen

1 "alert('hello world')"2 function sayHello() {3 alert('hello world');4 }5 "alert('hello world')"6 function sayHello() {7 alert('hello world');8 }9 function sayHello() {10 alert('hello world');11 }12 function sayHello() {13 alert('hello world');14 }15 function sayHello() {16 alert('hello world');17 }

Full Screen

Full Screen

script

Using AI Code Generation

copy

Full Screen

1script "alert('hi');"2 def script(script)3 page.execute_script(script)4<%= form_for @user, :html => { :id => "form" } do |f| %>5 <%= f.select :status, ['Active', 'Inactive', 'Pending'], { :include_blank => false }, { :onchange => "changeAction()" } %>6function changeAction() {7 $('form').action = '/users/' + $('form').user_status.value + '_users';8}

Full Screen

Full Screen

script

Using AI Code Generation

copy

Full Screen

1js.script("alert('Hello from Ruby!')")2js.script("alert('Hello from Ruby!')")3js.script("alert('Hello from Ruby!')")4js.script("alert('Hello from Ruby!')")5js.script("alert('Hello from Ruby!')")6js.script("alert('Hello from Ruby!')")7js.script("alert('Hello from Ruby!')")8js.script("alert('Hello from Ruby!')")9js.script("alert('Hello from Ruby!')")10js.script("alert('Hello from

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Site_prism automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful