aro 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile.lock +3 -2
  4. data/README.md +1 -1
  5. data/aro.gemspec +1 -0
  6. data/bin/aos +2 -2
  7. data/bin/aro +4 -4
  8. data/checksums/aro-0.2.1.gem.sha512 +1 -0
  9. data/checksums/aro-0.2.2.gem.sha512 +1 -0
  10. data/listen.rb +1 -1
  11. data/locale/en.amg.yml +44 -0
  12. data/locale/en.aos.yml +13 -8
  13. data/locale/en.data.yml +30 -0
  14. data/locale/en.dom.yml +10 -8
  15. data/locale/en.usage.yml +22 -22
  16. data/locale/en.yml +16 -11
  17. data/sys/aos/amg.rb +184 -0
  18. data/sys/aos/aos.rb +203 -89
  19. data/sys/aos/data.rb +117 -0
  20. data/{db → sys/aos/db}/migrate/1765148774_create_yous.rb +1 -0
  21. data/sys/aos/db/migrate/1765762724_create_ilibs.rb +22 -0
  22. data/sys/aos/db/migrate/1765907766_create_ilogs.rb +18 -0
  23. data/sys/aos/db.rb +44 -25
  24. data/sys/aos/models/ilib.rb +46 -0
  25. data/sys/aos/models/ilog.rb +27 -0
  26. data/sys/aos/models/you.rb +50 -0
  27. data/sys/aos/vws/base.rb +120 -0
  28. data/sys/aos/{views → vws}/dom.rb +6 -10
  29. data/sys/aos/vws/games/abpps.rb +19 -0
  30. data/sys/aos/{views → vws}/games/game.rb +26 -25
  31. data/sys/aos/vws/games/hbpps.rb +19 -0
  32. data/sys/aos/vws/games/shpps.rb +19 -0
  33. data/sys/aos/vws/games/vipps.rb +19 -0
  34. data/sys/aos/{views → vws}/games.rb +3 -3
  35. data/sys/aos/vws/know/body.rb +19 -0
  36. data/sys/aos/vws/know/mind.rb +19 -0
  37. data/sys/aos/vws/know/spirit.rb +19 -0
  38. data/sys/aos/{views → vws}/know.rb +3 -3
  39. data/sys/aos/vws/root/amg.rb +21 -0
  40. data/sys/aos/vws/root/config.rb +21 -0
  41. data/sys/aos/vws/root/data.rb +21 -0
  42. data/sys/aos/{views/setup.rb → vws/root.rb} +4 -4
  43. data/sys/aos/vws/welcome/waite.rb +31 -0
  44. data/sys/aos/{views → vws}/welcome/winner.rb +3 -3
  45. data/sys/aos/vws/welcome.rb +30 -0
  46. data/{db/migrate/1763374647_create_decks.rb → sys/aro/db/migrate/1763374647_create_tecks.rb} +5 -5
  47. data/sys/aro/db/migrate/1763432541_create_tlogs.rb +20 -0
  48. data/sys/aro/db.rb +16 -15
  49. data/sys/aro/mancy.rb +4 -3
  50. data/sys/{models/deck.rb → aro/models/teck.rb} +56 -62
  51. data/sys/aro/models/tlog.rb +20 -0
  52. data/sys/aro/v.rb +1 -1
  53. data/sys/cli/constants.rb +1 -1
  54. data/sys/cli/dom.rb +1 -1
  55. data/sys/cli/{deck.rb → teck.rb} +20 -15
  56. data/sys/cli.rb +12 -12
  57. data/sys/dom/config.rb +718 -0
  58. data/sys/dom/d.rb +36 -18
  59. data/sys/dom/dom.rb +24 -14
  60. data/sys/reiquire.rb +8 -8
  61. data/sys/shr/ilib/crs/CMakeLists.txt +12 -0
  62. data/sys/shr/ilib/crs/compile.sh +5 -0
  63. data/sys/shr/ilib/crs/crs.c +24 -0
  64. data/sys/shr/ilib/crs/crs.o +0 -0
  65. data/sys/shr/ilib/crs/libcrs.so +0 -0
  66. data/sys/shr/prompt.rb +1 -5
  67. data/sys/shr/t.rb +14 -8
  68. data/sys/shr/version.rb +1 -1
  69. metadata +63 -26
  70. data/db/migrate/1763432541_create_logs.rb +0 -20
  71. data/locale/en.cngelog.yml +0 -5
  72. data/sys/aos/views/base.rb +0 -166
  73. data/sys/aos/views/games/abpps.rb +0 -21
  74. data/sys/aos/views/games/hbpps.rb +0 -21
  75. data/sys/aos/views/games/shpps.rb +0 -21
  76. data/sys/aos/views/games/vipps.rb +0 -21
  77. data/sys/aos/views/know/library.rb +0 -19
  78. data/sys/aos/views/know/temple.rb +0 -19
  79. data/sys/aos/views/setup/settings.rb +0 -37
  80. data/sys/aos/views/welcome/waite.rb +0 -19
  81. data/sys/aos/views/welcome.rb +0 -19
  82. data/sys/aos/you.rb +0 -19
  83. data/sys/cli/config.rb +0 -669
  84. data/sys/models/log.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b015a69c685e9cda66781c4b96bd8ffbcb08165b71df89f300caa3bfb03eaff7
4
- data.tar.gz: 428e7d962faec02772f1ef203f055ffef482fd11912d9a87577ca17afe5bf657
3
+ metadata.gz: f91a54d4e715e8e4d60abdc8995af38490ef59c8ce1a1e96cd705c719048a7fe
4
+ data.tar.gz: e511fd595d93feb729dd2d1a24d9d8fbffb2695a048c4beb1f7ca3879b082ba0
5
5
  SHA512:
6
- metadata.gz: 4a0d9378161d2ca7a8b02ae10b5297dac32b1945af986e9538708df6be54ac85d4c23bf4692c77870259478adf35052d5ec5581c84eb8f32358b79f20cd3146d
7
- data.tar.gz: 27cebaa507ac475cb0d4204ba9874afcce52199d36c48f31f39ce318b7e8f5870c1be7cfb80cf938c3a1670329cde4d252d9e6fa6dd12efd9163980742e74e6c
6
+ metadata.gz: d78726504c8cea384672e6168ffbd28e1a49344534f18305ded0b6ba0c273444b65cc86f0d48c21e8b2890d1d37d220de792f95ab64ded12f495fb055d379327
7
+ data.tar.gz: 03dbf7645004603275e2d69ac2c5fbcf0fc22f7c02281e196d49533181d03db341e2087778132241b4281744019fbd68337f7582530cdb7849f442697eb10ef9
data/.gitignore CHANGED
@@ -3,4 +3,5 @@
3
3
  *.log
4
4
  *.name
5
5
  *.sql
6
+ ffi/build/*
6
7
  pkg/*
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aro (0.1.7)
4
+ aro (0.2.1)
5
5
  activerecord (~> 8.1, >= 8.1.1)
6
+ ffi (~> 1.17, >= 1.17.2)
6
7
  i18n (~> 1.14, >= 1.14.7)
7
- listen (~> 3.9, >= 3.9.0)
8
8
  sqlite3 (~> 2.8, >= 2.8.0)
9
9
  tty-prompt (~> 0.23.1, >= 0.23.1)
10
10
 
@@ -116,6 +116,7 @@ PLATFORMS
116
116
  DEPENDENCIES
117
117
  aro!
118
118
  bundler (~> 2.7, >= 2.7.2)
119
+ listen (~> 3.9, >= 3.9.0)
119
120
  rake (~> 13.3, >= 13.3.1)
120
121
  rspec (~> 3.13, >= 3.13.2)
121
122
 
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  ##### __current version:__
5
5
  [![Gem Version](https://badge.fury.io/rb/aro.svg)](https://badge.fury.io/rb/aro)
6
6
 
7
- aro is a command line interface that allows you to manage multiple tarot decks.
7
+ aro is a command line interface that allows you to manage multiple tarot tecks.
8
8
 
9
9
 
10
10
  ### install
data/aro.gemspec CHANGED
@@ -36,4 +36,5 @@ Gem::Specification.new do |spec|
36
36
  spec.add_runtime_dependency "activerecord", "~> 8.1", ">= 8.1.1"
37
37
  spec.add_runtime_dependency "sqlite3", "~> 2.8", ">= 2.8.0"
38
38
  spec.add_runtime_dependency "tty-prompt", "~> 0.23.1", ">= 0.23.1"
39
+ spec.add_runtime_dependency "ffi", "~> 1.17", ">= 1.17.2"
39
40
  end
data/bin/aos CHANGED
@@ -17,8 +17,8 @@ unless Aro::Dom.in_arodom?
17
17
  exit(CLI::EXIT_CODES[:GENERAL_ERROR])
18
18
  end
19
19
 
20
- if CLI::ARGV0.nil?
20
+ if CLI::ARGV0.nil? || CLI::ARGV0 == Aos::Os::YOU_FLAG.to_sym
21
21
  exit(Aos::run)
22
- else #if Aos::Os.is_aos_command?(ARGV[Aro::Mancy::O])
22
+ else
23
23
  exit(Aos::process)
24
24
  end
data/bin/aro CHANGED
@@ -23,21 +23,21 @@ end
23
23
  # cli parser
24
24
  case CLI::ARGV0
25
25
  when CLI::CMDS[:ARO][:CONFIG]
26
- CLI::config
26
+ Aro::config
27
27
  when CLI::CMDS[:ARO][:CREATE]
28
28
  CLI::create
29
29
  when CLI::CMDS[:ARO][:DECK]
30
- CLI::deck
30
+ CLI::teck
31
31
  when CLI::CMDS[:ARO][:DOM]
32
32
  CLI::dom
33
33
  when CLI::CMDS[:ARO][:INIT]
34
34
  Aro::Mancy.init
35
35
  else
36
36
  unless Aro::Mancy.game.nil? || CLI::FLAGS[:HELP].include?(CLI::ARGV0)
37
- # unless ARGV.include?(:aos.to_s)
37
+ unless ARGV.include?(:aos.to_s)
38
38
  Aro::P.say(I18n.t("cli.messages.welcome", name: "#{Aro::Mancy.name}.game"))
39
39
  Aro::Mancy.game.show
40
- # end
40
+ end
41
41
 
42
42
  exit(CLI::EXIT_CODES[:SUCCESS])
43
43
  end
@@ -0,0 +1 @@
1
+ 98e520a4e76c2a04f79f7b7207759dae278b366625735757c7612b75fddf5acdd0d0942fb613a0c8ecc5cb8304814a09fd0336f775df46c164a7a13397400a5f
@@ -0,0 +1 @@
1
+ 580e42a13fb83232b8282a3d2888ced1fc36790739ebc8b5c3bf99b9d7c5664f10d117d967a2d75896c7a2cabfbe84e628b3359d7f4d6771a2cad4784cd178e5
data/listen.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require :listen.to_s
2
2
 
3
- listener = Listen.to(*[:sys.to_s, :bin.to_s, :spec.to_s, :locale.to_s, :db.to_s], only: /[\.rb\.yml]/) {|modified, added, removed|
3
+ listener = Listen.to(*[:sys.to_s, :bin.to_s, :spec.to_s, :locale.to_s], only: /[\.rb\.yml]/) {|modified, added, removed|
4
4
  # puts modified
5
5
  # puts added
6
6
  # puts removed
data/locale/en.amg.yml ADDED
@@ -0,0 +1,44 @@
1
+ en:
2
+ amg:
3
+ commands:
4
+ description:
5
+ inst: "show installed ilibs or install a lib."
6
+ instun: "show uninstalled ilibs or uninstall a lib."
7
+ usage:
8
+ inst: "$ amg inst <lib>"
9
+ instun: "$ amg instun <lib>"
10
+ messages:
11
+ already_installed: "%{name} lib is already installed."
12
+ cannot_locate: "could not find %{name} lib."
13
+ ilib_name: "name: %{name}"
14
+ ilib_path: "path: %{path}"
15
+ ilib_usage: "usage: %{usage}"
16
+ install_success: "%{name} installed successfully."
17
+ install_failure: "failed to install %{name}."
18
+ listing_available: "listing available ilibs..."
19
+ listing_installed: "listing installed ilibs..."
20
+ none_available: "no ilibs available for install."
21
+ none_installed: "no ilibs installed."
22
+ not_installed: "%{name} lib is not installed."
23
+ uninstall_success: "%{name} uninstalled successfully."
24
+ uninstall_failure: "failed to uninstall %{name}."
25
+ usage: |
26
+
27
+ amg [-h | --help] <command>
28
+ aos system management.
29
+
30
+ COMMANDS
31
+
32
+ inst
33
+ show installed ilibs.
34
+
35
+ install a lib named <lib>.
36
+
37
+ $ amg inst <lib>
38
+
39
+ instun
40
+ show uninstalled ilibs.
41
+
42
+ uninstall a lib named <lib>.
43
+
44
+ $ amg instun <lib>
data/locale/en.aos.yml CHANGED
@@ -2,30 +2,35 @@ en:
2
2
  aos:
3
3
  commands:
4
4
  description:
5
- cd: "change directory. no args navigates to arodom root."
6
- config: "open settings."
7
- config_set: "sets an ivar to a specified value. the prefix '%{prefix}' can be omitted."
5
+ amg: "manage aos. a tool for package installation/management."
6
+ cd: "change directory. no args navigates to arodome root."
7
+ config: "read/write aos vars. (enter vars lowercase excluding bash prefix)."
8
+ data: "manage aos data."
8
9
  exit: "exit."
10
+ help: "help."
9
11
  ll: "list files and folders in the pwd including hidden files."
10
12
  ls: "list files and folders in the pwd."
11
13
  pwd: "show pwd."
12
14
  usage:
15
+ amg: "$ amg [-h | --help] <command>"
13
16
  cd: "$ cd <name>"
14
- config: "$ config"
15
- config_set: "$ config set <var_name> <var_value>"
17
+ config: "$ config <var_name> <var_value>"
18
+ data: "$ data [-h | --help] <command>"
16
19
  exit: "$ exit"
20
+ help: "$ help"
17
21
  ll: "$ ll"
18
22
  ls: "$ ls"
19
23
  pwd: "$ pwd"
20
24
  constants:
21
25
  commands: "COMMANDS"
26
+ subcommands: "SUBCOMMANDS"
22
27
  views:
23
28
  dom:
24
- title: "welcome to the dom. this is the hub of the arodome running on Aos::Os."
25
- description: "this is the root space where you begin. available commands are listed below."
29
+ title: "ready to go..."
30
+ description: "awaiting input..."
26
31
  quick_navigation: "the following room names are reserved for quick navigation. enter any of them to navigate to that room."
27
32
  game:
28
- title: "aro"
33
+ title: "you are playing aro..."
29
34
  description: "enter commands to play."
30
35
  is_the: "welcome to the %{name} game room."
31
36
  designed_for: "originally designed for %{description}"
@@ -0,0 +1,30 @@
1
+ en:
2
+ data:
3
+ commands:
4
+ description:
5
+ ilogs: "show aos ilogs."
6
+ yous: "show aos ilogs."
7
+ usage:
8
+ ilogs: "$ data ilogs"
9
+ yous: "$ data yous"
10
+ ilogs:
11
+ display: "%{you} entered '%{cmd}' at %{timestamp} in %{pwd}."
12
+ yous:
13
+ display: "name: %{name}, access: %{access}, pwd: %{pwd}."
14
+ messages:
15
+ listing_ilogs: "listing aos input ilogs..."
16
+ listing_yous: "listing yous..."
17
+ no_ilogs: "no input ilogs."
18
+ no_yous: "no yous."
19
+ usage: |
20
+
21
+ data [-h | --help] <command>
22
+ aos data management.
23
+
24
+ COMMANDS
25
+
26
+ ilogs
27
+ show aos ilogs.
28
+
29
+ yous
30
+ show aos yous.
data/locale/en.dom.yml CHANGED
@@ -7,8 +7,8 @@ en:
7
7
  description: "aro game rooms."
8
8
  know:
9
9
  description: "information space."
10
- setup:
11
- description: "user configuration space."
10
+ root:
11
+ description: "aos system space."
12
12
  rooms:
13
13
  waite:
14
14
  description: "sign up."
@@ -22,12 +22,14 @@ en:
22
22
  description: "human and artificial beings."
23
23
  vipps:
24
24
  description: "only dev_tarot users. no ruby_facots allowed."
25
- library:
26
- description: "definition management."
27
- temple:
28
- description: "mindfulness management."
29
- settings:
30
- description: "user settings and configuration."
25
+ body:
26
+ description: "body."
27
+ mind:
28
+ description: "mind."
29
+ spirit:
30
+ description: "spirit."
31
+ config:
32
+ description: "user config and configuration."
31
33
  errors:
32
34
  directory_exists: "unable to create arodome at %{name}. file or directory already exists."
33
35
  failed_already_in_arodom: "unable to create an arodome because you are already in arodom."
data/locale/en.usage.yml CHANGED
@@ -3,7 +3,7 @@ en:
3
3
  main: |
4
4
  NAME
5
5
 
6
- aro - a cli for tarot games in the arodom.
6
+ aro - a cli for tarot.
7
7
 
8
8
  SYNOPSIS
9
9
 
@@ -16,7 +16,7 @@ en:
16
16
  $ aro create <name>
17
17
 
18
18
  init
19
- set up the .aro directory that contains database and config
19
+ sets up the .aro directory that contains database and config
20
20
 
21
21
  note:
22
22
  this runs by default after create and has no effect if init is complete.
@@ -24,28 +24,28 @@ en:
24
24
  config
25
25
  aro config management.
26
26
 
27
- $ aro config <commands>
27
+ $ aro config <var_name> <var_value>
28
28
 
29
- passing no args opens prints the current config.
29
+ passing no args or only <var_name> prints the current config or <var_value>.
30
30
 
31
31
  SUBCOMMANDS
32
32
  set
33
33
  sets an ivar to a specified value. the aro var prefix can be omitted.
34
34
 
35
- $ aro config set <var_name> <var_value>
35
+ $ aro config <var_name> <var_value>
36
36
 
37
- deck
38
- manage decks in the current room.
37
+ teck
38
+ manage tecks in the current room.
39
39
 
40
- $ aro deck <commands>
40
+ $ aro teck <commands>
41
41
 
42
42
  passing no args opens the selection menu.
43
43
 
44
44
  note:
45
45
 
46
- deck subcommands do not require typing 'deck'. for example,
46
+ teck subcommands do not require typing 'teck'. for example,
47
47
 
48
- $ aro deck show
48
+ $ aro teck show
49
49
 
50
50
  is the same thing as:
51
51
 
@@ -53,29 +53,29 @@ en:
53
53
 
54
54
  SUBCOMMANDS
55
55
  draw
56
- draw a random card from the current deck.
56
+ draw a random card from the current teck.
57
57
 
58
58
  explore
59
- allows user to browse each card in the current deck.
59
+ allows user to browse each card in the current teck.
60
60
 
61
61
  new
62
- create a new deck with the specified name.
62
+ create a new teck with the specified name.
63
63
 
64
64
  example:
65
65
 
66
- $ aro deck new <name>
66
+ $ aro teck new <name>
67
67
 
68
68
  replace
69
69
  replaces all drawn cards FIFO and puts them on the bottom of
70
- the deck. this will preserve all card orientations.
70
+ the teck. this will preserve all card orientations.
71
71
 
72
72
  reset
73
- completely reset the deck. replace all drawn and reset order.
73
+ completely reset the teck. replace all drawn and reset order.
74
74
  all orientations will be set to upright. you must enter 'aroyes'
75
75
  to continue.
76
76
 
77
77
  show
78
- displays the current deck's log record(s).
78
+ displays the current teck's log record(s).
79
79
 
80
80
  the default behavior is to display only the most recent log record.
81
81
 
@@ -85,11 +85,11 @@ en:
85
85
 
86
86
  OPTIONS
87
87
 
88
- [-n | --count] specify number of deck logs to show.
88
+ [-n | --count] specify number of teck tlogs to show.
89
89
 
90
90
  default is 1 (latest/current state)
91
91
 
92
- passing 'all' display all logs
92
+ passing 'all' display all tlogs
93
93
 
94
94
  [-o | --order] specify the output order of the log records.
95
95
 
@@ -98,15 +98,15 @@ en:
98
98
  possible values: ['asc', 'desc']
99
99
 
100
100
  shuffle
101
- shuffles the current deck and generates a log record.
101
+ shuffles the current teck and generates a log record.
102
102
 
103
103
  dom
104
- arodom management.
104
+ aos arodome management.
105
105
 
106
106
  $ aro dom <commands>
107
107
 
108
108
  SUBCOMMANDS
109
- init
109
+ init <username> <password>
110
110
  generate the arodome
111
111
  new
112
112
  create a new arodome with the specified name.
data/locale/en.yml CHANGED
@@ -21,13 +21,17 @@ en:
21
21
  dev_tarot_description: "reads from /dev/tarot device if available."
22
22
  ruby_facot_description: "generated ruby_facot (facade randomness)."
23
23
  format:
24
- description: "aro output format."
25
- text_description: "show aro responses in text format (default)"
26
- json_description: "show aro responses in json format."
24
+ description: "aos output format."
25
+ text_description: "show aos output in text format (default)."
26
+ json_description: "show aos output in json format."
27
+ interface:
28
+ description: "aos output interface."
29
+ terminal_description: "render terminal output (default)."
30
+ lanimret_description: "render flie web output."
27
31
  height_description: "display height. valid range: (${min}-${max})"
28
32
  width_description: "display width. valid range: (${min}-${max})"
29
33
  env:
30
- description: "aro run environment."
34
+ description: "aos run environment."
31
35
  development_description: "basic development logs and features."
32
36
  production_description: "game logging only."
33
37
  test_description: "logging and features tailored for tests."
@@ -50,15 +54,15 @@ en:
50
54
  header: "%{cmd} says there was a problem."
51
55
  invalid_usage: "%{cmd} says you're not supposed to be here."
52
56
  missing_args: "%{cmd} says missing required argument(s)."
53
- missing_deck: "%{cmd} says no deck selected. use 'aro deck' to select one or 'aro deck new <name>' to create one."
57
+ missing_teck: "%{cmd} says no teck selected. use 'aro teck' to select one or 'aro teck new <name>' to create one."
54
58
  not_in_aro: "%{cmd} says you are not in aro space. that command will not work here."
55
59
  not_in_aos: "%{cmd} says you are not in aos space. that command will not work here."
56
60
  not_initialized: "%{cmd} says you need to initialize aro. run 'aro init' to do so"
57
61
  warnings:
58
- invalid_order: "the order specified for displaying logs in invalid. using default (desc)."
62
+ invalid_order: "the order specified for displaying tlogs in invalid. using default (desc)."
59
63
  messages:
60
64
  choose_card: "choose a card."
61
- choose_deck: "choose a deck."
65
+ choose_teck: "choose a teck."
62
66
  confirmation_prompt: "input 'aroyes' to reset %{name}, or enter to cancel (cancel): "
63
67
  creating: "creating %{name}..."
64
68
  creation_attempt: "attempting to create aro table named %{name}..."
@@ -71,7 +75,8 @@ en:
71
75
  $ cd %{name}
72
76
 
73
77
  see aro --help for usage.
74
- deck_created_sucessfully: "%{name} deck created successfully"
78
+ teck_created_sucessfully: "%{name} teck created successfully"
79
+ teck_selected: "%{name} teck selected in the %{room} room."
75
80
  drawing: "drawing a card from %{name}"
76
81
  drawing_from_dimension: "in the the %{dimension} dimension..."
77
82
  ruby_facot_random: |
@@ -79,12 +84,12 @@ en:
79
84
  for more information visit:
80
85
  https://github.com/arowmancy/dev_tarot
81
86
  history_drawn: "drawn cards"
82
- no_decks: |
83
- no decks created yet.
87
+ no_tecks: |
88
+ no tecks created yet.
84
89
 
85
90
  use the following command to create one:
86
91
 
87
- $ aro deck new <deck_name>
92
+ $ aro teck new <teck_name>
88
93
 
89
94
  see aro --help for usage.
90
95
  showing: "showing %{name} [count:%{count}, order:%{order}]..."
data/sys/aos/amg.rb ADDED
@@ -0,0 +1,184 @@
1
+ =begin
2
+
3
+ amg.rb
4
+
5
+ aos system management.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ module Aos
12
+ class Amg
13
+ include Singleton
14
+
15
+ attr_accessor :display_lines
16
+
17
+ CMDS = {
18
+ INST: {
19
+ key: :inst,
20
+ description: I18n.t("amg.commands.description.inst"),
21
+ usage: I18n.t("amg.commands.usage.inst"),
22
+ },
23
+ INSTUN: {
24
+ key: :instun,
25
+ description: I18n.t("amg.commands.description.instun"),
26
+ usage: I18n.t("amg.commands.usage.instun"),
27
+ },
28
+ }
29
+
30
+ def initialize
31
+ self.display_lines = Aos::Amg.base_lines
32
+ end
33
+
34
+ def self.process_cmd(args)
35
+ self.instance.display_lines = []
36
+ if args[Aro::Mancy::S].nil? ||
37
+ CLI::FLAGS[:HELP].include?(args[Aro::Mancy::S].to_sym)
38
+ Aos::Amg.amg
39
+ return true
40
+ end
41
+
42
+ case args[Aro::Mancy::S].to_sym
43
+ when Aos::Amg::CMDS[:INST][:key]
44
+ unless args[Aro::Mancy::OS].nil?
45
+ ilib_name = args[Aro::Mancy::OS]
46
+ ilib = Aos::Ilib.find_by(name: ilib_name)
47
+ unless ilib.nil?
48
+ if ilib.installed?
49
+ self.instance.display_lines << I18n.t("amg.messages.already_installed", name: ilib_name)
50
+ else
51
+ Aos::Amg.install(ilib)
52
+ if ilib.reload.installed?
53
+ self.instance.display_lines << I18n.t("amg.messages.install_success", name: ilib_name)
54
+ self.instance.display_lines += self.inst_lines
55
+ return true
56
+ else
57
+ self.instance.display_lines << I18n.t("amg.messages.install_failure", name: ilib_name)
58
+ end
59
+ end
60
+ else
61
+ self.instance.display_lines << I18n.t("amg.messages.cannot_locate", name: ilib_name)
62
+ end
63
+ else
64
+ # list installed ilibs
65
+ Aos::Amg.inst
66
+ return true
67
+ end
68
+ when Aos::Amg::CMDS[:INSTUN][:key]
69
+ unless args[Aro::Mancy::OS].nil?
70
+ ilib_name = args[Aro::Mancy::OS]
71
+ ilib = Aos::Ilib.find_by(name: ilib_name)
72
+ unless ilib.nil?
73
+ if ilib.available?
74
+ self.instance.display_lines << I18n.t("amg.messages.not_installed", name: ilib_name)
75
+ else
76
+ Aos::Amg.uninstall(ilib)
77
+ if ilib.reload.available?
78
+ self.instance.display_lines << I18n.t("amg.messages.uninstall_success", name: ilib_name)
79
+ self.instance.display_lines += self.instun_lines
80
+ return true
81
+ else
82
+ self.instance.display_lines << I18n.t("amg.messages.uninstall_failure", name: ilib_name)
83
+ end
84
+ end
85
+ else
86
+ self.instance.display_lines << I18n.t("amg.messages.cannot_locate", name: ilib_name)
87
+ end
88
+ else
89
+ # list available ilibs
90
+ Aos::Amg.instun
91
+ return true
92
+ end
93
+ end
94
+
95
+ return false
96
+ end
97
+
98
+ def self.load(ilib_name)
99
+ Aos::Ilib.find_or_create_by(name: ilib_name)
100
+ end
101
+
102
+ def self.install(ilib)
103
+ return unless ilib.kind_of?(Aos::Ilib)
104
+ ilib.installed!
105
+ end
106
+
107
+ def self.uninstall(ilib)
108
+ return unless ilib.kind_of?(Aos::Ilib)
109
+ ilib.available!
110
+ end
111
+
112
+ def self.inst
113
+ self.instance.display_lines = Aos::Amg.inst_lines
114
+ end
115
+
116
+ def self.instun
117
+ self.instance.display_lines = Aos::Amg.instun_lines
118
+ end
119
+
120
+ def self.amg
121
+ self.instance.display_lines = Aos::Amg.base_lines
122
+ end
123
+
124
+ def self.base_lines
125
+ # print amg commands
126
+ lines = []
127
+ lines << ""
128
+ lines << I18n.t("aos.constants.commands")
129
+ lines += Aos::Vw::Base.lines_for_cmd(Aos::Os::CMDS[:AMG])
130
+ lines << I18n.t("aos.constants.subcommands")
131
+ Aos::Amg::CMDS.keys.each{|k|
132
+ lines += Aos::Vw::Base.lines_for_cmd(Aos::Amg::CMDS[k])
133
+ }
134
+ lines << ""
135
+
136
+ lines
137
+ end
138
+
139
+ def self.inst_lines
140
+ # list installed ilibs
141
+ lines = []
142
+ lines << ""
143
+ installed_ilibs = Aos::Ilib.where(status: :installed)
144
+ unless installed_ilibs.any?
145
+ lines << I18n.t("amg.messages.none_installed")
146
+ else
147
+ lines << I18n.t("amg.messages.listing_installed")
148
+ lines += Aos::Amg.ilib_lines(installed_ilibs)
149
+ end
150
+ lines << ""
151
+
152
+ lines
153
+ end
154
+
155
+ def self.instun_lines
156
+ # list installed ilibs
157
+ lines = []
158
+ lines << ""
159
+ available_ilibs = Aos::Ilib.where(status: :available)
160
+ unless available_ilibs.any?
161
+ lines << I18n.t("amg.messages.none_available")
162
+ else
163
+ lines << I18n.t("amg.messages.listing_available")
164
+ lines += Aos::Amg.ilib_lines(available_ilibs)
165
+ end
166
+ lines << ""
167
+
168
+ lines
169
+ end
170
+
171
+ def self.ilib_lines(ilibs)
172
+ lines = []
173
+ ilibs.each_with_index{|ilib, i|
174
+ lines << "[#{i + Aro::Mancy::S} of #{ilibs.count}]"
175
+ lines << I18n.t("amg.messages.ilib_name", name: ilib.name)
176
+ lines << I18n.t("amg.messages.ilib_path", path: ilib.so_path.split("/").last(Aro::Mancy::N).join("/"))
177
+ lines << I18n.t("amg.messages.ilib_usage", usage: ilib.usage)
178
+ }
179
+
180
+ lines
181
+ end
182
+
183
+ end
184
+ end