Why are some methods not available in Page Objects? - nightwatch.js

I am using Page Objects, which are great, but I noticed that some methods, more specifically the selenium protocol methods, were not available in the this reference. I end up having to make a custom command as a wrapper, which works fine, but I was just wondering if there was a reason that these methods weren't available or a way to get them to become available without the wrapper methods?

The selenium protocol methods appear under this.api... instead of just being under the this reference.

Related

How can i set the api version on a generic controller when loading a plugin?

I have some plugin's which are basically input and output type definitions. I have a generic controller which i can add to the mvc pipeline. All works fine.
but I'm having trouble setting the api version on this generic controller. I know you can set this based upon an attribute on top of the controller class. But since you can't have this dynamic (attribute) don't allow it, i have no way to set the version for each instance of the generic controller.
Currently i just compile the controller for each instance on runtime and register i using the roslyn compiler.
is there a way to set the api-version somewhere in the pipeline of registering controllers in the mvc pipeline and endup with different api versions endpoints.
This can be achieved by using the Conventions API. It was designed to support this exact type of scenario:
https://github.com/microsoft/aspnet-api-versioning/wiki/API-Version-Conventions
This will only work on closed-generics, but it shouldn't be too much work to make that happen. Here's a couple of basic examples:
// typed, closed generic
options.Conventions.Controller<GenericController<PlugIn1>>().HasApiVersion(1,0);
// untyped, closed generic
var controllerType = typeof(GenericController<>).MakeGenericType(new []{typeof(PlugIn1)});
options.Conventions.Controller(controllerType).HasApiVersion(1,0);
You can also author your own custom conventions a la IControllerConvention. This approach could be used to version all controllers that inherit from GenericController<>. Then you just need to add it to the conventions like this:
options.Conventions.Add(new PlugInControllerConvention());
Hopefully that's enough to get you started. Feel free to ask more questions.

how to display all the mothods called in the codeigniter profiler

is there any way to display all the methods called in the codeigniter profiler.
Also like to display which method calls which method and which method trigger the query
Unfortunately, your question is not very clear to me. I am not really sure of what you want to do.
there is a PHP command available in later versions called debug-backtrace.
http://php.net/manual/en/function.debug-backtrace.php
this gives you the stack trace of all commands executed to get to a particular method.
The codeigniter profiler is a system library. If there is a feature you really need it is possible to extend the profiler class to have the functionality you require. the CI manual explains how to do this in the section about 'Extending Native Libraries'

Sharing code between NSDocument and UIDocument

I have created a document-based app that uses Core Data. I created the mac version first, and now that it's working properly, I am moving on to create an iOS version of it.
I just can't get my head around how to maximize code reuse between the iOS/mac versions, with respect to the Core data bit, since they don't use the same classes.
My document class that handles saving and such is a subclass of NSPersistentDocument. My intention is that a well-designed model class should work in both environments, especially since I don't do all that much fancy stuff with regards to Core data.
Now, since NSPersistentDocument isn't available in iOS, I hit a wall. I tried to get around this by using #if TARGET_OS_MAC and TARGET_OS_IPHONE and in that manner make it a subclass of UIManagedDocument in the iOS version. That obviously would have been convenient, but I can't seem to make it work like that. And it's really looks quite messy, since there are a lot of other stuff that has to be conditionalized as well.
I also tried building the classes atop of NSDocument/UIDocument instead, implementing the Core data hooks myself, but it also looks quite messy, leaving me thinking it's not the right way to go.
The question:
To me, it seems like a good idea to reuse the same document class between the iOS/mac versions, but maybe I'm being naive.
What's the best way to do this?
Should I forget about the code sharing and create a separate document class for the iOS version that emulates all the methods present in the mac version?
Am I right that the code you're wanting to share is model-related? I suggest refactoring that code to a separate object, which both an NSDocument and UIDocument contain (as rickster suggested above).
I use a DocumentRoot Core Data entity with its own NSManagedObject subclass, but if there are no properties you want to manage using Core Data, you can just subclass NSObject.
This may sound strange, but NSDocument and UIDocument are actually controller classes. (To be specific, they're part of the model-controller.) Their jobs are to load the model, set up windows, and save the model. If you need to provide an interface for higher-level access to model objects, it could be in a document root or model helper class instead.
Similarly NSPersistentDocument's job is to configure the managed object context and the persistent store and handle loading and saving. It doesn't necessarily need to provide a complete interface for accessing the model.
(Bringing this over from my comment.)
In general, the situation where you have two classes which must inherit from different superclasses but which also want to share a lot of code is composition. Put the shared code in a separate class; your NSDocument and UIDocument subclasses can each keep an instance of that class, and message it whenever they need to invoke that shared code. (Though as #noa mentions, you might want to consider whether all of that code belongs in your document class to begin with.)
Of course, then you might end up writing a bunch of methods that read like:
- (id)doSomething {
return [sharedController doSomething]
}
That can get to be a pain... so you might want to look into Objective-C's message forwarding system.

Accessing the Evernote API through Ruby

I have a bunch of notes in Evernote which I would like to access in a Rubyish way (instead of only using the web interface). I thought I'd use this gem (https://github.com/cgs/evernote), which is "...a high level wrapper around Evernote's Thrift-generated ruby code. It bundles up Evernote's thrift-generated code and creates some simple wrapper classes."
I got a developer key, and the sample code here (https://github.com/cgs/evernote/blob/master/example.rb) worked, giving me the correct name for my sandbox notebook.
However, I don't understand what to do next. By "simple wrapper classes" I was expecting the Evernote::EDAM::Type::Notebook object to be some Enumerable object that I could use blocks to query. I dunno, something like
notebook.select {|note| note.tags == 'foo'}
But when I do the notebook.TAB TAB trick in IRB to look at available methods, there is nothing like that. The author of the gem refers users to Evernote API at http://www.evernote.com/about/developer/api/ref/ , and I can't make heads or tails of the thing. Am I out of luck until I fully understand what things like THRIFT means, or is there a simple listing of methods somewhere that I'm failing to look?
You shouldn't have to learn anything about Thrift. The data model wrapper classes (Note, Notebook, Tag, etc) are basically dumb structs; the methods to exercise them are on the endpoint classes, UserStore and NoteStore. For example, to get a list of Notebooks, you'd call NoteStore.listNotebooks. You can see some examples in the SDK under ruby/sample.
I've run into this issue recently, to use Ruby accessing the Evernote API. And here is the list which may help:
Official Ruby Demo
Evernote Developer Guide
Evernote API: All declarations
ENML
And I wrote a demo to make it more specific and straight.
Evernote API Ruby demo

Calling protocols from a framework?

I am currently using the NinevehGL engine to develop a simple app. This engine has a class called NGLMesh that stores openGL data for an instance of this class. From NinevehGL's documentation for the copyInstance method located at http://nineveh.gl/docs/Protocols/NGLCopying.html it says:
"The NGLCopying is an extension of Cocoa protocol NSCopying.
It defines two basic copying modes to NinevehGL objects:
Copy: Makes a new clone, copying all the used memory.
Copy Instance: Makes a new clone, but clonning just the superficial memory."
I would like to copy one of my NGLMeshs into a new NGLMesh instance using this method, however Im having a hard time understanding protocols and how to call them. Could someone offer some explanation? The internet has proved to be a little confusing thus far.
From what I gather (although Im most likely wrong) I need to "adopt" the NGLCopying protocol in the class that I want to use it with. I cant seem to find much information on how to accomplish this.
A protocol is just a list of messages that a class can respond to. Think of it as an extension of the class's #interface block, only it can be shared by several classes. If you are just trying to copy another class that already conforms to this protocol (such as NGLMesh), you don't need to do anything special — just do [yourNGLMeshObject copy] or [yourNGLMeshObject copyInstance].

Resources