Skip to content

Commit

Permalink
init: start from Atom package template
Browse files Browse the repository at this point in the history
  • Loading branch information
everythingfunctional committed Aug 12, 2021
0 parents commit 6187aef
Show file tree
Hide file tree
Showing 12 changed files with 246 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
npm-debug.log
node_modules
3 changes: 3 additions & 0 deletions CHANGELOG.md
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
20 changes: 20 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2021 Brad Richardson

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.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# atom-build-fpm package

A plugin for running the Fortran Package Manager (fpm) from within Atom
5 changes: 5 additions & 0 deletions keymaps/atom-build-fpm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"atom-workspace": {
"ctrl-alt-o": "atom-build-fpm:toggle"
}
}
29 changes: 29 additions & 0 deletions lib/atom-build-fpm-view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use babel';

export default class AtomBuildFpmView {

constructor(serializedState) {
// Create root element
this.element = document.createElement('div');
this.element.classList.add('atom-build-fpm');

// Create message element
const message = document.createElement('div');
message.textContent = 'The AtomBuildFpm package is Alive! It\'s ALIVE!';
message.classList.add('message');
this.element.appendChild(message);
}

// Returns an object that can be retrieved when package is activated
serialize() {}

// Tear down any state and detach
destroy() {
this.element.remove();
}

getElement() {
return this.element;
}

}
49 changes: 49 additions & 0 deletions lib/atom-build-fpm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use babel';

import AtomBuildFpmView from './atom-build-fpm-view';
import { CompositeDisposable } from 'atom';

export default {

atomBuildFpmView: null,
modalPanel: null,
subscriptions: null,

activate(state) {
this.atomBuildFpmView = new AtomBuildFpmView(state.atomBuildFpmViewState);
this.modalPanel = atom.workspace.addModalPanel({
item: this.atomBuildFpmView.getElement(),
visible: false
});

// Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
this.subscriptions = new CompositeDisposable();

// Register command that toggles this view
this.subscriptions.add(atom.commands.add('atom-workspace', {
'atom-build-fpm:toggle': () => this.toggle()
}));
},

deactivate() {
this.modalPanel.destroy();
this.subscriptions.dispose();
this.atomBuildFpmView.destroy();
},

serialize() {
return {
atomBuildFpmViewState: this.atomBuildFpmView.serialize()
};
},

toggle() {
console.log('AtomBuildFpm was toggled!');
return (
this.modalPanel.isVisible() ?
this.modalPanel.hide() :
this.modalPanel.show()
);
}

};
26 changes: 26 additions & 0 deletions menus/atom-build-fpm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"context-menu": {
"atom-text-editor": [
{
"label": "Toggle atom-build-fpm",
"command": "atom-build-fpm:toggle"
}
]
},
"menu": [
{
"label": "Packages",
"submenu": [
{
"label": "atom-build-fpm",
"submenu": [
{
"label": "Toggle",
"command": "atom-build-fpm:toggle"
}
]
}
]
}
]
}
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "atom-build-fpm",
"main": "./lib/atom-build-fpm",
"version": "0.0.0",
"description": "A plugin for running the Fortran Package Manager (fpm) from within Atom",
"keywords": [
],
"activationCommands": {
"atom-workspace": "atom-build-fpm:toggle"
},
"repository": "https://github.com/everythingfunctional/atom-build-fpm",
"license": "MIT",
"engines": {
"atom": ">=1.0.0 <2.0.0"
},
"dependencies": {
}
}
73 changes: 73 additions & 0 deletions spec/atom-build-fpm-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
'use babel';

import AtomBuildFpm from '../lib/atom-build-fpm';

// Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
//
// To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit`
// or `fdescribe`). Remove the `f` to unfocus the block.

describe('AtomBuildFpm', () => {
let workspaceElement, activationPromise;

beforeEach(() => {
workspaceElement = atom.views.getView(atom.workspace);
activationPromise = atom.packages.activatePackage('atom-build-fpm');
});

describe('when the atom-build-fpm:toggle event is triggered', () => {
it('hides and shows the modal panel', () => {
// Before the activation event the view is not on the DOM, and no panel
// has been created
expect(workspaceElement.querySelector('.atom-build-fpm')).not.toExist();

// This is an activation event, triggering it will cause the package to be
// activated.
atom.commands.dispatch(workspaceElement, 'atom-build-fpm:toggle');

waitsForPromise(() => {
return activationPromise;
});

runs(() => {
expect(workspaceElement.querySelector('.atom-build-fpm')).toExist();

let atomBuildFpmElement = workspaceElement.querySelector('.atom-build-fpm');
expect(atomBuildFpmElement).toExist();

let atomBuildFpmPanel = atom.workspace.panelForItem(atomBuildFpmElement);
expect(atomBuildFpmPanel.isVisible()).toBe(true);
atom.commands.dispatch(workspaceElement, 'atom-build-fpm:toggle');
expect(atomBuildFpmPanel.isVisible()).toBe(false);
});
});

it('hides and shows the view', () => {
// This test shows you an integration test testing at the view level.

// Attaching the workspaceElement to the DOM is required to allow the
// `toBeVisible()` matchers to work. Anything testing visibility or focus
// requires that the workspaceElement is on the DOM. Tests that attach the
// workspaceElement to the DOM are generally slower than those off DOM.
jasmine.attachToDOM(workspaceElement);

expect(workspaceElement.querySelector('.atom-build-fpm')).not.toExist();

// This is an activation event, triggering it causes the package to be
// activated.
atom.commands.dispatch(workspaceElement, 'atom-build-fpm:toggle');

waitsForPromise(() => {
return activationPromise;
});

runs(() => {
// Now we can test for view visibility
let atomBuildFpmElement = workspaceElement.querySelector('.atom-build-fpm');
expect(atomBuildFpmElement).toBeVisible();
atom.commands.dispatch(workspaceElement, 'atom-build-fpm:toggle');
expect(atomBuildFpmElement).not.toBeVisible();
});
});
});
});
9 changes: 9 additions & 0 deletions spec/atom-build-fpm-view-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use babel';

import AtomBuildFpmView from '../lib/atom-build-fpm-view';

describe('AtomBuildFpmView', () => {
it('has one valid test', () => {
expect('life').toBe('easy');
});
});
8 changes: 8 additions & 0 deletions styles/atom-build-fpm.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// The ui-variables file is provided by base themes provided by Atom.
//
// See https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less
// for a full listing of what's available.
@import "ui-variables";

.atom-build-fpm {
}

0 comments on commit 6187aef

Please sign in to comment.