Use global variable in specification step - getgauge

I am quite new to gauge. I am trying to test API requests. Is it possible to specify an endpoint which contains an id defined globally? E.g. a specification step like
* Make Get Request To "/endpoint-path/${id}/value"
I use gauge with TypeScript. I was able to achieve what I want using a workaround using the variable id (which is defined globally in the step implementation file or possibly in a DataStore)
endpoint = endpoint.replace(${id}, id);
Is there a way of really using a variable bidirectional?
My gauge version is.
Gauge version: 1.0.6
Plugins
-------
html-report (4.0.8)
python (0.3.5)
screenshot (0.0.1)
ts (0.0.2)
xml-report (0.2.1)

Unfortunately, that is not possible with Gauge

Related

Importing the correct Wasi module in node.js

I've been stuck on something for some time now. I'm trying to use WebAssembly from Node.js, but in order to do that, I need NodeJs to instantiate a Wasi object. This is implemented here: https://github.com/nodejs/node/blob/master/lib/wasi.js and the documentation is here: https://nodejs.org/api/wasi.html
It is imported through import { WASI } from 'wasi';
But I have no idea how to access the correct wasi implementation, when I add wasi to the dependencies it will install https://www.npmjs.com/package/wasi which is an old user implementation which I don't need. It also does not conform the API documentation from above, it is not usable. My IDE's (WebStorm) code inspection features act as if it is the correct implementation, but when executing the code, it becomes clear it's using a wrong implementation.
If I don't install any at all package I get Cannot find package 'wasi' imported from ...
So the question is, how do I use the WASI class declared in https://github.com/nodejs/node/blob/master/lib/wasi.js?
The solution is to include the command line argument --experimental-wasi-unstable-preview1 when running node! (noted underneath the code example in https://nodejs.org/api/wasi.html)
Ex: node --experimental-wasi-unstable-preview1 index.js

Generate UUID5 in NiFi

In NiFi, I have a flow file with an attribute RSID. I need to generate a UUID v5 based on RSID and add it as an attribute to the flow file. This uuid needs to be based on RSID because some reports will have the same RSID and need to thus have the same UUID5.
I've seen some methods in Groovy that will generate a random uuid, but not v5 nor based on a string. Is this possible to do in Groovy/NiFi? If so, how would this be done? I'm very new to Groovy.
You can indeed do this with Groovy and NiFi using the ExecuteScript processor. This SO post includes the code for generating a UUID v5 which you can apply to your RSID namespace. If you want some pointers on using the NiFi API from ExecuteScript, feel free to check out my cookbook series, hopefully it will help you assemble a working solution.
I have also written a Jira to add a UUID5 function to NiFi Expression Language, to make this easier.

Attribute Resolution in Chef

I'm using a chef community cookbook that downloads, installs, a configures an SDK. (Let's call it the blah-sdk.) You just include_recipe 'blah-sdk' and viola, it's installed. It has an attribute specifying the version of the blah-sdk it will install. This version attribute in turn is used to form the value of a corresponding 'download_url' attribute. In theory I should be able to set the value of version attribute to something else in the cookbook where I include the blah-sdk. But there is a problem. The download_url attribute gets set (using the default version specified in the blah-sdk cookbook) before my override version attribute does. So the wrong url is used to retrieve the default version rather than the version I want. I could set the download_url in my cookbook as well, but that breaks the encapsulation of the 'blah-sdk' cookbook. I also might end up playing whack-a-mole experimentally with some long stream of attributes before getting it to work. There has got to be a better way. What is it?
cookbooks/blah-sdk/attributes/default.rb:
default['blah']['version'] = '24.4'
default['blah']['download_url'] = "http://dl.company.com/blah/blah-sdk_r#{node['blah']['version']}-linux.tgz"
cookbooks/blah-sdk/recipes/default.rb:
...
print("blah version: #{node['blah']['version']}")
print("blah download_url: #{node['blah']['download_url']}")
...
cookbooks/my_cookbook/attributes/default.rb:
normal['blah']['version'] = '24.4.1'
(I've also tried using default, force_default, override, and force_override. Made no difference.)
cookbooks/my_cookbook/recipes/default.rb
...
include_recipe 'blah-sdk'
...
Output:
==> default: blah version: 24.4.1
==> default: blah download_url: http://dl.company.com/blah/blah-sdk_r24.4-linux.tgz
Code demonstrating the issue and coderanger's suggested solution (if you can fix the third party cookbook):
https://github.com/marc-swingler/stackoverflow_question
Not the best solution, but due to the order in which attributes are loaded, dropping the version into a role or environment works too.
https://christinemdraper.wordpress.com/2014/10/06/avoiding-the-possible-pitfalls-of-derived-attributes/
See https://coderanger.net/derived-attributes/ for an overview of this problem. There is no good solution that doesn't involve modifying the upstream cookbook. Easiest solution is to duplicate the derived attribute in your wrapper as well.

How can I load Raphael within IPython notebook, avoiding some issues that arise due to require.js?

In an IPython notebook, one would expect the following code to cause Raphael.js to load successfully into the global namespace.
from IPython.display import Javascript
raphael_url = "https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"
Javascript('alert(Raphael);', lib=[raphael_url])
However, it does not work in recent versions of IPython which use require.js. Turns out, Raphael.js, which IPython loads using jQuery.getScript(), recognizes the presence of require.js and as such does not insert itself into the global namespace. In fact, if one first runs javascript code removing the window.define object, Raphael no longer realizes require.js is present, and it inserts itself into the global namespace as I would like. In other words, the code above works after running the following:
Javascript('window.define = undefined;')
Thus, the only way I am able to get Raphael to load within a recent version of IPython notebook is to delete (or set aside) window.define.
Having identified the problem, I am not familiar enough with require.js to know what piece of software is acting against protocol. Is Raphael using a poor way of testing for the existence of require.js? Should IPython be using require.js directly instead of jQuery.getScript() when it loads user-provided javascript libraries? Or is there a way I as the user ought to be embracing require.js, which will give me the Raphael object without needing any special hacks? (If the answer to the last question is yes, is there a way I can also support older versions of IPython notebook, which do not use require.js?)
The first part of my answer won't please you, but the loading and requirement of javascript library in the IPython-notebook-webapp has not yet been solved, so for now I would suggest not to build to much on the assumption you can load library like that, and rely more on custom.js for now.
That being said, if raphael is not in global namespace require is smart enough to cache it, and give you reference to it. Then in the callback you can just assign to a global :
require(['raphael'], function( raph ){
window.raphael = raph;
})
Or something like that should do the trick.

Node INTL locale Collation

I'm working on a side project that involves sorting Japanese and Thai strings. When I was testing the sorting in client-side Javascript, I was able to use a.localeCompare(b, "languageCode") which worked. When I tried this same logic in Node, it did not work, because the Node INTL object is restricted to English as the default.
I want to customize my node build as described in the above link, and came across the ICU4C-data Node Module, which I understand contains a full set of ICU data. I've been playing around with different build flags, like the one specified by the (sparse) README: --icu-data-dir=node_modules/icu4c-data, to no avail - no matter which flags I set I cannot get the INTL Collator's compare function to give the expected results. Is there an obvious flag that I'm missing, or key assumption I have wrong?
Here are a few things important notes/resources:
The end goal is Thai & Japanese collation - if there's another approach using Node to implement this, I'm open to suggestions.
Collation must be done in Node
I'm going to be relying on Array.prototype.sort() - mainly looking for a comparator
Using Node 0.12, with ECMA support
My first time customizing a Node build (~1 month experience)
Install the full-icu package instead. It will give instructions on how to load the rest of the data.
Also note that future node versions should not require any configuration to pick up the new data, you can see #3460 if interested.
I need to fix the icu4c-data's readme to reflect this.

Resources