From 567d78a12c2acc2ce0c75871948825089c94fd09 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 28 Aug 2019 00:09:30 -0700 Subject: Add snippets for ‘oni-ruby’ --- .gitlab-ci.yml | 11 +++++ GNUmakefile | 16 ++++++- oni-ruby.el | 36 ---------------- oni-ruby/Cask | 12 ++++++ oni-ruby/oni-ruby.el | 60 ++++++++++++++++++++++++++ oni-ruby/snippets/ruby-mode/ProductSeed | 5 +++ oni-ruby/snippets/ruby-mode/ProductSeedHW | 5 +++ oni-ruby/snippets/ruby-mode/ProductSeedHWGroup | 8 ++++ oni-ruby/snippets/ruby-mode/describe | 7 +++ oni-ruby/snippets/ruby-mode/do | 6 +++ oni-ruby/snippets/ruby-mode/factory | 9 ++++ oni-ruby/snippets/ruby-mode/fill_in | 5 +++ oni-ruby/snippets/ruby-mode/mod | 11 +++++ oni-ruby/snippets/ruby-mode/reduce | 5 +++ 14 files changed, 159 insertions(+), 37 deletions(-) delete mode 100644 oni-ruby.el create mode 100644 oni-ruby/Cask create mode 100644 oni-ruby/oni-ruby.el create mode 100644 oni-ruby/snippets/ruby-mode/ProductSeed create mode 100644 oni-ruby/snippets/ruby-mode/ProductSeedHW create mode 100644 oni-ruby/snippets/ruby-mode/ProductSeedHWGroup create mode 100644 oni-ruby/snippets/ruby-mode/describe create mode 100644 oni-ruby/snippets/ruby-mode/do create mode 100644 oni-ruby/snippets/ruby-mode/factory create mode 100644 oni-ruby/snippets/ruby-mode/fill_in create mode 100644 oni-ruby/snippets/ruby-mode/mod create mode 100644 oni-ruby/snippets/ruby-mode/reduce diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 21f57cd..cc85730 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -86,6 +86,16 @@ package-oni-python: paths: - oni-python/dist/ +package-oni-ruby: + stage: pre-package-multifile + before_script: + - rm -rf oni-elisp/dist + script: + - cask --path oni-ruby package + artifacts: + paths: + - oni-ruby/dist/ + test-oni-alert: stage: test script: make test-oni-alert @@ -141,6 +151,7 @@ package: - package-oni-nxml - package-oni-php - package-oni-python + - package-oni-ruby before_script: - rm -rf bin/ - mkdir bin/ diff --git a/GNUmakefile b/GNUmakefile index 557aa2a..2b478ff 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -4,7 +4,7 @@ PACKAGE_TARGETS := $(addprefix package-,$(FILES)) package: $(PACKAGE_TARGETS) package-oni-conf package-oni-css package-oni-elisp \ package-oni-haml package-oni-html package-oni-nxml package-oni-org \ - package-oni-php package-oni-python + package-oni-php package-oni-python package-oni-ruby package-%: % emacs --batch \ @@ -66,6 +66,12 @@ package-oni-python: --funcall package-initialize \ --eval "(package-upload-file (car (sort (file-expand-wildcards \"oni-python/dist/*.tar\") #'string>)))" +package-oni-ruby: + emacs --batch \ + --load oni-package.el \ + --funcall package-initialize \ + --eval "(package-upload-file (car (sort (file-expand-wildcards \"oni-ruby/dist/*.tar\") #'string>)))" + install-%: emacs --batch \ --load oni-package.el \ @@ -146,6 +152,14 @@ install-oni-python: $(foreach DEP,$(DEPS),--eval "(package-install-file \"$(DEP).el\")") \ --eval "(package-install-file (car (sort (file-expand-wildcards \"oni-python/dist/*.tar\") #'string>)))" +install-oni-ruby: + emacs --batch \ + --load oni-package.el \ + --fluncall package-initialize \ + --eval '(package-refresh-contents)' \ + $(foreach DEP,$(DEPS),--eval "(package-install-file \"$(DEP).el\")") \ + --eval "(package-install-file (car (sort (file-expand-wildcards \"oni-ruby/dist/*.tar\") #'string>)))" + test-%: install-% emacs --batch \ --load oni-package.el \ diff --git a/oni-ruby.el b/oni-ruby.el deleted file mode 100644 index 43de2c2..0000000 --- a/oni-ruby.el +++ /dev/null @@ -1,36 +0,0 @@ -;;; oni-ruby.el --- Ruby configuration -*- lexical-binding: t; -*- - -;; Copyright (C) 2019 Tom Willemse - -;; Author: Tom Willemse -;; Keywords: local -;; Version: 20190306003050 -;; Package-Requires: (ruby-mode oni-fci) - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: - -;; Ruby configuration. - -;;; Code: - -(add-hook 'ruby-mode-hook 'electric-indent-local-mode) -(add-hook 'ruby-mode-hook 'electric-pair-local-mode) -(add-hook 'ruby-mode-hook 'fci-mode) - -;;;###autoload(with-eval-after-load 'ruby-mode (require 'oni-ruby)) - -(provide 'oni-ruby) -;;; oni-ruby.el ends here diff --git a/oni-ruby/Cask b/oni-ruby/Cask new file mode 100644 index 0000000..6b8c51a --- /dev/null +++ b/oni-ruby/Cask @@ -0,0 +1,12 @@ +(source gnu) +(source melpa) + +(package-file "./oni-ruby.el") + +(depends-on "ruby-mode") +(depends-on "oni-yasnippet" :git "../" :files ("oni-yasnippet.el")) +(depends-on "oni-fci" :git "../" :files ("oni-fci.el")) + +(files + "*.el" + ("snippets" "./snippets/*")) diff --git a/oni-ruby/oni-ruby.el b/oni-ruby/oni-ruby.el new file mode 100644 index 0000000..6e84184 --- /dev/null +++ b/oni-ruby/oni-ruby.el @@ -0,0 +1,60 @@ +;;; oni-ruby.el --- Ruby configuration -*- lexical-binding: t; -*- + +;; Copyright (C) 2019 Tom Willemse + +;; Author: Tom Willemse +;; Keywords: local +;; Version: 20190828000216 +;; Package-Requires: (ruby-mode oni-fci oni-yasnippet) + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; Ruby configuration. + +;;; Code: + +(require 'yasnippet) + +(defconst oni-ruby-root + (file-name-directory + (or load-file-name + (buffer-file-name))) + "The directory where ‘oni-ruby’ was loaded from.") + +(defconst oni-ruby-snippets-dir + (expand-file-name "snippets" oni-ruby-root) + "The directory where ‘oni-ruby’ stores its snippets.") + +;;;###autoload +(defun oni-ruby-snippets-initialize () + "Initialize the snippets for ‘oni-ruby’." + (when (boundp 'yas-snippet-dirs) + (add-to-list 'yas-snippet-dirs oni-ruby-snippets-dir)) + (yas-load-directory oni-ruby-snippets-dir)) + +(add-hook 'ruby-mode-hook 'electric-indent-local-mode) +(add-hook 'ruby-mode-hook 'electric-pair-local-mode) +(add-hook 'ruby-mode-hook 'fci-mode) + +;;;###autoload +(with-eval-after-load 'ruby-mode + (with-eval-after-load 'yasnippet + (oni-ruby-snippets-initialize))) + +;;;###autoload(with-eval-after-load 'ruby-mode (require 'oni-ruby)) + +(provide 'oni-ruby) +;;; oni-ruby.el ends here diff --git a/oni-ruby/snippets/ruby-mode/ProductSeed b/oni-ruby/snippets/ruby-mode/ProductSeed new file mode 100644 index 0000000..7e836c2 --- /dev/null +++ b/oni-ruby/snippets/ruby-mode/ProductSeed @@ -0,0 +1,5 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: ProductSeed +# key: pseed +# -- +Product.find_or_create_by_name(parent_id: $1, name: '$2', description: '$3', price: '$4') \ No newline at end of file diff --git a/oni-ruby/snippets/ruby-mode/ProductSeedHW b/oni-ruby/snippets/ruby-mode/ProductSeedHW new file mode 100644 index 0000000..843b32e --- /dev/null +++ b/oni-ruby/snippets/ruby-mode/ProductSeedHW @@ -0,0 +1,5 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: ProductSeedWithHW +# key: pseed +# -- +Product.find_or_create_by_name(parent_id: $1, name: '$2', description: '$3', price: '$4', width_in_cm: '$5', height_in_cm: '$6', width_in_mm: '${5:$(round (* 10 (string-to-int yas-text)))}', height_in_mm: '${6:$(round (* 10 (string-to-int yas-text)))}') \ No newline at end of file diff --git a/oni-ruby/snippets/ruby-mode/ProductSeedHWGroup b/oni-ruby/snippets/ruby-mode/ProductSeedHWGroup new file mode 100644 index 0000000..25594c5 --- /dev/null +++ b/oni-ruby/snippets/ruby-mode/ProductSeedHWGroup @@ -0,0 +1,8 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: ProductSeedWithHWGroup +# key: pseed +# -- +Product.find_or_create_by_name(parent_id: $1, name: '$2', description: 'Small', price: '20.00', width_in_cm: '25.00', height_in_cm: '21.00', width_in_mm: '250', height_in_mm: '210') +Product.find_or_create_by_name(parent_id: $1, name: '$2', description: 'Medium', price: '20.00', width_in_cm: '30.00', height_in_cm: '25.80', width_in_mm: '300', height_in_mm: '258') +Product.find_or_create_by_name(parent_id: $1, name: '$2', description: 'Large', price: '20.00', width_in_cm: '35.00', height_in_cm: '30.00', width_in_mm: '350', height_in_mm: '300') +Product.find_or_create_by_name(parent_id: $1, name: '$2', description: 'Extra large', price: '20.00', width_in_cm: '40.00', height_in_cm: '34.00', width_in_mm: '400', height_in_mm: '340') diff --git a/oni-ruby/snippets/ruby-mode/describe b/oni-ruby/snippets/ruby-mode/describe new file mode 100644 index 0000000..acd3a6b --- /dev/null +++ b/oni-ruby/snippets/ruby-mode/describe @@ -0,0 +1,7 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: describe +# key: desc +# -- +describe '$1' do + $0 +end \ No newline at end of file diff --git a/oni-ruby/snippets/ruby-mode/do b/oni-ruby/snippets/ruby-mode/do new file mode 100644 index 0000000..3c556fc --- /dev/null +++ b/oni-ruby/snippets/ruby-mode/do @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: do +# key: do +# -- +do$0 +end \ No newline at end of file diff --git a/oni-ruby/snippets/ruby-mode/factory b/oni-ruby/snippets/ruby-mode/factory new file mode 100644 index 0000000..619b2e5 --- /dev/null +++ b/oni-ruby/snippets/ruby-mode/factory @@ -0,0 +1,9 @@ +# -*- mode: snippet -*- +# name: factory +# key: factory +# -- +FactoryGirl.define do + factory :${1:`(file-name-sans-extension (file-name-nondirectory buffer-file-name))`} do + $0 + end +end \ No newline at end of file diff --git a/oni-ruby/snippets/ruby-mode/fill_in b/oni-ruby/snippets/ruby-mode/fill_in new file mode 100644 index 0000000..854b029 --- /dev/null +++ b/oni-ruby/snippets/ruby-mode/fill_in @@ -0,0 +1,5 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: fill_in +# key: fin +# -- +fill_in '$1', with: $2 \ No newline at end of file diff --git a/oni-ruby/snippets/ruby-mode/mod b/oni-ruby/snippets/ruby-mode/mod new file mode 100644 index 0000000..9af7d23 --- /dev/null +++ b/oni-ruby/snippets/ruby-mode/mod @@ -0,0 +1,11 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: module ... end +# key: mod +# group: definitions +# -- +module ${1:`(let ((fn (capitalize (file-name-nondirectory + (directory-file-name + default-directory))))) + (replace-regexp-in-string "_" "" fn t t))`} + $0 +end \ No newline at end of file diff --git a/oni-ruby/snippets/ruby-mode/reduce b/oni-ruby/snippets/ruby-mode/reduce new file mode 100644 index 0000000..3d4bfe4 --- /dev/null +++ b/oni-ruby/snippets/ruby-mode/reduce @@ -0,0 +1,5 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: reduce +# key: reduce +# -- +reduce { |a, e| $0 } \ No newline at end of file -- cgit v1.2.3-54-g00ecf