simrb 1.0.4 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 08d0b17242e8c909cfb0bf359a32384261911518
4
- data.tar.gz: d933bcb7a53af6c263580ae9102ffc531ad5783e
3
+ metadata.gz: f7878b2a1a7e363b08799171e6153e01aba6f50b
4
+ data.tar.gz: e1c2104346c1b3b1ab527d29ce9dbfec531235e2
5
5
  SHA512:
6
- metadata.gz: a8f309668d5e1f668c3a9d6c6f93bbc6f7f173e58c5d7fd51d45509914258b0ad9c8cf7cf8a2df3f493ad2a2bb32e376c4feda16235a86d8d74d76966218f5f5
7
- data.tar.gz: 6b6f9a11dd06d04b141bcd59b7fe4bb7ad2fea8aa57339d6942284d9969f62db65cf78d4229f90e6cacb89bec1e706cacf48ccb1eaaba8fc8bde7f2568e6b62c
6
+ metadata.gz: 82258cd78ad586d504d984e473405f8d53094766967ad499d4ffdd509807a27a07bf93beb9766505b572b845f8eaea3fe8305990b3d4f9a7b4608e92d22445af
7
+ data.tar.gz: 11796bc82ccc3d168e5cf35d511f5e6d544f9a811e5a9c6ee3d1c10a75c889d48d7b6d4eb988f972841357e21b2971fb07cdce65be2ec436f3bc800ccd827397
data/lib/simrb/base.rb ADDED
@@ -0,0 +1,244 @@
1
+ #
2
+ # definition to the base methods, and default configuration options
3
+ # and the modules that would be loaded
4
+ #
5
+
6
+ Sroot = Dir.pwd + '/'
7
+ Sdocs = {}
8
+
9
+ require "simrb/scfg"
10
+
11
+ module Simrb
12
+ class << self
13
+
14
+ def yaml_read path
15
+ require 'yaml'
16
+ YAML.load_file path
17
+ rescue
18
+ []
19
+ end
20
+
21
+ def yaml_write path, data
22
+ require "yaml"
23
+ File.open(path, 'w+') do | f |
24
+ f.write data.to_yaml
25
+ end
26
+ end
27
+
28
+ def p args, action = nil
29
+ res = ""
30
+
31
+ if args.class.to_s == 'Array'
32
+ res = args.join("\n")
33
+ elsif args.class.to_s == 'Hash'
34
+ args.each do | k, v |
35
+ if action == :write
36
+ res << "#{k.to_s.ljust(7)} -- #{v}\n"
37
+ else
38
+ res << "#{k.to_s.ljust(15)} => #{v}\n"
39
+ end
40
+ end
41
+ res = res.chomp "\n"
42
+ else
43
+ res = args.to_s
44
+ end
45
+
46
+ # puts "="*30 + "\n" + res + "\n" + "="*30
47
+ puts res
48
+ exit if action == :exit
49
+ end
50
+
51
+ # return an hash that stores the modules that consists of local directory and repository
52
+ #
53
+ # == Example
54
+ #
55
+ # Simrb.module_load
56
+ #
57
+ # assuming the :requrie_module option of Scfg file that is set as 'system',
58
+ # and two modules demo, demo2 in your local directory of project,
59
+ # so, the result as below
60
+ #
61
+ # {
62
+ # 'system' => '/your_repo_dir/system',
63
+ # 'demo' => '/your_project_dir/modules/demo',
64
+ # 'demo2' => '/your_project_dir/modules/demo2',
65
+ # }
66
+ #
67
+ def module_load
68
+ module_dirs = {}
69
+ module_ds = {}
70
+
71
+ # load modules from local repository
72
+ Spath[:repo_dirs].map{|m| m + '*'}.each do | dir |
73
+ Dir[dir].each do | path |
74
+ name = path.split("/").last
75
+ module_dirs[name] = File.expand_path(path) if Scfg[:module_require].include? name
76
+ end
77
+ end
78
+
79
+ # load modules from project directory
80
+ Dir["#{Spath[:module]}*"].each do | path |
81
+ name = path.split("/").last
82
+ module_dirs[name] = File.expand_path("#{Spath[:module]}#{name}") unless Scfg[:module_disable].include? name
83
+ end
84
+
85
+ # load the info of module
86
+ module_dirs.each do | name, path |
87
+ path = "#{path}#{Spath[:modinfo]}"
88
+ res = Simrb.yaml_read path
89
+ if res[0] and res[0]["name"] and res[0]["name"] == name
90
+ module_ds[name] = (res[0]["order"] || 99)
91
+ else
92
+ Simrb.p "Loading error of module info, please check #{path}", :exit
93
+ end
94
+ end
95
+
96
+ # sort module by order field of module
97
+ res = {}
98
+ module_ds = module_ds.sort_by { |k, v| v }
99
+ module_ds.each do | name, order |
100
+ res[name] = module_dirs[name]
101
+ end
102
+ res
103
+ end
104
+
105
+ # initialize a path whatever it is a dir or file
106
+ #
107
+ # == Example
108
+ #
109
+ # new a file, or with the additional content
110
+ #
111
+ # path_write "myfile"
112
+ # path_write "myfile", "file content"
113
+ # path_write "myfile", "file content", "w+"
114
+ #
115
+ # create the dir
116
+ #
117
+ # path_write "newdir/"
118
+ # path_write "newdir/newdir2/"
119
+ #
120
+ # create the dir and file at the same time
121
+ #
122
+ # path_write "newdir/newdir2/myfile"
123
+ #
124
+ def path_write path, content = "", mode = "a+"
125
+ if File.exist?(path)
126
+ File.open(path, mode){|f| f.write content} unless path[-1] == '/'
127
+ else
128
+ arrs = path.split('/')
129
+ count = arrs.count - 1
130
+ prve = ""
131
+
132
+ if arrs[0] == ""
133
+ arrs.delete("")
134
+ prve = "/"
135
+ end
136
+
137
+ (0..count).each do | i |
138
+ sub_path = prve + arrs[0..i].join("/")
139
+ unless File.exist? sub_path
140
+ sub_path == path ? File.open(path, mode){|f| f.write content} : Dir.mkdir(sub_path)
141
+ end
142
+ end
143
+ end
144
+ end
145
+
146
+ def root_dir_force
147
+ # check the required module is that existing
148
+ Scfg[:module_require].each do | name |
149
+ unless Smods.keys.include? name
150
+ puts "Warning: the required module #{name} is not existing, wherever in local dir or repository"
151
+ end
152
+ end
153
+
154
+ # check the file that is necessary to be loaded
155
+ unless File.exist?(Sroot + Scfg[:name])
156
+ Simrb.p "Current command only allow to be used under root directory of project", :exit
157
+ end
158
+ end
159
+
160
+ # format the input argument from an array to two item,
161
+ # first item is orgin array, last is an hash option
162
+ #
163
+ # == Example
164
+ #
165
+ # args, opts = Simrb.input_format ["test", "test2", "--test", "--name=test2", "-n=test3"]
166
+ #
167
+ # the above is same as
168
+ #
169
+ # args, opts = Simrb.input_format ["--test", "test", "test2", "--name=test2", "-n=test3"]
170
+ #
171
+ # the options that starts with "-" you can write any positions of argument
172
+ #
173
+ # output
174
+ #
175
+ # args = ["test", "test2"]
176
+ # opts = {test: true, name: test2, n:test3}
177
+ #
178
+ def input_format args = []
179
+ resa = [] # return an array
180
+ resh = {} # return an hash
181
+ unless args.empty?
182
+ args.each do | item |
183
+
184
+ if item[0] == "-"
185
+ new_item = item.split("-").uniq.last
186
+ if new_item.index "="
187
+ key, val = new_item.split "="
188
+ resh[key.to_sym] = val
189
+ else
190
+ resh[new_item.to_sym] = true
191
+ end
192
+ else
193
+ resa << item
194
+ end
195
+
196
+ end
197
+ end
198
+ [resa, resh]
199
+ end
200
+
201
+ def help args = []
202
+ res = []
203
+ i = 0
204
+ docs_key = {}
205
+ docs_val = {}
206
+ Sdocs.each do | key, val |
207
+ docs_key[i] = key
208
+ docs_val[i] = val
209
+ i = i + 1
210
+ end
211
+
212
+ if args.empty?
213
+ res << 'Please select the number before the list to see detials'
214
+ docs_key.each do | i, key |
215
+ res << "#{i.to_s}, #{key}"
216
+ end
217
+ else
218
+ args.each do | i |
219
+ res << (docs_val.include?(i.to_i) ? docs_val[i.to_i] : 'no document')
220
+ end
221
+ end
222
+ Simrb.p res
223
+ end
224
+
225
+ def addslash path
226
+ path[-1] == '/' ? path : "#{path}/"
227
+ end
228
+
229
+ def random size = 12
230
+ charset = ('a'..'z').to_a + ('0'..'9').to_a + ('A'..'Z').to_a
231
+ (0...size).map{charset.to_a[rand(charset.size)]}.join
232
+ end
233
+
234
+ end
235
+ end
236
+
237
+ # load config file
238
+ if File.exist?(Sroot + Scfg[:name])
239
+ require (Sroot + Scfg[:name])
240
+ end
241
+
242
+ # load modules
243
+ Smods = Simrb.module_load
244
+
data/lib/simrb/comd.rb CHANGED
@@ -1,22 +1,29 @@
1
1
  #
2
2
  # the file defines the base functionality of commands
3
- # that let you initializing a project, create an empty directory of module, or clone
3
+ # that let you initializing a project, create an empty directory of module, or get
4
4
  # from remote repository, show the info of this software version, help document, and so on
5
5
  #
6
6
 
7
7
  module Simrb
8
8
  class Scommand
9
9
 
10
+ # run the command
11
+ #
12
+ # == Example
13
+ #
14
+ # sapp = Simrb::Scommand.new
15
+ # sapp.run ARGV
16
+ #
10
17
  def run args = []
11
- @output = []
12
- cmd = args.empty? ? '' : args.shift
18
+ cmd = args.empty? ? '' : args.shift
13
19
  if Scommand.private_method_defined? cmd
14
20
  self.send(cmd, args)
21
+ elsif cmd == "help"
22
+ require 'simrb/docs'
23
+ Simrb.help args
15
24
  else
16
- @output << ">> WARNING: No #{cmd} command found >>"
17
- help
25
+ puts "No command called #{cmd}, please try `$ simrb help`"
18
26
  end
19
- Simrb.p(@output.empty? ? 'Implemented complete' : @output)
20
27
  end
21
28
 
22
29
  private
@@ -29,35 +36,40 @@ module Simrb
29
36
  #
30
37
  # or, initialize directory and module at the same time with more arguments,
31
38
  # the simrb/system is from remote, the blog is generated by local,
32
- # details see the new and clone method
39
+ # details see the new and get method
33
40
  #
34
41
  # $ simrb init myapp simrb/system blog
35
42
  #
36
43
  def init args
37
44
  app_name = args.empty? ? 'myapp' : args.shift
45
+ # app_name = File.expand_path "./#{app_name}"
46
+
47
+ # initialize the repositories
48
+ Spath[:repo_dirs].each do | path |
49
+ Simrb.path_write Simrb.addslash(path)
50
+ end
38
51
 
39
52
  # generate module directories and files
40
- Dir.mkdir app_name
53
+ Dir.mkdir app_name unless File.exist? app_name
41
54
  Dir.chdir app_name
42
55
 
56
+ # generate project directories
43
57
  Scfg[:init_root_path].each do | item |
44
58
  path = "#{Spath[item]}"
45
- Simrb::path_init path
59
+ Simrb.path_write path
46
60
  end
47
61
 
48
- # initialize scfg file
49
- data = {}
50
- Scfg[:init_scfg_item].each do | item |
51
- data[item] = Scfg[item]
52
- end
53
- Simrb.yaml_write('scfg', data)
62
+ # initialize config file
63
+ data = File.read(File.dirname(__FILE__) + Scfg[:name_overwrite])
64
+ data << "\nScfg[:key]\t\t\t\t= '#{Simrb.random(16)}'\n"
65
+ Simrb.path_write(Scfg[:name], data)
54
66
 
55
67
  # create module if it is given,
56
68
  # get module from remote repository if it has the backslash,
57
69
  # other is created at local
58
70
  unless args.empty?
59
71
  args.each do | name |
60
- name.index("/") ? clone(args) : new(args)
72
+ name.index("/") ? get(args) : new(args)
61
73
  end
62
74
  end
63
75
 
@@ -68,7 +80,7 @@ module Simrb
68
80
  # end
69
81
  # system("bundle install --gemfile=#{@app_name}/apps/#{@module_name}#{@gemfile_path} --without=#{mode}")
70
82
 
71
- @output << "Initialized project complete"
83
+ puts "Initialized completely"
72
84
  end
73
85
 
74
86
  # create a module, initialize default paths of file and directory
@@ -83,61 +95,101 @@ module Simrb
83
95
  #
84
96
  def new args
85
97
  Simrb.root_dir_force
98
+ puts "Starting to create module directories"
86
99
 
87
100
  args.each do | name |
88
- if Smodules.include? name
89
- @output << "The module #{name} is existing, not new it"
101
+ if Smods.keys.include? name
102
+ puts "The module #{name} is existing, hasn't new it"
90
103
  else
91
104
  # create root dir of module
92
- Simrb::path_init "#{Spath[:module]}#{name}/"
105
+ Simrb.path_write "#{Spath[:module]}#{name}/"
93
106
 
94
107
  Dir.chdir "."
95
108
 
96
109
  # create sub dir of module
97
110
  Scfg[:init_module_path].each do | item |
98
111
  path = "#{Spath[:module]}#{name}#{Spath[item]}"
99
- Simrb::path_init path
112
+ Simrb.path_write path
113
+ Simrb.p({created: path}, :write)
100
114
  end
101
115
 
102
116
  # write the content of module info
103
- text = [{ 'name' => name, 'author' => 'unknown', 'version' => '1.0.0' }]
104
- Simrb.yaml_write "#{Spath[:module]}#{name}#{Spath[:modinfo]}", text
117
+ res = Scfg[:init_module_field].merge({'name' => name})
118
+ path = "#{Spath[:module]}#{name}#{Spath[:modinfo]}"
119
+ Simrb.yaml_write path, [res]
120
+ Simrb.p({wrote: path}, :write)
105
121
 
106
122
  # write the content of .gitignore
107
123
  path = "#{Spath[:module]}#{name}#{Spath[:gitignore]}"
108
124
  File.open(path, "w+") do | f |
109
- f.write "*.swp\n*.gem\n*~"
125
+ f.write Scfg[:init_gitinore_item].join("\n")
110
126
  end
127
+ Simrb.p({wrote: path}, :write)
111
128
  end
112
129
  end
113
130
 
114
- @output << "Initialized module complete"
131
+ puts "Initializing module completed"
115
132
  end
116
133
 
117
- # clone a module from remote repository to local
134
+ # get a module from remote repository to local
135
+ # autually, this is a clone method of git
118
136
  #
119
137
  # == Example
120
138
  #
121
- # $ simrb clone simrb/system
139
+ # $ simrb get system
122
140
  #
123
141
  # or, more than one at same time
124
142
  #
125
- # $ simrb clone simrb/system simrb/test
143
+ # $ simrb get system test
126
144
  #
127
- def clone args
145
+ def get args
128
146
  Simrb.root_dir_force
129
147
 
148
+ repo_dir = Simrb.addslash(Spath[:repo_dirs][0] + Spath[:repo_mods])
149
+ Simrb.path_write repo_dir
150
+
130
151
  args.each do | name |
131
- if Smodules.include? name
132
- @output << "The module #{name} is existing, not clone from remote"
152
+ if Smods.keys.include? name
153
+ puts "The module #{name} is existing at local repository, hasn't got from remote"
133
154
  else
134
- path = "#{Scfg[:repo_source]}#{name[0]}.git"
135
- name = "#{Spath[:module]}#{name[0].split('/').last}"
136
- system("git clone #{path} #{name}")
155
+ path = "#{Scfg[:source]}#{name}.git"
156
+ local = "#{repo_dir}#{name}"
157
+ system("git clone #{path} #{local}")
137
158
  end
138
159
  end
139
160
 
140
- @output << "Cloned module complete"
161
+ puts "Implemented completely"
162
+ end
163
+
164
+ # pull whole remote repository from github
165
+ #
166
+ # == Example
167
+ #
168
+ # by default, that will pull the official repo
169
+ #
170
+ # $ simrb pull
171
+ #
172
+ # add the option `-f` force to pulling
173
+ #
174
+ # $ simrb pull -f
175
+ #
176
+ # or, specify the link you need in second parameter
177
+ #
178
+ # $ simrb pull repo ~/simrb_repo
179
+ #
180
+ def pull args = []
181
+ args, opts = Simrb.input_format args
182
+ repo_name = args[0] ? args[0] : Scfg[:main_repo]
183
+ from_repo = Scfg[:source] + repo_name
184
+ to_repo = Simrb.addslash(args[1] ? args[1] : Spath[:repo_dirs][0])
185
+ ispull = File.exist?(to_repo + repo_name + "/README.md") ? (opts[:f] ? true : false) : true
186
+
187
+ if ispull
188
+ Simrb.path_write to_repo
189
+ system("git clone #{from_repo}.git")
190
+ system("mv #{repo_name} #{to_repo}")
191
+ end
192
+ puts "Implemented completely"
141
193
  end
142
194
 
143
195
  # kill the current process of Simrb of that is running in background
@@ -153,7 +205,7 @@ module Simrb
153
205
  # `rm #{Spath[:tmp_dir]}pid`
154
206
 
155
207
  system("kill #{s}")
156
- @output << "Killed the process #{s} of Simrb"
208
+ puts "Killed the process #{s} of Simrb"
157
209
  end
158
210
 
159
211
  # display the basic inforamtion of current version of Simrb
@@ -164,20 +216,7 @@ module Simrb
164
216
  #
165
217
  def info args = []
166
218
  require 'simrb/info'
167
- @output << Simrb::Info
168
- end
169
-
170
- # the help document
171
- #
172
- # == Example
173
- #
174
- # $ simrb help
175
- # $ simrb help 0
176
- #
177
- def help args = []
178
- require 'simrb/help'
179
- require 'simrb/docs'
180
- @output << Simrb.help(args)
219
+ Simrb.p Simrb::Info
181
220
  end
182
221
 
183
222
  end
data/lib/simrb/docs.rb CHANGED
@@ -4,16 +4,10 @@
4
4
 
5
5
  Sdocs['Preface'] =<<Doc
6
6
 
7
- === What about the Simrb ?
7
+ This is a project to help you build the web service easily, it let you save more time on front-end developing of various terminal applications under the same background data provider.
8
8
 
9
- Simrb is a framework for building server application. Many years ago, i had tried to find an application to do work of that i want to build something that could be used to run at server, and support the web service, web page, json data, xml data, and varied formats of data.
9
+ The core goal of Simrb is focused on how to process background data and assist the data interaction of between front-end and back-end. It aims to get you a most pure utility, and efficient, modular, focused.
10
10
 
11
- The importance things in using is need to be simple, flexible, comfortable. I couldn't find it, So this is the reason why would i build this software called Simrb.
12
-
13
-
14
- === What responsibility Simrb does ?
15
-
16
- Defining the directory architecture, basic command-line, configuration option, initialize loading workflow, that is all.
17
11
  Doc
18
12
 
19
13
 
@@ -22,37 +16,40 @@ Sdocs['Directory'] =<<Doc
22
16
  /home/project
23
17
  ├── modules
24
18
  │ ├── module_name1
25
- │ │ ├── boxes ───│ ---- DATA LAYER ----
26
- │ │ │ ├── docs │ stores the documents
27
- │ │ │ ├── tpls │ stores the templates, like *.erb
28
- │ │ │ ├── migrations │ stores the migration records
29
- │ │ │ ├── langs │ stores the language file, *.en, *.de, *.cn, etc
30
- │ │ │ │ ├── name.en
31
- │ │ │ │ └── name.cn
32
- │ │ │ ├── misc │ stores the Gemfile, Gemfile.lock, and others
33
- │ │ │ │ └── Gemfile
34
- │ │ │ ├── installs │ stores the installing file that will be write into database, by
35
- │ │ │ │ └── _mods │ the file name as the table name
36
- │ │ │ ├── tool.rb │ these files will be loaded in command `$ 3s`
37
- │ │ │ └── ...
38
- │ │ ├── views ───│ ---- VIEW LAYER ----
39
- │ │ │ ├── assets │ assets dir stores the file *.js, *.css, *.jpg, *.png, etc
40
- │ │ │ │ ├── jqeury.js
41
- │ │ │ │ └── style.css
42
- │ │ │ ├── temp.slim │ here is stored the template files that will be loaded
43
- │ │ │ ├── demo.slim │ when the route file need it
44
- │ │ │ ├── demo2.slim
45
- │ │ │ └── ...
46
- │ │ ├── README.md ───│ ---- LOGIC LAYER ----
47
- │ │ ├── .gitignore
48
- │ │ ├── routes.rb │ any files with suffix `rb`, like routes.rb, all will be loaded in
49
- │ │ ├── demo.rb startup of web server
50
- │ │ ├── demo2.rb
51
- │ │ └── ... ───│
52
- │ │
53
- │ ├── module_name2 ───│ other modules, you add it according to the requirement
54
- ├── module_name3 │
55
- └── ...
19
+ │ │ ├── store ───│ ---- DATA LAYER ----
20
+ │ │ │ ├── docs │ stores the documents
21
+ │ │ │ ├── tpls │ stores the templates, like *.erb
22
+ │ │ │ ├── migrations │ stores the migration records
23
+ │ │ │ ├── langs │ stores the language file, *.en, *.de, *.cn, etc
24
+ │ │ │ │ ├── name.en
25
+ │ │ │ │ └── name.cn
26
+ │ │ │ ├── misc │ stores the Gemfile, Gemfile.lock, and others
27
+ │ │ │ │ └── Gemfile
28
+ │ │ │ ├── installs │ stores the installing file that will be write into database, by
29
+ │ │ │ │ └── base_info │ the file name as the table name
30
+ │ │ │ ├── tool.rb │ these files will be loaded in command `$ 3s`
31
+ │ │ │ └── ...
32
+ │ │ ├── views ───│ ---- VIEW LAYER ----
33
+ │ │ │ ├── assets │ assets dir stores the file *.js, *.css, *.jpg, *.png, etc
34
+ │ │ │ │ ├── jqeury.js
35
+ │ │ │ │ └── style.css
36
+ │ │ │ ├── temp.slim │ here is stored the template files that will be loaded
37
+ │ │ │ ├── demo.slim │ when the route file need it
38
+ │ │ │ ├── demo2.slim
39
+ │ │ │ └── ...
40
+ │ │ ├── logic ───│ ---- LOGIC LAYER ----
41
+ │ │ ├── routes.rb
42
+ │ │ │ └── ... │ any files with suffix `rb` under the logic dir, or root dir
43
+ │ │ ├── README.md like routes.rb, logic/routes.rb, all will be loaded when
44
+ │ │ ├── .gitignore the web server startup
45
+ │ │ ├── routes.rb │
46
+ │ │ ├── demo.rb │
47
+ ├── demo2.rb │
48
+ │ └── ... ───│
49
+ │ │
50
+ │ ├── module_name2 ───│ other modules, you add it according to the requirement
51
+ │ ├── module_name3 │
52
+ │ └── ... │
56
53
 
57
54
  ├── db
58
55
  │ ├── backup
@@ -63,36 +60,50 @@ Sdocs['Directory'] =<<Doc
63
60
  │ └── command_error_log.html
64
61
  ├── tmp
65
62
  │ └── install.lock
66
- └── scfg put any options of static configuration here with an hash form
63
+ └── scfg.rb put any options of static configuration here with an hash form
64
+
67
65
  Doc
68
66
 
67
+ Sdocs['Module'] =<<Doc
69
68
 
70
- Sdocs['Configuration'] =<<Doc
69
+ Here is some core modules that is helpful to common application
70
+
71
+ base - some common methods
72
+ data - process data and interact with database
73
+ provide an hash key-val variable as settings that stores in database
74
+ provide the tag interface for classifing any datas
75
+ provide the menu interface for managing the routers of applications
76
+
77
+ view - create shortcut view, generate view template, like form, list, table
78
+ admin - manage data with build-in view
79
+
80
+ file - provide the file upload, download
81
+ user - about user login, logout, register, authorise
82
+
83
+ the base, data and view are core modules, the admin, file and user are extended modules for common requirement
71
84
 
72
- Simrb has two configuration files that is scfg and spath under the root directory, spath stores all of paths of default directory and file, and the scfg file is for setting options to your project application.
73
85
  Doc
74
86
 
75
87
 
76
- Sdocs['Modularization'] =<<Doc
88
+ Sdocs['Configuration'] =<<Doc
77
89
 
78
- In Simrb, any functionalities that should be packed into module, whatever you want to do, three ways is there for you: new a module, or clone a module that has the requirement you want from remote repository, modify existed module at local.
90
+ Simrb has two configuration files that are the scfg.rb and spath under the root directory, the spath file stores all of paths of directory and file, scfg.rb file stores the setting options of your project application.
79
91
 
80
- Here is a core [system](https://github.com/simrb/system) module for common application.
81
92
  Doc
82
93
 
83
94
 
84
95
  Sdocs['Command-line'] =<<Doc
85
96
 
86
- === Overview
97
+ == Overview
87
98
 
88
- Simrb includes two commands, `simrb`, `3s`. `simrb` is ran at global, except the `new` and `clone`. The `3s` is only allowed to run under root directory of project. And the functionality of `3s` command could be extended by that file *.rb under the boxes dir
99
+ Simrb includes many commands, `simrb`, `3s`. `simrb` is ran at global, except the `new` and `get`. The `3s` is only allowed to run under root directory of project. And the functionality of `3s` command could be extended by the file *.rb that is under the store dir.
89
100
 
90
101
 
91
- === Description of command simrb
102
+ == Description of command simrb
92
103
 
93
104
  init - initialize a project directory
94
105
  new - create a new module
95
- clone - clone a module from remote repository
106
+ get - get a module from remote repository
96
107
  help - show the help documentation
97
108
  info - show the information of current version of Simrb
98
109
  start - boot Simrb up via web server mode
@@ -124,7 +135,7 @@ Command format:
124
135
 
125
136
  $ simrb new [module_name] [module_name2] [module_name3] ...
126
137
 
127
- note that this command only be used in root directory that includes the scfg file
138
+ note that this command only be used in root directory that includes the scfg.rb file
128
139
 
129
140
  Example 1,
130
141
 
@@ -135,17 +146,17 @@ Example 2, new module more than one at the same time
135
146
  $ simrb new test test2 test3
136
147
 
137
148
 
138
- clone
149
+ get
139
150
  ==================
140
151
  Command format:
141
152
 
142
- $ simrb clone [repo_name/module_name] [repo_name/module_name2] [repo_name/module_name3] ...
153
+ $ simrb get [repo_name/module_name] [repo_name/module_name2] [repo_name/module_name3] ...
143
154
 
144
155
  its usage is as same as the new command, but just get the module from remote repository.
145
156
 
146
157
  Example 1
147
158
 
148
- $ simrb clone repos_name/module_name repos_name2/module_name2
159
+ $ simrb get repos_name/module_name repos_name2/module_name2
149
160
 
150
161
 
151
162
  help
@@ -179,6 +190,7 @@ kill
179
190
  Command format:
180
191
 
181
192
  $ simrb kill
193
+
182
194
  Doc
183
195
 
184
196
 
@@ -194,7 +206,7 @@ Step 02, new a module called demo
194
206
 
195
207
  $ cd myapp && simrb new demo
196
208
 
197
- Step 03, add content to file
209
+ Step 03, add code to file
198
210
 
199
211
  $ echo 'get "/" do "Hello world" end' > modules/demo/routes.rb
200
212
 
@@ -202,6 +214,7 @@ Step 04, start up by web server to see what we have done
202
214
 
203
215
  $ simrb start
204
216
 
205
- So, open browser and type the link http://0.0.0.0:3000 to address bar,
206
- yup, if you see the Hello world is there, welcome you fall in Simrb.
217
+ So, put the default address `http://0.0.0.0:3000` to browser
218
+ yup, if you see the `Hello world` is there, welcome to Simrb.
219
+
207
220
  Doc
data/lib/simrb/info.rb CHANGED
@@ -8,13 +8,13 @@ module Simrb
8
8
  :name => 'simrb',
9
9
  :created => '2014-01-01',
10
10
  :alias_name => '3s',
11
- :version => '1.0.4',
11
+ :version => '1.0.6',
12
12
  :author => 'Linyu Deng',
13
13
  :email => 'coolesting@gmail.com',
14
- :homepage => 'https://github.com/simrb/simrb-gem',
14
+ :homepage => 'https://github.com/simrb/simrb-help',
15
15
  :license => 'MIT',
16
- :summary => 'Simrb',
17
- :description => 'This is a command helper for simrb'
16
+ :description => 'This is a command helper for simrb',
17
+ :summary => 'A utility of simrb',
18
18
  }
19
19
 
20
20
  end
data/lib/simrb/init.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # this is a configuration file and loading workflow of application
3
3
  #
4
4
 
5
- require 'simrb/config'
5
+ require 'simrb/base'
6
6
 
7
7
  Simrb.root_dir_force
8
8
 
@@ -29,13 +29,13 @@ Sload[:main] = []
29
29
  Sload[:tool] = []
30
30
  Sload[:view] = []
31
31
 
32
- Smodules.each do | name |
33
- Sload[:lang] += Dir["#{Sroot}#{Spath[:module]}#{name}#{Spath[:lang]}*.#{Scfg[:lang]}"]
34
- Sload[:tool] += Dir["#{Sroot}#{Spath[:module]}#{name}#{Spath[:store]}*.rb"]
35
- Sload[:tool] += Dir["#{Sroot}#{Spath[:module]}#{name}#{Spath[:tool]}*.rb"]
36
- Sload[:main] += Dir["#{Sroot}#{Spath[:module]}#{name}/*.rb"]
37
- Sload[:main] += Dir["#{Sroot}#{Spath[:module]}#{name}#{Spath[:logic]}*.rb"]
38
- Sload[:view] << "#{Sroot}#{Spath[:module]}#{name}#{Spath[:view]}".chomp("/")
32
+ Smods.each do | name, path |
33
+ Sload[:lang] += Dir["#{path}#{Spath[:lang]}*.#{Scfg[:lang]}"]
34
+ Sload[:tool] += Dir["#{path}#{Spath[:store]}*.rb"]
35
+ Sload[:tool] += Dir["#{path}#{Spath[:tool]}*.rb"]
36
+ Sload[:main] += Dir["#{path}/*.rb"]
37
+ Sload[:main] += Dir["#{path}#{Spath[:logic]}*.rb"]
38
+ Sload[:view] << "#{path}#{Spath[:view]}".chomp("/")
39
39
  end
40
40
 
41
41
  # cache label statement of language
data/lib/simrb/scfg.rb ADDED
@@ -0,0 +1,120 @@
1
+
2
+ # default path of project directory and module
3
+ Spath = {
4
+
5
+ # the required repository
6
+ :repo_dirs => [(File.expand_path("~/.simrb") + '/')],
7
+
8
+ # default directory for saving the pulled module from remote
9
+ :repo_mods => 'simrb-mods/',
10
+
11
+ # root directory path of project
12
+ :module => 'modules/',
13
+ :public => 'public/',
14
+ :db_dir => 'db/',
15
+ :upload_dir => 'db/upload/',
16
+ :backup_dir => 'db/backup/',
17
+ :tmp_dir => 'tmp/',
18
+ :cache_dir => 'tmp/cache/simrb/',
19
+ :install_lock => 'tmp/install.lock',
20
+ :log_dir => 'log/',
21
+ :server_log => 'log/thin.log',
22
+ :command_log => 'log/command_error_log.html',
23
+ :schema => 'log/migrations/',
24
+
25
+ # module directory path
26
+ :tool => '/tool/',
27
+ :logic => '/logic/',
28
+ :store => '/store/',
29
+ :lang => '/store/langs/',
30
+ :doc => '/store/docs/',
31
+ :install => '/store/installs/',
32
+ :modinfo => '/store/installs/base_info',
33
+ :tpl => '/store/tpls/',
34
+ :misc => '/store/misc/',
35
+ :gemfile => '/store/misc/Gemfile',
36
+ :view => '/views/',
37
+ :assets => '/views/assets/',
38
+ :gitignore => '/.gitignore',
39
+ :route => '/routes.rb',
40
+ :readme => '/README.md',
41
+
42
+ }
43
+
44
+ # default setting options
45
+ Scfg = {
46
+
47
+ # disable the modules of current project
48
+ :module_disable => [],
49
+
50
+ # require the modules of local repository
51
+ :module_require => [],
52
+
53
+ :module_focus => nil,
54
+
55
+ :user => 'unknown',
56
+
57
+ # default config filename
58
+ :name => 'scfg.rb',
59
+
60
+ # overwrite the file Scfg[:name]
61
+ :name_overwrite => "/scfg_copy.rb",
62
+
63
+ :encoding => 'utf-8',
64
+ :lang => 'en',
65
+ :install_lock => 'yes',
66
+ :db_connection => 'sqlite://db/data.db',
67
+ :server => 'thin',
68
+ :bind => '0.0.0.0',
69
+ :port => 3000,
70
+
71
+ :source => 'https://github.com/simrb/',
72
+
73
+ # a default core repository for loading when the server booting
74
+ :main_repo => 'simrb-repo',
75
+
76
+ # options: development, production, test
77
+ :environment => 'development',
78
+
79
+ :server_log_mode => 'file',
80
+
81
+ :field_time => ['created', 'changed'],
82
+ :field_fixnum => ['order', 'level'],
83
+ :field_number => ['Fixnum', 'Integer', 'Float'],
84
+
85
+ :alias_fields => {
86
+ int:'Fixnum', str:'String', text:'Text',
87
+ time:'Time', big:'Bignum', fl:'Float'
88
+ },
89
+
90
+ # command alias name of generating methods
91
+ :alias_gcmd => {
92
+ 'm' => 'migration', 'i' => 'install', 'd' => 'data', 'v' => 'view'
93
+ },
94
+
95
+ :alias_cmd => {
96
+ },
97
+
98
+ :init_module_path => [
99
+ :store, :install, :modinfo, :misc,
100
+ :gemfile, :view, :assets, :readme, :route
101
+ ],
102
+
103
+ :init_root_path => [
104
+ :db_dir, :upload_dir, :backup_dir,
105
+ :tmp_dir, :log_dir, :module, :schema
106
+ ],
107
+
108
+ :init_module_field => {
109
+ 'name' => 'unname', 'author' => 'unknown', 'version' => '1.0.0'
110
+ },
111
+
112
+ :init_gitinore_item => [
113
+ "*.swo", "*.swp", "*.gem", "*~", "*.lock", "*.bak"
114
+ ],
115
+
116
+ }
117
+
118
+ # append the children repository
119
+ Spath[:repo_dirs] << (Spath[:repo_dirs][0] + Spath[:repo_mods])
120
+ Spath[:repo_dirs] << (Spath[:repo_dirs][0] + Scfg[:main_repo] + '/')
@@ -0,0 +1,19 @@
1
+
2
+ Scfg[:encoding] = 'utf-8'
3
+ Scfg[:lang] = 'en'
4
+ Scfg[:install_lock] = 'yes'
5
+
6
+ Scfg[:db_connection] = 'sqlite://db/data.db'
7
+ Scfg[:bind] = '0.0.0.0'
8
+ Scfg[:port] = 3000
9
+
10
+ # options: development, production, test
11
+ Scfg[:environment] = 'development'
12
+
13
+ # Scfg[:module_require] = ['base','data','view','file','admin','user']
14
+
15
+ # your directory path of local
16
+ # Spath[:repo_dirs][0] = (File.expand_path("~/.simrb") + '/')
17
+
18
+ # add repository path like this
19
+ # Spath[:repo_dirs] << "/home/yours"
@@ -2,6 +2,7 @@
2
2
  # this is an entrance for running the task command in tool box
3
3
  #
4
4
 
5
+ puts "="*30
5
6
  require 'simrb/init'
6
7
 
7
8
  module Simrb
@@ -12,50 +13,54 @@ end
12
13
  Sload[:tool].each do | path |
13
14
  require path
14
15
  end
15
- argv = ARGV.clone
16
- output = []
16
+
17
+ argv = ARGV.clone
18
+ method = argv.shift(1)[0]
19
+ method = Scfg[:alias_cmd][method] if Scfg[:alias_cmd].keys.include? method
20
+
21
+ # output = []
17
22
 
18
23
  # command mode
19
- if argv.count > 0 and Simrb::Stool.method_defined?(argv[0])
20
-
24
+ if Simrb::Stool.method_defined?(method)
25
+
21
26
  helpers do
22
27
  include Simrb::Stool
23
28
  end
24
29
 
25
30
  get '/_tools' do
26
- method = argv.shift(1)[0]
27
31
  argv.empty? ? eval(method).to_s : eval("#{method} #{argv}").to_s
28
32
  end
29
33
 
30
34
  env = {'PATH_INFO' => "/_tools", 'REQUEST_METHOD' => 'GET', 'rack.input' => ''}
31
35
  status, type, body = Sinatra::Application.call env
32
36
  if status == 200
33
- body.each do | line |
34
- output << line
35
- end
37
+ # body.each do | line |
38
+ # output << line
39
+ # end
36
40
  else
37
41
  File.open(Spath[:command_log], 'a+') do | f |
38
42
  f.write "\n#{'='*10}#{Time.now.to_s}\n#{'='*10}\n"
39
43
  # f.write body
40
44
  f.write (Sinatra::ShowExceptions.new(self).call(env.merge("HTTP_USER_AGENT" => "curl"))[2][0].to_s + "\n")
41
45
  end
42
- output << env["sinatra.error"]
46
+ # output << env["sinatra.error"]
47
+ puts env["sinatra.error"]
43
48
  end
44
49
 
45
50
  # document mode
46
- else
47
-
48
- require 'simrb/help'
51
+ elsif method == "help"
49
52
 
50
- Smodules.each do | name |
51
- Dir["#{Spath[:module]}#{name}#{Spath[:doc]}*.#{Scfg[:lang]}.rb"].each do | path |
52
- require(Sroot + path)
53
+ Smods.each do | name, path |
54
+ Dir["#{path}#{Spath[:doc]}*.#{Scfg[:lang]}.rb"].each do | path2 |
55
+ require(path2)
53
56
  end
54
57
  end
55
58
 
56
- argv.shift 1
57
- output << Simrb.help(argv)
59
+ # argv.shift 1
60
+ puts Simrb.help(argv)
58
61
 
62
+ else
63
+ puts "No command #{method}, please try $3s help"
59
64
  end
60
65
 
61
- Simrb.p output
66
+ puts "="*30
data/lib/simrb.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # this is an entrance to base command operated
3
3
  #
4
4
 
5
- require 'simrb/config'
5
+ require 'simrb/base'
6
6
  require 'simrb/comd'
7
7
  simrb_app = Simrb::Scommand.new
8
8
  simrb_app.run ARGV
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linyu Deng
@@ -30,42 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 4.10.0
33
+ version: 4.15.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 4.10.0
40
+ version: 4.15.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: slim
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 2.0.2
47
+ version: 2.1.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 2.0.2
54
+ version: 2.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: thin
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 1.6.2
61
+ version: 1.6.3
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 1.6.2
68
+ version: 1.6.3
69
69
  description: This is a command helper for simrb
70
70
  email: coolesting@gmail.com
71
71
  executables:
@@ -77,16 +77,17 @@ files:
77
77
  - bin/3s
78
78
  - bin/simrb
79
79
  - lib/simrb.rb
80
+ - lib/simrb/base.rb
80
81
  - lib/simrb/comd.rb
81
- - lib/simrb/config.rb
82
82
  - lib/simrb/docs.rb
83
- - lib/simrb/help.rb
84
83
  - lib/simrb/hook.rb
85
84
  - lib/simrb/info.rb
86
85
  - lib/simrb/init.rb
86
+ - lib/simrb/scfg.rb
87
+ - lib/simrb/scfg_copy.rb
87
88
  - lib/simrb/thin_start.rb
88
89
  - lib/simrb/tool_start.rb
89
- homepage: https://github.com/simrb/simrb-gem
90
+ homepage: https://github.com/simrb/simrb-help
90
91
  licenses:
91
92
  - MIT
92
93
  metadata: {}
@@ -109,5 +110,5 @@ rubyforge_project: simrb
109
110
  rubygems_version: 2.2.2
110
111
  signing_key:
111
112
  specification_version: 4
112
- summary: Simrb
113
+ summary: A utility of simrb
113
114
  test_files: []
data/lib/simrb/config.rb DELETED
@@ -1,212 +0,0 @@
1
- #
2
- # definition to the base methods, and default configuration options
3
- # and the modules that would be loaded
4
- #
5
-
6
- Sroot = Dir.pwd + '/'
7
- module Simrb
8
-
9
- # common methods
10
- class << self
11
-
12
- def yaml_read path
13
- require 'yaml'
14
- YAML.load_file path
15
- rescue
16
- []
17
- end
18
-
19
- def yaml_write path, data
20
- require "yaml"
21
- File.open(path, 'w+') do | f |
22
- f.write data.to_yaml
23
- end
24
- end
25
-
26
- def p args
27
- res = ""
28
-
29
- if args.class.to_s == 'Array'
30
- res = args.join("\n")
31
- elsif args.class.to_s == 'Hash'
32
- args.each do | k, v |
33
- res << "#{k.to_s.ljust(15)} => #{v}\n"
34
- end
35
- res = res.chomp "\n"
36
- else
37
- res = args.to_s
38
- end
39
-
40
- puts "="*30 + "\n" + res + "\n" + "="*30
41
- end
42
-
43
- def module_load
44
- dirs = []
45
- module_ds = {}
46
-
47
- # get the path of module
48
- if Scfg[:only_enable_modules].empty?
49
- dirs = Dir["#{Spath[:module]}*"]
50
- else
51
- Scfg[:only_enable_modules].each do | name |
52
- path = "#{Spath[:module]}#{name}"
53
- dirs << path if File.exist?(path)
54
- end
55
- end
56
-
57
- # load the info of module
58
- dirs.each do | path |
59
- path = "#{path}#{Spath[:modinfo]}"
60
- content = Simrb.yaml_read path
61
- name = content[0]["name"]
62
- order = (content[0]["order"] || 99)
63
- module_ds[name] = order unless Scfg[:disable_modules].include?(name.to_s)
64
- end
65
-
66
- # sort the module by order field
67
- res = []
68
- module_ds = module_ds.sort_by { |k, v| v }
69
- module_ds.each do | item |
70
- res << item[0]
71
- end
72
- res
73
- end
74
-
75
- def path_init path, content = ""
76
- unless File.exist?(path)
77
- path[-1] == '/' ? Dir.mkdir(path) : File.open(path, 'w+') {|f| f.write content}
78
- end
79
- end
80
-
81
- def root_dir_force
82
- unless File.exist? 'scfg'
83
- Simrb.p "Current command only allow to be used under root directory of project"
84
- exit
85
- end
86
- end
87
-
88
- # format the input argument from an array to two item,
89
- # first item is orgin array, last is an hash option
90
- #
91
- # == Example
92
- #
93
- # args, opts = Simrb.input_format ["test", "test2", "--test", "--name=test2", "-n=test3"]
94
- #
95
- # the above is same as
96
- #
97
- # args, opts = Simrb.input_format ["--test", "test", "test2", "--name=test2", "-n=test3"]
98
- #
99
- # the options that starts with "-" you can write any positions of argument
100
- #
101
- # output
102
- #
103
- # args = ["test", "test2"]
104
- # opts = {test: true, name: test2, n:test3}
105
- #
106
- def input_format args = []
107
- resa = [] # return an array
108
- resh = {} # return an hash
109
- unless args.empty?
110
- args.each do | item |
111
-
112
- if item[0] == "-"
113
- new_item = item.split("-").uniq.last
114
- if new_item.index "="
115
- key, val = new_item.split "="
116
- resh[key.to_sym] = val
117
- else
118
- resh[new_item.to_sym] = true
119
- end
120
- else
121
- resa << item
122
- end
123
-
124
- end
125
- end
126
- [resa, resh]
127
- end
128
-
129
- end
130
-
131
- # basic path definition
132
- Spath = {
133
- # root path of project
134
- :module => 'modules/',
135
- :public => 'public/',
136
- :db_dir => 'db/',
137
- :upload_dir => 'db/upload/',
138
- :backup_dir => 'db/backup/',
139
- :tmp_dir => 'tmp/',
140
- :cache_dir => 'tmp/cache/simrb/',
141
- :install_lock_file => 'tmp/install.lock',
142
- :log_dir => 'log/',
143
- :server_log => 'log/thin.log',
144
- :command_log => 'log/command_error_log.html',
145
-
146
- # sub path under module directory of project
147
- :tool => '/tool/',
148
- :logic => '/logic/',
149
- :store => '/boxes/',
150
- :lang => '/boxes/langs/',
151
- :doc => '/boxes/docs/',
152
- :schema => '/boxes/migrations/',
153
- :install => '/boxes/installs/',
154
- :modinfo => '/boxes/installs/_mods',
155
- :vars => '/boxes/installs/_vars',
156
- :menu => '/boxes/installs/_menu',
157
- :tpl => '/boxes/tpls/',
158
- :layout_css => '/boxes/tpls/layout.css',
159
- :common_css => '/boxes/tpls/common.css',
160
- :misc => '/boxes/misc/',
161
- :gemfile => '/boxes/misc/Gemfile',
162
- :view => '/views/',
163
- :assets => '/views/assets/',
164
- :gitignore => '/.gitignore',
165
- :route => '/routes.rb',
166
- :readme => '/README.md',
167
- }
168
-
169
- # default settings of scfg file
170
- Scfg = {
171
- :time_types => ['created', 'changed'],
172
- :fixnum_types => ['order', 'level'],
173
- :number_types => ['Fixnum', 'Integer', 'Float'],
174
- :field_alias => {int:'Fixnum', str:'String', text:'Text', time:'Time', big:'Bignum', fl:'Float'},
175
- :init_module_path => [:store, :lang, :schema, :install, :modinfo, :misc, :gemfile, :view, :assets, :readme, :route],
176
- :init_root_path => [:db_dir, :upload_dir, :backup_dir, :tmp_dir, :log_dir, :module],
177
- :environment => 'development', # or production, test
178
- :only_enable_modules => [],
179
- :disable_modules => [],
180
- :encoding => 'utf-8',
181
- :lang => 'en',
182
- :install_lock => 'yes',
183
- :db_connection => 'sqlite://db/data.db',
184
- :server_log_mode => 'file',
185
- :repo_source => 'https://github.com/',
186
- :server => 'thin',
187
- :bind => '0.0.0.0',
188
- :port => 3000,
189
- :init_scfg_item => [:lang, :db_connection, :environment, :bind, :port],
190
- }
191
-
192
- end
193
-
194
- # load config file in shortcut pipe
195
- Scfg = Simrb::Scfg
196
- if File.exist? 'scfg'
197
- Simrb.yaml_read('scfg').each do | k, v |
198
- Scfg[k.to_sym] = v
199
- end
200
- end
201
-
202
- # load path in shortcut pipe
203
- Spath = Simrb::Spath
204
- if File.exist? 'spath'
205
- Simrb.yaml_read('spath').each do | k, v |
206
- Spath[k.to_sym] = v
207
- end
208
- end
209
-
210
- # load modules
211
- Smodules = Simrb.module_load
212
-
data/lib/simrb/help.rb DELETED
@@ -1,33 +0,0 @@
1
- #
2
- # a help interface for document
3
- #
4
-
5
- Sdocs = {}
6
-
7
- module Simrb
8
-
9
- def self.help args = []
10
- res = []
11
- i = 0
12
- docs_key = {}
13
- docs_val = {}
14
- Sdocs.each do | key, val |
15
- docs_key[i] = key
16
- docs_val[i] = val
17
- i = i + 1
18
- end
19
-
20
- if args.empty?
21
- res << 'please select the number before the list to see detials'
22
- docs_key.each do | i, key |
23
- res << "#{i.to_s}, #{key}"
24
- end
25
- else
26
- args.each do | i |
27
- res << (docs_val.include?(i.to_i) ? docs_val[i.to_i] : 'no document')
28
- end
29
- end
30
- res
31
- end
32
-
33
- end