Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
charlierudolph
committed
Aug 5, 2016
0 parents
commit 9f52b7b
Showing
8 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
npm-debug.log | ||
node_modules |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 0.1.0 - First Release | ||
* Every feature added | ||
* Every bug fixed |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2016 Charles Rudolph | ||
|
||
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: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# tertestrial package | ||
|
||
A short description of your package. | ||
|
||
![A screenshot of your package](https://f.cloud.github.com/assets/69169/2290250/c35d867a-a017-11e3-86be-cd7c5bf3ff9b.gif) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{CompositeDisposable} = require 'atom' | ||
|
||
module.exports = | ||
activate: -> | ||
@autoTest = false | ||
@subscriptions = new CompositeDisposable | ||
@subscriptions.add atom.workspace.observeTextEditors (editor) => @handleEvents(editor) | ||
@subscriptions.add atom.commands.add 'atom-workspace', | ||
'tertestrial:test-file': => | ||
@testFile(editor) if editor = atom.workspace.getActiveTextEditor() | ||
'tertestrial:test-line': => | ||
@testLine(editor) if editor = atom.workspace.getActiveTextEditor() | ||
'tertestrial:repeat-last-test': => | ||
@repeatLastTest() | ||
'tertestrial:toggle-auto-test': => | ||
@toggleAutoTest() | ||
|
||
|
||
deactivate: -> | ||
@subscriptions.dispose() | ||
|
||
|
||
handleEvents: (editor) -> | ||
buffer = editor.getBuffer() | ||
bufferSavedSubscription = buffer.onWillSave => | ||
buffer.transact => @repeatLastTest(editor) if @autoTest | ||
|
||
editorDestroyedSubscription = editor.onDidDestroy => | ||
bufferSavedSubscription.dispose() | ||
editorDestroyedSubscription.dispose() | ||
@subscriptions.remove(bufferSavedSubscription) | ||
@subscriptions.remove(editorDestroyedSubscription) | ||
|
||
@subscriptions.add(bufferSavedSubscription) | ||
@subscriptions.add(editorDestroyedSubscription) | ||
|
||
|
||
testFile: (editor) -> | ||
filename = editor.getPath() | ||
command = {filename} | ||
message = "testing file #{filename}" | ||
@sendCommand command, message | ||
|
||
|
||
testLine: (editor) -> | ||
filename = editor.getPath() | ||
line = editor.getCursorBufferPosition().row | ||
command = {filename, line} | ||
message = "testing file #{filename} at line #{line}" | ||
@sendCommand command, message | ||
|
||
|
||
repeatLastTest: -> | ||
command = operation: 'repeatLastTest' | ||
message = if @autoTest then '' else 'repeating last test' | ||
@sendCommand command, message | ||
|
||
|
||
sendCommand: (command, message) -> | ||
if @rootDirectories.length !== 1 | ||
atom.notifications.addError "tertestrial requires a single root directory" | ||
else | ||
projectPath = @rootDirectories[0].getPath() | ||
pipeFile = path.join projectPath, '.tertestrial.tmp' | ||
fs.access pipeFile, (err) -> | ||
if err | ||
atom.notifications.addError "tertestrial server is not running" | ||
else | ||
fs.appendFile pipeFile, JSON.stringify(command), (err) -> | ||
if err | ||
atom.notifications.addError "error writing to tertestrial pipe" | ||
else | ||
atom.notifications.addInfo message | ||
|
||
|
||
toggleAutoTest: -> | ||
@autoTest = !@autoTest | ||
atom.notifications.addInfo "autoRepeat is #{if @autoTest then 'on' else 'off'}" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
menu: [ | ||
{ | ||
label: "Packages" | ||
submenu: [ | ||
{ | ||
label: "tertestrial" | ||
submenu: [ | ||
{ label: "Test File", command: "tertestrial:test-file" } | ||
{ label: "Test Line", command: "tertestrial:test-line" } | ||
{ label: "Repeat Last Test", command: "tertestrial:repeat-last-test" } | ||
{ label: "Toggle Auto Test", command: "tertestrial:toggle-auto-test" } | ||
] | ||
} | ||
] | ||
} | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "tertestrial", | ||
"main": "./lib/tertestrial", | ||
"version": "0.1.0", | ||
"description": "Atom package for tertestrial", | ||
"activationCommands": { | ||
"atom-workspace": [ | ||
"tertestrial:test-file", | ||
"tertestrial:test-line", | ||
"tertestrial:repeat-last-test", | ||
"tertestrial:toggle-auto-repeat", | ||
"tertestrial:set-action-set" | ||
] | ||
}, | ||
"repository": "https://github.com/charlierudolph/tertestrial-atom", | ||
"license": "MIT", | ||
"engines": { | ||
"atom": ">=1.0.0 <2.0.0" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
packages/tertestrial |