nucleon 0.2.2 → 0.2.3
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.
- checksums.yaml +7 -7
- data/.gitignore +50 -0
- data/ARCHITECTURE.rdoc +12 -11
- data/Gemfile +7 -11
- data/Gemfile.lock +47 -70
- data/Rakefile +22 -20
- data/TODO.rdoc +1 -1
- data/VERSION +1 -1
- data/bin/nucleon +16 -15
- data/lib/core/codes.rb +65 -38
- data/lib/core/config.rb +774 -153
- data/lib/core/config/collection.rb +134 -25
- data/lib/core/config/options.rb +160 -36
- data/lib/core/core.rb +207 -45
- data/lib/core/environment.rb +626 -206
- data/lib/core/facade.rb +211 -185
- data/lib/core/gems.rb +60 -44
- data/lib/core/manager.rb +587 -237
- data/lib/core/mixin/colors.rb +66 -36
- data/lib/core/mixin/config/collection.rb +58 -23
- data/lib/core/mixin/config/options.rb +67 -24
- data/lib/core/mixin/macro/object_interface.rb +129 -135
- data/lib/core/mixin/macro/plugin_interface.rb +118 -124
- data/lib/core/mixin/settings.rb +7 -13
- data/lib/core/mixin/sub_config.rb +37 -43
- data/lib/core/mod/hash.rb +31 -10
- data/lib/core/plugin/action.rb +274 -238
- data/lib/core/plugin/base.rb +140 -132
- data/lib/core/plugin/project.rb +316 -311
- data/lib/core/util/cli.rb +146 -146
- data/lib/core/util/console.rb +567 -124
- data/lib/core/util/data.rb +654 -139
- data/lib/core/util/logger.rb +255 -66
- data/lib/nucleon.rb +6 -8
- data/lib/nucleon_base.rb +364 -106
- data/nucleon.gemspec +40 -389
- data/spec/core/codes_spec.rb +209 -0
- data/spec/core/config_spec.rb +810 -0
- data/spec/core/core_spec.rb +185 -0
- data/spec/core/environment_spec.rb +148 -0
- data/spec/core/util/console_spec.rb +254 -446
- data/spec/nucleon/test.rb +59 -0
- data/spec/nucleon/test/first.rb +28 -0
- data/spec/nucleon/test/second.rb +28 -0
- data/spec/nucleon_codes.rb +98 -0
- data/spec/nucleon_config.rb +523 -0
- data/spec/nucleon_plugin.rb +439 -0
- data/spec/nucleon_test.rb +34 -0
- data/spec/spec_helper.rb +6 -4
- metadata +157 -615
- data/.document +0 -5
- data/rdoc/site/0.1.19/ARCHITECTURE_rdoc.html +0 -634
- data/rdoc/site/0.1.19/Hash.html +0 -347
- data/rdoc/site/0.1.19/Kernel.html +0 -413
- data/rdoc/site/0.1.19/Nucleon.html +0 -570
- data/rdoc/site/0.1.19/Nucleon/Action.html +0 -280
- data/rdoc/site/0.1.19/Nucleon/Action/Add.html +0 -458
- data/rdoc/site/0.1.19/Nucleon/Action/Create.html +0 -415
- data/rdoc/site/0.1.19/Nucleon/Action/Extract.html +0 -413
- data/rdoc/site/0.1.19/Nucleon/Action/Remove.html +0 -461
- data/rdoc/site/0.1.19/Nucleon/Action/Save.html +0 -434
- data/rdoc/site/0.1.19/Nucleon/Action/Update.html +0 -381
- data/rdoc/site/0.1.19/Nucleon/Codes.html +0 -563
- data/rdoc/site/0.1.19/Nucleon/Command.html +0 -275
- data/rdoc/site/0.1.19/Nucleon/Command/Bash.html +0 -544
- data/rdoc/site/0.1.19/Nucleon/Config.html +0 -1623
- data/rdoc/site/0.1.19/Nucleon/Config/Collection.html +0 -509
- data/rdoc/site/0.1.19/Nucleon/Config/Options.html +0 -489
- data/rdoc/site/0.1.19/Nucleon/Core.html +0 -635
- data/rdoc/site/0.1.19/Nucleon/Errors.html +0 -275
- data/rdoc/site/0.1.19/Nucleon/Errors/BatchError.html +0 -281
- data/rdoc/site/0.1.19/Nucleon/Errors/NucleonError.html +0 -657
- data/rdoc/site/0.1.19/Nucleon/Errors/SSHUnavailable.html +0 -281
- data/rdoc/site/0.1.19/Nucleon/Event.html +0 -275
- data/rdoc/site/0.1.19/Nucleon/Event/Regex.html +0 -467
- data/rdoc/site/0.1.19/Nucleon/Facade.html +0 -2336
- data/rdoc/site/0.1.19/Nucleon/Gems.html +0 -635
- data/rdoc/site/0.1.19/Nucleon/Manager.html +0 -1828
- data/rdoc/site/0.1.19/Nucleon/Mixin.html +0 -284
- data/rdoc/site/0.1.19/Nucleon/Mixin/Action.html +0 -277
- data/rdoc/site/0.1.19/Nucleon/Mixin/Action/Commit.html +0 -381
- data/rdoc/site/0.1.19/Nucleon/Mixin/Action/Project.html +0 -395
- data/rdoc/site/0.1.19/Nucleon/Mixin/Action/Push.html +0 -371
- data/rdoc/site/0.1.19/Nucleon/Mixin/Colors.html +0 -545
- data/rdoc/site/0.1.19/Nucleon/Mixin/ConfigCollection.html +0 -481
- data/rdoc/site/0.1.19/Nucleon/Mixin/ConfigOptions.html +0 -449
- data/rdoc/site/0.1.19/Nucleon/Mixin/Macro.html +0 -276
- data/rdoc/site/0.1.19/Nucleon/Mixin/Macro/ObjectInterface.html +0 -695
- data/rdoc/site/0.1.19/Nucleon/Mixin/Macro/PluginInterface.html +0 -682
- data/rdoc/site/0.1.19/Nucleon/Mixin/Settings.html +0 -481
- data/rdoc/site/0.1.19/Nucleon/Mixin/SubConfig.html +0 -887
- data/rdoc/site/0.1.19/Nucleon/Parallel.html +0 -325
- data/rdoc/site/0.1.19/Nucleon/Parallel/ClassMethods.html +0 -325
- data/rdoc/site/0.1.19/Nucleon/Parallel/InstanceMethods.html +0 -334
- data/rdoc/site/0.1.19/Nucleon/Plugin.html +0 -282
- data/rdoc/site/0.1.19/Nucleon/Plugin/Action.html +0 -1368
- data/rdoc/site/0.1.19/Nucleon/Plugin/Action/Option.html +0 -459
- data/rdoc/site/0.1.19/Nucleon/Plugin/Base.html +0 -1737
- data/rdoc/site/0.1.19/Nucleon/Plugin/Command.html +0 -721
- data/rdoc/site/0.1.19/Nucleon/Plugin/Event.html +0 -442
- data/rdoc/site/0.1.19/Nucleon/Plugin/Extension.html +0 -281
- data/rdoc/site/0.1.19/Nucleon/Plugin/Project.html +0 -2864
- data/rdoc/site/0.1.19/Nucleon/Plugin/Template.html +0 -476
- data/rdoc/site/0.1.19/Nucleon/Plugin/Translator.html +0 -371
- data/rdoc/site/0.1.19/Nucleon/Project.html +0 -276
- data/rdoc/site/0.1.19/Nucleon/Project/Git.html +0 -1801
- data/rdoc/site/0.1.19/Nucleon/Project/Github.html +0 -549
- data/rdoc/site/0.1.19/Nucleon/Template.html +0 -277
- data/rdoc/site/0.1.19/Nucleon/Template/Json.html +0 -329
- data/rdoc/site/0.1.19/Nucleon/Template/Wrapper.html +0 -329
- data/rdoc/site/0.1.19/Nucleon/Template/Yaml.html +0 -329
- data/rdoc/site/0.1.19/Nucleon/Translator.html +0 -276
- data/rdoc/site/0.1.19/Nucleon/Translator/Json.html +0 -366
- data/rdoc/site/0.1.19/Nucleon/Translator/Yaml.html +0 -366
- data/rdoc/site/0.1.19/Nucleon/Util.html +0 -285
- data/rdoc/site/0.1.19/Nucleon/Util/CLI.html +0 -388
- data/rdoc/site/0.1.19/Nucleon/Util/CLI/Parser.html +0 -1183
- data/rdoc/site/0.1.19/Nucleon/Util/Cache.html +0 -780
- data/rdoc/site/0.1.19/Nucleon/Util/Console.html +0 -1294
- data/rdoc/site/0.1.19/Nucleon/Util/Data.html +0 -1399
- data/rdoc/site/0.1.19/Nucleon/Util/Disk.html +0 -522
- data/rdoc/site/0.1.19/Nucleon/Util/Git.html +0 -361
- data/rdoc/site/0.1.19/Nucleon/Util/Liquid.html +0 -365
- data/rdoc/site/0.1.19/Nucleon/Util/Logger.html +0 -806
- data/rdoc/site/0.1.19/Nucleon/Util/Package.html +0 -558
- data/rdoc/site/0.1.19/Nucleon/Util/SSH.html +0 -910
- data/rdoc/site/0.1.19/Nucleon/Util/SSH/Keypair.html +0 -453
- data/rdoc/site/0.1.19/Nucleon/Util/Shell.html +0 -686
- data/rdoc/site/0.1.19/Nucleon/Util/Shell/Result.html +0 -497
- data/rdoc/site/0.1.19/README_rdoc.html +0 -312
- data/rdoc/site/0.1.19/TODO_rdoc.html +0 -267
- data/rdoc/site/0.1.19/created.rid +0 -60
- data/rdoc/site/0.1.19/images/add.png +0 -0
- data/rdoc/site/0.1.19/images/brick.png +0 -0
- data/rdoc/site/0.1.19/images/brick_link.png +0 -0
- data/rdoc/site/0.1.19/images/bug.png +0 -0
- data/rdoc/site/0.1.19/images/bullet_black.png +0 -0
- data/rdoc/site/0.1.19/images/bullet_toggle_minus.png +0 -0
- data/rdoc/site/0.1.19/images/bullet_toggle_plus.png +0 -0
- data/rdoc/site/0.1.19/images/date.png +0 -0
- data/rdoc/site/0.1.19/images/delete.png +0 -0
- data/rdoc/site/0.1.19/images/find.png +0 -0
- data/rdoc/site/0.1.19/images/loadingAnimation.gif +0 -0
- data/rdoc/site/0.1.19/images/macFFBgHack.png +0 -0
- data/rdoc/site/0.1.19/images/package.png +0 -0
- data/rdoc/site/0.1.19/images/page_green.png +0 -0
- data/rdoc/site/0.1.19/images/page_white_text.png +0 -0
- data/rdoc/site/0.1.19/images/page_white_width.png +0 -0
- data/rdoc/site/0.1.19/images/plugin.png +0 -0
- data/rdoc/site/0.1.19/images/ruby.png +0 -0
- data/rdoc/site/0.1.19/images/tag_blue.png +0 -0
- data/rdoc/site/0.1.19/images/tag_green.png +0 -0
- data/rdoc/site/0.1.19/images/transparent.png +0 -0
- data/rdoc/site/0.1.19/images/wrench.png +0 -0
- data/rdoc/site/0.1.19/images/wrench_orange.png +0 -0
- data/rdoc/site/0.1.19/images/zoom.png +0 -0
- data/rdoc/site/0.1.19/index.html +0 -311
- data/rdoc/site/0.1.19/js/darkfish.js +0 -155
- data/rdoc/site/0.1.19/js/jquery.js +0 -18
- data/rdoc/site/0.1.19/js/navigation.js +0 -142
- data/rdoc/site/0.1.19/js/search.js +0 -94
- data/rdoc/site/0.1.19/js/search_index.js +0 -1
- data/rdoc/site/0.1.19/js/searcher.js +0 -228
- data/rdoc/site/0.1.19/rdoc.css +0 -543
- data/rdoc/site/0.1.19/table_of_contents.html +0 -1541
- data/rdoc/site/0.2.0/ARCHITECTURE_rdoc.html +0 -638
- data/rdoc/site/0.2.0/Hash.html +0 -351
- data/rdoc/site/0.2.0/Kernel.html +0 -416
- data/rdoc/site/0.2.0/Nucleon.html +0 -607
- data/rdoc/site/0.2.0/Nucleon/Action.html +0 -284
- data/rdoc/site/0.2.0/Nucleon/Action/Extract.html +0 -455
- data/rdoc/site/0.2.0/Nucleon/Action/Project.html +0 -283
- data/rdoc/site/0.2.0/Nucleon/Action/Project/Add.html +0 -500
- data/rdoc/site/0.2.0/Nucleon/Action/Project/Create.html +0 -457
- data/rdoc/site/0.2.0/Nucleon/Action/Project/Remove.html +0 -503
- data/rdoc/site/0.2.0/Nucleon/Action/Project/Save.html +0 -476
- data/rdoc/site/0.2.0/Nucleon/Action/Project/Update.html +0 -423
- data/rdoc/site/0.2.0/Nucleon/Codes.html +0 -567
- data/rdoc/site/0.2.0/Nucleon/Command.html +0 -279
- data/rdoc/site/0.2.0/Nucleon/Command/Bash.html +0 -548
- data/rdoc/site/0.2.0/Nucleon/Config.html +0 -1631
- data/rdoc/site/0.2.0/Nucleon/Config/Collection.html +0 -513
- data/rdoc/site/0.2.0/Nucleon/Config/Options.html +0 -493
- data/rdoc/site/0.2.0/Nucleon/Core.html +0 -639
- data/rdoc/site/0.2.0/Nucleon/Environment.html +0 -1208
- data/rdoc/site/0.2.0/Nucleon/Errors.html +0 -279
- data/rdoc/site/0.2.0/Nucleon/Errors/BatchError.html +0 -285
- data/rdoc/site/0.2.0/Nucleon/Errors/NucleonError.html +0 -661
- data/rdoc/site/0.2.0/Nucleon/Errors/SSHUnavailable.html +0 -285
- data/rdoc/site/0.2.0/Nucleon/Event.html +0 -279
- data/rdoc/site/0.2.0/Nucleon/Event/Regex.html +0 -471
- data/rdoc/site/0.2.0/Nucleon/Facade.html +0 -2409
- data/rdoc/site/0.2.0/Nucleon/Gems.html +0 -639
- data/rdoc/site/0.2.0/Nucleon/Manager.html +0 -1860
- data/rdoc/site/0.2.0/Nucleon/Mixin.html +0 -288
- data/rdoc/site/0.2.0/Nucleon/Mixin/Action.html +0 -281
- data/rdoc/site/0.2.0/Nucleon/Mixin/Action/Commit.html +0 -385
- data/rdoc/site/0.2.0/Nucleon/Mixin/Action/Project.html +0 -399
- data/rdoc/site/0.2.0/Nucleon/Mixin/Action/Push.html +0 -375
- data/rdoc/site/0.2.0/Nucleon/Mixin/Colors.html +0 -549
- data/rdoc/site/0.2.0/Nucleon/Mixin/ConfigCollection.html +0 -485
- data/rdoc/site/0.2.0/Nucleon/Mixin/ConfigOptions.html +0 -453
- data/rdoc/site/0.2.0/Nucleon/Mixin/Macro.html +0 -280
- data/rdoc/site/0.2.0/Nucleon/Mixin/Macro/ObjectInterface.html +0 -699
- data/rdoc/site/0.2.0/Nucleon/Mixin/Macro/PluginInterface.html +0 -686
- data/rdoc/site/0.2.0/Nucleon/Mixin/Settings.html +0 -485
- data/rdoc/site/0.2.0/Nucleon/Mixin/SubConfig.html +0 -891
- data/rdoc/site/0.2.0/Nucleon/Parallel.html +0 -330
- data/rdoc/site/0.2.0/Nucleon/Parallel/ClassMethods.html +0 -329
- data/rdoc/site/0.2.0/Nucleon/Parallel/InstanceMethods.html +0 -456
- data/rdoc/site/0.2.0/Nucleon/Plugin.html +0 -286
- data/rdoc/site/0.2.0/Nucleon/Plugin/Action.html +0 -1829
- data/rdoc/site/0.2.0/Nucleon/Plugin/Action/Option.html +0 -463
- data/rdoc/site/0.2.0/Nucleon/Plugin/Base.html +0 -1803
- data/rdoc/site/0.2.0/Nucleon/Plugin/Command.html +0 -725
- data/rdoc/site/0.2.0/Nucleon/Plugin/Event.html +0 -446
- data/rdoc/site/0.2.0/Nucleon/Plugin/Extension.html +0 -285
- data/rdoc/site/0.2.0/Nucleon/Plugin/Project.html +0 -2898
- data/rdoc/site/0.2.0/Nucleon/Plugin/Template.html +0 -480
- data/rdoc/site/0.2.0/Nucleon/Plugin/Translator.html +0 -375
- data/rdoc/site/0.2.0/Nucleon/Project.html +0 -280
- data/rdoc/site/0.2.0/Nucleon/Project/Git.html +0 -1805
- data/rdoc/site/0.2.0/Nucleon/Project/Github.html +0 -553
- data/rdoc/site/0.2.0/Nucleon/Template.html +0 -281
- data/rdoc/site/0.2.0/Nucleon/Template/JSON.html +0 -333
- data/rdoc/site/0.2.0/Nucleon/Template/Wrapper.html +0 -333
- data/rdoc/site/0.2.0/Nucleon/Template/YAML.html +0 -333
- data/rdoc/site/0.2.0/Nucleon/Translator.html +0 -280
- data/rdoc/site/0.2.0/Nucleon/Translator/JSON.html +0 -370
- data/rdoc/site/0.2.0/Nucleon/Translator/YAML.html +0 -370
- data/rdoc/site/0.2.0/Nucleon/Util.html +0 -289
- data/rdoc/site/0.2.0/Nucleon/Util/CLI.html +0 -392
- data/rdoc/site/0.2.0/Nucleon/Util/CLI/Parser.html +0 -1250
- data/rdoc/site/0.2.0/Nucleon/Util/Cache.html +0 -784
- data/rdoc/site/0.2.0/Nucleon/Util/Console.html +0 -1318
- data/rdoc/site/0.2.0/Nucleon/Util/Data.html +0 -1411
- data/rdoc/site/0.2.0/Nucleon/Util/Disk.html +0 -526
- data/rdoc/site/0.2.0/Nucleon/Util/Git.html +0 -365
- data/rdoc/site/0.2.0/Nucleon/Util/Liquid.html +0 -369
- data/rdoc/site/0.2.0/Nucleon/Util/Logger.html +0 -810
- data/rdoc/site/0.2.0/Nucleon/Util/Package.html +0 -562
- data/rdoc/site/0.2.0/Nucleon/Util/SSH.html +0 -1033
- data/rdoc/site/0.2.0/Nucleon/Util/SSH/Keypair.html +0 -605
- data/rdoc/site/0.2.0/Nucleon/Util/Shell.html +0 -693
- data/rdoc/site/0.2.0/Nucleon/Util/Shell/Result.html +0 -501
- data/rdoc/site/0.2.0/README_rdoc.html +0 -316
- data/rdoc/site/0.2.0/TODO_rdoc.html +0 -265
- data/rdoc/site/0.2.0/created.rid +0 -61
- data/rdoc/site/0.2.0/images/add.png +0 -0
- data/rdoc/site/0.2.0/images/brick.png +0 -0
- data/rdoc/site/0.2.0/images/brick_link.png +0 -0
- data/rdoc/site/0.2.0/images/bug.png +0 -0
- data/rdoc/site/0.2.0/images/bullet_black.png +0 -0
- data/rdoc/site/0.2.0/images/bullet_toggle_minus.png +0 -0
- data/rdoc/site/0.2.0/images/bullet_toggle_plus.png +0 -0
- data/rdoc/site/0.2.0/images/date.png +0 -0
- data/rdoc/site/0.2.0/images/delete.png +0 -0
- data/rdoc/site/0.2.0/images/find.png +0 -0
- data/rdoc/site/0.2.0/images/loadingAnimation.gif +0 -0
- data/rdoc/site/0.2.0/images/macFFBgHack.png +0 -0
- data/rdoc/site/0.2.0/images/package.png +0 -0
- data/rdoc/site/0.2.0/images/page_green.png +0 -0
- data/rdoc/site/0.2.0/images/page_white_text.png +0 -0
- data/rdoc/site/0.2.0/images/page_white_width.png +0 -0
- data/rdoc/site/0.2.0/images/plugin.png +0 -0
- data/rdoc/site/0.2.0/images/ruby.png +0 -0
- data/rdoc/site/0.2.0/images/tag_blue.png +0 -0
- data/rdoc/site/0.2.0/images/tag_green.png +0 -0
- data/rdoc/site/0.2.0/images/transparent.png +0 -0
- data/rdoc/site/0.2.0/images/wrench.png +0 -0
- data/rdoc/site/0.2.0/images/wrench_orange.png +0 -0
- data/rdoc/site/0.2.0/images/zoom.png +0 -0
- data/rdoc/site/0.2.0/index.html +0 -315
- data/rdoc/site/0.2.0/js/darkfish.js +0 -155
- data/rdoc/site/0.2.0/js/jquery.js +0 -18
- data/rdoc/site/0.2.0/js/navigation.js +0 -142
- data/rdoc/site/0.2.0/js/search.js +0 -94
- data/rdoc/site/0.2.0/js/search_index.js +0 -1
- data/rdoc/site/0.2.0/js/searcher.js +0 -228
- data/rdoc/site/0.2.0/rdoc.css +0 -543
- data/rdoc/site/0.2.0/table_of_contents.html +0 -1657
- data/rdoc/site/0.2.1/ARCHITECTURE_rdoc.html +0 -640
- data/rdoc/site/0.2.1/Hash.html +0 -353
- data/rdoc/site/0.2.1/Kernel.html +0 -420
- data/rdoc/site/0.2.1/Nucleon.html +0 -674
- data/rdoc/site/0.2.1/Nucleon/Action.html +0 -286
- data/rdoc/site/0.2.1/Nucleon/Action/Extract.html +0 -457
- data/rdoc/site/0.2.1/Nucleon/Action/Project.html +0 -285
- data/rdoc/site/0.2.1/Nucleon/Action/Project/Add.html +0 -502
- data/rdoc/site/0.2.1/Nucleon/Action/Project/Create.html +0 -459
- data/rdoc/site/0.2.1/Nucleon/Action/Project/Remove.html +0 -505
- data/rdoc/site/0.2.1/Nucleon/Action/Project/Save.html +0 -478
- data/rdoc/site/0.2.1/Nucleon/Action/Project/Update.html +0 -425
- data/rdoc/site/0.2.1/Nucleon/Codes.html +0 -569
- data/rdoc/site/0.2.1/Nucleon/Command.html +0 -281
- data/rdoc/site/0.2.1/Nucleon/Command/Bash.html +0 -550
- data/rdoc/site/0.2.1/Nucleon/Config.html +0 -1634
- data/rdoc/site/0.2.1/Nucleon/Config/Collection.html +0 -515
- data/rdoc/site/0.2.1/Nucleon/Config/Options.html +0 -495
- data/rdoc/site/0.2.1/Nucleon/Core.html +0 -641
- data/rdoc/site/0.2.1/Nucleon/Environment.html +0 -1210
- data/rdoc/site/0.2.1/Nucleon/Errors.html +0 -281
- data/rdoc/site/0.2.1/Nucleon/Errors/BatchError.html +0 -287
- data/rdoc/site/0.2.1/Nucleon/Errors/NucleonError.html +0 -663
- data/rdoc/site/0.2.1/Nucleon/Errors/SSHUnavailable.html +0 -287
- data/rdoc/site/0.2.1/Nucleon/Event.html +0 -281
- data/rdoc/site/0.2.1/Nucleon/Event/Regex.html +0 -473
- data/rdoc/site/0.2.1/Nucleon/Facade.html +0 -2452
- data/rdoc/site/0.2.1/Nucleon/Gems.html +0 -641
- data/rdoc/site/0.2.1/Nucleon/Manager.html +0 -1862
- data/rdoc/site/0.2.1/Nucleon/Mixin.html +0 -291
- data/rdoc/site/0.2.1/Nucleon/Mixin/Action.html +0 -284
- data/rdoc/site/0.2.1/Nucleon/Mixin/Action/Commit.html +0 -387
- data/rdoc/site/0.2.1/Nucleon/Mixin/Action/Project.html +0 -401
- data/rdoc/site/0.2.1/Nucleon/Mixin/Action/Push.html +0 -377
- data/rdoc/site/0.2.1/Nucleon/Mixin/Action/Registration.html +0 -575
- data/rdoc/site/0.2.1/Nucleon/Mixin/Colors.html +0 -551
- data/rdoc/site/0.2.1/Nucleon/Mixin/ConfigCollection.html +0 -487
- data/rdoc/site/0.2.1/Nucleon/Mixin/ConfigOptions.html +0 -455
- data/rdoc/site/0.2.1/Nucleon/Mixin/Macro.html +0 -282
- data/rdoc/site/0.2.1/Nucleon/Mixin/Macro/ObjectInterface.html +0 -701
- data/rdoc/site/0.2.1/Nucleon/Mixin/Macro/PluginInterface.html +0 -688
- data/rdoc/site/0.2.1/Nucleon/Mixin/Settings.html +0 -487
- data/rdoc/site/0.2.1/Nucleon/Mixin/SubConfig.html +0 -893
- data/rdoc/site/0.2.1/Nucleon/Parallel.html +0 -332
- data/rdoc/site/0.2.1/Nucleon/Parallel/ClassMethods.html +0 -331
- data/rdoc/site/0.2.1/Nucleon/Parallel/InstanceMethods.html +0 -458
- data/rdoc/site/0.2.1/Nucleon/Plugin.html +0 -288
- data/rdoc/site/0.2.1/Nucleon/Plugin/Action.html +0 -2133
- data/rdoc/site/0.2.1/Nucleon/Plugin/Action/Option.html +0 -465
- data/rdoc/site/0.2.1/Nucleon/Plugin/Base.html +0 -1988
- data/rdoc/site/0.2.1/Nucleon/Plugin/Command.html +0 -765
- data/rdoc/site/0.2.1/Nucleon/Plugin/Event.html +0 -448
- data/rdoc/site/0.2.1/Nucleon/Plugin/Extension.html +0 -287
- data/rdoc/site/0.2.1/Nucleon/Plugin/Project.html +0 -2900
- data/rdoc/site/0.2.1/Nucleon/Plugin/Template.html +0 -482
- data/rdoc/site/0.2.1/Nucleon/Plugin/Translator.html +0 -377
- data/rdoc/site/0.2.1/Nucleon/Project.html +0 -282
- data/rdoc/site/0.2.1/Nucleon/Project/Git.html +0 -1807
- data/rdoc/site/0.2.1/Nucleon/Project/Github.html +0 -555
- data/rdoc/site/0.2.1/Nucleon/Template.html +0 -283
- data/rdoc/site/0.2.1/Nucleon/Template/JSON.html +0 -335
- data/rdoc/site/0.2.1/Nucleon/Template/Wrapper.html +0 -335
- data/rdoc/site/0.2.1/Nucleon/Template/YAML.html +0 -335
- data/rdoc/site/0.2.1/Nucleon/Translator.html +0 -282
- data/rdoc/site/0.2.1/Nucleon/Translator/JSON.html +0 -372
- data/rdoc/site/0.2.1/Nucleon/Translator/YAML.html +0 -372
- data/rdoc/site/0.2.1/Nucleon/Util.html +0 -291
- data/rdoc/site/0.2.1/Nucleon/Util/CLI.html +0 -394
- data/rdoc/site/0.2.1/Nucleon/Util/CLI/Parser.html +0 -1404
- data/rdoc/site/0.2.1/Nucleon/Util/Cache.html +0 -824
- data/rdoc/site/0.2.1/Nucleon/Util/Console.html +0 -1330
- data/rdoc/site/0.2.1/Nucleon/Util/Data.html +0 -1423
- data/rdoc/site/0.2.1/Nucleon/Util/Disk.html +0 -528
- data/rdoc/site/0.2.1/Nucleon/Util/Git.html +0 -367
- data/rdoc/site/0.2.1/Nucleon/Util/Liquid.html +0 -371
- data/rdoc/site/0.2.1/Nucleon/Util/Logger.html +0 -822
- data/rdoc/site/0.2.1/Nucleon/Util/Package.html +0 -564
- data/rdoc/site/0.2.1/Nucleon/Util/SSH.html +0 -1036
- data/rdoc/site/0.2.1/Nucleon/Util/SSH/Keypair.html +0 -607
- data/rdoc/site/0.2.1/Nucleon/Util/Shell.html +0 -697
- data/rdoc/site/0.2.1/Nucleon/Util/Shell/Result.html +0 -503
- data/rdoc/site/0.2.1/README_rdoc.html +0 -318
- data/rdoc/site/0.2.1/TODO_rdoc.html +0 -267
- data/rdoc/site/0.2.1/created.rid +0 -62
- data/rdoc/site/0.2.1/images/add.png +0 -0
- data/rdoc/site/0.2.1/images/brick.png +0 -0
- data/rdoc/site/0.2.1/images/brick_link.png +0 -0
- data/rdoc/site/0.2.1/images/bug.png +0 -0
- data/rdoc/site/0.2.1/images/bullet_black.png +0 -0
- data/rdoc/site/0.2.1/images/bullet_toggle_minus.png +0 -0
- data/rdoc/site/0.2.1/images/bullet_toggle_plus.png +0 -0
- data/rdoc/site/0.2.1/images/date.png +0 -0
- data/rdoc/site/0.2.1/images/delete.png +0 -0
- data/rdoc/site/0.2.1/images/find.png +0 -0
- data/rdoc/site/0.2.1/images/loadingAnimation.gif +0 -0
- data/rdoc/site/0.2.1/images/macFFBgHack.png +0 -0
- data/rdoc/site/0.2.1/images/package.png +0 -0
- data/rdoc/site/0.2.1/images/page_green.png +0 -0
- data/rdoc/site/0.2.1/images/page_white_text.png +0 -0
- data/rdoc/site/0.2.1/images/page_white_width.png +0 -0
- data/rdoc/site/0.2.1/images/plugin.png +0 -0
- data/rdoc/site/0.2.1/images/ruby.png +0 -0
- data/rdoc/site/0.2.1/images/tag_blue.png +0 -0
- data/rdoc/site/0.2.1/images/tag_green.png +0 -0
- data/rdoc/site/0.2.1/images/transparent.png +0 -0
- data/rdoc/site/0.2.1/images/wrench.png +0 -0
- data/rdoc/site/0.2.1/images/wrench_orange.png +0 -0
- data/rdoc/site/0.2.1/images/zoom.png +0 -0
- data/rdoc/site/0.2.1/index.html +0 -317
- data/rdoc/site/0.2.1/js/darkfish.js +0 -155
- data/rdoc/site/0.2.1/js/jquery.js +0 -18
- data/rdoc/site/0.2.1/js/navigation.js +0 -142
- data/rdoc/site/0.2.1/js/search.js +0 -94
- data/rdoc/site/0.2.1/js/search_index.js +0 -1
- data/rdoc/site/0.2.1/js/searcher.js +0 -228
- data/rdoc/site/0.2.1/rdoc.css +0 -543
- data/rdoc/site/0.2.1/table_of_contents.html +0 -1718
- data/spec/coral_mock_input.rb +0 -29
- data/spec/coral_test_kernel.rb +0 -22
data/lib/core/environment.rb
CHANGED
|
@@ -1,340 +1,760 @@
|
|
|
1
|
-
|
|
2
1
|
module Nucleon
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
#
|
|
3
|
+
# == Plugin environment
|
|
4
|
+
#
|
|
5
|
+
# The Nucleon::Environment class defines a container for registered plugins and
|
|
6
|
+
# autoloaded providers.
|
|
7
|
+
#
|
|
8
|
+
# One of the primary functions of the Nucleon library is to provide a very
|
|
9
|
+
# flexible extensible architectural base for Ruby applications needing ready
|
|
10
|
+
# made modularity. To fulfill our objectives, the Nucleon library defines
|
|
11
|
+
# plugin managers managed as a global multition.
|
|
12
|
+
#
|
|
13
|
+
# These managers should be able to fail gracefully and recover to the state
|
|
14
|
+
# they left off if a plugin provider crashes. To acomplish this, each manager
|
|
15
|
+
# is a Celluloid actor that manages a globally defined environment (also within
|
|
16
|
+
# a multition). This environment contains all of the plugins and providers
|
|
17
|
+
# that they manager has registered and loaded.
|
|
18
|
+
#
|
|
19
|
+
# Three collections are managed:
|
|
20
|
+
#
|
|
21
|
+
# 1. Defined plugin types
|
|
22
|
+
#
|
|
23
|
+
# The environment maintains a collection of registered plugin types with a
|
|
24
|
+
# default provider. Default providers can easily be changed in runtime as
|
|
25
|
+
# needs change.
|
|
26
|
+
#
|
|
27
|
+
# 2. Plugin load info
|
|
28
|
+
#
|
|
29
|
+
# Whenever a plugin is defined and initialized by the manager a specification
|
|
30
|
+
# is created and maintained that lets the manager know details about the
|
|
31
|
+
# plugin, such as where the base plugin resides, namespace, type, etc...
|
|
32
|
+
#
|
|
33
|
+
# 3. Active plugins
|
|
34
|
+
#
|
|
35
|
+
# The environment maintains a registry of all of the plugin instances across
|
|
36
|
+
# the application. These active plugins are accessed by the manager, usually
|
|
37
|
+
# through the facade. When we work with plugins in the application, we are
|
|
38
|
+
# usually working with these instances.
|
|
39
|
+
#
|
|
40
|
+
#
|
|
41
|
+
# See also:
|
|
42
|
+
# - Nucleon::Manager
|
|
43
|
+
# - Nucleon::Plugin::Base
|
|
44
|
+
#
|
|
45
|
+
class Environment < Core
|
|
46
|
+
|
|
47
|
+
#*****************************************************************************
|
|
6
48
|
# Constructor / Destructor
|
|
7
|
-
|
|
49
|
+
|
|
50
|
+
# Initialize a new Nucleon environment
|
|
51
|
+
#
|
|
52
|
+
# IMORTANT: The environment constructor should accept no parameters!
|
|
53
|
+
#
|
|
54
|
+
# * *Parameters*
|
|
55
|
+
#
|
|
56
|
+
# * *Returns*
|
|
57
|
+
# - [Void] This method does not return a value
|
|
58
|
+
#
|
|
59
|
+
# * *Errors*
|
|
60
|
+
#
|
|
61
|
+
# See also:
|
|
62
|
+
# - Nucleon::Manager
|
|
63
|
+
#
|
|
8
64
|
def initialize
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
65
|
+
super({
|
|
66
|
+
:plugin_types => {},
|
|
67
|
+
:load_info => {},
|
|
68
|
+
:active_info => {}
|
|
69
|
+
}, {}, true, true, false)
|
|
70
|
+
|
|
71
|
+
@instance_map = Config.new
|
|
13
72
|
end
|
|
14
|
-
|
|
15
|
-
|
|
73
|
+
|
|
74
|
+
#*****************************************************************************
|
|
16
75
|
# Plugin type accessor / modifiers
|
|
17
|
-
|
|
76
|
+
|
|
77
|
+
# Return all of the defined namespaces in the plugin environment.
|
|
78
|
+
#
|
|
79
|
+
# * *Parameters*
|
|
80
|
+
#
|
|
81
|
+
# * *Returns*
|
|
82
|
+
# - [Array<Symbol>] Array of defined plugin namespaces
|
|
83
|
+
#
|
|
84
|
+
# * *Errors*
|
|
85
|
+
#
|
|
86
|
+
# See:
|
|
87
|
+
# - Nucleon::Config#get_hash
|
|
88
|
+
#
|
|
18
89
|
def namespaces
|
|
19
|
-
|
|
90
|
+
get_hash(:plugin_types).keys
|
|
20
91
|
end
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
92
|
+
|
|
93
|
+
# Return all of the defined plugin types in a plugin namespace.
|
|
94
|
+
#
|
|
95
|
+
# * *Parameters*
|
|
96
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
97
|
+
#
|
|
98
|
+
# * *Returns*
|
|
99
|
+
# - [Array<Symbol>] Array of defined plugin types
|
|
100
|
+
#
|
|
101
|
+
# * *Errors*
|
|
102
|
+
#
|
|
103
|
+
# See:
|
|
104
|
+
# - Nucleon::Config#get_hash
|
|
105
|
+
#
|
|
24
106
|
def plugin_types(namespace)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return [] unless @plugin_types.has_key?(namespace)
|
|
28
|
-
@plugin_types[namespace].keys
|
|
107
|
+
get_hash([ :plugin_types, namespace ]).keys
|
|
29
108
|
end
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
109
|
+
|
|
110
|
+
# Define a new plugin type in a specified namespace.
|
|
111
|
+
#
|
|
112
|
+
# * *Parameters*
|
|
113
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
114
|
+
# - [String, Symbol] *plugin_type* Plugin type name within namespace
|
|
115
|
+
# - [nil, String, Symbol] *default_provider* Default provider (defaults to none)
|
|
116
|
+
#
|
|
117
|
+
# * *Returns*
|
|
118
|
+
# - [Nucleon::Environment] Returns reference to self for compound operations
|
|
119
|
+
#
|
|
120
|
+
# * *Errors*
|
|
121
|
+
#
|
|
122
|
+
# See:
|
|
123
|
+
# - Nucleon::Config#set
|
|
124
|
+
#
|
|
125
|
+
# See also:
|
|
126
|
+
# - #sanitize_id
|
|
127
|
+
#
|
|
33
128
|
def define_plugin_type(namespace, plugin_type, default_provider = nil)
|
|
34
|
-
namespace
|
|
35
|
-
|
|
36
|
-
@plugin_types[namespace] = {} unless @plugin_types.has_key?(namespace)
|
|
37
|
-
@plugin_types[namespace][sanitize_id(plugin_type)] = default_provider
|
|
129
|
+
set([ :plugin_types, namespace, sanitize_id(plugin_type) ], default_provider)
|
|
38
130
|
end
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
131
|
+
|
|
132
|
+
# Define one or more new plugin types in a specified namespace.
|
|
133
|
+
#
|
|
134
|
+
# * *Parameters*
|
|
135
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
136
|
+
# - [Hash<String, Symbol|String, Symbol>] *type_info* Plugin type, default provider pairs
|
|
137
|
+
#
|
|
138
|
+
# * *Returns*
|
|
139
|
+
# - [Nucleon::Environment] Returns reference to self for compound operations
|
|
140
|
+
#
|
|
141
|
+
# * *Errors*
|
|
142
|
+
#
|
|
143
|
+
# See:
|
|
144
|
+
# - #define_plugin_type
|
|
145
|
+
#
|
|
42
146
|
def define_plugin_types(namespace, type_info)
|
|
43
147
|
if type_info.is_a?(Hash)
|
|
44
148
|
type_info.each do |plugin_type, default_provider|
|
|
45
149
|
define_plugin_type(namespace, plugin_type, default_provider)
|
|
46
150
|
end
|
|
47
151
|
end
|
|
152
|
+
self
|
|
48
153
|
end
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
154
|
+
|
|
155
|
+
# Check if a specified plugin type has been defined
|
|
156
|
+
#
|
|
157
|
+
# * *Parameters*
|
|
158
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
159
|
+
# - [String, Symbol] *plugin_type* Plugin type name to check within namespace
|
|
160
|
+
#
|
|
161
|
+
# * *Returns*
|
|
162
|
+
# - [Boolean] Returns true if plugin type exists, false otherwise
|
|
163
|
+
#
|
|
164
|
+
# * *Errors*
|
|
165
|
+
#
|
|
166
|
+
# See:
|
|
167
|
+
# - Nucleon::Config#get_hash
|
|
168
|
+
#
|
|
169
|
+
# See also:
|
|
170
|
+
# - #sanitize_id
|
|
171
|
+
#
|
|
52
172
|
def plugin_type_defined?(namespace, plugin_type)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return false unless @plugin_types.has_key?(namespace)
|
|
56
|
-
@plugin_types[namespace].has_key?(sanitize_id(plugin_type))
|
|
173
|
+
get_hash([ :plugin_types, namespace ]).has_key?(sanitize_id(plugin_type))
|
|
57
174
|
end
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
175
|
+
|
|
176
|
+
# Return the default provider currently registered for a plugin type
|
|
177
|
+
#
|
|
178
|
+
# * *Parameters*
|
|
179
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
180
|
+
# - [String, Symbol] *plugin_type* Plugin type name to fetch default provider
|
|
181
|
+
#
|
|
182
|
+
# * *Returns*
|
|
183
|
+
# - [nil, Symbol] Returns default provider if plugin type exists, nil otherwise
|
|
184
|
+
#
|
|
185
|
+
# * *Errors*
|
|
186
|
+
#
|
|
187
|
+
# See:
|
|
188
|
+
# - Nucleon::Config#get
|
|
189
|
+
#
|
|
190
|
+
# See also:
|
|
191
|
+
# - #sanitize_id
|
|
192
|
+
#
|
|
61
193
|
def plugin_type_default(namespace, plugin_type)
|
|
62
|
-
namespace
|
|
63
|
-
|
|
64
|
-
return nil unless @plugin_types.has_key?(namespace)
|
|
65
|
-
@plugin_types[namespace][sanitize_id(plugin_type)]
|
|
194
|
+
get([ :plugin_types, namespace, sanitize_id(plugin_type) ])
|
|
66
195
|
end
|
|
67
|
-
|
|
68
|
-
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
#*****************************************************************************
|
|
69
199
|
# Loaded plugin accessor / modifiers
|
|
70
|
-
|
|
71
|
-
|
|
200
|
+
|
|
201
|
+
# Define a new plugin provider of a specified plugin type.
|
|
202
|
+
#
|
|
203
|
+
# * *Parameters*
|
|
204
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
205
|
+
# - [String, Symbol] *plugin_type* Plugin type name to fetch default provider
|
|
206
|
+
# - [String] *base_path* Base load path of the plugin provider
|
|
207
|
+
# - [String] *file* File that contains the provider definition
|
|
208
|
+
#
|
|
209
|
+
# * *Returns*
|
|
210
|
+
# - [Nucleon::Environment] Returns reference to self for compound operations
|
|
211
|
+
#
|
|
212
|
+
# * *Errors*
|
|
213
|
+
#
|
|
214
|
+
# * *Yields*
|
|
215
|
+
# - [Hash<Symbol|ANY>] *data* Plugin load information
|
|
216
|
+
#
|
|
217
|
+
# See:
|
|
218
|
+
# - Nucleon::Config#get_hash
|
|
219
|
+
# - Nucleon::Config#set
|
|
220
|
+
#
|
|
221
|
+
# See also:
|
|
222
|
+
# - #sanitize_id
|
|
223
|
+
# - #parse_plugin_info
|
|
224
|
+
#
|
|
225
|
+
def define_plugin(namespace, plugin_type, base_path, file, &code) # :yields: data
|
|
72
226
|
namespace = namespace.to_sym
|
|
73
227
|
plugin_type = sanitize_id(plugin_type)
|
|
74
|
-
|
|
75
|
-
@load_info[namespace] = {} unless @load_info.has_key?(namespace)
|
|
76
|
-
@load_info[namespace][plugin_type] = {} unless @load_info[namespace].has_key?(plugin_type)
|
|
77
|
-
|
|
78
228
|
plugin_info = parse_plugin_info(namespace, plugin_type, base_path, file)
|
|
79
|
-
|
|
80
|
-
unless
|
|
229
|
+
|
|
230
|
+
unless get_hash([ :load_info, namespace, plugin_type ]).has_key?(plugin_info[:provider])
|
|
81
231
|
data = {
|
|
82
232
|
:namespace => namespace,
|
|
83
233
|
:type => plugin_type,
|
|
84
234
|
:base_path => base_path,
|
|
85
235
|
:file => file,
|
|
86
|
-
:provider => plugin_info[:provider],
|
|
87
|
-
:directory => plugin_info[:directory],
|
|
236
|
+
:provider => plugin_info[:provider],
|
|
237
|
+
:directory => plugin_info[:directory],
|
|
88
238
|
:class_components => plugin_info[:class_components]
|
|
89
239
|
}
|
|
90
240
|
code.call(data) if code
|
|
91
|
-
|
|
92
|
-
|
|
241
|
+
|
|
242
|
+
set([ :load_info, namespace, plugin_type, plugin_info[:provider] ], data)
|
|
93
243
|
end
|
|
244
|
+
self
|
|
94
245
|
end
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
246
|
+
|
|
247
|
+
# Return the load information for a specified plugin provider if it exists
|
|
248
|
+
#
|
|
249
|
+
# * *Parameters*
|
|
250
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
251
|
+
# - [String, Symbol] *plugin_type* Plugin type name of provider
|
|
252
|
+
# - [String, Symbol] *provider* Plugin provider to return load information
|
|
253
|
+
#
|
|
254
|
+
# * *Returns*
|
|
255
|
+
# - [nil, Hash<Symbol|ANY>] Returns provider load information if provider exists, nil otherwise
|
|
256
|
+
#
|
|
257
|
+
# * *Errors*
|
|
258
|
+
#
|
|
259
|
+
# See:
|
|
260
|
+
# - Nucleon::Config#get
|
|
261
|
+
#
|
|
262
|
+
# See also:
|
|
263
|
+
# - #sanitize_id
|
|
264
|
+
#
|
|
98
265
|
def loaded_plugin(namespace, plugin_type, provider)
|
|
99
|
-
namespace
|
|
100
|
-
plugin_type = sanitize_id(plugin_type)
|
|
101
|
-
provider = sanitize_id(provider)
|
|
102
|
-
info = nil
|
|
103
|
-
|
|
104
|
-
if @load_info.has_key?(namespace) &&
|
|
105
|
-
@load_info[namespace].has_key?(plugin_type) &&
|
|
106
|
-
@load_info[namespace][plugin_type].has_key?(provider)
|
|
107
|
-
|
|
108
|
-
info = @load_info[namespace][plugin_type][provider]
|
|
109
|
-
end
|
|
110
|
-
info
|
|
266
|
+
get([ :load_info, namespace, sanitize_id(plugin_type), sanitize_id(provider) ], nil)
|
|
111
267
|
end
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
268
|
+
|
|
269
|
+
# Return the load information for namespaces, plugin types, providers if it exists
|
|
270
|
+
#
|
|
271
|
+
# * *Parameters*
|
|
272
|
+
# - [nil, String, Symbol] *namespace* Namespace to return load information
|
|
273
|
+
# - [nil, String, Symbol] *plugin_type* Plugin type name to return load information
|
|
274
|
+
# - [nil, String, Symbol] *provider* Plugin provider to return load information
|
|
275
|
+
# - [ANY] *default* Default results if nothing found (empty hash by default)
|
|
276
|
+
#
|
|
277
|
+
# * *Returns*
|
|
278
|
+
# - [nil, Hash<Symbol|Symbol|Symbol|Symbol|ANY>] Returns all load information if no parameters given
|
|
279
|
+
# - [nil, Hash<Symbol|Symbol|Symbol|ANY>] Returns namespace load information if only namespace given
|
|
280
|
+
# - [nil, Hash<Symbol|Symbol|ANY>] Returns plugin type load information if namespace and plugin type given
|
|
281
|
+
# - [nil, Hash<Symbol|ANY>] Returns provider load information if namespace, plugin type, and provider given
|
|
282
|
+
#
|
|
283
|
+
# * *Errors*
|
|
284
|
+
#
|
|
285
|
+
# See:
|
|
286
|
+
# - Nucleon::Config#get_hash
|
|
287
|
+
#
|
|
288
|
+
# See also:
|
|
289
|
+
# - #sanitize_id
|
|
290
|
+
#
|
|
115
291
|
def loaded_plugins(namespace = nil, plugin_type = nil, provider = nil, default = {})
|
|
292
|
+
load_info = get_hash(:load_info)
|
|
293
|
+
|
|
116
294
|
namespace = namespace.to_sym if namespace
|
|
117
295
|
plugin_type = sanitize_id(plugin_type) if plugin_type
|
|
118
296
|
provider = sanitize_id(provider) if provider
|
|
119
297
|
results = default
|
|
120
|
-
|
|
121
|
-
if namespace &&
|
|
122
|
-
if plugin_type &&
|
|
123
|
-
if provider &&
|
|
124
|
-
results =
|
|
298
|
+
|
|
299
|
+
if namespace && load_info.has_key?(namespace)
|
|
300
|
+
if plugin_type && load_info[namespace].has_key?(plugin_type)
|
|
301
|
+
if provider && load_info[namespace][plugin_type].has_key?(provider)
|
|
302
|
+
results = load_info[namespace][plugin_type][provider]
|
|
125
303
|
elsif ! provider
|
|
126
|
-
results =
|
|
304
|
+
results = load_info[namespace][plugin_type]
|
|
127
305
|
end
|
|
128
306
|
elsif ! plugin_type
|
|
129
|
-
results =
|
|
307
|
+
results = load_info[namespace]
|
|
130
308
|
end
|
|
131
309
|
elsif ! namespace
|
|
132
|
-
results =
|
|
310
|
+
results = load_info
|
|
133
311
|
end
|
|
134
312
|
results
|
|
135
313
|
end
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
314
|
+
|
|
315
|
+
# Check if a specified plugin type has been loaded
|
|
316
|
+
#
|
|
317
|
+
# * *Parameters*
|
|
318
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
319
|
+
# - [String, Symbol] *plugin_type* Plugin type name to check
|
|
320
|
+
#
|
|
321
|
+
# * *Returns*
|
|
322
|
+
# - [Boolean] Returns true if plugin type has been loaded, false otherwise
|
|
323
|
+
#
|
|
324
|
+
# * *Errors*
|
|
325
|
+
#
|
|
326
|
+
# See:
|
|
327
|
+
# - Nucleon::Config#get_hash
|
|
328
|
+
#
|
|
329
|
+
# See also:
|
|
330
|
+
# - #sanitize_id
|
|
331
|
+
#
|
|
139
332
|
def plugin_has_type?(namespace, plugin_type)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return false unless @load_info.has_key?(namespace)
|
|
143
|
-
@load_info[namespace].has_key?(sanitize_id(plugin_type))
|
|
333
|
+
get_hash([ :load_info, namespace ]).has_key?(sanitize_id(plugin_type))
|
|
144
334
|
end
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
335
|
+
|
|
336
|
+
# Check if a specified plugin provider has been loaded
|
|
337
|
+
#
|
|
338
|
+
# * *Parameters*
|
|
339
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
340
|
+
# - [String, Symbol] *plugin_type* Plugin type name to check
|
|
341
|
+
# - [String, Symbol] *provider* Plugin provider name to check
|
|
342
|
+
#
|
|
343
|
+
# * *Returns*
|
|
344
|
+
# - [Boolean] Returns true if plugin provider has been loaded, false otherwise
|
|
345
|
+
#
|
|
346
|
+
# * *Errors*
|
|
347
|
+
#
|
|
348
|
+
# See:
|
|
349
|
+
# - Nucleon::Config#get_hash
|
|
350
|
+
#
|
|
351
|
+
# See also:
|
|
352
|
+
# - #sanitize_id
|
|
353
|
+
#
|
|
148
354
|
def plugin_has_provider?(namespace, plugin_type, provider)
|
|
149
|
-
namespace
|
|
150
|
-
plugin_type = sanitize_id(plugin_type)
|
|
151
|
-
provider = sanitize_id(provider)
|
|
152
|
-
|
|
153
|
-
return false unless @load_info.has_key?(namespace) && @load_info[namespace].has_key?(plugin_type)
|
|
154
|
-
@load_info[namespace][plugin_type].has_key?(provider)
|
|
355
|
+
get_hash([ :load_info, namespace, sanitize_id(plugin_type) ]).has_key?(sanitize_id(provider))
|
|
155
356
|
end
|
|
156
|
-
|
|
157
|
-
|
|
357
|
+
|
|
358
|
+
# Autoload all of the defined plugins
|
|
359
|
+
#
|
|
360
|
+
# * *Parameters*
|
|
361
|
+
#
|
|
362
|
+
# * *Returns*
|
|
363
|
+
# - [Void] This method does not return a value
|
|
364
|
+
#
|
|
365
|
+
# * *Errors*
|
|
366
|
+
# - TODO
|
|
367
|
+
#
|
|
368
|
+
# * *Yields*
|
|
369
|
+
# - [Symbol] *namespace* Plugin namespace
|
|
370
|
+
# - [Symbol] *plugin_type* Plugin type
|
|
371
|
+
# - [Symbol] *provider* Plugin provider
|
|
372
|
+
# - [Hash<Symbol|ANY>] *plugin* Plugin load information
|
|
373
|
+
#
|
|
374
|
+
# See:
|
|
375
|
+
# - #loaded_plugins
|
|
376
|
+
# - #class_const
|
|
377
|
+
#
|
|
378
|
+
def autoload # :yields: namespace, plugin_type, provider, plugin
|
|
379
|
+
load_info = loaded_plugins
|
|
380
|
+
|
|
381
|
+
load_info.keys.each do |namespace|
|
|
382
|
+
load_info[namespace].keys.each do |plugin_type|
|
|
383
|
+
load_info[namespace][plugin_type].each do |provider, plugin|
|
|
384
|
+
require plugin[:file]
|
|
385
|
+
|
|
386
|
+
load_info[namespace][plugin_type][provider][:class] = class_const(plugin[:class_components])
|
|
387
|
+
|
|
388
|
+
yield(namespace, plugin_type, provider, plugin) if block_given?
|
|
389
|
+
end
|
|
390
|
+
end
|
|
391
|
+
end
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
#*****************************************************************************
|
|
158
396
|
# Active plugin accessor / modifiers
|
|
159
|
-
|
|
160
|
-
|
|
397
|
+
|
|
398
|
+
# Create a new plugin instance of a specified provider
|
|
399
|
+
#
|
|
400
|
+
# * *Parameters*
|
|
401
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
402
|
+
# - [String, Symbol] *plugin_type* Plugin type name of provider
|
|
403
|
+
# - [String, Symbol] *provider* Plugin provider to return load information
|
|
404
|
+
# - [Hash] *options* Create options (plugin initialization configurations)
|
|
405
|
+
#
|
|
406
|
+
# * *Returns*
|
|
407
|
+
# - [nil, Nucleon::Plugin::Base] Returns plugin instance (inherited from Nucleon::Plugin::Base)
|
|
408
|
+
#
|
|
409
|
+
# * *Errors*
|
|
410
|
+
#
|
|
411
|
+
# * *Yields*
|
|
412
|
+
# - [nil, Hash<Symbol|ANY>] *type_info* Provider load information if it has been loaded
|
|
413
|
+
# - [Hash] *options* Create options (plugin initialization configurations)
|
|
414
|
+
#
|
|
415
|
+
# See:
|
|
416
|
+
# - Nucleon::Plugin::Base
|
|
417
|
+
# - Nucleon::Config#get
|
|
418
|
+
# - Nucleon::Config#set
|
|
419
|
+
#
|
|
420
|
+
# See also:
|
|
421
|
+
# - #sanitize_id
|
|
422
|
+
# - #plugin_type_defined?
|
|
423
|
+
# - #loaded_plugin
|
|
424
|
+
# - Nucleon::Config
|
|
425
|
+
# - Nucleon::Config::array
|
|
426
|
+
# - Nucleon::Util::Data::subset
|
|
427
|
+
# - Nucleon::Facade#sha1
|
|
428
|
+
#
|
|
429
|
+
def create_plugin(namespace, plugin_type, provider, options = {}, &code) # :yields: type_info, options
|
|
161
430
|
namespace = namespace.to_sym
|
|
162
431
|
plugin_type = sanitize_id(plugin_type)
|
|
163
432
|
provider = sanitize_id(provider)
|
|
164
|
-
|
|
433
|
+
options = Util::Data.clone(options)
|
|
434
|
+
plugin = nil
|
|
435
|
+
result = nil
|
|
436
|
+
|
|
165
437
|
unless plugin_type_defined?(namespace, plugin_type)
|
|
166
|
-
return
|
|
438
|
+
return plugin
|
|
167
439
|
end
|
|
168
|
-
|
|
169
|
-
if type_info = loaded_plugin(namespace, plugin_type, provider)
|
|
170
|
-
ids =
|
|
440
|
+
|
|
441
|
+
if type_info = Util::Data.clone(loaded_plugin(namespace, plugin_type, provider))
|
|
442
|
+
ids = array(type_info[:class].register_ids).flatten
|
|
171
443
|
instance_config = Config.new(options)
|
|
172
444
|
ensure_new = instance_config.delete(:new, false)
|
|
173
|
-
|
|
174
|
-
instance_options = Util::Data.subset(instance_config.export, ids, true)
|
|
445
|
+
|
|
446
|
+
instance_options = Util::Data.subset(instance_config.export, ids, true)
|
|
175
447
|
instance_name = "#{provider}_" + Nucleon.sha1(instance_options)
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if ensure_new || ! ( instance_name && @active_info[namespace][plugin_type].has_key?(instance_name) )
|
|
448
|
+
plugin = get([ :active_info, namespace, plugin_type, instance_name ])
|
|
449
|
+
|
|
450
|
+
if ensure_new || ! ( instance_name && plugin )
|
|
181
451
|
type_info[:instance_name] = instance_name
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
452
|
+
|
|
453
|
+
result = code.call(type_info, options) if code
|
|
454
|
+
options = result if result.is_a?(Hash)
|
|
455
|
+
|
|
456
|
+
options[:meta] = Config.new(type_info).import(hash(options[:meta]))
|
|
457
|
+
|
|
458
|
+
options.delete(:new)
|
|
459
|
+
|
|
460
|
+
plugin = type_info[:class].new(namespace, plugin_type, provider, options)
|
|
461
|
+
set([ :active_info, namespace, plugin_type, instance_name ], plugin)
|
|
462
|
+
|
|
463
|
+
@instance_map.append([ namespace, plugin_type, plugin.plugin_name.to_sym ], instance_name.to_sym)
|
|
187
464
|
end
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
nil
|
|
465
|
+
end
|
|
466
|
+
plugin
|
|
191
467
|
end
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
468
|
+
|
|
469
|
+
# Return a plugin instance by name if it exists
|
|
470
|
+
#
|
|
471
|
+
# * *Parameters*
|
|
472
|
+
# - [String, Symbol] *namespace* Namespace that contains the plugin
|
|
473
|
+
# - [String, Symbol] *plugin_type* Plugin type name
|
|
474
|
+
# - [String, Symbol] *plugin_name* Plugin name to return
|
|
475
|
+
#
|
|
476
|
+
# * *Returns*
|
|
477
|
+
# - [nil, Nucleon::Plugin::Base] Returns a plugin instance of name specified if it exists
|
|
478
|
+
#
|
|
479
|
+
# * *Errors*
|
|
480
|
+
#
|
|
481
|
+
# See:
|
|
482
|
+
# - Nucleon::Plugin::Base
|
|
483
|
+
# - Nucleon::Config#get_hash
|
|
484
|
+
#
|
|
485
|
+
# See also:
|
|
486
|
+
# - #sanitize_id
|
|
487
|
+
#
|
|
195
488
|
def get_plugin(namespace, plugin_type, plugin_name)
|
|
196
|
-
namespace
|
|
197
|
-
plugin_type
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
end
|
|
489
|
+
namespace = namespace.to_sym
|
|
490
|
+
plugin_type = sanitize_id(plugin_type)
|
|
491
|
+
|
|
492
|
+
instances = get_hash([ :active_info, namespace, plugin_type ])
|
|
493
|
+
instance_ids = array(@instance_map.get([ namespace, plugin_type, plugin_name.to_s.to_sym ]))
|
|
494
|
+
|
|
495
|
+
if instance_ids.size
|
|
496
|
+
return instances[instance_ids[0]]
|
|
205
497
|
end
|
|
206
|
-
nil
|
|
498
|
+
nil
|
|
207
499
|
end
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
500
|
+
|
|
501
|
+
# Remove a plugin instance from the environment
|
|
502
|
+
#
|
|
503
|
+
# * *Parameters*
|
|
504
|
+
# - [String, Symbol] *namespace* Namespace that contains the plugin
|
|
505
|
+
# - [String, Symbol] *plugin_type* Plugin type name
|
|
506
|
+
# - [String, Symbol] *instance_name* Plugin instance name to tremove
|
|
507
|
+
#
|
|
508
|
+
# * *Returns*
|
|
509
|
+
# - [nil, Nucleon::Plugin::Base] Returns the plugin instance that was removed from environment
|
|
510
|
+
#
|
|
511
|
+
# * *Errors*
|
|
512
|
+
#
|
|
513
|
+
# * *Yields*
|
|
514
|
+
# - [Nucleon::Plugin::Base] *plugin* Plugin object being removed (cleanup)
|
|
515
|
+
#
|
|
516
|
+
# See:
|
|
517
|
+
# - Nucleon::Plugin::Base
|
|
518
|
+
# - Nucleon::Config#delete
|
|
519
|
+
#
|
|
520
|
+
# See also:
|
|
521
|
+
# - #sanitize_id
|
|
522
|
+
#
|
|
523
|
+
def remove_plugin(namespace, plugin_type, instance_name, &code) # :yields: plugin
|
|
524
|
+
plugin = delete([ :active_info, namespace, sanitize_id(plugin_type), instance_name ])
|
|
525
|
+
code.call(plugin) if code && plugin
|
|
526
|
+
plugin
|
|
220
527
|
end
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
528
|
+
|
|
529
|
+
# Return active plugins for namespaces, plugin types, providers if specified
|
|
530
|
+
#
|
|
531
|
+
# * *Parameters*
|
|
532
|
+
# - [nil, String, Symbol] *namespace* Namespace to return plugin instance
|
|
533
|
+
# - [nil, String, Symbol] *plugin_type* Plugin type name to return plugin instance
|
|
534
|
+
# - [nil, String, Symbol] *provider* Plugin provider to return plugin instance
|
|
535
|
+
#
|
|
536
|
+
# * *Returns*
|
|
537
|
+
# - [nil, Hash<Symbol|Symbol|Symbol|Symbol|Nucleon::Plugin::Base>] Returns all plugin instances if no parameters given
|
|
538
|
+
# - [nil, Hash<Symbol|Symbol|Symbol|Nucleon::Plugin::Base>] Returns namespace plugin instances if only namespace given
|
|
539
|
+
# - [nil, Hash<Symbol|Symbol|Nucleon::Plugin::Base>] Returns plugin type instances if namespace and plugin type given
|
|
540
|
+
# - [nil, Hash<Symbol|Nucleon::Plugin::Base>] Returns provider instances if namespace, plugin type, and provider given
|
|
541
|
+
#
|
|
542
|
+
# * *Errors*
|
|
543
|
+
#
|
|
544
|
+
# See:
|
|
545
|
+
# - Nucleon::Config#get_hash
|
|
546
|
+
#
|
|
547
|
+
# See also:
|
|
548
|
+
# - #sanitize_id
|
|
549
|
+
#
|
|
224
550
|
def active_plugins(namespace = nil, plugin_type = nil, provider = nil)
|
|
551
|
+
active_info = get_hash(:active_info)
|
|
552
|
+
|
|
225
553
|
namespace = namespace.to_sym if namespace
|
|
226
554
|
plugin_type = sanitize_id(plugin_type) if plugin_type
|
|
227
555
|
provider = sanitize_id(provider) if provider
|
|
228
556
|
results = {}
|
|
229
|
-
|
|
230
|
-
if namespace &&
|
|
231
|
-
if plugin_type &&
|
|
232
|
-
if provider && !
|
|
233
|
-
|
|
234
|
-
plugin =
|
|
557
|
+
|
|
558
|
+
if namespace && active_info.has_key?(namespace)
|
|
559
|
+
if plugin_type && active_info[namespace].has_key?(plugin_type)
|
|
560
|
+
if provider && ! active_info[namespace][plugin_type].keys.empty?
|
|
561
|
+
active_info[namespace][plugin_type].each do |instance_name, plugin|
|
|
562
|
+
plugin = active_info[namespace][plugin_type][instance_name]
|
|
235
563
|
results[instance_name] = plugin if plugin.plugin_provider == provider
|
|
236
564
|
end
|
|
237
565
|
elsif ! provider
|
|
238
|
-
results =
|
|
566
|
+
results = active_info[namespace][plugin_type]
|
|
239
567
|
end
|
|
240
568
|
elsif ! plugin_type
|
|
241
|
-
results =
|
|
569
|
+
results = active_info[namespace]
|
|
242
570
|
end
|
|
243
571
|
elsif ! namespace
|
|
244
|
-
results =
|
|
245
|
-
end
|
|
572
|
+
results = active_info
|
|
573
|
+
end
|
|
246
574
|
results
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
|
|
575
|
+
end
|
|
576
|
+
|
|
577
|
+
#*****************************************************************************
|
|
250
578
|
# Utilities
|
|
251
|
-
|
|
252
|
-
|
|
579
|
+
|
|
580
|
+
# Return a fully formed class name as a string
|
|
581
|
+
#
|
|
582
|
+
# * *Parameters*
|
|
583
|
+
# - [String, Symbol, Array] *name* Class name components
|
|
584
|
+
# - [String, Symbol] *separator* Class component separator (default '::')
|
|
585
|
+
# - [Boolean] *want_array* Whether or not to return array of final components or string version
|
|
586
|
+
#
|
|
587
|
+
# * *Returns*
|
|
588
|
+
# - [String] Returns fully rendered class name as string unless want_array is true
|
|
589
|
+
# - [Array] Returns array of final class components if want_array is true
|
|
590
|
+
#
|
|
591
|
+
# * *Errors*
|
|
592
|
+
#
|
|
593
|
+
def class_name(name, separator = '::', want_array = false)
|
|
253
594
|
components = []
|
|
254
|
-
|
|
595
|
+
|
|
255
596
|
case name
|
|
256
597
|
when String, Symbol
|
|
257
598
|
components = name.to_s.split(separator)
|
|
258
599
|
when Array
|
|
259
|
-
components = name
|
|
600
|
+
components = name.flatten
|
|
260
601
|
end
|
|
261
|
-
|
|
602
|
+
|
|
262
603
|
components.collect! do |value|
|
|
263
|
-
value = value.to_s.strip
|
|
264
|
-
value[0] = value.capitalize[0] if value =~ /^[a-z]/
|
|
604
|
+
value = value.to_s.strip
|
|
605
|
+
value[0] = value.capitalize[0] if value =~ /^[a-z]/
|
|
265
606
|
value
|
|
266
607
|
end
|
|
267
|
-
|
|
608
|
+
|
|
268
609
|
if want_array
|
|
269
610
|
return components
|
|
270
|
-
end
|
|
611
|
+
end
|
|
271
612
|
components.join(separator)
|
|
272
613
|
end
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
614
|
+
|
|
615
|
+
# Return a fully formed class name as a machine usable constant
|
|
616
|
+
#
|
|
617
|
+
# * *Parameters*
|
|
618
|
+
# - [String, Symbol, Array] *name* Class name components
|
|
619
|
+
# - [String, Symbol] *separator* Class component separator (default '::')
|
|
620
|
+
#
|
|
621
|
+
# * *Returns*
|
|
622
|
+
# - [Class Constant] Returns class constant for fully formed class name of given components
|
|
623
|
+
#
|
|
624
|
+
# * *Errors*
|
|
625
|
+
#
|
|
626
|
+
# See also:
|
|
627
|
+
# - #class_name
|
|
628
|
+
#
|
|
276
629
|
def class_const(name, separator = '::')
|
|
277
630
|
components = class_name(name, separator, TRUE)
|
|
278
631
|
constant = Object
|
|
279
|
-
|
|
632
|
+
|
|
280
633
|
components.each do |component|
|
|
281
|
-
constant = constant.const_defined?(component) ?
|
|
282
|
-
constant.const_get(component) :
|
|
634
|
+
constant = constant.const_defined?(component) ?
|
|
635
|
+
constant.const_get(component) :
|
|
283
636
|
constant.const_missing(component)
|
|
284
637
|
end
|
|
285
638
|
constant
|
|
286
639
|
end
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
640
|
+
|
|
641
|
+
# Sanitize an identifier for internal plugin environment use.
|
|
642
|
+
#
|
|
643
|
+
# * *Parameters*
|
|
644
|
+
# - [String, Symbol] *id_component* Identifier to sanitize
|
|
645
|
+
#
|
|
646
|
+
# * *Returns*
|
|
647
|
+
# - [Symbol] Returns a sanitized symbol representing the given id component
|
|
648
|
+
#
|
|
649
|
+
# * *Errors*
|
|
650
|
+
#
|
|
290
651
|
def sanitize_id(id_component)
|
|
291
652
|
id_component.to_s.gsub(/([a-z0-9])(?:\-|\_)?([A-Z])/, '\1_\2').downcase.to_sym
|
|
292
653
|
end
|
|
293
654
|
protected :sanitize_id
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
655
|
+
|
|
656
|
+
# Sanitize a class identifier for internal use.
|
|
657
|
+
#
|
|
658
|
+
# * *Parameters*
|
|
659
|
+
# - [String, Symbol] *class_component* Class identifier to sanitize
|
|
660
|
+
#
|
|
661
|
+
# * *Returns*
|
|
662
|
+
# - [String] Returns a sanitized string representing the given class component
|
|
663
|
+
#
|
|
664
|
+
# * *Errors*
|
|
665
|
+
#
|
|
297
666
|
def sanitize_class(class_component)
|
|
298
|
-
class_component.to_s.split('_').collect {|elem| elem.slice(0,1).capitalize + elem.slice(1..-1) }.join('')
|
|
667
|
+
class_component.to_s.split('_').collect {|elem| elem.slice(0,1).capitalize + elem.slice(1..-1) }.join('')
|
|
299
668
|
end
|
|
300
669
|
protected :sanitize_class
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
670
|
+
|
|
671
|
+
# Return a class constant representing a base plugin class generated from namespace and plugin_type.
|
|
672
|
+
#
|
|
673
|
+
# * *Parameters*
|
|
674
|
+
# - [String, Symbol] *namespace* Plugin namespace to constantize
|
|
675
|
+
# - [String, Symbol] *plugin_type* Plugin type to constantize
|
|
676
|
+
#
|
|
677
|
+
# * *Returns*
|
|
678
|
+
# - [String] Returns a class constant representing the plugin namespace and type
|
|
679
|
+
#
|
|
680
|
+
# * *Errors*
|
|
681
|
+
#
|
|
682
|
+
# See also:
|
|
683
|
+
# - #class_const
|
|
684
|
+
# - #sanitize_class
|
|
685
|
+
#
|
|
304
686
|
def plugin_class(namespace, plugin_type)
|
|
305
|
-
class_const([ sanitize_class(namespace), :plugin, sanitize_class(plugin_type) ])
|
|
687
|
+
class_const([ sanitize_class(namespace), :plugin, sanitize_class(plugin_type) ])
|
|
688
|
+
end
|
|
689
|
+
|
|
690
|
+
# Return a class constant representing a plugin provider class generated from
|
|
691
|
+
# namespace, plugin_type, and provider name.
|
|
692
|
+
#
|
|
693
|
+
# The provider name can be entered as an array if it is included in sub modules.
|
|
694
|
+
#
|
|
695
|
+
# * *Parameters*
|
|
696
|
+
# - [String, Symbol] *namespace* Plugin namespace to constantize
|
|
697
|
+
# - [String, Symbol] *plugin_type* Plugin type to constantize
|
|
698
|
+
# - [String, Symbol, Array] *provider* Plugin provider name to constantize
|
|
699
|
+
#
|
|
700
|
+
# * *Returns*
|
|
701
|
+
# - [String] Returns a class constant representing the plugin provider
|
|
702
|
+
#
|
|
703
|
+
# * *Errors*
|
|
704
|
+
#
|
|
705
|
+
# See also:
|
|
706
|
+
# - #class_const
|
|
707
|
+
# - #sanitize_class
|
|
708
|
+
#
|
|
709
|
+
def provider_class(namespace, plugin_type, provider)
|
|
710
|
+
class_const([ sanitize_class(namespace), sanitize_class(plugin_type), provider ])
|
|
306
711
|
end
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
712
|
+
|
|
713
|
+
# Parse plugin information for a specified namespace and plugin type.
|
|
714
|
+
#
|
|
715
|
+
# * *Parameters*
|
|
716
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
717
|
+
# - [String, Symbol] *plugin_type* Plugin type name to fetch default provider
|
|
718
|
+
# - [String] *base_path* Base load path of the plugin provider
|
|
719
|
+
# - [String] *file* File that contains the provider definition
|
|
720
|
+
#
|
|
721
|
+
# * *Returns*
|
|
722
|
+
# - [Hash<Symbol|ANY>] Returns a hash of the parsed plugin information
|
|
723
|
+
#
|
|
724
|
+
# * *Errors*
|
|
725
|
+
#
|
|
726
|
+
# See also:
|
|
727
|
+
# - #sanitize_id
|
|
728
|
+
# - #sanitize_class
|
|
729
|
+
#
|
|
310
730
|
def parse_plugin_info(namespace, plugin_type, base_path, file)
|
|
311
|
-
dir_components = base_path.split(File::SEPARATOR)
|
|
731
|
+
dir_components = base_path.split(File::SEPARATOR)
|
|
312
732
|
file_components = file.split(File::SEPARATOR)
|
|
313
|
-
|
|
733
|
+
|
|
314
734
|
file_name = file_components.pop.sub(/\.rb/, '')
|
|
315
735
|
directory = file_components.join(File::SEPARATOR)
|
|
316
|
-
|
|
736
|
+
|
|
317
737
|
file_class = sanitize_class(file_name)
|
|
318
738
|
group_components = directory.sub(/^#{base_path}#{File::SEPARATOR}?/, '').split(File::SEPARATOR)
|
|
319
|
-
|
|
739
|
+
|
|
320
740
|
class_components = [ sanitize_class(namespace), sanitize_class(plugin_type) ]
|
|
321
|
-
|
|
322
|
-
if ! group_components.empty?
|
|
741
|
+
|
|
742
|
+
if ! group_components.empty?
|
|
323
743
|
group_name = group_components.collect {|elem| elem.downcase }.join('_')
|
|
324
744
|
provider = [ group_name, file_name ].join('_')
|
|
325
|
-
|
|
745
|
+
|
|
326
746
|
group_components = group_components.collect {|elem| sanitize_class(elem) }
|
|
327
747
|
class_components = [ class_components, group_components, file_class ].flatten
|
|
328
748
|
else
|
|
329
749
|
provider = file_name
|
|
330
750
|
class_components = [ class_components, file_class ].flatten
|
|
331
751
|
end
|
|
332
|
-
|
|
333
|
-
{
|
|
334
|
-
:directory => directory,
|
|
335
|
-
:provider => sanitize_id(provider),
|
|
752
|
+
|
|
753
|
+
{
|
|
754
|
+
:directory => directory,
|
|
755
|
+
:provider => sanitize_id(provider),
|
|
336
756
|
:class_components => class_components
|
|
337
|
-
}
|
|
757
|
+
}
|
|
338
758
|
end
|
|
339
759
|
protected :parse_plugin_info
|
|
340
760
|
end
|