unageanu-jiji 1.1.4 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +24 -1
- data/README +0 -0
- data/base/shared_lib/moving_average.rb +34 -33
- data/base/shared_lib/system/cross.rb +76 -0
- data/base/shared_lib/system/position_manager.rb +160 -0
- data/base/shared_lib/system/signal.rb +347 -0
- data/html/css/datatable.css +4 -4
- data/html/css/default.css +57 -5
- data/html/css/treeview.css +205 -0
- data/html/img/bin_closed.png +0 -0
- data/html/img/bin_empty.png +0 -0
- data/html/img/button_add_small.gif +0 -0
- data/html/img/button_add_small_gray.gif +0 -0
- data/html/img/button_add_small_over.gif +0 -0
- data/html/img/button_mkcol.gif +0 -0
- data/html/img/button_mkcol_gray.gif +0 -0
- data/html/img/button_mkcol_over.gif +0 -0
- data/html/img/button_remove_small.gif +0 -0
- data/html/img/button_remove_small_gray.gif +0 -0
- data/html/img/button_remove_small_over.gif +0 -0
- data/html/img/button_rename.gif +0 -0
- data/html/img/button_rename_gray.gif +0 -0
- data/html/img/button_rename_over.gif +0 -0
- data/html/img/control_play.png +0 -0
- data/html/img/control_play_blue.png +0 -0
- data/html/img/folder.png +0 -0
- data/html/img/folder_brick.png +0 -0
- data/html/img/folder_user.png +0 -0
- data/html/{js/codepress/images → img}/line-numbers.png +0 -0
- data/html/img/page_white_ruby.png +0 -0
- data/html/img/sidebar_agent_edit.png +0 -0
- data/html/img/sidebar_agent_edit_over.png +0 -0
- data/html/img/sidebar_agent_edit_s.png +0 -0
- data/html/img/yui/treeview-sprite.gif +0 -0
- data/html/index.html +34 -18
- data/html/js/agent-editor/agent-editor-page.js +324 -0
- data/html/js/agent-editor/agent-editor.js +363 -0
- data/html/js/agent-editor/agent-list-tree.js +251 -0
- data/html/js/agent-selector.js +23 -28
- data/html/js/app.js +63 -91
- data/html/js/bt-create-page.js +25 -19
- data/html/js/container-min.js +1 -1
- data/html/js/container.js +944 -0
- data/html/js/edit_area/autocompletion.js +11 -13
- data/html/js/edit_area/edit_area.css +79 -40
- data/html/js/edit_area/edit_area.js +255 -226
- data/html/js/edit_area/edit_area_compressor.php +4 -4
- data/html/js/edit_area/edit_area_full.gz +0 -0
- data/html/js/edit_area/edit_area_full.js +31 -31
- data/html/js/edit_area/edit_area_full_with_plugins.gz +0 -0
- data/html/js/edit_area/edit_area_full_with_plugins.js +31 -31
- data/html/js/edit_area/edit_area_functions.js +448 -341
- data/html/js/edit_area/edit_area_loader.js +409 -397
- data/html/js/edit_area/elements_functions.js +120 -123
- data/html/js/edit_area/highlight.js +305 -197
- data/html/js/edit_area/images/goto.png +0 -0
- data/html/js/edit_area/images/help.png +0 -0
- data/html/js/edit_area/images/redo.png +0 -0
- data/html/js/edit_area/images/save.png +0 -0
- data/html/js/edit_area/images/search.png +0 -0
- data/html/js/edit_area/images/undo.png +0 -0
- data/html/js/edit_area/images/word_wrap.gif +0 -0
- data/html/js/edit_area/keyboard.js +5 -5
- data/html/js/edit_area/langs/bg.js +73 -0
- data/html/js/edit_area/langs/cs.js +2 -0
- data/html/js/edit_area/langs/de.js +2 -0
- data/html/js/edit_area/langs/dk.js +2 -0
- data/html/js/edit_area/langs/en.js +2 -0
- data/html/js/edit_area/langs/eo.js +2 -0
- data/html/js/edit_area/langs/es.js +2 -0
- data/html/js/edit_area/langs/fi.js +67 -0
- data/html/js/edit_area/langs/fr.js +2 -0
- data/html/js/edit_area/langs/hr.js +2 -0
- data/html/js/edit_area/langs/it.js +2 -0
- data/html/js/edit_area/langs/ja.js +2 -0
- data/html/js/edit_area/langs/mk.js +2 -0
- data/html/js/edit_area/langs/nl.js +2 -0
- data/html/js/edit_area/langs/pl.js +2 -0
- data/html/js/edit_area/langs/pt.js +2 -0
- data/html/js/edit_area/langs/ru.js +2 -0
- data/html/js/edit_area/langs/sk.js +2 -0
- data/html/js/edit_area/langs/zh.js +67 -0
- data/html/js/edit_area/manage_area.js +362 -205
- data/html/js/edit_area/plugins/charmap/langs/bg.js +12 -0
- data/html/js/edit_area/plugins/charmap/langs/zh.js +6 -0
- data/html/js/edit_area/plugins/test/langs/bg.js +10 -0
- data/html/js/edit_area/plugins/test/langs/zh.js +4 -0
- data/html/js/edit_area/reg_syntax/java.js +56 -0
- data/html/js/edit_area/reg_syntax/ruby.js +9 -9
- data/html/js/edit_area/reg_syntax.js +15 -13
- data/html/js/edit_area/regexp.js +36 -32
- data/html/js/edit_area/resize_area.js +43 -47
- data/html/js/edit_area/search_replace.js +29 -29
- data/html/js/edit_area/template.html +6 -4
- data/html/js/json-broker-client.js +23 -17
- data/html/js/result-page.js +107 -57
- data/html/js/rt-setting-page.js +38 -15
- data/html/js/sidebar.js +41 -27
- data/html/js/templates.js +167 -32
- data/html/js/utils.js +143 -7
- data/html/js/yui/treeview.js +3671 -0
- data/html/swf/chart.swf +0 -0
- data/html/test/agent_editor_spec.js +815 -0
- data/html/test/index.html +40 -0
- data/html/test/jsspec/JSSpec.css +224 -0
- data/html/test/jsspec/JSSpec.js +1549 -0
- data/html/test/jsspec/diff_match_patch.js +1 -0
- data/html/test/utils_spec.js +111 -0
- data/lib/jiji/agent/agent.rb +69 -12
- data/lib/jiji/agent/agent_manager.rb +18 -12
- data/lib/jiji/agent/agent_registry.rb +35 -121
- data/lib/jiji/collector.rb +16 -6
- data/lib/jiji/command.rb +46 -5
- data/lib/jiji/dao/file_system_dao.rb +158 -0
- data/lib/jiji/dao/timed_data_dao.rb +2 -0
- data/lib/jiji/dao/trade_result_dao.rb +1 -1
- data/lib/jiji/error.rb +24 -8
- data/lib/jiji/migration/migrator1_2_0.rb +67 -0
- data/lib/jiji/models.rb +82 -24
- data/lib/jiji/operator.rb +55 -51
- data/lib/jiji/output.rb +85 -29
- data/lib/jiji/output_manager.rb +84 -0
- data/lib/jiji/plugin/embedded/single_click_client.rb +2 -2
- data/lib/jiji/plugin/securities_plugin.rb +0 -1
- data/lib/jiji/process.rb +229 -208
- data/lib/jiji/process_manager.rb +190 -96
- data/lib/jiji/registry.rb +87 -19
- data/lib/jiji/server.rb +1 -0
- data/lib/jiji/service/agent_service.rb +147 -48
- data/lib/jiji/service/output_service.rb +37 -17
- data/lib/jiji/service/process_service.rb +3 -5
- data/lib/jiji/service/trade_result_service.rb +4 -5
- data/lib/jiji/util/file_lock.rb +4 -4
- data/lib/jiji/util/include_proxy.rb +17 -0
- data/lib/jiji/util/json_broker.rb +6 -4
- data/lib/jiji/util/util.rb +1 -1
- data/swf/chart/fx/chart/Chart.as +7 -0
- data/swf/chart/fx/chart/ui/graph/GraphManager.as +15 -2
- data/test/ProcessTest/agents/foo.rb +10 -0
- data/test/ProcessTest/conf/configuration.yaml +3 -0
- data/test/agent/agent_tests.rb +10 -0
- data/test/agent/test_AgentManager.rb +28 -12
- data/test/agent/test_AgentRegistry.rb +194 -99
- data/test/agent/test_PeriodicallyAgent.rb +1 -2
- data/test/agent/test_Permitter.rb +1 -2
- data/test/all_tests.rb +7 -19
- data/test/dao/dao_tests.rb +9 -0
- data/test/dao/test_FileSystemDao.rb +431 -0
- data/test/dao/test_RateDao.rb +5 -7
- data/test/dao/test_TradeResultDao.rb +1 -2
- data/test/migration/migration_tests.rb +10 -0
- data/test/migration/migrator1_2_0test_data/basic/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/basic/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/basic/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/basic/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
- data/test/migration/migrator1_2_0test_data/basic/props.yaml +85 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/props.yaml +1 -0
- data/test/migration/migrator1_2_0test_data/no_outs/props.yaml +85 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
- data/test/migration/test_Migrator.rb +1 -1
- data/test/migration/test_Migrator1_0_3.rb +1 -1
- data/test/migration/test_Migrator1_1_0.rb +1 -1
- data/test/migration/test_Migrator1_2_0.rb +94 -0
- data/test/plugin/embedded/test_SingleClickClient.rb +1 -2
- data/test/plugin/plugin_tests.rb +8 -0
- data/test/plugin/test_Loader.rb +1 -1
- data/test/shared/rate.csv +144 -0
- data/test/shared/shared_tests.rb +9 -0
- data/test/shared/test_Cross.rb +144 -0
- data/test/shared/test_PositionManager.rb +285 -0
- data/test/shared/test_Signal.rb +65 -0
- data/test/test_Output.rb +28 -21
- data/test/test_OutputManager.rb +162 -0
- data/test/test_Output_registry.rb +6 -17
- data/test/test_Process.rb +434 -222
- data/test/test_ProcessManager.rb +458 -101
- data/test/test_utils.rb +71 -8
- data/test/util/test_BlockToSession.rb +1 -2
- data/test/util/test_CSV.rb +1 -2
- data/test/util/test_SynchronizeInterceptor.rb +1 -2
- data/test/util/util_tests.rb +9 -0
- metadata +127 -47
- data/html/js/agent-editor-page.js +0 -440
- data/html/js/codepress/codepress.css +0 -21
- data/html/js/codepress/codepress.html +0 -35
- data/html/js/codepress/codepress.js +0 -138
- data/html/js/codepress/engines/gecko.js +0 -293
- data/html/js/codepress/engines/khtml.js +0 -0
- data/html/js/codepress/engines/msie.js +0 -304
- data/html/js/codepress/engines/older.js +0 -0
- data/html/js/codepress/engines/opera.js +0 -260
- data/html/js/codepress/images/line-numbers.gif +0 -0
- data/html/js/codepress/index.html +0 -443
- data/html/js/codepress/languages/asp.css +0 -71
- data/html/js/codepress/languages/asp.js +0 -117
- data/html/js/codepress/languages/autoit.css +0 -13
- data/html/js/codepress/languages/autoit.js +0 -32
- data/html/js/codepress/languages/csharp.css +0 -9
- data/html/js/codepress/languages/csharp.js +0 -25
- data/html/js/codepress/languages/css.css +0 -10
- data/html/js/codepress/languages/css.js +0 -23
- data/html/js/codepress/languages/generic.css +0 -9
- data/html/js/codepress/languages/generic.js +0 -25
- data/html/js/codepress/languages/html.css +0 -13
- data/html/js/codepress/languages/html.js +0 -59
- data/html/js/codepress/languages/java.css +0 -7
- data/html/js/codepress/languages/java.js +0 -24
- data/html/js/codepress/languages/javascript.css +0 -8
- data/html/js/codepress/languages/javascript.js +0 -30
- data/html/js/codepress/languages/perl.css +0 -11
- data/html/js/codepress/languages/perl.js +0 -27
- data/html/js/codepress/languages/php.css +0 -12
- data/html/js/codepress/languages/php.js +0 -61
- data/html/js/codepress/languages/ruby.css +0 -10
- data/html/js/codepress/languages/ruby.js +0 -26
- data/html/js/codepress/languages/sql.css +0 -10
- data/html/js/codepress/languages/sql.js +0 -30
- data/html/js/codepress/languages/text.css +0 -5
- data/html/js/codepress/languages/text.js +0 -9
- data/html/js/codepress/languages/vbscript.css +0 -71
- data/html/js/codepress/languages/vbscript.js +0 -117
- data/html/js/codepress/languages/xsl.css +0 -15
- data/html/js/codepress/languages/xsl.js +0 -103
- data/html/js/codepress/license.txt +0 -458
- data/html/js/edit_area/images/Thumbs.db +0 -0
- data/test/plugin/test_gem/a/lib/jiji_plugin_test.rb +0 -6
data/lib/jiji/command.rb
CHANGED
@@ -116,10 +116,7 @@ module JIJI
|
|
116
116
|
FileUtils.chmod(0600, "#{dir}/conf/configuration.yaml")
|
117
117
|
|
118
118
|
# サンプルエージェント
|
119
|
-
|
120
|
-
mkdir("#{dir}/#{d}")
|
121
|
-
FileUtils.copy( Dir.glob(File.expand_path("#{__FILE__}/../../../base/#{d}/*")), "#{dir}/#{d}" )
|
122
|
-
}
|
119
|
+
copy_base_files( dir, h )
|
123
120
|
rescue Exception
|
124
121
|
puts "[ERROR] setting failed.(#{$!.to_s})"
|
125
122
|
return
|
@@ -144,6 +141,44 @@ module JIJI
|
|
144
141
|
end
|
145
142
|
|
146
143
|
private
|
144
|
+
#サンプルのエージェント、共有ライブラリをコピーする。
|
145
|
+
def copy_base_files( dir, h )
|
146
|
+
src_dir = File.expand_path("#{__FILE__}/../../../base/")
|
147
|
+
files = []
|
148
|
+
["agents","shared_lib"].each {|d|
|
149
|
+
files += Dir.glob(File.expand_path("#{src_dir}/#{d}/**/*")).reject {|i|
|
150
|
+
File.directory? i
|
151
|
+
}
|
152
|
+
}
|
153
|
+
overwrite = :yes
|
154
|
+
files.each {|f|
|
155
|
+
new_path = f.sub( /#{src_dir}/, dir )
|
156
|
+
if File.exist?(new_path) && overwrite != :all
|
157
|
+
overwrite = ask_overwrite( h, new_path )
|
158
|
+
else
|
159
|
+
overwrite = overwrite != :all ? :yes : :all
|
160
|
+
end
|
161
|
+
if overwrite != :no
|
162
|
+
mkdir( File.dirname( new_path ) )
|
163
|
+
copy( f, new_path )
|
164
|
+
end
|
165
|
+
}
|
166
|
+
end
|
167
|
+
#上書きするかどうか確認する。
|
168
|
+
def ask_overwrite( h, f )
|
169
|
+
result = nil
|
170
|
+
while ( !result )
|
171
|
+
tmp = h.ask("> File #{f} is already exist. Do you want to overwrite? ([y]es/[n]o/[a]ll files)")
|
172
|
+
next if !tmp || tmp.length == 0
|
173
|
+
result = case tmp[0,1].downcase
|
174
|
+
when "y"; :yes
|
175
|
+
when "n"; :no
|
176
|
+
when "a"; :all
|
177
|
+
end
|
178
|
+
end
|
179
|
+
result
|
180
|
+
end
|
181
|
+
|
147
182
|
# データディレクトリを得る
|
148
183
|
def data_dir
|
149
184
|
base = "#{File.expand_path(JIJI_DIR_NAME)}/base"
|
@@ -154,10 +189,16 @@ module JIJI
|
|
154
189
|
end
|
155
190
|
# ディレクトリを作る。
|
156
191
|
def mkdir( path )
|
192
|
+
return if File.exist? path
|
157
193
|
FileUtils.mkdir_p path
|
158
194
|
FileUtils.chmod(0755, path)
|
159
195
|
puts "create. #{path}"
|
160
196
|
end
|
161
|
-
|
197
|
+
# ファイルをコピーする。
|
198
|
+
def copy( path, to )
|
199
|
+
FileUtils.copy( path, to )
|
200
|
+
FileUtils.chmod(0644, to)
|
201
|
+
puts "create. #{to}"
|
202
|
+
end
|
162
203
|
end
|
163
204
|
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
|
2
|
+
require 'fileutils'
|
3
|
+
require 'jiji/error'
|
4
|
+
|
5
|
+
module JIJI
|
6
|
+
module Dao
|
7
|
+
|
8
|
+
#ファイルシステムにデータを保存するDAO
|
9
|
+
class FileSystemDao
|
10
|
+
|
11
|
+
#コンストラクタ
|
12
|
+
#base:: 保存先の基点となるディレクトリ
|
13
|
+
def initialize( base )
|
14
|
+
@base = base
|
15
|
+
end
|
16
|
+
|
17
|
+
#パスが示すファイルのデータを取得する。
|
18
|
+
def get( path )
|
19
|
+
path = validate_path( path, :exist, :is_file )
|
20
|
+
return FileLock.new(path).readlock {|f|
|
21
|
+
f.read
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
#パスが示すフォルダ配下の一覧を取得する。
|
26
|
+
def list( path="", recursive=false )
|
27
|
+
path = validate_path( path, :exist, :is_directory )
|
28
|
+
Dir.glob( "#{path}/#{recursive ? '**/*' : '*' }" ).map {|item|
|
29
|
+
next if File.basename(item) =~ /^\..*/
|
30
|
+
{ :path =>item.sub( /^#{@base}\//, "" ),
|
31
|
+
:name =>File.basename(item),
|
32
|
+
:update=>File.mtime(item).to_i,
|
33
|
+
:type =>File.directory?(item) ? :directory : :file}
|
34
|
+
}.sort_by {|item| "#{item[:type]}/#{item[:path]}" }
|
35
|
+
end
|
36
|
+
|
37
|
+
#ファイルを追加する。
|
38
|
+
def add( path, body )
|
39
|
+
validate_path( path, :exist_parent, :not_exist )
|
40
|
+
put( path, body )
|
41
|
+
:success
|
42
|
+
end
|
43
|
+
|
44
|
+
#ファイルを追加/更新する。
|
45
|
+
def put( path, body )
|
46
|
+
path = validate_path( path, :exist_parent, :is_file )
|
47
|
+
FileLock.new(path).writelock {|f|
|
48
|
+
f << body
|
49
|
+
}
|
50
|
+
:success
|
51
|
+
end
|
52
|
+
|
53
|
+
#ファイルまたはディレクトリを破棄する
|
54
|
+
def delete( path )
|
55
|
+
path = validate_path( path, :exist )
|
56
|
+
if ( File.file? path )
|
57
|
+
FileLock.new(path).writelock {|f|
|
58
|
+
FileUtils.rm_rf path
|
59
|
+
}
|
60
|
+
else
|
61
|
+
FileUtils.rm_rf path
|
62
|
+
end
|
63
|
+
:success
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
#ファイル/フォルダを移動する
|
68
|
+
def move( from, to )
|
69
|
+
from = validate_path( from, :exist )
|
70
|
+
to = validate_path( to, :exist, :is_directory )
|
71
|
+
FileUtils.mv from, to
|
72
|
+
:success
|
73
|
+
end
|
74
|
+
|
75
|
+
#ファイル/フォルダをリネームする
|
76
|
+
def rename( from, to )
|
77
|
+
from = validate_path( from, :exist )
|
78
|
+
to = validate_path( to, :not_exist )
|
79
|
+
FileUtils.mv from, to
|
80
|
+
:success
|
81
|
+
end
|
82
|
+
|
83
|
+
#ファイル/フォルダをコピーする
|
84
|
+
def copy( from, to )
|
85
|
+
from = validate_path( from, :exist )
|
86
|
+
to = validate_path( to )
|
87
|
+
FileUtils.cp_r from, to
|
88
|
+
:success
|
89
|
+
end
|
90
|
+
|
91
|
+
#フォルダを作成する
|
92
|
+
def mkcol(path)
|
93
|
+
path = validate_path( path, :exist_parent, :not_exist )
|
94
|
+
FileUtils.mkdir_p path
|
95
|
+
:success
|
96
|
+
end
|
97
|
+
|
98
|
+
#ディレクトリかどうか評価する。
|
99
|
+
def directory?(path)
|
100
|
+
path = validate_path( path, :exist )
|
101
|
+
File.directory?(path)
|
102
|
+
end
|
103
|
+
|
104
|
+
#データ保存先の基点となるディレクトリ
|
105
|
+
attr_reader :base
|
106
|
+
|
107
|
+
private
|
108
|
+
#パスを正規化する
|
109
|
+
#steps:: パスを示す文字列
|
110
|
+
#return:: 正規化されたパス(baseからの絶対パス)
|
111
|
+
def validate_path( path, *options )
|
112
|
+
# パスの文字列をチェック。
|
113
|
+
steps = path.split( /\/+/ ).map{|str| str.strip }
|
114
|
+
steps.each {|step|
|
115
|
+
if !step || step.length <= 0 || step.strip.length <= 0
|
116
|
+
raise JIJI::UserError.new( JIJI::ERROR_ILLEGAL_NAME, "illegal file or directory name. name=#{step}" )
|
117
|
+
end
|
118
|
+
unless step =~ VALID_FILE_NAME
|
119
|
+
raise JIJI::UserError.new( JIJI::ERROR_ILLEGAL_NAME, "illegal file or directory name. name=#{step}" )
|
120
|
+
end
|
121
|
+
if step =~ /^\.+$/
|
122
|
+
raise JIJI::UserError.new( JIJI::ERROR_ILLEGAL_NAME, "illegal file or directory name. name=#{step}" )
|
123
|
+
end
|
124
|
+
if step =~ /^\..*/
|
125
|
+
raise JIJI::UserError.new( JIJI::ERROR_ILLEGAL_NAME, "illegal file or directory name. name=#{step}" )
|
126
|
+
end
|
127
|
+
}
|
128
|
+
#ファイルパス構築
|
129
|
+
file = "#{@base}#{ steps.empty? ? "" : "/" + steps.join( "/" )}"
|
130
|
+
parent = File.dirname( file )
|
131
|
+
|
132
|
+
#オプションのチェック
|
133
|
+
op = options.inject({}){|h,o| h[o] = true; h }
|
134
|
+
if op.key?(:is_directory) && File.exist?( file )
|
135
|
+
unless File.directory?( file )
|
136
|
+
raise JIJI::UserError.new( JIJI::ERROR_IS_NOT_FOLDER, "target is not a folder. path=#{file}" )
|
137
|
+
end
|
138
|
+
end
|
139
|
+
if op.key?(:is_file) && File.exist?( file )
|
140
|
+
unless File.file?( file )
|
141
|
+
raise JIJI::UserError.new( JIJI::ERROR_IS_NOT_FILE, "target is not a file. path=#{file}" )
|
142
|
+
end
|
143
|
+
end
|
144
|
+
if op.key?(:exist) && !File.exist?( file )
|
145
|
+
raise JIJI::UserError.new( JIJI::ERROR_NOT_FOUND, "file or directory is not found. path=#{file}" )
|
146
|
+
end
|
147
|
+
if op.key?(:not_exist) && File.exist?( file )
|
148
|
+
raise JIJI::UserError.new( JIJI::ERROR_ALREADY_EXIST, "file or directory is already exist. path=#{file}" )
|
149
|
+
end
|
150
|
+
if op.key?(:exist_parent) && !( File.exist?( parent ) && File.directory?( parent ))
|
151
|
+
raise JIJI::UserError.new( JIJI::ERROR_NOT_FOUND, "directory is not found. directory=#{parent}" )
|
152
|
+
end
|
153
|
+
return file
|
154
|
+
end
|
155
|
+
VALID_FILE_NAME = /^[A-Za-z0-9_\+\-\#\'\!\~\(\)\[\]\.\{\}]+$/
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
data/lib/jiji/error.rb
CHANGED
@@ -1,29 +1,45 @@
|
|
1
1
|
|
2
2
|
module JIJI
|
3
|
-
|
4
|
-
class
|
5
|
-
def initialize( code, message="" )
|
3
|
+
|
4
|
+
class AbstractError < StandardError
|
5
|
+
def initialize( code, message="", info={} )
|
6
6
|
super( message )
|
7
7
|
@code = code
|
8
|
+
@info = info
|
9
|
+
end
|
10
|
+
def detail
|
11
|
+
{"code"=>@code,"info"=>@info}
|
8
12
|
end
|
9
13
|
attr :code
|
14
|
+
attr :info, true
|
15
|
+
end
|
16
|
+
|
17
|
+
# 致命的エラー
|
18
|
+
class FatalError < AbstractError
|
19
|
+
def initialize( code, message="", info={} )
|
20
|
+
super
|
21
|
+
end
|
10
22
|
end
|
11
23
|
# ユーザー操作により発生しうるエラー
|
12
|
-
class UserError <
|
13
|
-
def initialize( code, message="" )
|
14
|
-
super
|
15
|
-
@code = code
|
24
|
+
class UserError < AbstractError
|
25
|
+
def initialize( code, message="", info={} )
|
26
|
+
super
|
16
27
|
end
|
17
|
-
attr :code
|
18
28
|
end
|
19
29
|
|
20
30
|
# エラーコード:存在しない
|
21
31
|
ERROR_NOT_FOUND = "not_found"
|
22
32
|
# エラーコード:すでに存在する
|
23
33
|
ERROR_ALREADY_EXIST = "already_exist"
|
34
|
+
# エラーコード:ファイルでない
|
35
|
+
ERROR_IS_NOT_FILE = "is_not_file"
|
36
|
+
# エラーコード:フォルダでない
|
37
|
+
ERROR_IS_NOT_FOLDER = "is_not_folder"
|
24
38
|
|
25
39
|
# エラーコード:不正な名前
|
26
40
|
ERROR_ILLEGAL_NAME = "illegal_name"
|
41
|
+
# エラーコード:不正な引数
|
42
|
+
ERROR_ILLEGAL_ARGUMENTS = "illegal_arguments"
|
27
43
|
|
28
44
|
# エラーコード:想定外エラー
|
29
45
|
ERROR_FATAL = "fatal"
|
@@ -0,0 +1,67 @@
|
|
1
|
+
|
2
|
+
require 'fileutils'
|
3
|
+
require 'yaml'
|
4
|
+
require 'jiji/util/fix_yaml_bug'
|
5
|
+
require 'jiji/util/file_lock'
|
6
|
+
require 'jiji/process'
|
7
|
+
require 'kconv'
|
8
|
+
|
9
|
+
module JIJI
|
10
|
+
module Migration
|
11
|
+
|
12
|
+
#===1.1.3 → 1.2.0
|
13
|
+
class Migrator1_2_0
|
14
|
+
def migrate( registry )
|
15
|
+
logger = registry.server_logger
|
16
|
+
|
17
|
+
#出力の保存先を置換
|
18
|
+
Dir.glob("#{registry.process_dir}/*") {|d|
|
19
|
+
|
20
|
+
logger.info "convert : #{d}"
|
21
|
+
process_id = File.basename(d)
|
22
|
+
process_info = {}
|
23
|
+
begin
|
24
|
+
file = "#{d}/#{JIJI::ProcessInfo::PROPERTY_FILE}"
|
25
|
+
process_info = YAML.load_file(file) if File.exist?(file)
|
26
|
+
rescue Exception
|
27
|
+
logger.error $!
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
# 出力データを列挙
|
32
|
+
Dir.glob("#{d}/out/*").map.each {|out_dir|
|
33
|
+
convert_out_dir( out_dir, process_info, logger )
|
34
|
+
}
|
35
|
+
rescue Exception
|
36
|
+
logger.error $!
|
37
|
+
end
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
#各出力ディリクトリデータのリネーム
|
42
|
+
def convert_out_dir( out_dir, info, logger )
|
43
|
+
begin
|
44
|
+
agent_id = JIJI::Util.decode( File.basename(out_dir))
|
45
|
+
agent_name = resolve_name( info, agent_id )
|
46
|
+
FileLock.new( "#{out_dir}/#{JIJI::Output::PROPERTIES_FILE_NAME}" ).writelock { |f|
|
47
|
+
f.write( YAML.dump({:agent_name=>agent_name}) )
|
48
|
+
}
|
49
|
+
FileUtils.mv out_dir, "#{File.dirname(out_dir)}/#{agent_id}"
|
50
|
+
rescue Exception
|
51
|
+
logger.error $!
|
52
|
+
end
|
53
|
+
end
|
54
|
+
#エージェント名を解決する
|
55
|
+
def resolve_name( process_info, agent_id )
|
56
|
+
if ( process_info["agents"] )
|
57
|
+
item = process_info["agents"].find {|i| i["id"] == agent_id }
|
58
|
+
return item["name"] if item
|
59
|
+
end
|
60
|
+
return "不明"
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
data/lib/jiji/models.rb
CHANGED
@@ -4,12 +4,23 @@ require "jiji/dao/timed_data_dao"
|
|
4
4
|
|
5
5
|
module JIJI
|
6
6
|
|
7
|
-
|
7
|
+
#===レートの集合
|
8
|
+
#通貨ペアコード(:EURJPYのようなシンボル)をキーとしてJIJI::Rateを保持します。
|
9
|
+
#
|
10
|
+
# rates = <省略>
|
11
|
+
#
|
12
|
+
# #EURJPYのレートを取得。
|
13
|
+
# rate = rates[:EURJPY] #=> JIJI::Rate
|
14
|
+
#
|
15
|
+
# #bidレート,askレートを取得
|
16
|
+
# p rate.bid
|
17
|
+
# p rate.ask
|
18
|
+
#
|
8
19
|
class Rates < Hash
|
9
20
|
|
10
21
|
include JIJI::Util::Model
|
11
22
|
|
12
|
-
def initialize( pair_infos, list, time=Time.now )
|
23
|
+
def initialize( pair_infos, list, time=Time.now ) #:nodoc:
|
13
24
|
super()
|
14
25
|
@pair_infos = pair_infos
|
15
26
|
@time = time
|
@@ -30,7 +41,7 @@ module JIJI
|
|
30
41
|
include JIJI::Util::Model
|
31
42
|
include JIJI::Dao::TimedData
|
32
43
|
|
33
|
-
def initialize( bid=nil, ask=nil, sell_swap=nil, buy_swap=nil, time=nil )
|
44
|
+
def initialize( bid=nil, ask=nil, sell_swap=nil, buy_swap=nil, time=nil ) #:nodoc:
|
34
45
|
@bid = bid
|
35
46
|
@ask = ask
|
36
47
|
@sell_swap = sell_swap
|
@@ -38,31 +49,54 @@ module JIJI
|
|
38
49
|
@time = time
|
39
50
|
end
|
40
51
|
# 値を配列で取得する
|
41
|
-
def values
|
52
|
+
def values #:nodoc:
|
42
53
|
[bid,ask,sell_swap,buy_swap,time.to_i]
|
43
54
|
end
|
44
55
|
# 値を配列で設定する
|
45
|
-
def values=(values)
|
56
|
+
def values=(values) #:nodoc:
|
46
57
|
@bid = values[0].to_f
|
47
58
|
@ask = values[1].to_f
|
48
59
|
@sell_swap = values[2].to_f
|
49
60
|
@buy_swap = values[3].to_f
|
50
61
|
end
|
51
|
-
|
62
|
+
#bidレート
|
63
|
+
attr_reader :bid
|
64
|
+
#askレート
|
65
|
+
attr_reader :ask
|
66
|
+
#売りスワップ
|
67
|
+
attr_reader :sell_swap
|
68
|
+
#買いスワップ
|
69
|
+
attr_reader :buy_swap
|
52
70
|
end
|
53
71
|
|
54
|
-
|
72
|
+
#===一定期間のレートの集合
|
73
|
+
#通貨ペアコード(:EURJPYのようなシンボル)をキーとしてJIJI::PeriodicallyRateを保持します。
|
74
|
+
#
|
75
|
+
# rates = <省略>
|
76
|
+
#
|
77
|
+
# #EURJPYのレートを取得。
|
78
|
+
# rate = rates[:EURJPY] #=> JIJI::PeriodicallyRate
|
79
|
+
#
|
80
|
+
# #bidレートの高値、安値を取得
|
81
|
+
# bid = rate.bid
|
82
|
+
# p bid.max
|
83
|
+
# p bid.min
|
84
|
+
#
|
55
85
|
class PeriodicallyRates < Hash
|
56
86
|
|
57
87
|
include JIJI::Util::Model
|
58
|
-
|
59
|
-
|
88
|
+
#====コンストラクタ
|
89
|
+
#pair_infos:: 通貨ペアの情報
|
90
|
+
#list:: 初期データ
|
91
|
+
def initialize( pair_infos, list=[] ) #:nodoc:
|
60
92
|
super()
|
61
93
|
@pair_infos = pair_infos
|
62
94
|
list.each {|rates|
|
63
95
|
self << rates
|
64
96
|
}
|
65
97
|
end
|
98
|
+
#====JIJI::Ratesを追加し各値の四本値を再計算します。
|
99
|
+
#rates:: JIJI::Rates
|
66
100
|
def <<(rates)
|
67
101
|
now = rates.time
|
68
102
|
@start_time = now unless @start_time
|
@@ -72,22 +106,27 @@ module JIJI
|
|
72
106
|
self[code] << rate
|
73
107
|
}
|
74
108
|
end
|
75
|
-
def time
|
109
|
+
def time #:nodoc:
|
76
110
|
@start_time
|
77
111
|
end
|
112
|
+
#通貨ペアの情報(取引数量など)
|
78
113
|
attr_reader :pair_infos
|
114
|
+
#集計開始日時
|
79
115
|
attr :start_time, true
|
116
|
+
#集計終了日時
|
80
117
|
attr :end_time, true
|
81
118
|
end
|
82
119
|
|
83
|
-
|
84
|
-
#bid,ask,sell_swap,buy_swap
|
120
|
+
#===一定期間のレート
|
121
|
+
#bid,ask,sell_swap,buy_swapの各値が四本値(JIJI::PeriodicallyValue)で保持されます。
|
85
122
|
class PeriodicallyRate
|
86
123
|
|
87
124
|
include JIJI::Util::Model
|
88
125
|
include JIJI::Dao::TimedData
|
89
|
-
|
90
|
-
|
126
|
+
|
127
|
+
#====コンストラクタ
|
128
|
+
#list:: 初期データ
|
129
|
+
def initialize( list=[] ) #:nodoc:
|
91
130
|
@bid = PeriodicallyValue.new
|
92
131
|
@ask = PeriodicallyValue.new
|
93
132
|
@sell_swap = PeriodicallyValue.new
|
@@ -96,7 +135,9 @@ module JIJI
|
|
96
135
|
self << item
|
97
136
|
}
|
98
137
|
end
|
99
|
-
|
138
|
+
#====JIJI::Rateを追加し各値の四本値を再計算します。
|
139
|
+
#rate:: JIJI::Rate
|
140
|
+
def <<( rate ) #:nodoc:
|
100
141
|
@bid << rate.bid
|
101
142
|
@ask << rate.ask
|
102
143
|
@sell_swap << rate.sell_swap
|
@@ -105,12 +146,12 @@ module JIJI
|
|
105
146
|
@end_time = rate.time
|
106
147
|
end
|
107
148
|
# 値を配列で取得する
|
108
|
-
def values
|
149
|
+
def values #:nodoc:
|
109
150
|
bid.values + ask.values + sell_swap.values + buy_swap.values \
|
110
151
|
+ [@start_time.to_i, @end_time.to_i]
|
111
152
|
end
|
112
153
|
# 値を配列で設定する
|
113
|
-
def values=(values)
|
154
|
+
def values=(values) #:nodoc:
|
114
155
|
@bid.values = values[0..3]
|
115
156
|
@ask.values = values[4..7]
|
116
157
|
@sell_swap.values = values[8..11]
|
@@ -118,28 +159,41 @@ module JIJI
|
|
118
159
|
@start_time = Time.at(values[16].to_i)
|
119
160
|
@end_time = Time.at(values[17].to_i)
|
120
161
|
end
|
121
|
-
def time
|
162
|
+
def time #:nodoc:
|
122
163
|
@end_time
|
123
164
|
end
|
124
|
-
def time=(t)
|
165
|
+
def time=(t) #:nodoc:
|
125
166
|
@end_time = t
|
126
167
|
end
|
127
|
-
|
168
|
+
#bidレート
|
169
|
+
attr_reader :bid
|
170
|
+
#askレート
|
171
|
+
attr_reader :ask
|
172
|
+
#売りスワップ
|
173
|
+
attr_reader :sell_swap
|
174
|
+
#買いスワップ
|
175
|
+
attr_reader :buy_swap
|
176
|
+
#集計開始日時
|
128
177
|
attr :start_time, true
|
178
|
+
#集計終了日時
|
129
179
|
attr :end_time, true
|
130
180
|
end
|
131
181
|
|
132
|
-
|
182
|
+
#===一定期間の値
|
133
183
|
#始値、終値、高値、安値の四本値
|
134
184
|
class PeriodicallyValue
|
135
185
|
|
136
186
|
include JIJI::Util::Model
|
137
|
-
|
187
|
+
|
188
|
+
#====コンストラクタ
|
189
|
+
#list:: 初期データ
|
138
190
|
def initialize( list=[] )
|
139
191
|
list.each { |item|
|
140
192
|
self << item
|
141
193
|
}
|
142
194
|
end
|
195
|
+
#====値を追加し四本値を再計算します。
|
196
|
+
#value:: 値
|
143
197
|
def <<( value )
|
144
198
|
@start = value if @start == nil
|
145
199
|
@end = value
|
@@ -147,19 +201,23 @@ module JIJI
|
|
147
201
|
@min = value if @min == nil || value < @min
|
148
202
|
end
|
149
203
|
# 値を配列で取得する
|
150
|
-
def values
|
204
|
+
def values #:nodoc:
|
151
205
|
[@start, @end, @max, @min]
|
152
206
|
end
|
153
207
|
# 値を配列で設定する
|
154
|
-
def values=(values)
|
208
|
+
def values=(values) #:nodoc:
|
155
209
|
@start = values[0].to_f
|
156
210
|
@end = values[1].to_f
|
157
211
|
@max = values[2].to_f
|
158
212
|
@min = values[3].to_f
|
159
213
|
end
|
214
|
+
#始値
|
160
215
|
attr :start
|
216
|
+
#終値
|
161
217
|
attr :end
|
218
|
+
#高値
|
162
219
|
attr :max
|
220
|
+
#安値
|
163
221
|
attr :min
|
164
222
|
end
|
165
223
|
end
|