1
0

Initial usecase: collection of useful MiniZinc packages

This commit is contained in:
Jip J. Dekker 2017-11-29 17:09:37 +11:00
parent e7a5f508ae
commit 6e9eaf483d
No known key found for this signature in database
GPG Key ID: 9CB1B58997DD0D58
9 changed files with 173 additions and 157 deletions

14
CHANGELOG.md Normal file
View File

@ -0,0 +1,14 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [0.0.1]
### Added
- Basic package dependencies on `language-mzn` and `linter-mzn`.
[Unreleased]: https://github.com/Dekker1/atom-minisuite/compare/v0.0.1...HEAD
[0.1.0]: https://github.com/Dekker1/atom-minisuite/compare/e7a5f508ae9975c310ae6fcb6c73c84b63dd6f49...v0.0.1

View File

@ -1,11 +1,11 @@
# Keybindings require three things to be fully defined: A selector that is # # Keybindings require three things to be fully defined: A selector that is
# matched against the focused element, the keystroke and the command to # # matched against the focused element, the keystroke and the command to
# execute. # # execute.
# #
# # Below is a basic keybinding which registers on all platforms by applying to
# # the root workspace element.
# #
# Below is a basic keybinding which registers on all platforms by applying to # # For more detailed documentation see
# the root workspace element. # # https://atom.io/docs/latest/behind-atom-keymaps-in-depth
# 'atom-workspace':
# For more detailed documentation see # 'ctrl-alt-o': 'minisuite:toggle'
# https://atom.io/docs/latest/behind-atom-keymaps-in-depth
'atom-workspace':
'ctrl-alt-o': 'minisuite:toggle'

View File

@ -1,22 +1,22 @@
module.exports = # module.exports =
class MinisuiteView # class MinisuiteView
constructor: (serializedState) -> # constructor: (serializedState) ->
# Create root element # # Create root element
@element = document.createElement('div') # @element = document.createElement('div')
@element.classList.add('minisuite') # @element.classList.add('minisuite')
#
# Create message element # # Create message element
message = document.createElement('div') # message = document.createElement('div')
message.textContent = "The Minisuite package is Alive! It's ALIVE!" # message.textContent = "The Minisuite package is Alive! It's ALIVE!"
message.classList.add('message') # message.classList.add('message')
@element.appendChild(message) # @element.appendChild(message)
#
# Returns an object that can be retrieved when package is activated # # Returns an object that can be retrieved when package is activated
serialize: -> # serialize: ->
#
# Tear down any state and detach # # Tear down any state and detach
destroy: -> # destroy: ->
@element.remove() # @element.remove()
#
getElement: -> # getElement: ->
@element # @element

View File

@ -1,5 +1,5 @@
MinisuiteView = require './minisuite-view' # MinisuiteView = require './minisuite-view'
{CompositeDisposable} = require 'atom' # {CompositeDisposable} = require 'atom'
module.exports = Minisuite = module.exports = Minisuite =
minisuiteView: null minisuiteView: null
@ -7,27 +7,28 @@ module.exports = Minisuite =
subscriptions: null subscriptions: null
activate: (state) -> activate: (state) ->
@minisuiteView = new MinisuiteView(state.minisuiteViewState) require('atom-package-deps').install 'MiniSuite'
@modalPanel = atom.workspace.addModalPanel(item: @minisuiteView.getElement(), visible: false) # @minisuiteView = new MinisuiteView(state.minisuiteViewState)
# @modalPanel = atom.workspace.addModalPanel(item: @minisuiteView.getElement(), visible: false)
#
# # Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
# @subscriptions = new CompositeDisposable
#
# # Register command that toggles this view
# @subscriptions.add atom.commands.add 'atom-workspace', 'minisuite:toggle': => @toggle()
# Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable # deactivate: ->
@subscriptions = new CompositeDisposable # @modalPanel.destroy()
# @subscriptions.dispose()
# Register command that toggles this view # @minisuiteView.destroy()
@subscriptions.add atom.commands.add 'atom-workspace', 'minisuite:toggle': => @toggle() #
# serialize: ->
deactivate: -> # minisuiteViewState: @minisuiteView.serialize()
@modalPanel.destroy() #
@subscriptions.dispose() # toggle: ->
@minisuiteView.destroy() # console.log 'Minisuite was toggled!'
#
serialize: -> # if @modalPanel.isVisible()
minisuiteViewState: @minisuiteView.serialize() # @modalPanel.hide()
# else
toggle: -> # @modalPanel.show()
console.log 'Minisuite was toggled!'
if @modalPanel.isVisible()
@modalPanel.hide()
else
@modalPanel.show()

View File

@ -1,22 +1,22 @@
# See https://atom.io/docs/latest/hacking-atom-package-word-count#menus for more details # # See https://atom.io/docs/latest/hacking-atom-package-word-count#menus for more details
'context-menu': # 'context-menu':
'atom-text-editor': [ # 'atom-text-editor': [
{ # {
'label': 'Toggle minisuite' # 'label': 'Toggle minisuite'
'command': 'minisuite:toggle' # 'command': 'minisuite:toggle'
} # }
] # ]
'menu': [ # 'menu': [
{ # {
'label': 'Packages' # 'label': 'Packages'
'submenu': [ # 'submenu': [
'label': 'minisuite' # 'label': 'minisuite'
'submenu': [ # 'submenu': [
{ # {
'label': 'Toggle' # 'label': 'Toggle'
'command': 'minisuite:toggle' # 'command': 'minisuite:toggle'
} # }
] # ]
] # ]
} # }
] # ]

View File

@ -2,17 +2,18 @@
"name": "MiniSuite", "name": "MiniSuite",
"main": "./lib/minisuite", "main": "./lib/minisuite",
"version": "0.0.0", "version": "0.0.0",
"description": "A short description of your package", "description": "Bringing an MiniZinc IDE experience to atom",
"keywords": [ "keywords": ["MiniZinc", "IDE", "linter", "autocompletion"],
], "repository": "https://github.com/Dekker1/atom-minisuite",
"activationCommands": {
"atom-workspace": "minisuite:toggle"
},
"repository": "https://github.com/Dekker1/minisuite",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"atom": ">=1.0.0 <2.0.0" "atom": ">=1.0.0 <2.0.0"
}, },
"dependencies": { "dependencies": {
} "atom-package-deps": "^4.3.1"
},
"package-deps": [
"language-mzn",
"linter-mzn"
]
} }

View File

@ -1,62 +1,62 @@
Minisuite = require '../lib/minisuite' # Minisuite = require '../lib/minisuite'
# 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` # # Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
# or `fdescribe`). Remove the `f` to unfocus the block. # #
# # To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit`
describe "Minisuite", -> # # or `fdescribe`). Remove the `f` to unfocus the block.
[workspaceElement, activationPromise] = [] #
# describe "Minisuite", ->
beforeEach -> # [workspaceElement, activationPromise] = []
workspaceElement = atom.views.getView(atom.workspace) #
activationPromise = atom.packages.activatePackage('minisuite') # beforeEach ->
# workspaceElement = atom.views.getView(atom.workspace)
describe "when the minisuite:toggle event is triggered", -> # activationPromise = atom.packages.activatePackage('minisuite')
it "hides and shows the modal panel", -> #
# Before the activation event the view is not on the DOM, and no panel # describe "when the minisuite:toggle event is triggered", ->
# has been created # it "hides and shows the modal panel", ->
expect(workspaceElement.querySelector('.minisuite')).not.toExist() # # Before the activation event the view is not on the DOM, and no panel
# # has been created
# This is an activation event, triggering it will cause the package to be # expect(workspaceElement.querySelector('.minisuite')).not.toExist()
# activated. #
atom.commands.dispatch workspaceElement, 'minisuite:toggle' # # This is an activation event, triggering it will cause the package to be
# # activated.
waitsForPromise -> # atom.commands.dispatch workspaceElement, 'minisuite:toggle'
activationPromise #
# waitsForPromise ->
runs -> # activationPromise
expect(workspaceElement.querySelector('.minisuite')).toExist() #
# runs ->
minisuiteElement = workspaceElement.querySelector('.minisuite') # expect(workspaceElement.querySelector('.minisuite')).toExist()
expect(minisuiteElement).toExist() #
# minisuiteElement = workspaceElement.querySelector('.minisuite')
minisuitePanel = atom.workspace.panelForItem(minisuiteElement) # expect(minisuiteElement).toExist()
expect(minisuitePanel.isVisible()).toBe true #
atom.commands.dispatch workspaceElement, 'minisuite:toggle' # minisuitePanel = atom.workspace.panelForItem(minisuiteElement)
expect(minisuitePanel.isVisible()).toBe false # expect(minisuitePanel.isVisible()).toBe true
# atom.commands.dispatch workspaceElement, 'minisuite:toggle'
it "hides and shows the view", -> # expect(minisuitePanel.isVisible()).toBe false
# This test shows you an integration test testing at the view level. #
# it "hides and shows the view", ->
# Attaching the workspaceElement to the DOM is required to allow the # # This test shows you an integration test testing at the view level.
# `toBeVisible()` matchers to work. Anything testing visibility or focus #
# requires that the workspaceElement is on the DOM. Tests that attach the # # Attaching the workspaceElement to the DOM is required to allow the
# workspaceElement to the DOM are generally slower than those off DOM. # # `toBeVisible()` matchers to work. Anything testing visibility or focus
jasmine.attachToDOM(workspaceElement) # # requires that the workspaceElement is on the DOM. Tests that attach the
# # workspaceElement to the DOM are generally slower than those off DOM.
expect(workspaceElement.querySelector('.minisuite')).not.toExist() # jasmine.attachToDOM(workspaceElement)
#
# This is an activation event, triggering it causes the package to be # expect(workspaceElement.querySelector('.minisuite')).not.toExist()
# activated. #
atom.commands.dispatch workspaceElement, 'minisuite:toggle' # # This is an activation event, triggering it causes the package to be
# # activated.
waitsForPromise -> # atom.commands.dispatch workspaceElement, 'minisuite:toggle'
activationPromise #
# waitsForPromise ->
runs -> # activationPromise
# Now we can test for view visibility #
minisuiteElement = workspaceElement.querySelector('.minisuite') # runs ->
expect(minisuiteElement).toBeVisible() # # Now we can test for view visibility
atom.commands.dispatch workspaceElement, 'minisuite:toggle' # minisuiteElement = workspaceElement.querySelector('.minisuite')
expect(minisuiteElement).not.toBeVisible() # expect(minisuiteElement).toBeVisible()
# atom.commands.dispatch workspaceElement, 'minisuite:toggle'
# expect(minisuiteElement).not.toBeVisible()

View File

@ -1,5 +1,5 @@
MinisuiteView = require '../lib/minisuite-view' # MinisuiteView = require '../lib/minisuite-view'
#
describe "MinisuiteView", -> # describe "MinisuiteView", ->
it "has one valid test", -> # it "has one valid test", ->
expect("life").toBe "easy" # expect("life").toBe "easy"

View File

@ -2,7 +2,7 @@
// //
// See https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less // See https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less
// for a full listing of what's available. // for a full listing of what's available.
@import "ui-variables"; // @import "ui-variables";
//
.minisuite { // .minisuite {
} // }