<commit_before>#mechanic.js (UIAutomation for the rest of us)

mechanic.js lets you take the power of UIAutomation with the simplicity of modern javascript CSS selector engines to make your UIAutomation scripts terse and beautiful.

Use mechanic.js to trim down your iOS automation scripts or to cut out the cruft in your iOS UATs.

You can also just use it to have fun. Want to click every button in the application? That's one line of code with mechanic. Need to get screenshots of every table cell in your favorite UITableView? Still just one line.

##Features

Selecting elements with mechanic.js looks a lot like jQuery, Dojo, Zepto, etc. The followimg will select all static text elements in the element named "My Scroll View":

``` js
$('#My Scroll View').find('UIAStaticText');
```

Mechanic provides selector shortcuts to remove some of the verbosity in selecting elements by type. The same elements could be selected with the following line:

``` js
$('#My Scroll View').find('text');
```

If you've already got a hold of the instances you care about, they can be passed into mechanic, giving them all the benefits of mechanic:

``` js
var mainWindow = UIATarget.localTarget().frontMostApp().mainWindow();
$(mainWindow).children().log();		// this calls logElement() internally
```

Mechanic comes with a number of utility functions to make your life easier:

``` js
$.backgroundApp(2);
$.delay(5);			// this calls UIATarget.localTarget().delay() internally
$("window").children().log();
```

Many of the utility functions are also tagged onto the selector implementation to allow chaining of selector commands and app-level commands, creating a nice cadence to your automation scripts. The following code captures screenshots of each cell in the "trip table" UITableView, waits for 5 seconds, and then logs their parent:

``` js
$.delay(5);
$('#trip table').find('cell')
	.capture()
	.delay(5)
	.parent().log();
```

Many of the UIAutomation user interaction functions have been simplified:

``` js
$.volume({direction: "up", duration: 2});	// UIATarget.localTarget().holdVolumeUp(2)
$.volume({direction: "down"});				// UIATarget.localTarget().clickVolumeDown();
$.prefs({
	"pref1": "value1", 						// ... frontMostApp().setPreferencesValueForKey("value1", "pref1");
	"pref2": "value2"						// ... frontMostApp().setPreferencesValueForKey("value2", "pref2")
});						
```

###... and more!

Mechanic has many more functions to make your life in iOS automation easier. API documentation is underway, and a test coverage is also a priority. In the mean time, take a look at the source to get an idea of what mechanic has to offer.

##Extending Mechanic.js

If there's a feature you're missing, it's easy to extend mechanic with your own "mixins"

``` js
(function() {
	$.extend($, {
		someAwesomeFeature: function() {
			// do something awesome
		},
		andAnother: function(someArg, anotherArg) {
			// more amazing greatness
		}
	});
	$.extend($.fn, {
		aNewSelectorMethod: function() {
			// yadda yadda yadda
			return this;	// returning 'this' allows you to chain selector-based functions together
		}
	});
})();

$.someAwesomeFeature();
$("tableview").aNewSelectorMethod();	
```

##Including Mechanic.js

Grab a copy of mechanic.js and place it alongside your UIAutomation scripts. At the top of your UIAutomation script(s), import mechanic.js:

``` js
#import "mechanic.js"

// you'll now have "mechanic" (with "$" as a shortcut) in the global context.
mechanic("#some element name").ancestry().capture();
...
```

## Feature Requests/Bugs

 Mechanic is not perfect. Submit bugs and feature requests if there's something that you think is missing! If you encounter bugs, please report it on mechanic's Issues page: http://github.com/jaykz52/mechanic/issues
 
If you've got a fix in mind, fork and submit a pull request. We need contributors!

## Contributing

The project is currently in its infancy (~ 1 week old!). We need API documentation, additional features, and test coverage (!!!), so feel free to get in touch via github, or just start submitting patches! Try to keep patches to single issues, this will make our lives easier in the long term.

# License

Copyright (c) 2012 <NAME>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
<commit_msg>Consistency in headers in README<commit_after>#mechanic.js (UIAutomation for the rest of us)

mechanic.js lets you take the power of UIAutomation with the simplicity of modern javascript CSS selector engines to make your UIAutomation scripts terse and beautiful.

Use mechanic.js to trim down your iOS automation scripts or to cut out the cruft in your iOS UATs.

You can also just use it to have fun. Want to click every button in the application? That's one line of code with mechanic. Need to get screenshots of every table cell in your favorite UITableView? Still just one line.

##Features

Selecting elements with mechanic.js looks a lot like jQuery, Dojo, Zepto, etc. The followimg will select all static text elements in the element named "My Scroll View":

``` js
$('#My Scroll View').find('UIAStaticText');
```

Mechanic provides selector shortcuts to remove some of the verbosity in selecting elements by type. The same elements could be selected with the following line:

``` js
$('#My Scroll View').find('text');
```

If you've already got a hold of the instances you care about, they can be passed into mechanic, giving them all the benefits of mechanic:

``` js
var mainWindow = UIATarget.localTarget().frontMostApp().mainWindow();
$(mainWindow).children().log();		// this calls logElement() internally
```

Mechanic comes with a number of utility functions to make your life easier:

``` js
$.backgroundApp(2);
$.delay(5);			// this calls UIATarget.localTarget().delay() internally
$("window").children().log();
```

Many of the utility functions are also tagged onto the selector implementation to allow chaining of selector commands and app-level commands, creating a nice cadence to your automation scripts. The following code captures screenshots of each cell in the "trip table" UITableView, waits for 5 seconds, and then logs their parent:

``` js
$.delay(5);
$('#trip table').find('cell')
	.capture()
	.delay(5)
	.parent().log();
```

Many of the UIAutomation user interaction functions have been simplified:

``` js
$.volume({direction: "up", duration: 2});	// UIATarget.localTarget().holdVolumeUp(2)
$.volume({direction: "down"});				// UIATarget.localTarget().clickVolumeDown();
$.prefs({
	"pref1": "value1", 						// ... frontMostApp().setPreferencesValueForKey("value1", "pref1");
	"pref2": "value2"						// ... frontMostApp().setPreferencesValueForKey("value2", "pref2")
});						
```

###... and more!

Mechanic has many more functions to make your life in iOS automation easier. API documentation is underway, and a test coverage is also a priority. In the mean time, take a look at the source to get an idea of what mechanic has to offer.

##Extending Mechanic.js

If there's a feature you're missing, it's easy to extend mechanic with your own "mixins"

``` js
(function() {
	$.extend($, {
		someAwesomeFeature: function() {
			// do something awesome
		},
		andAnother: function(someArg, anotherArg) {
			// more amazing greatness
		}
	});
	$.extend($.fn, {
		aNewSelectorMethod: function() {
			// yadda yadda yadda
			return this;	// returning 'this' allows you to chain selector-based functions together
		}
	});
})();

$.someAwesomeFeature();
$("tableview").aNewSelectorMethod();	
```

##Including Mechanic.js

Grab a copy of mechanic.js and place it alongside your UIAutomation scripts. At the top of your UIAutomation script(s), import mechanic.js:

``` js
#import "mechanic.js"

// you'll now have "mechanic" (with "$" as a shortcut) in the global context.
mechanic("#some element name").ancestry().capture();
...
```

##Feature Requests/Bugs

 Mechanic is not perfect. Submit bugs and feature requests if there's something that you think is missing! If you encounter bugs, please report it on mechanic's Issues page: http://github.com/jaykz52/mechanic/issues
 
If you've got a fix in mind, fork and submit a pull request. We need contributors!

##Contributing

The project is currently in its infancy (~ 1 week old!). We need API documentation, additional features, and test coverage (!!!), so feel free to get in touch via github, or just start submitting patches! Try to keep patches to single issues, this will make our lives easier in the long term.

##License

Copyright (c) 2012 <NAME>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

{'fraction_non_alphanumeric': 0.10355188324927567, 'fraction_numerical': 0.004721536645562829, 'mean_word_length': 4.482352941176471, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3536151', 'n_tokens_mistral': 2703, 'n_tokens_neox': 2499, 'n_words': 1204}