This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/sh | |
| if [ $# -eq 0 ]; then | |
| echo "tell me your plugin name" | |
| exit 1 | |
| fi | |
| # set your language | |
| LANG="ja" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ActiveSupport::TestCase | |
| self.fixture_path = File.dirname(__FILE__) + '/fixtures' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Foo | |
| end | |
| class Bar | |
| extend Foo | |
| end | |
| Bar.included_modules.include?(Foo) | |
| Bar.include?(Foo) | |
| # => false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Adds the app/{controllers,helpers,models} directories of the plugin to the autoload path | |
| Dir.glob File.expand_path(File.join(p.directory, 'app', '{controllers,helpers,models}')) do |dir| | |
| ActiveSupport::Dependencies.autoload_paths += [dir] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Adds the app/{controllers,helpers,models} directories of the plugin to the autoload path | |
| Dir.glob File.expand_path(File.join(p.directory, 'app', '{controllers,helpers,models}')) do |dir| | |
| ActiveSupport::Dependencies.autoload_paths += [dir] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Redmine::Plugin.register :hoge do | |
| # other plugin settings | |
| # simple | |
| ActiveSupport::Dependencies.autoload_paths += [File.dirname(__FILE__) + "/app/forms"] | |
| # multiple | |
| Dir.glob(File.expand_path(File.join(File.dirname(__FILE__), "app", "{forms,services}"))) do |dir| | |
| ActiveSupport::Dependencies.autoload_paths += [dir] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| module TestModule | |
| def method_missing(name, *args) | |
| puts name | |
| self.class.class_eval do | |
| define_method name do |*params| | |
| self.sub(params) | |
| end | |
| end | |
| self.__send__(name, *args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set rails_env= | |
| copy plugins\<plugin_name>\test\fixtures\*.yml test\fixtures | |
| bundle exec rake redmine:plugins:test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| label = "foo bar" | |
| data = label.match(/foo (?<name>.+)\z/) | |
| p data[:name] | |
| # => bar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def coprime?(x, y) | |
| max = x > y ? Math.sqrt(y) : Math.sqrt(x) | |
| 2.upto(max) do |n| | |
| return false if x % n == 0 && y % n == 0 | |
| end | |
| true | |
| end |