Created
July 19, 2013 19:59
-
-
Save sheniff/6041946 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
**Please read:** This is a project in progress. Thus, every bug, suggestion, improvement or whatever you want to do to it will be welcome. Once the project is in a decent state, it'll be ported to an independent gem. | |
Description | |
--- | |
AB Tester makes Front End AB Test generation simpler than ever! | |
It allows the developer to create a copy of the Front End of the project based on default assets or on a previously generated test. | |
What AB Tester does is making a copy of the layout file the application is using to load the one-page app (generally, `application.html.haml`) along with the respective css and js manifests, renaming them to the name of the test. | |
Afterwards, it inspects the js manifest and copies all those folders that are involved in the application launch. | |
Once it's done, each testing version can be launch by simply changing the layout that's going to be rendered in the rails controller, like | |
```rails | |
render layout: "ab_testing/test1" | |
``` | |
And all the dependencies will be automatically taken from the newly generated manifests. | |
This way, it becomes as simple as modify the new files as much as we want to set up the testing version we want to provide. | |
Copying an old test: | |
=== | |
Sometimes we don't want to modify again the default app to create a new test that is basically the same as a previously generated one... | |
AB Tester also allows to copy from a previous test just by adding the option "--from". See examples below. | |
To Do: | |
=== | |
* Folders aren't removed, just files. Need a way to get rid of them too (Asked thru StackOverflow) | |
* Add extra params for many different settings | |
- layout_name (if differs from application) | |
- html_extension (html.haml, html.erb, .haml, .erb...) | |
Example - basic generation: | |
--- | |
``` | |
rails generate ab_tester test1 | |
This will create: | |
create app/views/layouts/ab_testing/ab_test1.html.haml | |
gsub app/views/layouts/ab_testing/ab_test1.html.haml | |
create app/assets/stylesheets/ab_test1.css | |
create app/assets/javascripts/ab_test1.js | |
gsub app/assets/javascripts/ab_test1.js | |
gsub app/assets/javascripts/ab_test1.js | |
Exploring app/assets/javascripts/application.js | |
create app/assets/javascripts/ab_test1/random_file.js | |
[...] | |
create app/assets/javascripts/ab_test1/random_folder/random_file.js | |
create app/assets/templates_ab_test1 | |
create app/assets/templates_ab_test1/random_folder/random_template.jst.hamlc | |
[...] | |
create app/assets/templates_ab_test1/random_folder/random_template.jst.hamlc | |
``` | |
Example - destroy: | |
--- | |
``` | |
rails destroy ab_tester test1 | |
This will destroy all the previously generated files: | |
remove app/views/layouts/ab_testing/ab_test1.html.haml | |
remove app/assets/stylesheets/ab_test1.css | |
remove app/assets/javascripts/ab_test1.js | |
Exploring app/assets/javascripts/application.js | |
remove app/assets/javascripts/ab_test1/random_file.js | |
[...] | |
remove app/assets/javascripts/ab_test1/random_folder/random_file.js | |
remove app/assets/templates_ab_test1/random_folder/random_template.jst.hamlc | |
[...] | |
remove app/assets/templates_ab_test1/random_folder/random_template.jst.hamlc | |
``` | |
**Heads Up!** | |
As Thor can't find out if you want to remove a folder that was generated when used `generate` (as you could have generated extra files in them lately), all the created folders (though empty) **won't be automatically removed**. They are easy to detect, though. | |
Example - creating from another test: | |
--- | |
rails generate ab_tester test2 --from test1 | |
``` | |
This will create: | |
Same as basic generation, but copying from test1 :) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment