Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkadwill committed Mar 17, 2014
1 parent 0d19080 commit 864f767
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 1 deletion.
20 changes: 20 additions & 0 deletions LICENSE.md
@@ -0,0 +1,20 @@
Copyright (c) 2014 <Your name here>

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.
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
atom-rails
==========

Commands for Ruby on Rails development
Commands for Ruby on Rails development. Porting the best features of [tpope's](https://twitter.com/tpope) awesome [vim-rails](https://github.com/tpope/vim-rails).
11 changes: 11 additions & 0 deletions keymaps/atom-rails.cson
@@ -0,0 +1,11 @@
# Keybindings require three things to be fully defined: A selector that is
# matched against the focused element, the keystroke and the command to
# execute.
#
# Below is a basic keybinding which registers on all platforms by applying to
# the root workspace element.

# For more detailed documentation see
# https://atom.io/docs/latest/advanced/keymaps
'.workspace':
'ctrl-alt-o': 'atom-rails:toggle'
Empty file added lib/atom-rails-view.coffee
Empty file.
12 changes: 12 additions & 0 deletions lib/atom-rails.coffee
@@ -0,0 +1,12 @@
Model = require './model'

module.exports =
atomRailsView: null

activate: (state) ->
atom.workspaceView.command "atom-rails:switch-to-model", => @switchToModel()

switchToModel: ->
currentFile = atom.workspace.getActiveEditor().getPath()
file = new Model(currentFile).path()
atom.workspaceView.open(file) if file?
13 changes: 13 additions & 0 deletions lib/model.coffee
@@ -0,0 +1,13 @@
fs = require 'fs'
Path = require 'path'

module.exports =
class Model
constructor: (@currentFile) ->

path: ->
if @currentFile.match /_controller\.rb$/
@getModel @currentFile

getModel: (currentFile) ->
"/Users/tomkadwill/.atom/packages/atom-rails/README.md"
16 changes: 16 additions & 0 deletions menus/atom-rails.cson
@@ -0,0 +1,16 @@
# See https://atom.io/docs/latest/creating-a-package#menus for more details
'context-menu':
'.overlayer':
'Enable atom-rails': 'atom-rails:toggle'

'menu': [
{
'label': 'Packages'
'submenu': [
'label': 'atom-rails'
'submenu': [
{ 'label': 'Toggle', 'command': 'atom-rails:toggle' }
]
]
}
]
17 changes: 17 additions & 0 deletions package.json
@@ -0,0 +1,17 @@
{
"name": "atom-rails",
"main": "./lib/atom-rails",
"version": "0.1.0",
"description": "Commands for Ruby on Rails development",
"author": "Tom Kadwill",
"activationEvents": [
"atom-rails:switch-to-model"
],
"repository": "https://github.com/atom/atom-rails",
"license": "MIT",
"engines": {
"atom": ">0.50.0"
},
"dependencies": {
}
}
29 changes: 29 additions & 0 deletions spec/atom-rails-spec.coffee
@@ -0,0 +1,29 @@
AtomRails = require '../lib/atom-rails'

# 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 "AtomRails", ->
activationPromise = null

beforeEach ->
atom.workspaceView = new WorkspaceView
activationPromise = atom.packages.activatePackage('atomRails')

describe "when the atom-rails:toggle event is triggered", ->
it "attaches and then detaches the view", ->
expect(atom.workspaceView.find('.atom-rails')).not.toExist()

# This is an activation event, triggering it will cause the package to be
# activated.
atom.workspaceView.trigger 'atom-rails:toggle'

waitsForPromise ->
activationPromise

runs ->
expect(atom.workspaceView.find('.atom-rails')).toExist()
atom.workspaceView.trigger 'atom-rails:toggle'
expect(atom.workspaceView.find('.atom-rails')).not.toExist()
6 changes: 6 additions & 0 deletions spec/atom-rails-view-spec.coffee
@@ -0,0 +1,6 @@
AtomRailsView = require '../lib/atom-rails-view'
{WorkspaceView} = require 'atom'

describe "AtomRailsView", ->
it "has one valid test", ->
expect("life").toBe "easy"
8 changes: 8 additions & 0 deletions stylesheets/atom-rails.less
@@ -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/stylesheets/ui-variables.less
// for a full listing of what's available.
@import "ui-variables";

.atom-rails {
}
1 change: 1 addition & 0 deletions test_controller.rb
@@ -0,0 +1 @@
REMOVE ME

0 comments on commit 864f767

Please sign in to comment.