Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
charlierudolph committed Aug 5, 2016
0 parents commit 9f52b7b
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
.DS_Store
npm-debug.log
node_modules
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,3 @@
## 0.1.0 - First Release
* Every feature added
* Every bug fixed
20 changes: 20 additions & 0 deletions LICENSE.md
@@ -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.
5 changes: 5 additions & 0 deletions README.md
@@ -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)
78 changes: 78 additions & 0 deletions lib/tertestrial.coffee
@@ -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'}"
16 changes: 16 additions & 0 deletions menus/tertestrial.cson
@@ -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" }
]
}
]
}
]
20 changes: 20 additions & 0 deletions package.json
@@ -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"
}
}
1 change: 1 addition & 0 deletions tertestrial

0 comments on commit 9f52b7b

Please sign in to comment.