Redmine插件开发帮助

这里先零星记录二次开发用得上的知识点:

1、windows下开发环境,参考此文。最好使用rubyinstaller安装,注意选择版本。或者直接安装railsinstaller。

2、获取issue自定义字段内容,参考此文

Every customizable redmine object has custom_field_values field, that value is array ofCustomFieldValueCustomFieldValue contains current value, custom field description and customized object.

Needed values i reads and alters by sort out. May be it's not best variant, but i acquainted with ruby language not so long ago.

Method for reading custom fields values:

def object_custom_field_value(object, field_name)
  object.custom_field_values.each do |field|
    if field.custom_field.name == field_name
      return field.value
    end
  end
end

And for changing:

def object_custom_field_set_value(object, field_name, value)
  object.custom_field_values.each do |field|
    if field.custom_field.name == field_name
      field.value = value
    end
  end
end

 3、bundle源修改

方法一:

bundle config --delete 'mirror.https://rubygems.org/'  # 删除全局变量

bundle config 'mirror.https://rubygems.org' 'https://ruby.taobao.org' 

2016.12.29设置后运行bundle install也失效,需将taobao的源更新至aliyun

bundle config 'mirror.https://rubygems.org' 'http://mirrors.aliyun.com/rubygems/'

bundle config 'mirror.http://mirrors.aliyun.com/rubygems/'http://gems.ruby-china.org/'  # 2017.1.7 发现gems.ruby-china.org好用。

方法二:

在Gemfile里加入:source 'http://mirrors.aliyun.com/rubygems/'

4、gem install rails --version 4.2.6 --no-ri --no-rdoc 失败的解决方法

原因还是因为默认的源地址不对,gem sources可查看gem使用的服务器地址。修改:

      gem sources -a http://mirrors.aliyun.com/rubygems/ --remove https://rubygems.org/ 

20170107 update: 因为ruby版本的原因,会出现“bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)”错误,修改:

      gem sources -a http://gems.ruby-china.org/ -V

C:\Sites>gem install rails --version 4.2.6 --no-ri --no-rdoc
Fetching: activesupport-4.2.6.gem (100%)
Successfully installed activesupport-4.2.6
Fetching: actionview-4.2.6.gem (100%)
Successfully installed actionview-4.2.6
Fetching: actionpack-4.2.6.gem (100%)
Successfully installed actionpack-4.2.6
Fetching: activejob-4.2.6.gem (100%)
Successfully installed activejob-4.2.6
Fetching: actionmailer-4.2.6.gem (100%)
Successfully installed actionmailer-4.2.6
Fetching: activemodel-4.2.6.gem (100%)
Successfully installed activemodel-4.2.6
Fetching: activerecord-4.2.6.gem (100%)
Successfully installed activerecord-4.2.6
Fetching: railties-4.2.6.gem (100%)
Successfully installed railties-4.2.6
Fetching: rails-4.2.6.gem (100%)
Successfully installed rails-4.2.6
9 gems installed

5、bundle与gem

6、创建插件框架

ruby htdocs/script/rails generate redmine_plugin Polls  # database connect error, maybe need to config first

6、帮助文档

自己生成chm帮助文档(参考1参考2),前提是已安装HTML HELP WORKSHOP

To create the documentation for Ruby, go to the Ruby source directory (\src\ruby-x.x.x-pxxx) in the console and enter: rdoc -f [format] -o [destination-folder].

To create the documentation for Rails, go to the ruby gems directory (i.e. \lib\ruby\gems\1.8\gems) and enter: rdoc -f [format] -x test/* -x template/* -o [destination-folder] action* active* rails-* .

The extra argument -x template/* is needed here to prevent errors from occurring during compilation, as discussed here. This problem occurs for both html and chm compilation.

我的实例:

D:\App\Coder\RailsInstaller\Ruby2.1.0\lib\ruby\gems\2.1.0\gems>rdoc -f chm -x test/* -x template/* -x rails-4.2.5.1/* -o d:\rails4.2.6.chm action* active* rails-*

也可直接下载ruby文档。

7、Rubymine设置github,参考此文,主要几步:

To use GitHub integration, perform these general steps

 

posted @ 2016-07-03 11:31  LustForLife  阅读(2143)  评论(0编辑  收藏  举报