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/gems.rb
CHANGED
|
@@ -1,87 +1,103 @@
|
|
|
1
1
|
|
|
2
2
|
module Nucleon
|
|
3
3
|
module Gems
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
#-----------------------------------------------------------------------------
|
|
6
|
-
|
|
7
|
-
@@core
|
|
8
|
-
@@gems
|
|
9
|
-
|
|
6
|
+
|
|
7
|
+
@@core = nil
|
|
8
|
+
@@gems = {}
|
|
9
|
+
@@gateways = []
|
|
10
|
+
|
|
10
11
|
#-----------------------------------------------------------------------------
|
|
11
12
|
# Gem interface
|
|
12
|
-
|
|
13
|
+
|
|
13
14
|
def self.logger
|
|
14
15
|
Core.logger
|
|
15
16
|
end
|
|
16
|
-
|
|
17
|
+
|
|
17
18
|
#---
|
|
18
|
-
|
|
19
|
+
|
|
19
20
|
def self.core
|
|
20
21
|
@@core
|
|
21
22
|
end
|
|
22
|
-
|
|
23
|
+
|
|
23
24
|
#---
|
|
24
|
-
|
|
25
|
+
|
|
26
|
+
def self.gateway(name)
|
|
27
|
+
unless @@gateways.include?(name.to_s)
|
|
28
|
+
@@gateways << name.to_s
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
#---
|
|
33
|
+
|
|
25
34
|
def self.registered
|
|
26
35
|
@@gems
|
|
27
36
|
end
|
|
28
|
-
|
|
37
|
+
|
|
29
38
|
#---
|
|
30
|
-
|
|
39
|
+
|
|
31
40
|
def self.register(reset = false, loaded = [])
|
|
32
41
|
if reset || Util::Data.empty?(@@gems)
|
|
33
42
|
logger.info("Registering external gem defined Nucleon plugins at #{Time.now}")
|
|
34
|
-
|
|
43
|
+
|
|
35
44
|
each_gem do |spec|
|
|
36
45
|
register_gem(spec, loaded)
|
|
37
46
|
end
|
|
38
47
|
end
|
|
39
48
|
@@gems
|
|
40
49
|
end
|
|
41
|
-
|
|
50
|
+
|
|
42
51
|
#---
|
|
43
|
-
|
|
52
|
+
|
|
44
53
|
def self.register_gem(spec, loaded = [])
|
|
45
54
|
name = spec.name.to_sym
|
|
46
55
|
base_path = File.join(spec.full_gem_path, 'lib')
|
|
47
|
-
|
|
56
|
+
loaded = loaded.collect {|item| item.to_sym }
|
|
57
|
+
|
|
48
58
|
if name == :nucleon
|
|
49
59
|
logger.debug("Setting Nucleon core gemspec")
|
|
50
|
-
@@core = spec
|
|
51
|
-
@@gems[name] = {
|
|
52
|
-
:spec => spec,
|
|
53
|
-
:base_path => base_path,
|
|
54
|
-
:namespaces => [ :nucleon ]
|
|
55
|
-
}
|
|
60
|
+
@@core = spec
|
|
61
|
+
@@gems[name] = {
|
|
62
|
+
:spec => spec,
|
|
63
|
+
:base_path => base_path,
|
|
64
|
+
:namespaces => [ :nucleon ]
|
|
65
|
+
}
|
|
56
66
|
else
|
|
57
67
|
Manager.connection.register(base_path) do |data|
|
|
58
68
|
namespace = data[:namespace]
|
|
59
69
|
plugin_path = data[:directory]
|
|
60
|
-
|
|
70
|
+
|
|
61
71
|
unless @@gems.has_key?(name)
|
|
62
72
|
logger.info("Registering gem #{name} at #{plugin_path} at #{Time.now}")
|
|
63
|
-
|
|
64
|
-
unless loaded.include?(name)
|
|
65
|
-
|
|
66
|
-
|
|
73
|
+
|
|
74
|
+
unless @@gateways.include?(name.to_s) || loaded.include?(name)
|
|
75
|
+
base_loader = File.join(base_path, "#{name}_base.rb")
|
|
76
|
+
loader = File.join(base_path, "#{name}.rb")
|
|
77
|
+
|
|
78
|
+
if File.exists?(base_loader)
|
|
79
|
+
require base_loader
|
|
80
|
+
elsif File.exists?(loader)
|
|
81
|
+
require loader
|
|
82
|
+
end
|
|
67
83
|
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
@@gems[name] = {
|
|
71
|
-
:spec => spec,
|
|
72
|
-
:base_path => base_path,
|
|
73
|
-
:namespaces => []
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
@@gems[name] = {
|
|
87
|
+
:spec => spec,
|
|
88
|
+
:base_path => base_path,
|
|
89
|
+
:namespaces => []
|
|
74
90
|
}
|
|
75
91
|
@@gems[name][:namespaces] << namespace unless @@gems[name][:namespaces].include?(namespace)
|
|
76
92
|
end
|
|
77
93
|
end
|
|
78
94
|
end
|
|
79
|
-
|
|
95
|
+
|
|
80
96
|
#-----------------------------------------------------------------------------
|
|
81
97
|
# Utilities
|
|
82
|
-
|
|
98
|
+
|
|
83
99
|
def self.each_gem(&block)
|
|
84
|
-
if defined?(Gem)
|
|
100
|
+
if defined?(Gem)
|
|
85
101
|
if ! defined?(Bundler) && Gem::Specification.respond_to?(:latest_specs)
|
|
86
102
|
logger.debug("Not using bundler")
|
|
87
103
|
Gem::Specification.latest_specs(true).each do |spec|
|
|
@@ -91,13 +107,13 @@ module Gems
|
|
|
91
107
|
logger.debug("Using bundler or Gem specification without latest_specs")
|
|
92
108
|
Gem.loaded_specs.each do |name, spec|
|
|
93
109
|
block.call(spec)
|
|
94
|
-
end
|
|
110
|
+
end
|
|
95
111
|
end
|
|
96
112
|
end
|
|
97
113
|
end
|
|
98
|
-
|
|
114
|
+
|
|
99
115
|
#---
|
|
100
|
-
|
|
116
|
+
|
|
101
117
|
def self.exist?(*names)
|
|
102
118
|
checks = Hash[names.map{|name| [ name.to_s, true ] }]
|
|
103
119
|
each_gem do |spec|
|
|
@@ -105,13 +121,13 @@ module Gems
|
|
|
105
121
|
end
|
|
106
122
|
checks.empty? ? true : false
|
|
107
123
|
end
|
|
108
|
-
|
|
124
|
+
|
|
109
125
|
#---
|
|
110
|
-
|
|
126
|
+
|
|
111
127
|
def self.specs(*names)
|
|
112
128
|
checks = Hash[names.map{|name| [ name.to_s, true ] }]
|
|
113
129
|
specs = []
|
|
114
|
-
|
|
130
|
+
|
|
115
131
|
each_gem do |spec|
|
|
116
132
|
if checks.has_key?(spec.name.to_s)
|
|
117
133
|
specs << spec
|
|
@@ -119,9 +135,9 @@ module Gems
|
|
|
119
135
|
end
|
|
120
136
|
specs
|
|
121
137
|
end
|
|
122
|
-
|
|
138
|
+
|
|
123
139
|
#---
|
|
124
|
-
|
|
140
|
+
|
|
125
141
|
def self.spec(name)
|
|
126
142
|
results = specs(name)
|
|
127
143
|
return results[0] unless results.empty?
|
data/lib/core/manager.rb
CHANGED
|
@@ -1,34 +1,127 @@
|
|
|
1
|
-
|
|
2
1
|
module Nucleon
|
|
2
|
+
#
|
|
3
|
+
# == Plugin manager
|
|
4
|
+
#
|
|
5
|
+
# The Nucleon::Manager class defines a manager for defined plugin types, loaded,
|
|
6
|
+
# metadata, and active instances.
|
|
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 accomplish 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
|
+
#
|
|
20
|
+
# See also:
|
|
21
|
+
# - Nucleon::Environment
|
|
22
|
+
# - Nucleon::Plugin::Base
|
|
23
|
+
#
|
|
3
24
|
class Manager
|
|
4
|
-
|
|
25
|
+
|
|
26
|
+
#
|
|
27
|
+
# Make instances of this class parallel capable (through Celluloid actors)
|
|
28
|
+
#
|
|
5
29
|
include Parallel
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
30
|
+
|
|
31
|
+
#*****************************************************************************
|
|
32
|
+
|
|
33
|
+
#
|
|
34
|
+
# Global collection of plugin manager supervisors or managers.
|
|
35
|
+
#
|
|
36
|
+
# If parallel is enabled this will be supervisors, otherwise just the managers.
|
|
37
|
+
#
|
|
38
|
+
@@supervisors = {}
|
|
39
|
+
|
|
40
|
+
#
|
|
41
|
+
# Accessor for the global supervisors (mostly for testing purposes)
|
|
42
|
+
#
|
|
43
|
+
def self.supervisors
|
|
44
|
+
@@supervisors
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
#
|
|
48
|
+
# Global collection of plugin manager environments.
|
|
49
|
+
#
|
|
50
|
+
# Environments are keyed by an actor id set by the manager
|
|
51
|
+
#
|
|
10
52
|
@@environments = {}
|
|
11
|
-
|
|
12
|
-
|
|
53
|
+
|
|
54
|
+
#
|
|
55
|
+
# Accessor for the global plugin manager environments (mostly for testing purposes)
|
|
56
|
+
#
|
|
57
|
+
def self.environments
|
|
58
|
+
@@environments
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
#*****************************************************************************
|
|
13
62
|
# Plugin manager interface
|
|
14
|
-
|
|
63
|
+
|
|
64
|
+
# Return a specified plugin manager instance
|
|
65
|
+
#
|
|
66
|
+
# * *Parameters*
|
|
67
|
+
# - [String, Symbol] *name* Name of the plugin manager (actor id)
|
|
68
|
+
# - [Boolean] *reset* Whether or not to reinitialize the manager
|
|
69
|
+
#
|
|
70
|
+
# * *Returns*
|
|
71
|
+
# - [Nucleon::Manager, Celluloid::Actor] Returns an interface to manage plugins
|
|
72
|
+
#
|
|
73
|
+
# * *Errors*
|
|
74
|
+
#
|
|
75
|
+
# See:
|
|
76
|
+
# - Nucleon::Facade#manager
|
|
77
|
+
#
|
|
15
78
|
def self.connection(name = :core, reset = false)
|
|
16
79
|
Nucleon.manager(@@supervisors, name, self, reset)
|
|
17
80
|
end
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
81
|
+
|
|
82
|
+
# Initialize a new Nucleon environment
|
|
83
|
+
#
|
|
84
|
+
# IMORTANT: The environment constructor should accept no parameters!
|
|
85
|
+
#
|
|
86
|
+
# * *Parameters*
|
|
87
|
+
# - [String, Symbol] *actor_id* Name of the plugin manager
|
|
88
|
+
# - [Boolean] *reset* Whether or not to reinitialize the manager
|
|
89
|
+
#
|
|
90
|
+
# * *Returns*
|
|
91
|
+
# - [Void] This method does not return a value
|
|
92
|
+
#
|
|
93
|
+
# * *Errors*
|
|
94
|
+
#
|
|
95
|
+
# See also:
|
|
96
|
+
# - Nucleon::Facade#logger
|
|
97
|
+
# - Nucleon::Environment
|
|
98
|
+
#
|
|
21
99
|
def initialize(actor_id, reset)
|
|
22
100
|
@logger = Nucleon.logger
|
|
23
|
-
@actor_id = actor_id
|
|
24
|
-
|
|
101
|
+
@actor_id = actor_id.to_sym
|
|
102
|
+
|
|
103
|
+
@provider_cache = {}
|
|
104
|
+
|
|
25
105
|
if reset || ! @@environments[@actor_id]
|
|
26
|
-
@@environments[@actor_id] = Environment.new
|
|
106
|
+
@@environments[@actor_id] = Environment.new
|
|
27
107
|
end
|
|
28
108
|
end
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
109
|
+
|
|
110
|
+
# Perform any cleanup operations during manager shutdown
|
|
111
|
+
#
|
|
112
|
+
# This only runs when in parallel mode.
|
|
113
|
+
#
|
|
114
|
+
# * *Parameters*
|
|
115
|
+
#
|
|
116
|
+
# * *Returns*
|
|
117
|
+
# - [Void] This method does not return a value
|
|
118
|
+
#
|
|
119
|
+
# * *Errors*
|
|
120
|
+
#
|
|
121
|
+
# See also:
|
|
122
|
+
# - #active_plugins
|
|
123
|
+
# - #remove
|
|
124
|
+
#
|
|
32
125
|
def parallel_finalize
|
|
33
126
|
active_plugins.each do |namespace, namespace_plugins|
|
|
34
127
|
namespace_plugins.each do |plugin_type, type_plugins|
|
|
@@ -38,261 +131,460 @@ class Manager
|
|
|
38
131
|
end
|
|
39
132
|
end
|
|
40
133
|
end
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
134
|
+
|
|
135
|
+
#
|
|
136
|
+
# [Nucleon::Util::Logger] Instance logger
|
|
137
|
+
#
|
|
44
138
|
attr_reader :logger
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
139
|
+
|
|
140
|
+
#
|
|
141
|
+
# [Symbol] Plugin manager identifier
|
|
142
|
+
#
|
|
143
|
+
attr_reader :actor_id
|
|
144
|
+
|
|
145
|
+
# Return a reference to self
|
|
146
|
+
#
|
|
147
|
+
# This is needed so we can wrap instances in Celluloid actor proxies.
|
|
148
|
+
# Using self directly causes a lot of headaches.
|
|
149
|
+
#
|
|
150
|
+
# https://github.com/celluloid/celluloid/wiki/Gotchas#never-return-self-or-pass-self-as-an-argument-to-other-actors
|
|
151
|
+
#
|
|
152
|
+
# * *Parameters*
|
|
153
|
+
#
|
|
154
|
+
# * *Returns*
|
|
155
|
+
# - [Nucleon::Manager, Celluloid::Actor] Returns a reference to this manager instance
|
|
156
|
+
#
|
|
157
|
+
# * *Errors*
|
|
158
|
+
#
|
|
159
|
+
# See also:
|
|
160
|
+
# - Nucleon::Facade#handle
|
|
161
|
+
#
|
|
48
162
|
def myself
|
|
49
163
|
Nucleon.handle(self)
|
|
50
164
|
end
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
165
|
+
|
|
166
|
+
# Return true as a test method for checking for running manager
|
|
167
|
+
#
|
|
168
|
+
# This method should always return true and is only really called internally
|
|
169
|
+
# to perform a system check when running in parallel mode.
|
|
170
|
+
#
|
|
171
|
+
# * *Parameters*
|
|
172
|
+
#
|
|
173
|
+
# * *Returns*
|
|
174
|
+
# - [Nucleon::Manager, Celluloid::Actor] Returns a reference to this manager instance
|
|
175
|
+
#
|
|
176
|
+
# * *Errors*
|
|
177
|
+
#
|
|
178
|
+
# See also:
|
|
179
|
+
# - Nucleon::Facade#manager
|
|
180
|
+
# - Nucleon::Facade#test_connection
|
|
181
|
+
#
|
|
54
182
|
def test_connection
|
|
55
183
|
true
|
|
56
184
|
end
|
|
57
|
-
|
|
58
|
-
|
|
185
|
+
|
|
186
|
+
#*****************************************************************************
|
|
59
187
|
# Plugin model accessors / modifiers
|
|
60
|
-
|
|
188
|
+
|
|
189
|
+
# Return all of the defined namespaces in the plugin environment.
|
|
190
|
+
#
|
|
191
|
+
# * *Parameters*
|
|
192
|
+
#
|
|
193
|
+
# * *Returns*
|
|
194
|
+
# - [Array<Symbol>] Array of defined plugin namespaces
|
|
195
|
+
#
|
|
196
|
+
# * *Errors*
|
|
197
|
+
#
|
|
198
|
+
# See:
|
|
199
|
+
# - Nucleon::Environment#namespaces
|
|
200
|
+
#
|
|
61
201
|
def namespaces
|
|
62
202
|
@@environments[@actor_id].namespaces
|
|
63
203
|
end
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
204
|
+
|
|
205
|
+
# Return all of the defined plugin types in a plugin namespace.
|
|
206
|
+
#
|
|
207
|
+
# * *Parameters*
|
|
208
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
209
|
+
#
|
|
210
|
+
# * *Returns*
|
|
211
|
+
# - [Array<Symbol>] Array of defined plugin types
|
|
212
|
+
#
|
|
213
|
+
# * *Errors*
|
|
214
|
+
#
|
|
215
|
+
# See:
|
|
216
|
+
# - Nucleon::Environment#plugin_types
|
|
217
|
+
#
|
|
67
218
|
def types(namespace)
|
|
68
219
|
@@environments[@actor_id].plugin_types(namespace)
|
|
69
220
|
end
|
|
70
|
-
|
|
221
|
+
|
|
222
|
+
# Define a new plugin type in a specified namespace.
|
|
223
|
+
#
|
|
224
|
+
# * *Parameters*
|
|
225
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
226
|
+
# - [String, Symbol] *plugin_type* Plugin type name within namespace
|
|
227
|
+
# - [String, Symbol] *default_provider* Default provider
|
|
228
|
+
#
|
|
229
|
+
# * *Returns*
|
|
230
|
+
# - [Nucleon::Manager, Celluloid::Actor] Returns reference to self for compound operations
|
|
231
|
+
#
|
|
232
|
+
# * *Errors*
|
|
233
|
+
#
|
|
234
|
+
# See:
|
|
235
|
+
# - Nucleon::Environment#define_plugin_type
|
|
236
|
+
#
|
|
71
237
|
def define_type(namespace, plugin_type, default_provider)
|
|
72
|
-
@@environments[@actor_id].define_plugin_type(namespace, plugin_type, default_provider)
|
|
238
|
+
@@environments[@actor_id].define_plugin_type(namespace, plugin_type, default_provider)
|
|
239
|
+
myself
|
|
73
240
|
end
|
|
74
|
-
|
|
241
|
+
|
|
242
|
+
# Define one or more new plugin types in a specified namespace.
|
|
243
|
+
#
|
|
244
|
+
# * *Parameters*
|
|
245
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
246
|
+
# - [Hash<String, Symbol|String, Symbol>] *type_info* Plugin type, default provider pairs
|
|
247
|
+
#
|
|
248
|
+
# * *Returns*
|
|
249
|
+
# - [Nucleon::Manager, Celluloid::Actor] Returns reference to self for compound operations
|
|
250
|
+
#
|
|
251
|
+
# * *Errors*
|
|
252
|
+
#
|
|
253
|
+
# See:
|
|
254
|
+
# - Nucleon::Environment#define_plugin_types
|
|
255
|
+
#
|
|
75
256
|
def define_types(namespace, type_info)
|
|
76
|
-
@@environments[@actor_id].define_plugin_types(namespace, type_info)
|
|
257
|
+
@@environments[@actor_id].define_plugin_types(namespace, type_info)
|
|
77
258
|
end
|
|
78
|
-
|
|
259
|
+
|
|
260
|
+
# Check if a specified plugin type has been defined
|
|
261
|
+
#
|
|
262
|
+
# * *Parameters*
|
|
263
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
264
|
+
# - [String, Symbol] *plugin_type* Plugin type name to check within namespace
|
|
265
|
+
#
|
|
266
|
+
# * *Returns*
|
|
267
|
+
# - [Boolean] Returns true if plugin type exists, false otherwise
|
|
268
|
+
#
|
|
269
|
+
# * *Errors*
|
|
270
|
+
#
|
|
271
|
+
# See:
|
|
272
|
+
# - Nucleon::Environment#plugin_type_defined
|
|
273
|
+
#
|
|
79
274
|
def type_defined?(namespace, plugin_type)
|
|
80
|
-
@@environments[@actor_id].plugin_type_defined?(namespace, plugin_type)
|
|
275
|
+
@@environments[@actor_id].plugin_type_defined?(namespace, plugin_type)
|
|
81
276
|
end
|
|
82
|
-
|
|
277
|
+
|
|
278
|
+
# Return the default provider currently registered for a plugin type
|
|
279
|
+
#
|
|
280
|
+
# * *Parameters*
|
|
281
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
282
|
+
# - [String, Symbol] *plugin_type* Plugin type name to fetch default provider
|
|
283
|
+
#
|
|
284
|
+
# * *Returns*
|
|
285
|
+
# - [nil, Symbol] Returns default provider if plugin type exists, nil otherwise
|
|
286
|
+
#
|
|
287
|
+
# * *Errors*
|
|
288
|
+
#
|
|
289
|
+
# See:
|
|
290
|
+
# - Nucleon::Environment#plugin_type_default
|
|
291
|
+
#
|
|
83
292
|
def type_default(namespace, plugin_type)
|
|
84
293
|
@@environments[@actor_id].plugin_type_default(namespace, plugin_type)
|
|
85
294
|
end
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
295
|
+
|
|
296
|
+
# Return the load information for a specified plugin provider if it exists
|
|
297
|
+
#
|
|
298
|
+
# * *Parameters*
|
|
299
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
300
|
+
# - [String, Symbol] *plugin_type* Plugin type name of provider
|
|
301
|
+
# - [String, Symbol] *provider* Plugin provider to return load information
|
|
302
|
+
#
|
|
303
|
+
# * *Returns*
|
|
304
|
+
# - [nil, Hash<Symbol|ANY>] Returns provider load information if provider exists, nil otherwise
|
|
305
|
+
#
|
|
306
|
+
# * *Errors*
|
|
307
|
+
#
|
|
308
|
+
# See:
|
|
309
|
+
# - Nucleon::Environment#loaded_plugin
|
|
310
|
+
#
|
|
89
311
|
def loaded_plugin(namespace, plugin_type, provider)
|
|
90
|
-
@@environments[@actor_id].loaded_plugin(namespace, plugin_type, provider)
|
|
312
|
+
@@environments[@actor_id].loaded_plugin(namespace, plugin_type, provider)
|
|
91
313
|
end
|
|
92
|
-
|
|
314
|
+
|
|
315
|
+
# Return the load information for namespaces, plugin types, providers if it exists
|
|
316
|
+
#
|
|
317
|
+
# * *Parameters*
|
|
318
|
+
# - [nil, String, Symbol] *namespace* Namespace to return load information
|
|
319
|
+
# - [nil, String, Symbol] *plugin_type* Plugin type name to return load information
|
|
320
|
+
# - [nil, String, Symbol] *provider* Plugin provider to return load information
|
|
321
|
+
#
|
|
322
|
+
# * *Returns*
|
|
323
|
+
# - [nil, Hash<Symbol|Symbol|Symbol|Symbol|ANY>] Returns all load information if no parameters given
|
|
324
|
+
# - [nil, Hash<Symbol|Symbol|Symbol|ANY>] Returns namespace load information if only namespace given
|
|
325
|
+
# - [nil, Hash<Symbol|Symbol|ANY>] Returns plugin type load information if namespace and plugin type given
|
|
326
|
+
# - [nil, Hash<Symbol|ANY>] Returns provider load information if namespace, plugin type, and provider given
|
|
327
|
+
#
|
|
328
|
+
# * *Errors*
|
|
329
|
+
#
|
|
330
|
+
# See:
|
|
331
|
+
# - Nucleon::Environment#loaded_plugins
|
|
332
|
+
#
|
|
93
333
|
def loaded_plugins(namespace = nil, plugin_type = nil, provider = nil)
|
|
94
334
|
@@environments[@actor_id].loaded_plugins(namespace, plugin_type, provider)
|
|
95
335
|
end
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
336
|
+
|
|
337
|
+
# Define a new plugin provider of a specified plugin type.
|
|
338
|
+
#
|
|
339
|
+
# * *Parameters*
|
|
340
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
341
|
+
# - [String, Symbol] *plugin_type* Plugin type name to fetch default provider
|
|
342
|
+
# - [String] *base_path* Base load path of the plugin provider
|
|
343
|
+
# - [String] *file* File that contains the provider definition
|
|
344
|
+
#
|
|
345
|
+
# * *Returns*
|
|
346
|
+
# - [Nucleon::Manager, Celluloid::Actor] Returns reference to self for compound operations
|
|
347
|
+
#
|
|
348
|
+
# * *Errors*
|
|
349
|
+
#
|
|
350
|
+
# * *Yields*
|
|
351
|
+
# - [Hash<Symbol|ANY>] *data* Plugin load information
|
|
352
|
+
#
|
|
353
|
+
# See:
|
|
354
|
+
# - Nucleon::Environment#define_plugin
|
|
355
|
+
#
|
|
356
|
+
#
|
|
357
|
+
def define_plugin(namespace, plugin_type, base_path, file, &code) # :yields: data
|
|
358
|
+
@@environments[@actor_id].define_plugin(namespace, plugin_type, base_path, file, &code)
|
|
359
|
+
myself
|
|
99
360
|
end
|
|
100
|
-
|
|
361
|
+
|
|
362
|
+
# Check if a specified plugin provider has been loaded
|
|
363
|
+
#
|
|
364
|
+
# * *Parameters*
|
|
365
|
+
# - [String, Symbol] *namespace* Namespace that contains plugin types
|
|
366
|
+
# - [String, Symbol] *plugin_type* Plugin type name to check
|
|
367
|
+
# - [String, Symbol] *provider* Plugin provider name to check
|
|
368
|
+
#
|
|
369
|
+
# * *Returns*
|
|
370
|
+
# - [Boolean] Returns true if plugin provider has been loaded, false otherwise
|
|
371
|
+
#
|
|
372
|
+
# * *Errors*
|
|
373
|
+
#
|
|
374
|
+
# See:
|
|
375
|
+
# - Nucleon::Environment#plugin_has_provider?
|
|
376
|
+
#
|
|
101
377
|
def plugin_has_provider?(namespace, plugin_type, provider)
|
|
102
|
-
@@environments[@actor_id].plugin_has_provider?(namespace, plugin_type, provider)
|
|
378
|
+
@@environments[@actor_id].plugin_has_provider?(namespace, plugin_type, provider)
|
|
103
379
|
end
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
380
|
+
|
|
381
|
+
# Return active plugins for namespaces, plugin types, providers if specified
|
|
382
|
+
#
|
|
383
|
+
# * *Parameters*
|
|
384
|
+
# - [nil, String, Symbol] *namespace* Namespace to return plugin instance
|
|
385
|
+
# - [nil, String, Symbol] *plugin_type* Plugin type name to return plugin instance
|
|
386
|
+
# - [nil, String, Symbol] *provider* Plugin provider to return plugin instance
|
|
387
|
+
#
|
|
388
|
+
# * *Returns*
|
|
389
|
+
# - [nil, Hash<Symbol|Symbol|Symbol|Symbol|Nucleon::Plugin::Base>] Returns all plugin instances if no parameters given
|
|
390
|
+
# - [nil, Hash<Symbol|Symbol|Symbol|Nucleon::Plugin::Base>] Returns namespace plugin instances if only namespace given
|
|
391
|
+
# - [nil, Hash<Symbol|Symbol|Nucleon::Plugin::Base>] Returns plugin type instances if namespace and plugin type given
|
|
392
|
+
# - [nil, Hash<Symbol|Nucleon::Plugin::Base>] Returns provider instances if namespace, plugin type, and provider given
|
|
393
|
+
#
|
|
394
|
+
# * *Errors*
|
|
395
|
+
#
|
|
396
|
+
# See:
|
|
397
|
+
# - Nucleon::Plugin::Base
|
|
398
|
+
# - Nucleon::Environment#active_plugins
|
|
399
|
+
#
|
|
107
400
|
def active_plugins(namespace = nil, plugin_type = nil, provider = nil)
|
|
108
401
|
@@environments[@actor_id].active_plugins(namespace, plugin_type, provider)
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
#*****************************************************************************
|
|
112
405
|
# Plugin registration / initialization
|
|
113
|
-
|
|
406
|
+
|
|
114
407
|
def reload(core = false, loaded = [], &code)
|
|
115
408
|
logger.info("Loading Nucleon plugins at #{Time.now}")
|
|
116
|
-
|
|
409
|
+
|
|
117
410
|
if core
|
|
118
|
-
Celluloid.logger = logger if Nucleon.parallel?
|
|
119
|
-
|
|
411
|
+
Celluloid.logger = logger if Nucleon.parallel?
|
|
412
|
+
|
|
120
413
|
define_types :nucleon, {
|
|
121
|
-
:extension => nil,
|
|
122
|
-
:action => :
|
|
123
|
-
:project => :git,
|
|
124
|
-
:command => :bash,
|
|
125
|
-
:event => :regex,
|
|
126
|
-
:template => :json,
|
|
127
|
-
:translator => :json
|
|
414
|
+
:extension => nil, # Core
|
|
415
|
+
:action => :project_update, # Core
|
|
416
|
+
:project => :git, # Core
|
|
417
|
+
:command => :bash, # Core
|
|
418
|
+
:event => :regex, # Utility
|
|
419
|
+
:template => :json, # Utility
|
|
420
|
+
:translator => :json # Utility
|
|
128
421
|
}
|
|
129
422
|
end
|
|
130
|
-
|
|
423
|
+
|
|
131
424
|
# Allow block level namespace and type registration
|
|
132
425
|
code.call(:define, myself) if code
|
|
133
|
-
|
|
134
|
-
load_plugins(core, loaded, &code)
|
|
135
|
-
logger.info("Finished loading Nucleon plugins at #{Time.now}")
|
|
426
|
+
|
|
427
|
+
load_plugins(core, loaded, &code)
|
|
428
|
+
logger.info("Finished loading Nucleon plugins at #{Time.now}")
|
|
136
429
|
end
|
|
137
|
-
|
|
138
|
-
#---
|
|
139
|
-
|
|
430
|
+
|
|
140
431
|
def load_plugins(core = false, loaded = [], &code)
|
|
141
|
-
if core
|
|
432
|
+
if core
|
|
142
433
|
# Register core plugins
|
|
143
434
|
logger.info("Initializing core plugins at #{Time.now}")
|
|
144
435
|
register(File.join(File.dirname(__FILE__), '..'))
|
|
145
436
|
end
|
|
146
|
-
|
|
437
|
+
|
|
147
438
|
# Register external Gem defined plugins
|
|
148
439
|
Gems.register(true, Util::Data.array(loaded))
|
|
149
|
-
|
|
440
|
+
|
|
150
441
|
# Register any other extension plugins
|
|
151
442
|
exec(:register_plugins)
|
|
152
|
-
|
|
443
|
+
|
|
153
444
|
# Catch any block level requests before autoloading
|
|
154
445
|
code.call(:load, myself) if code
|
|
155
|
-
|
|
446
|
+
|
|
156
447
|
# Autoload all registered plugins
|
|
157
448
|
autoload
|
|
158
449
|
end
|
|
159
450
|
protected :load_plugins
|
|
160
|
-
|
|
161
|
-
#---
|
|
162
|
-
|
|
451
|
+
|
|
163
452
|
def register(base_path, &code)
|
|
164
453
|
namespaces.each do |namespace|
|
|
165
454
|
namespace_path = File.join(base_path, namespace.to_s)
|
|
166
455
|
register_namespace(namespace, namespace_path, &code)
|
|
167
456
|
end
|
|
168
457
|
end
|
|
169
|
-
|
|
170
|
-
#---
|
|
171
|
-
|
|
458
|
+
|
|
172
459
|
def register_namespace(namespace, base_path, &code)
|
|
173
460
|
if File.directory?(base_path)
|
|
174
461
|
logger.info("Loading files from #{base_path} at #{Time.now}")
|
|
175
|
-
|
|
462
|
+
|
|
176
463
|
Dir.glob(File.join(base_path, '*.rb')).each do |file|
|
|
177
464
|
logger.debug("Loading file: #{file}")
|
|
178
465
|
require file
|
|
179
466
|
end
|
|
180
|
-
|
|
467
|
+
|
|
181
468
|
logger.info("Loading directories from #{base_path} at #{Time.now}")
|
|
182
469
|
Dir.entries(base_path).each do |path|
|
|
183
470
|
unless path.match(/^\.\.?$/)
|
|
184
|
-
register_type(namespace, base_path, path, &code) if type_defined?(namespace, path)
|
|
471
|
+
register_type(namespace, base_path, path, &code) if type_defined?(namespace, path)
|
|
185
472
|
end
|
|
186
473
|
end
|
|
187
|
-
end
|
|
474
|
+
end
|
|
188
475
|
end
|
|
189
476
|
protected :register_namespace
|
|
190
|
-
|
|
191
|
-
#---
|
|
192
|
-
|
|
477
|
+
|
|
193
478
|
def register_type(namespace, base_path, plugin_type, &code)
|
|
194
479
|
base_directory = File.join(base_path, plugin_type.to_s)
|
|
195
|
-
|
|
480
|
+
|
|
196
481
|
if File.directory?(base_directory)
|
|
197
482
|
logger.info("Registering #{base_directory} at #{Time.now}")
|
|
198
|
-
|
|
483
|
+
|
|
199
484
|
Dir.glob(File.join(base_directory, '**', '*.rb')).each do |file|
|
|
200
485
|
define_plugin(namespace, plugin_type, base_directory, file, &code)
|
|
201
486
|
end
|
|
202
487
|
end
|
|
203
488
|
end
|
|
204
489
|
protected :register_type
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
490
|
+
|
|
491
|
+
# Autoload all of the defined plugins
|
|
492
|
+
#
|
|
493
|
+
# * *Parameters*
|
|
494
|
+
#
|
|
495
|
+
# * *Returns*
|
|
496
|
+
# - [Void] This method does not return a value
|
|
497
|
+
#
|
|
498
|
+
# * *Errors*
|
|
499
|
+
#
|
|
500
|
+
# See:
|
|
501
|
+
# - Nucleon::Environment#autoload
|
|
502
|
+
#
|
|
503
|
+
# See also:
|
|
504
|
+
# - #load
|
|
505
|
+
#
|
|
208
506
|
def autoload
|
|
209
507
|
logger.info("Autoloading registered plugins at #{Time.now}")
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
require plugin[:file]
|
|
221
|
-
|
|
222
|
-
load_info[namespace][plugin_type][provider][:class] = class_const(plugin[:class_components])
|
|
223
|
-
logger.debug("Updated #{plugin_type} #{provider} load info")
|
|
224
|
-
|
|
225
|
-
# Make sure extensions are listening from the time they are loaded
|
|
226
|
-
if plugin[:namespace] == :nucleon && plugin_type == :extension
|
|
227
|
-
# Create a persistent instance
|
|
228
|
-
load(plugin[:namespace], :extension, provider, { :name => provider })
|
|
229
|
-
end
|
|
230
|
-
end
|
|
508
|
+
|
|
509
|
+
@@environments[@actor_id].autoload do |namespace, plugin_type, provider, plugin|
|
|
510
|
+
logger.debug("Autoloading provider #{provider} at #{plugin[:directory]}")
|
|
511
|
+
|
|
512
|
+
# Make sure extensions are listening from the time they are loaded
|
|
513
|
+
if plugin[:namespace] == :nucleon && plugin_type == :extension
|
|
514
|
+
logger.debug("Creating #{plugin_type} #{provider}")
|
|
515
|
+
|
|
516
|
+
# Create a persistent instance
|
|
517
|
+
load(plugin[:namespace], :extension, provider, { :name => provider })
|
|
231
518
|
end
|
|
232
519
|
end
|
|
233
520
|
end
|
|
234
|
-
|
|
235
|
-
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
#*****************************************************************************
|
|
236
524
|
# Plugin workflow
|
|
237
|
-
|
|
525
|
+
|
|
238
526
|
def load_base(namespace, plugin_type, provider, options = {})
|
|
239
527
|
logger.info("Fetching plugin #{namespace} #{plugin_type} provider #{provider} at #{Time.now}")
|
|
240
|
-
|
|
528
|
+
|
|
241
529
|
type_info = loaded_plugin(namespace, plugin_type, provider)
|
|
242
|
-
options = translate_type(type_info, options)
|
|
530
|
+
options = translate_type(type_info, options)
|
|
243
531
|
config = Config.ensure(options)
|
|
244
532
|
name = config.get(:name, nil)
|
|
245
533
|
ensure_new = config.get(:new, false)
|
|
246
|
-
|
|
534
|
+
|
|
247
535
|
if name
|
|
248
536
|
logger.debug("Looking up existing instance of #{name}")
|
|
249
|
-
|
|
537
|
+
|
|
250
538
|
if existing_instance = get(namespace, plugin_type, name)
|
|
251
539
|
unless ensure_new
|
|
252
540
|
config.delete(:new)
|
|
253
|
-
|
|
541
|
+
|
|
254
542
|
config.export.each do |property_name, value|
|
|
255
543
|
unless [ :name, :meta ].include?(property_name)
|
|
256
|
-
existing_instance[property_name] = value
|
|
544
|
+
existing_instance[property_name] = value
|
|
257
545
|
end
|
|
258
546
|
end
|
|
259
547
|
existing_instance.normalize(true)
|
|
260
|
-
|
|
548
|
+
|
|
261
549
|
logger.debug("Using existing instance of #{plugin_type}, #{name}")
|
|
262
550
|
return existing_instance
|
|
263
551
|
end
|
|
264
552
|
end
|
|
265
553
|
end
|
|
266
|
-
create(namespace, plugin_type, provider, config)
|
|
554
|
+
create(namespace, plugin_type, provider, config)
|
|
267
555
|
end
|
|
268
|
-
|
|
269
|
-
#---
|
|
270
|
-
|
|
556
|
+
|
|
271
557
|
def load(namespace, plugin_type, provider = nil, options = {})
|
|
272
558
|
default_provider = type_default(namespace, plugin_type)
|
|
273
|
-
|
|
559
|
+
|
|
274
560
|
# Allow options to override provider
|
|
275
561
|
config = Config.ensure(options)
|
|
276
562
|
provider = config.delete(:provider, provider)
|
|
277
563
|
provider = default_provider unless provider
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
:namespace => namespace,
|
|
281
|
-
:type => plugin_type
|
|
282
|
-
}])
|
|
283
|
-
|
|
564
|
+
|
|
565
|
+
provider_data = Util::Data.merge([ config.export, {
|
|
566
|
+
:namespace => namespace,
|
|
567
|
+
:type => plugin_type
|
|
568
|
+
}])
|
|
569
|
+
provider_id = Nucleon.sha1(Util::Data.merge([ provider_data, { :provider => provider }]))
|
|
570
|
+
|
|
571
|
+
if @provider_cache.has_key?(provider_id)
|
|
572
|
+
provider = @provider_cache[provider_id]
|
|
573
|
+
else
|
|
574
|
+
provider = value(:manager_plugin_provider, provider, provider_data)
|
|
575
|
+
@provider_cache[provider_id] = provider
|
|
576
|
+
end
|
|
577
|
+
|
|
284
578
|
load_base(namespace, plugin_type, provider, config)
|
|
285
579
|
end
|
|
286
|
-
|
|
287
|
-
#---
|
|
288
|
-
|
|
580
|
+
|
|
289
581
|
def load_multiple(namespace, plugin_type, data, build_hash = false, keep_array = false)
|
|
290
582
|
logger.info("Fetching multiple plugins of #{plugin_type} at #{Time.now}")
|
|
291
|
-
|
|
583
|
+
|
|
292
584
|
group = ( build_hash ? {} : [] )
|
|
293
|
-
klass = plugin_class(namespace, plugin_type)
|
|
585
|
+
klass = plugin_class(namespace, plugin_type)
|
|
294
586
|
data = klass.build_info(namespace, plugin_type, data) if klass.respond_to?(:build_info)
|
|
295
|
-
|
|
587
|
+
|
|
296
588
|
data.each do |options|
|
|
297
589
|
if plugin = load(namespace, plugin_type, options[:provider], options)
|
|
298
590
|
if build_hash
|
|
@@ -303,45 +595,52 @@ class Manager
|
|
|
303
595
|
end
|
|
304
596
|
end
|
|
305
597
|
return group.shift if ! build_hash && group.length == 1 && ! keep_array
|
|
306
|
-
group
|
|
598
|
+
group
|
|
307
599
|
end
|
|
308
|
-
|
|
309
|
-
#---
|
|
310
|
-
|
|
600
|
+
|
|
311
601
|
def create(namespace, plugin_type, provider, options = {})
|
|
312
602
|
@@environments[@actor_id].create_plugin(namespace, plugin_type, provider, options) do |type_info, plugin_options|
|
|
313
603
|
logger.info("Creating new plugin #{provider} #{plugin_type}")
|
|
314
|
-
|
|
315
|
-
plugin_options = translate(type_info, plugin_options)
|
|
316
|
-
plugin_options[:meta] = Config.new(type_info).import(Util::Data.hash(plugin_options[:meta]))
|
|
317
|
-
plugin_options
|
|
604
|
+
translate(type_info, plugin_options)
|
|
318
605
|
end
|
|
319
606
|
end
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
607
|
+
|
|
608
|
+
# Return a plugin instance by name if it exists
|
|
609
|
+
#
|
|
610
|
+
# * *Parameters*
|
|
611
|
+
# - [String, Symbol] *namespace* Namespace that contains the plugin
|
|
612
|
+
# - [String, Symbol] *plugin_type* Plugin type name
|
|
613
|
+
# - [String, Symbol] *plugin_name* Plugin name to return
|
|
614
|
+
#
|
|
615
|
+
# * *Returns*
|
|
616
|
+
# - [nil, Nucleon::Plugin::Base] Returns a plugin instance of name specified if it exists
|
|
617
|
+
#
|
|
618
|
+
# * *Errors*
|
|
619
|
+
#
|
|
620
|
+
# See:
|
|
621
|
+
# - Nucleon::Plugin::Base
|
|
622
|
+
# - Nucleon::Environment#get_plugin
|
|
623
|
+
#
|
|
323
624
|
def get(namespace, plugin_type, plugin_name)
|
|
324
625
|
@@environments[@actor_id].get_plugin(namespace, plugin_type, plugin_name)
|
|
325
626
|
end
|
|
326
|
-
|
|
327
|
-
#---
|
|
328
|
-
|
|
627
|
+
|
|
329
628
|
def remove_by_name(namespace, plugin_type, plugin_instance_name)
|
|
330
629
|
active_instances = active_plugins(namespace, plugin_type)
|
|
331
|
-
|
|
630
|
+
|
|
332
631
|
if active_instances.has_key?(plugin_instance_name)
|
|
333
632
|
@@environments[@actor_id].remove_plugin(namespace, plugin_type, plugin_instance_name) do |plugin|
|
|
334
633
|
logger.debug("Removing #{plugin_type} #{plugin_instance_name}")
|
|
335
|
-
|
|
634
|
+
|
|
336
635
|
if plugin.respond_to?(:terminate) # For Celluloid plugins
|
|
337
|
-
plugin.terminate
|
|
636
|
+
plugin.terminate
|
|
338
637
|
else
|
|
339
|
-
plugin.remove_plugin
|
|
340
|
-
end
|
|
341
|
-
end
|
|
638
|
+
plugin.remove_plugin
|
|
639
|
+
end
|
|
640
|
+
end
|
|
342
641
|
end
|
|
343
642
|
end
|
|
344
|
-
|
|
643
|
+
|
|
345
644
|
def remove(plugin)
|
|
346
645
|
begin # TODO: Figure out what do do about the plugin proxy being terminated before respond_to? method called.
|
|
347
646
|
if plugin && plugin.respond_to?(:plugin_type)
|
|
@@ -350,57 +649,55 @@ class Manager
|
|
|
350
649
|
rescue
|
|
351
650
|
end
|
|
352
651
|
end
|
|
353
|
-
|
|
354
|
-
|
|
652
|
+
|
|
653
|
+
#*****************************************************************************
|
|
355
654
|
# Extension hook execution
|
|
356
|
-
|
|
655
|
+
|
|
357
656
|
def exec(method, options = {})
|
|
358
657
|
results = nil
|
|
359
|
-
|
|
360
|
-
logger.info("Executing extension hook #{Nucleon.blue(method)} at #{Nucleon.green(Time.now.to_s)}")
|
|
361
|
-
|
|
658
|
+
|
|
659
|
+
logger.info("Executing extension hook #{Nucleon.blue(method)} at #{Nucleon.green(Time.now.to_s)}")
|
|
660
|
+
|
|
362
661
|
extensions = active_plugins(:nucleon, :extension)
|
|
363
|
-
|
|
662
|
+
|
|
364
663
|
extensions.each do |name, plugin|
|
|
365
664
|
provider = plugin.plugin_provider
|
|
366
|
-
result = nil
|
|
367
|
-
|
|
665
|
+
result = nil
|
|
666
|
+
|
|
368
667
|
logger.debug("Checking extension #{provider}")
|
|
369
|
-
|
|
668
|
+
|
|
370
669
|
if plugin.respond_to?(method)
|
|
371
|
-
results = {} if results.nil?
|
|
372
|
-
|
|
670
|
+
results = {} if results.nil?
|
|
671
|
+
|
|
373
672
|
result = plugin.send(method, options)
|
|
374
673
|
logger.info("Completed hook #{method} at #{Time.now}")
|
|
375
|
-
|
|
674
|
+
|
|
376
675
|
if block_given?
|
|
377
676
|
results[provider] = yield(:process, result)
|
|
378
|
-
logger.debug("Processed extension result into: #{results[provider].inspect}")
|
|
677
|
+
logger.debug("Processed extension result into: #{results[provider].inspect}")
|
|
379
678
|
end
|
|
380
|
-
|
|
679
|
+
|
|
381
680
|
if results[provider].nil?
|
|
382
|
-
logger.debug("Setting extension result to: #{result.inspect}")
|
|
681
|
+
logger.debug("Setting extension result to: #{result.inspect}")
|
|
383
682
|
results[provider] = result
|
|
384
683
|
end
|
|
385
684
|
end
|
|
386
685
|
end
|
|
387
|
-
|
|
388
|
-
if ! results.nil? && block_given?
|
|
686
|
+
|
|
687
|
+
if ! results.nil? && block_given?
|
|
389
688
|
results = yield(:reduce, results)
|
|
390
689
|
logger.debug("Reducing extension results to: #{results.inspect}")
|
|
391
690
|
else
|
|
392
|
-
logger.debug("Final extension results: #{results.inspect}")
|
|
393
|
-
end
|
|
394
|
-
results
|
|
691
|
+
logger.debug("Final extension results: #{results.inspect}")
|
|
692
|
+
end
|
|
693
|
+
results
|
|
395
694
|
end
|
|
396
|
-
|
|
397
|
-
#---
|
|
398
|
-
|
|
695
|
+
|
|
399
696
|
def config(type, options = {})
|
|
400
697
|
config = Config.ensure(options)
|
|
401
|
-
|
|
698
|
+
|
|
402
699
|
logger.debug("Generating #{type} extended configuration")
|
|
403
|
-
|
|
700
|
+
|
|
404
701
|
exec("#{type}_config", Config.new(config.export)) do |op, data|
|
|
405
702
|
if op == :reduce
|
|
406
703
|
data.each do |provider, result|
|
|
@@ -410,18 +707,16 @@ class Manager
|
|
|
410
707
|
else
|
|
411
708
|
data
|
|
412
709
|
end
|
|
413
|
-
end
|
|
710
|
+
end
|
|
414
711
|
config.delete(:extension_type)
|
|
415
|
-
config
|
|
712
|
+
config
|
|
416
713
|
end
|
|
417
|
-
|
|
418
|
-
#---
|
|
419
|
-
|
|
714
|
+
|
|
420
715
|
def check(method, options = {})
|
|
421
716
|
config = Config.ensure(options)
|
|
422
|
-
|
|
717
|
+
|
|
423
718
|
logger.debug("Checking extension #{method}")
|
|
424
|
-
|
|
719
|
+
|
|
425
720
|
success = exec(method, config.import({ :extension_type => :check })) do |op, data|
|
|
426
721
|
if op == :reduce
|
|
427
722
|
! data.values.include?(false)
|
|
@@ -429,91 +724,146 @@ class Manager
|
|
|
429
724
|
data ? true : false
|
|
430
725
|
end
|
|
431
726
|
end
|
|
432
|
-
|
|
727
|
+
|
|
433
728
|
success = success.nil? || success ? true : false
|
|
434
|
-
|
|
435
|
-
logger.debug("Extension #{method} check result: #{success.inspect}")
|
|
729
|
+
|
|
730
|
+
logger.debug("Extension #{method} check result: #{success.inspect}")
|
|
436
731
|
success
|
|
437
732
|
end
|
|
438
|
-
|
|
439
|
-
#---
|
|
440
|
-
|
|
733
|
+
|
|
441
734
|
def value(method, value, options = {})
|
|
442
735
|
config = Config.ensure(options)
|
|
443
|
-
|
|
736
|
+
|
|
444
737
|
logger.debug("Setting extension #{method} value")
|
|
445
|
-
|
|
738
|
+
|
|
446
739
|
exec(method, config.import({ :value => value, :extension_type => :value })) do |op, data|
|
|
447
740
|
if op == :process
|
|
448
|
-
value = data unless data.nil?
|
|
741
|
+
value = data unless data.nil?
|
|
449
742
|
end
|
|
450
743
|
end
|
|
451
|
-
|
|
744
|
+
|
|
452
745
|
logger.debug("Extension #{method} retrieved value: #{value.inspect}")
|
|
453
746
|
value
|
|
454
747
|
end
|
|
455
|
-
|
|
456
|
-
#---
|
|
457
|
-
|
|
748
|
+
|
|
458
749
|
def collect(method, options = {})
|
|
459
750
|
config = Config.ensure(options)
|
|
460
751
|
values = []
|
|
461
|
-
|
|
752
|
+
|
|
462
753
|
logger.debug("Collecting extension #{method} values")
|
|
463
|
-
|
|
754
|
+
|
|
464
755
|
exec(method, config.import({ :extension_type => :collect })) do |op, data|
|
|
465
756
|
if op == :process
|
|
466
|
-
values << data unless data.nil?
|
|
757
|
+
values << data unless data.nil?
|
|
467
758
|
end
|
|
468
759
|
end
|
|
469
760
|
values = values.flatten
|
|
470
|
-
|
|
471
|
-
logger.debug("Extension #{method} collected values: #{values.inspect}")
|
|
761
|
+
|
|
762
|
+
logger.debug("Extension #{method} collected values: #{values.inspect}")
|
|
472
763
|
values
|
|
473
764
|
end
|
|
474
|
-
|
|
475
|
-
|
|
765
|
+
|
|
766
|
+
#*****************************************************************************
|
|
476
767
|
# Utilities
|
|
477
|
-
|
|
768
|
+
|
|
478
769
|
def translate_type(type_info, options)
|
|
479
770
|
if type_info
|
|
480
771
|
klass = plugin_class(type_info[:namespace], type_info[:type])
|
|
481
|
-
logger.debug("Executing option translation for: #{klass.inspect}")
|
|
482
|
-
|
|
772
|
+
logger.debug("Executing option translation for: #{klass.inspect}")
|
|
773
|
+
|
|
483
774
|
options = klass.send(:translate, options) if klass.respond_to?(:translate)
|
|
484
775
|
end
|
|
485
776
|
options
|
|
486
777
|
end
|
|
487
|
-
|
|
488
|
-
#---
|
|
489
|
-
|
|
778
|
+
|
|
490
779
|
def translate(type_info, options)
|
|
491
780
|
if type_info
|
|
492
781
|
klass = type_info[:class]
|
|
493
|
-
|
|
782
|
+
|
|
494
783
|
logger.debug("Executing option translation for: #{klass.inspect}")
|
|
495
|
-
|
|
784
|
+
|
|
496
785
|
options = klass.send(:translate, options) if klass.respond_to?(:translate)
|
|
497
786
|
end
|
|
498
787
|
options
|
|
499
788
|
end
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
789
|
+
|
|
790
|
+
# Return a fully formed class name as a string
|
|
791
|
+
#
|
|
792
|
+
# * *Parameters*
|
|
793
|
+
# - [String, Symbol, Array] *name* Class name components
|
|
794
|
+
# - [String, Symbol] *separator* Class component separator (default '::')
|
|
795
|
+
# - [Boolean] *want_array* Whether or not to return array of final components or string version
|
|
796
|
+
#
|
|
797
|
+
# * *Returns*
|
|
798
|
+
# - [String] Returns fully rendered class name as string unless want_array is true
|
|
799
|
+
# - [Array] Returns array of final class components if want_array is true
|
|
800
|
+
#
|
|
801
|
+
# * *Errors*
|
|
802
|
+
#
|
|
803
|
+
# See:
|
|
804
|
+
# - Nucleon::Environment#class_name
|
|
805
|
+
#
|
|
806
|
+
def class_name(name, separator = '::', want_array = false)
|
|
504
807
|
@@environments[@actor_id].class_name(name, separator, want_array)
|
|
505
808
|
end
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
809
|
+
|
|
810
|
+
# Return a fully formed class name as a machine usable constant
|
|
811
|
+
#
|
|
812
|
+
# * *Parameters*
|
|
813
|
+
# - [String, Symbol, Array] *name* Class name components
|
|
814
|
+
# - [String, Symbol] *separator* Class component separator (default '::')
|
|
815
|
+
#
|
|
816
|
+
# * *Returns*
|
|
817
|
+
# - [Class Constant] Returns class constant for fully formed class name of given components
|
|
818
|
+
#
|
|
819
|
+
# * *Errors*
|
|
820
|
+
#
|
|
821
|
+
# See:
|
|
822
|
+
# - Nucleon::Environment#class_const
|
|
823
|
+
#
|
|
509
824
|
def class_const(name, separator = '::')
|
|
510
825
|
@@environments[@actor_id].class_const(name, separator)
|
|
511
826
|
end
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
827
|
+
|
|
828
|
+
# Return a class constant representing a base plugin class generated from namespace and plugin_type.
|
|
829
|
+
#
|
|
830
|
+
# * *Parameters*
|
|
831
|
+
# - [String, Symbol] *namespace* Plugin namespace to constantize
|
|
832
|
+
# - [String, Symbol] *plugin_type* Plugin type to constantize
|
|
833
|
+
#
|
|
834
|
+
# * *Returns*
|
|
835
|
+
# - [String] Returns a class constant representing the plugin namespace and type
|
|
836
|
+
#
|
|
837
|
+
# * *Errors*
|
|
838
|
+
#
|
|
839
|
+
# See:
|
|
840
|
+
# - Nucleon::Environment#plugin_class
|
|
841
|
+
#
|
|
515
842
|
def plugin_class(namespace, plugin_type)
|
|
516
843
|
@@environments[@actor_id].plugin_class(namespace, plugin_type)
|
|
517
844
|
end
|
|
845
|
+
|
|
846
|
+
# Return a class constant representing a plugin provider class generated from
|
|
847
|
+
# namespace, plugin_type, and provider name.
|
|
848
|
+
#
|
|
849
|
+
# The provider name can be entered as an array if it is included in sub modules.
|
|
850
|
+
#
|
|
851
|
+
# * *Parameters*
|
|
852
|
+
# - [String, Symbol] *namespace* Plugin namespace to constantize
|
|
853
|
+
# - [String, Symbol] *plugin_type* Plugin type to constantize
|
|
854
|
+
# - [String, Symbol, Array] *provider* Plugin provider name to constantize
|
|
855
|
+
#
|
|
856
|
+
# * *Returns*
|
|
857
|
+
# - [String] Returns a class constant representing the plugin provider
|
|
858
|
+
#
|
|
859
|
+
# * *Errors*
|
|
860
|
+
#
|
|
861
|
+
# See also:
|
|
862
|
+
# - #class_const
|
|
863
|
+
# - #sanitize_class
|
|
864
|
+
#
|
|
865
|
+
def provider_class(namespace, plugin_type, provider)
|
|
866
|
+
@@environments[@actor_id].provider_class(namespace, plugin_type, provider)
|
|
867
|
+
end
|
|
518
868
|
end
|
|
519
869
|
end
|