Include JSTalk framework in a project?

88 views
Skip to first unread message

Kyle Swank

unread,
May 8, 2012, 9:54:31 AM5/8/12
to JSTalk Dev
Hi All,

I have a few questions here that hopefully someone can answer for me.

We have an existing project that uses Ruby to probe the system for a
bunch of system information to help diagnose and troubleshoot problems
customers are encountering with our products. I'm currently looking at
alternatives to see if we can find something that may be easier to
write and maintain.

What I'd like to be able to do is write a simple library that probes
for the common data fields (software versions, and simple settings,
tail ends of log files).

Then write a script that uses this library and creates a report of all
of the information in an easy to read way. Currently it is a very long
html file. Which is perfectly fine for our purposes.

Bonus points if I can replicate a testing framework to use the
library, and create a cocoa front-end for it that tells the user of
common problems. Basically something like this (in pseudo code):

if software version != current version then "Provide user with
instructions on how to update"

if extension version != current version then "Provide user with
instructions on how to update"

if software setting == false then "Provide user with instructions on
how to turn it on"

Even more bonus points if I can do something like this:

if path's permissions != readable and writable then "Provide user with
warning, and allow them to click a "Fix" button that runs a script to
fix it"

Lastly, I'd like to just fiddle with JSTalk in a brand new empty
project but I'm having trouble getting it to work. Does anyone have a
very basic project with an example for how to set it up?

1) I've gone to the project settings->Build Phase and included the
JSTalk.framework folder.
2) Run the application. It gives me a library error (if you need the
error let me know and I'll get it to you). But the app won't compile
or run due to this library error.

So at this point I can't even get the thing to sit in the project and
do nothing without the app ceasing to function.

Would appreciate any guidance on these questions.

Thanks,
Kyle

Kyle Swank

unread,
May 8, 2012, 4:16:33 PM5/8/12
to JSTalk Dev
Alright, I'm clearly just a dunce. I've gotten it to work in a
compiled application.

Now the biggest thing I'm trying to figure out is whether there is an
easy way for JS to execute a command from the command line.

For example, anyway that I can have it execute the command "sw_vers"
from the command line and provide the results of the command as a
string?

Thanks,
Kyle

Gus Mueller

unread,
May 8, 2012, 4:34:27 PM5/8/12
to jstal...@googlegroups.com
On May 8, 2012, at 1:16 PM, Kyle Swank wrote:

> Alright, I'm clearly just a dunce. I've gotten it to work in a
> compiled application.

Yay!

I was going to suggest the jstmakeamalgamation.jstalk script, which will combine all the sources into a single.m file as well. I do this for VoodooPad for various reasons- sometimes a framework is a pain.

> Now the biggest thing I'm trying to figure out is whether there is an
> easy way for JS to execute a command from the command line.
>
> For example, anyway that I can have it execute the command "sw_vers"
> from the command line and provide the results of the command as a
> string?

Yes, you could use GTMScriptRunner, which is a plugin you can include.

var s = [[GTMScriptRunner runner] run:'/usr/bin/sw_vers'];

However, it might be easier to just load up the SystemVersion plist:
var d = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"];

print(d['ProductBuildVersion']);
print(d['ProductName']);
print(d['ProductUserVisibleVersion']);
print(d['ProductVersion']);

-gus

--

August 'Gus' Mueller
Flying Meat Inc.
http://flyingmeat.com/

Kyle Swank

unread,
May 11, 2012, 1:45:36 PM5/11/12
to JSTalk Dev
Gus,

This is fantastic and something I hadn't considered.

How would you include GTMScriptRunner?

Basically all I'm doing right now is creating a JSTalk item and
telling it to execute a script inside the bundle.

What I am very curious about is how to use the JSTalk:include:
method.

So far I've tried to use it, but it keeps telling me it cannot find
the script. Is there a default location it looks? Or do I need to
provide the full path? Both scripts are in the same folder inside the
app bundle.

Thank you again for your help. I really appreciate it.

Kyle

Gus Mueller

unread,
May 11, 2012, 3:29:16 PM5/11/12
to jstal...@googlegroups.com
On May 11, 2012, at 10:45 AM, Kyle Swank wrote:

> This is fantastic and something I hadn't considered.
>
> How would you include GTMScriptRunner?

You could include the source, or you could put it in your Contents/PlugIns folder of your app bundle, and then load it dynamically (though… JSTalk might automatically do that for you. It'd be nice if it did anyway).

> Basically all I'm doing right now is creating a JSTalk item and
> telling it to execute a script inside the bundle.
>
> What I am very curious about is how to use the JSTalk:include:
> method.

That's for use from within a jstalk script, as a way to load and execute a supporting script of some sort.

(as an aside, I've recently found out that JSEvaluateScript isn't reentrant, so "bad things" might happen when you use this from within a script. I haven't encountered any problems with it yet though, but I'll have to figure out another way of doing this in the future).

> So far I've tried to use it, but it keeps telling me it cannot find
> the script. Is there a default location it looks? Or do I need to
> provide the full path? Both scripts are in the same folder inside the
> app bundle.

You can pass the full path, or you can add the original script path to JSTalk's environment as "scriptURL", and it will figure out where to load it from based on that.

> Thank you again for your help. I really appreciate it.

No problem, and let us know if you run into any more issues.
Reply all
Reply to author
Forward
0 new messages