fanforce-plugin-factory 0.41.0 → 1.6.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/.yardopts +5 -0
- data/.yardopts.rb +1 -0
- data/Gemfile +9 -0
- data/README.md +40 -75
- data/Rakefile +61 -4
- data/fanforce-plugin-factory.gemspec +21 -21
- data/lib/fanforce/plugin_factory.rb +16 -58
- data/lib/fanforce/plugin_factory/Rakefile +51 -0
- data/lib/fanforce/plugin_factory/Routes.rb +33 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/_bootstrap.scss +2 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/_common.scss +1 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/_directives.scss +7 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/_font-awesome.scss +1 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/_ui-select.scss +3 -0
- data/lib/fanforce/plugin_factory/{assets/lib/common → asset_framework/plugin_factory/bootstrap}/_bootstrap-overrides.scss +2 -0
- data/lib/fanforce/plugin_factory/{assets/lib/vendors/bootstrap/css → asset_framework/plugin_factory/bootstrap}/bootstrap.css +2 -2
- data/lib/fanforce/plugin_factory/{assets/lib/vendors/bootstrap/js → asset_framework/plugin_factory/bootstrap}/bootstrap.js +0 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/bootstrap/bootstrap.min.css +7 -0
- data/lib/fanforce/plugin_factory/{assets/lib/vendors/bootstrap/js → asset_framework/plugin_factory/bootstrap}/bootstrap.min.js +0 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/bootstrap/glyphicons-halflings-regular.eot +0 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/bootstrap/glyphicons-halflings-regular.svg +229 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/bootstrap/glyphicons-halflings-regular.ttf +0 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/bootstrap/glyphicons-halflings-regular.woff +0 -0
- data/lib/fanforce/plugin_factory/{assets/lib → asset_framework/plugin_factory}/common/_mixins.scss +2 -1
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/directives.coffee +1 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/directives/error/_error.scss +6 -0
- data/lib/fanforce/plugin_factory/{assets/lib/common/module-error → asset_framework/plugin_factory/directives/error}/arrow-left.png +0 -0
- data/lib/fanforce/plugin_factory/{assets/lib/common/module-error → asset_framework/plugin_factory/directives/error}/icon-error.png +0 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/directives/initiative-footer/_initiative-footer.coffee +16 -0
- data/lib/fanforce/plugin_factory/{assets/lib/common/_module-add-initiative-footer.scss → asset_framework/plugin_factory/directives/initiative-footer/_initiative-footer.scss} +4 -1
- data/lib/fanforce/plugin_factory/{assets/lib/common/_module-initiative-searcher.scss → asset_framework/plugin_factory/directives/initiative-searcher/_initiative-searcher.scss} +14 -13
- data/lib/fanforce/plugin_factory/{assets/lib/common/module-initiative-searcher → asset_framework/plugin_factory/directives/initiative-searcher}/icon-search.png +0 -0
- data/lib/fanforce/plugin_factory/{assets/lib/common/module-initiative-searcher → asset_framework/plugin_factory/directives/initiative-searcher}/spinner.gif +0 -0
- data/lib/fanforce/plugin_factory/{assets/lib/common/module-initiative-searcher → asset_framework/plugin_factory/directives/initiative-searcher}/sprite-arrows.png +0 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/directives/loading/_loading.coffee +4 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/directives/loading/_loading.scss +4 -0
- data/lib/fanforce/plugin_factory/{assets/js/add_source_popup.js → asset_framework/plugin_factory/directives/saving-to-server/_saving-to-server.coffee} +0 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/directives/saving-to-server/_saving-to-server.scss +6 -0
- data/lib/fanforce/plugin_factory/{assets/lib/common/module-saving-initiative → asset_framework/plugin_factory/directives/saving-to-server}/spinner.gif +0 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/directives/start-arrow/_start-arrow.coffee +8 -0
- data/lib/fanforce/plugin_factory/{assets/lib/common/_module-start-here.scss → asset_framework/plugin_factory/directives/start-arrow/_start-arrow.scss} +5 -4
- data/lib/fanforce/plugin_factory/{assets/lib/common/module-start-here → asset_framework/plugin_factory/directives/start-arrow}/arrow.png +0 -0
- data/lib/fanforce/plugin_factory/{assets/lib/common/_module-video-thumbnail.scss → asset_framework/plugin_factory/directives/video-thumbnail/_video-thumbnail.scss} +4 -4
- data/lib/fanforce/plugin_factory/{assets/lib/common/module-video-thumbnail → asset_framework/plugin_factory/directives/video-thumbnail}/icon-play.png +0 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/font-awesome.coffee +1 -0
- data/lib/fanforce/plugin_factory/{assets/lib/vendors/font-awesome/font → asset_framework/plugin_factory/font-awesome}/FontAwesome.otf +0 -0
- data/lib/fanforce/plugin_factory/{assets/lib/vendors/font-awesome/css → asset_framework/plugin_factory/font-awesome}/font-awesome.css +2 -2
- data/lib/fanforce/plugin_factory/{assets/lib/vendors/font-awesome/css → asset_framework/plugin_factory/font-awesome}/font-awesome.min.css +0 -0
- data/lib/fanforce/plugin_factory/{assets/lib/vendors/font-awesome/font → asset_framework/plugin_factory/font-awesome}/fontawesome-webfont.eot +0 -0
- data/lib/fanforce/plugin_factory/{assets/lib/vendors/font-awesome/font → asset_framework/plugin_factory/font-awesome}/fontawesome-webfont.svg +0 -0
- data/lib/fanforce/plugin_factory/{assets/lib/vendors/font-awesome/font → asset_framework/plugin_factory/font-awesome}/fontawesome-webfont.ttf +0 -0
- data/lib/fanforce/plugin_factory/{assets/lib/vendors/font-awesome/font → asset_framework/plugin_factory/font-awesome}/fontawesome-webfont.woff +0 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/lib.coffee +1 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/lib/ng-focus-blur.js +68 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/lib/ng-visible.js +7 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/ui-select.coffee +1 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/ui-select/select.css +171 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/ui-select/select.js +1281 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/ui-select/select_override.scss +1 -0
- data/lib/fanforce/plugin_factory/asset_framework/plugin_factory/ui-select/selectize.default.css +443 -0
- data/lib/fanforce/plugin_factory/cli.rb +5 -0
- data/lib/fanforce/plugin_factory/cli/lib/bitbucket.rb +77 -0
- data/lib/fanforce/plugin_factory/cli/lib/bundler.rb +21 -0
- data/lib/fanforce/plugin_factory/cli/lib/env.rb +96 -0
- data/lib/fanforce/plugin_factory/cli/lib/git.rb +59 -0
- data/lib/fanforce/plugin_factory/cli/lib/heroku.rb +94 -0
- data/lib/fanforce/plugin_factory/cli/lib/iron.rb +71 -0
- data/lib/fanforce/plugin_factory/cli/lib/pow.rb +46 -0
- data/lib/fanforce/plugin_factory/cli/lib/scaffolding.rb +74 -0
- data/lib/fanforce/plugin_factory/cli/lib/scaffolding_file.rb +510 -0
- data/lib/fanforce/plugin_factory/cli/lib/uranium.rb +77 -0
- data/lib/fanforce/plugin_factory/cli/lib/utils.rb +57 -0
- data/lib/fanforce/plugin_factory/cli/scripts/config.rb +9 -0
- data/lib/fanforce/plugin_factory/cli/scripts/create.rb +64 -0
- data/lib/fanforce/plugin_factory/cli/scripts/destroy.rb +61 -0
- data/lib/fanforce/plugin_factory/cli/scripts/diff.rb +156 -0
- data/lib/fanforce/plugin_factory/cli/scripts/push.rb +88 -0
- data/lib/fanforce/plugin_factory/cli/scripts/restart.rb +41 -0
- data/lib/fanforce/plugin_factory/cli/scripts/setup.rb +70 -0
- data/lib/fanforce/plugin_factory/cli/scripts/update.rb +132 -0
- data/lib/fanforce/plugin_factory/cli_directory_of_plugins.rb +51 -0
- data/lib/fanforce/plugin_factory/cli_single_plugin.rb +52 -0
- data/lib/fanforce/plugin_factory/controllers/base_controller.rb +15 -0
- data/lib/fanforce/plugin_factory/core_config.rb +94 -0
- data/lib/fanforce/plugin_factory/directive_views/initiative-footer.haml +8 -0
- data/lib/fanforce/plugin_factory/load.rb +7 -0
- data/lib/fanforce/plugin_factory/load_iron_worker.rb +2 -0
- data/lib/fanforce/plugin_factory/load_sprockets.rb +2 -0
- data/lib/fanforce/plugin_factory/plugin.rb +60 -0
- data/lib/fanforce/plugin_factory/scaffolding/._.gitignore.registry +1 -0
- data/lib/fanforce/plugin_factory/scaffolding/._Gemfile.registry +3 -0
- data/lib/fanforce/plugin_factory/scaffolding/._Rakefile.registry +3 -0
- data/lib/fanforce/plugin_factory/scaffolding/._config.json.registry +2 -0
- data/lib/fanforce/plugin_factory/scaffolding/._config.ru.registry +4 -0
- data/lib/fanforce/plugin_factory/scaffolding/._favicon.ico.registry +1 -0
- data/lib/fanforce/plugin_factory/scaffolding/._robots.txt.registry +3 -0
- data/lib/fanforce/plugin_factory/scaffolding/.gitignore +27 -0
- data/lib/fanforce/plugin_factory/scaffolding/Gemfile +9 -0
- data/lib/fanforce/plugin_factory/scaffolding/Rakefile +7 -0
- data/lib/fanforce/plugin_factory/scaffolding/Routes.rb +67 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/css/._fembedded.scss.registry +4 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/css/._promotional.scss.registry +4 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/css/._visitor.scss.registry +4 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/css/fembedded.scss +24 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/css/promotional.scss +33 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/css/visitor.scss +61 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/img/._icon-16.png.registry +1 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/img/._icon-32.png.registry +1 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/img/._icon-42.png.registry +1 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/img/._marketplace.png.registry +1 -0
- data/lib/fanforce/plugin_factory/{assets → scaffolding/assets}/img/icon-16.png +0 -0
- data/lib/fanforce/plugin_factory/{assets → scaffolding/assets}/img/icon-32.png +0 -0
- data/lib/fanforce/plugin_factory/{assets → scaffolding/assets}/img/icon-42.png +0 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/img/marketplace.png +0 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/img/promotional/._fanforce_bg.png.registry +1 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/img/promotional/._icon-42.png.registry +1 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/img/promotional/._icon-plus.png.registry +1 -0
- data/lib/fanforce/plugin_factory/{assets/lib → scaffolding/assets/img}/promotional/fanforce_bg.png +0 -0
- data/lib/fanforce/plugin_factory/{assets/lib → scaffolding/assets/img}/promotional/icon-42.png +0 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/img/promotional/icon-plus.png +0 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/js/._fembedded-app.coffee.registry +5 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/js/._fembedded.js.registry +3 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/js/._promotional.js.registry +3 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/js/fembedded-app.coffee +11 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/js/fembedded.js +12 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/js/lib/._cookie.coffee.registry +3 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/js/lib/._filters.coffee.registry +3 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/js/lib/._utils.coffee.registry +3 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/js/lib/cookie.coffee +24 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/js/lib/filters.coffee +9 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/js/lib/utils.coffee +40 -0
- data/lib/fanforce/plugin_factory/scaffolding/assets/js/promotional.js +4 -0
- data/lib/fanforce/plugin_factory/scaffolding/config.json +24 -0
- data/lib/fanforce/plugin_factory/scaffolding/config.ru +8 -0
- data/lib/fanforce/plugin_factory/{public → scaffolding}/favicon.ico +0 -0
- data/lib/fanforce/plugin_factory/scaffolding/layouts/._fembedded.haml.registry +4 -0
- data/lib/fanforce/plugin_factory/scaffolding/layouts/._promotional.haml.registry +2 -0
- data/lib/fanforce/plugin_factory/scaffolding/layouts/._visitor.haml.registry +6 -0
- data/lib/fanforce/plugin_factory/scaffolding/layouts/fembedded.haml +26 -0
- data/lib/fanforce/plugin_factory/{layouts → scaffolding/layouts}/promotional.haml +6 -6
- data/lib/fanforce/plugin_factory/{layouts/engage.haml → scaffolding/layouts/visitor.haml} +10 -7
- data/lib/fanforce/plugin_factory/scaffolding/robots.txt +7 -0
- data/lib/fanforce/plugin_factory/scaffolding/views/._index.haml.registry +3 -0
- data/lib/fanforce/plugin_factory/{views → scaffolding/views}/index.haml +13 -7
- data/lib/fanforce/plugin_factory/sinatra/_load.rb +87 -0
- data/lib/fanforce/plugin_factory/sinatra/error_handling.rb +48 -0
- data/lib/fanforce/plugin_factory/sinatra/helper_routes/com_behavior.rb +19 -0
- data/lib/fanforce/plugin_factory/sinatra/helper_routes/com_broadcaster.rb +7 -0
- data/lib/fanforce/plugin_factory/sinatra/helper_routes/com_connector.rb +11 -0
- data/lib/fanforce/plugin_factory/sinatra/helper_routes/com_identifier.rb +3 -0
- data/lib/fanforce/plugin_factory/sinatra/helper_routes/com_js_widget.rb +8 -0
- data/lib/fanforce/plugin_factory/sinatra/helper_routes/plugin.rb +50 -0
- data/lib/fanforce/plugin_factory/sinatra/helpers/assets.rb +23 -0
- data/lib/fanforce/plugin_factory/sinatra/helpers/css_frameworks.rb +70 -0
- data/lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb +18 -0
- data/lib/fanforce/plugin_factory/{config → sinatra}/helpers/json.rb +2 -2
- data/lib/fanforce/plugin_factory/sinatra/helpers/ractive.rb +45 -0
- data/lib/fanforce/plugin_factory/sprockets/compiler.rb +5 -11
- data/lib/fanforce/plugin_factory/sprockets/hacks.rb +2 -2
- data/lib/fanforce/plugin_factory/version.rb +2 -2
- metadata +201 -195
- data/.rbenv-gemsets +0 -1
- data/.rbenv-version +0 -1
- data/lib/fanforce/plugin_factory.rake +0 -72
- data/lib/fanforce/plugin_factory/_init_sinatra.rb +0 -54
- data/lib/fanforce/plugin_factory/assets/css/add_edit_initiative.scss +0 -1
- data/lib/fanforce/plugin_factory/assets/css/add_source.scss +0 -1
- data/lib/fanforce/plugin_factory/assets/css/convert_pending_initiative.scss +0 -1
- data/lib/fanforce/plugin_factory/assets/css/engage.scss +0 -1
- data/lib/fanforce/plugin_factory/assets/css/new_message.scss +0 -1
- data/lib/fanforce/plugin_factory/assets/css/promotional.scss +0 -1
- data/lib/fanforce/plugin_factory/assets/css/source_details.scss +0 -1
- data/lib/fanforce/plugin_factory/assets/js/add_edit_initiative.js +0 -1
- data/lib/fanforce/plugin_factory/assets/js/add_source.js +0 -1
- data/lib/fanforce/plugin_factory/assets/js/convert_pending_initiative.js +0 -1
- data/lib/fanforce/plugin_factory/assets/js/engage.js +0 -1
- data/lib/fanforce/plugin_factory/assets/js/new_message.js +0 -1
- data/lib/fanforce/plugin_factory/assets/js/promotional.js +0 -2
- data/lib/fanforce/plugin_factory/assets/js/source_details.js +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/common/_module-error.scss +0 -11
- data/lib/fanforce/plugin_factory/assets/lib/common/_module-page-loading.scss +0 -1
- data/lib/fanforce/plugin_factory/assets/lib/common/_module-saving-initiative.scss +0 -6
- data/lib/fanforce/plugin_factory/assets/lib/common/_tags.scss +0 -1
- data/lib/fanforce/plugin_factory/assets/lib/common/_variables.scss +0 -27
- data/lib/fanforce/plugin_factory/assets/lib/common/broadcaster-divider-arrow.png +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/common/icons/dropdown-arrow.png +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/common/icons/initiative.png +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/common/layouts/_add_edit_initiative.scss +0 -27
- data/lib/fanforce/plugin_factory/assets/lib/common/layouts/_add_source.scss +0 -18
- data/lib/fanforce/plugin_factory/assets/lib/common/layouts/_convert_pending_initiative.scss +0 -27
- data/lib/fanforce/plugin_factory/assets/lib/common/layouts/_engage.scss +0 -78
- data/lib/fanforce/plugin_factory/assets/lib/common/layouts/_new_message.scss +0 -24
- data/lib/fanforce/plugin_factory/assets/lib/common/layouts/_promotional.scss +0 -27
- data/lib/fanforce/plugin_factory/assets/lib/common/layouts/_source_details.scss +0 -17
- data/lib/fanforce/plugin_factory/assets/lib/common/layouts/add_edit_initiative.js +0 -6
- data/lib/fanforce/plugin_factory/assets/lib/common/layouts/add_source.js +0 -6
- data/lib/fanforce/plugin_factory/assets/lib/common/layouts/convert_pending_initiative.js +0 -6
- data/lib/fanforce/plugin_factory/assets/lib/common/layouts/engage.js +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/common/layouts/new_message.js +0 -5
- data/lib/fanforce/plugin_factory/assets/lib/common/layouts/promotional.js +0 -1
- data/lib/fanforce/plugin_factory/assets/lib/common/layouts/source_details.js +0 -5
- data/lib/fanforce/plugin_factory/assets/lib/promotional/icon-behavior.png +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/promotional/icon-broadcaster.png +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/promotional/icon-data-connector.png +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/promotional/icon-data-processor.png +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/promotional/icon-identifier.png +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap-datepicker/datepicker.css +0 -7
- data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap-datepicker/datepicker.js +0 -454
- data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap-timepicker/timepicker.css +0 -82
- data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap-timepicker/timepicker.js +0 -803
- data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap/css/bootstrap.min.css +0 -7
- data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap/img/glyphicons-halflings-regular.eot +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap/img/glyphicons-halflings-regular.svg +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap/img/glyphicons-halflings-regular.ttf +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap/img/glyphicons-halflings-regular.woff +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/vendors/chosen/_chosen_override.scss +0 -6
- data/lib/fanforce/plugin_factory/assets/lib/vendors/chosen/chosen-sprite.png +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/vendors/chosen/chosen-sprite@2x.png +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/vendors/chosen/chosen.jquery.js +0 -1166
- data/lib/fanforce/plugin_factory/assets/lib/vendors/chosen/chosen.scss +0 -434
- data/lib/fanforce/plugin_factory/assets/lib/vendors/jquery/jquery-1.10.2.js +0 -9789
- data/lib/fanforce/plugin_factory/assets/lib/vendors/jquery/jquery.inputHint.js +0 -154
- data/lib/fanforce/plugin_factory/assets/lib/vendors/jquery/jquery.tmpl.debug.js +0 -484
- data/lib/fanforce/plugin_factory/assets/lib/vendors/knockout/knockout.custom-handlers.coffee +0 -155
- data/lib/fanforce/plugin_factory/assets/lib/vendors/knockout/knockout.debug.js +0 -4469
- data/lib/fanforce/plugin_factory/assets/lib/vendors/knockout/knockout.min.js +0 -96
- data/lib/fanforce/plugin_factory/assets/lib/vendors/select2/_select2_override.scss +0 -47
- data/lib/fanforce/plugin_factory/assets/lib/vendors/select2/select2-spinner.gif +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/vendors/select2/select2.png +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/vendors/select2/select2.scss +0 -617
- data/lib/fanforce/plugin_factory/assets/lib/vendors/select2/select2_modified.js +0 -3225
- data/lib/fanforce/plugin_factory/assets/lib/vendors/select2/select2x2.png +0 -0
- data/lib/fanforce/plugin_factory/assets/lib/vendors/underscore/underscore.debug.js +0 -999
- data/lib/fanforce/plugin_factory/config/_error_handling.rb +0 -27
- data/lib/fanforce/plugin_factory/config/core_config.rb +0 -92
- data/lib/fanforce/plugin_factory/config/helpers/assets.rb +0 -72
- data/lib/fanforce/plugin_factory/config/helpers/fanforce.rb +0 -19
- data/lib/fanforce/plugin_factory/layouts/add_edit_initiative.haml +0 -19
- data/lib/fanforce/plugin_factory/layouts/add_source.haml +0 -19
- data/lib/fanforce/plugin_factory/layouts/convert_pending_initiative.haml +0 -19
- data/lib/fanforce/plugin_factory/layouts/new_message.haml +0 -19
- data/lib/fanforce/plugin_factory/layouts/source_details.haml +0 -19
- data/lib/fanforce/plugin_factory/public/robots.txt +0 -2
- data/lib/fanforce/plugin_factory/routes.rb +0 -48
- data/lib/fanforce/plugin_factory/routes_behavior.rb +0 -34
- data/lib/fanforce/plugin_factory/routes_broadcaster.rb +0 -9
- data/lib/fanforce/plugin_factory/routes_data_connector.rb +0 -21
- data/lib/fanforce/plugin_factory/routes_identifier.rb +0 -3
- data/lib/fanforce/plugin_factory/views/add_initiative.haml +0 -1
- data/lib/fanforce/plugin_factory/views/add_source.haml +0 -1
- data/lib/fanforce/plugin_factory/views/close_popup.haml +0 -8
- data/lib/fanforce/plugin_factory/views/convert_pending_initiative.haml +0 -1
- data/lib/fanforce/plugin_factory/views/edit_initiative.haml +0 -1
- data/lib/fanforce/plugin_factory/views/engage.haml +0 -1
- data/lib/fanforce/plugin_factory/views/new_message.haml +0 -1
- data/lib/fanforce/plugin_factory/views/source_details.haml +0 -1
- data/lib/fanforce/plugin_factory/views/widget_tmpls.haml +0 -1
- data/lib/fanforce/plugin_factory_workers.rb +0 -2
@@ -0,0 +1,74 @@
|
|
1
|
+
class Fanforce::PluginFactory::CLI::Scaffolding
|
2
|
+
include Fanforce::PluginFactory::CLI::Utils
|
3
|
+
|
4
|
+
require_relative 'scaffolding_file'
|
5
|
+
|
6
|
+
attr_reader :plugin
|
7
|
+
|
8
|
+
def initialize(plugin)
|
9
|
+
@plugin = plugin
|
10
|
+
error 'Your .fanforce-plugin-factory file must specify a default fanforce_version_dependency' if !config[:fanforce_version_dependency]
|
11
|
+
end
|
12
|
+
|
13
|
+
def setup
|
14
|
+
if File.directory?("#{plugin.dir}/tmp")
|
15
|
+
log "#{'Found '.format(:green,:bold)} #{plugin._id}/tmp/"
|
16
|
+
else
|
17
|
+
Dir.mkdir("#{plugin.dir}/tmp")
|
18
|
+
log "#{'Created'.format(:green,:bold)} #{plugin._id}/tmp/"
|
19
|
+
end
|
20
|
+
files.each {|file| file.create }
|
21
|
+
end
|
22
|
+
|
23
|
+
def update
|
24
|
+
files_updated = false
|
25
|
+
files.each {|file| files_updated = true if file.update }
|
26
|
+
return files_updated
|
27
|
+
end
|
28
|
+
|
29
|
+
def metadata
|
30
|
+
# status = :exists, :current, :missing, :previous, :diverged, :forked
|
31
|
+
change_data = {}
|
32
|
+
files.each do |file|
|
33
|
+
next change_data[file.filepath] = {
|
34
|
+
status: File.directory?(file.filepath) ? :exists : :missing,
|
35
|
+
} if File.directory?(file.scaffold_filepath)
|
36
|
+
|
37
|
+
status = file.status
|
38
|
+
diff = file.diff_changes if [:previous,:diverged].include?(status)
|
39
|
+
insertions = 0
|
40
|
+
deletions = 0
|
41
|
+
diff.lines do |line|
|
42
|
+
next deletions += 1 if line[0] == '-'
|
43
|
+
next insertions += 1 if line[0] == '+'
|
44
|
+
end if diff
|
45
|
+
|
46
|
+
change_data[file.filepath] = {
|
47
|
+
status: status,
|
48
|
+
diff: diff,
|
49
|
+
insertions: insertions,
|
50
|
+
deletions: deletions
|
51
|
+
}
|
52
|
+
end
|
53
|
+
return change_data
|
54
|
+
end
|
55
|
+
|
56
|
+
######################################################################################################################
|
57
|
+
|
58
|
+
def files
|
59
|
+
Dir.glob("#{self.class.dir}/**/*", File::FNM_DOTMATCH).inject([]) do |files, scaffold_filepath|
|
60
|
+
next files if scaffold_filepath =~ /\.registry$/
|
61
|
+
next files if scaffold_filepath =~ /\/\.\.?$/
|
62
|
+
scaffold_filepath = "#{scaffold_filepath}/" if File.directory?(scaffold_filepath) and scaffold_filepath !~ /\/$/
|
63
|
+
files << Fanforce::PluginFactory::CLI::ScaffoldingFile.new(scaffold_filepath, plugin)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
######################################################################################################################
|
68
|
+
|
69
|
+
def self.dir
|
70
|
+
File.expand_path('scaffolding', Fanforce::PluginFactory.base_dir)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
@@ -0,0 +1,510 @@
|
|
1
|
+
class Fanforce::PluginFactory::CLI::ScaffoldingFile
|
2
|
+
include Fanforce::PluginFactory::CLI::Utils
|
3
|
+
|
4
|
+
require 'digest'
|
5
|
+
require 'multi_json'
|
6
|
+
require_gem 'diffy', 'diffy'
|
7
|
+
|
8
|
+
attr_reader :scaffold_filepath, :plugin
|
9
|
+
|
10
|
+
def initialize(scaffold_filepath, plugin=nil)
|
11
|
+
@scaffold_filepath = scaffold_filepath
|
12
|
+
@plugin = plugin
|
13
|
+
if plugin
|
14
|
+
@filepath = "#{plugin.dir}/" + scaffold_filepath.gsub("#{Fanforce::PluginFactory::CLI::Scaffolding.dir}/", '')
|
15
|
+
@relativepath = extract_relativepath(@filepath)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
if File.directory?(scaffold_filepath)
|
21
|
+
mkdir
|
22
|
+
return nil
|
23
|
+
end
|
24
|
+
|
25
|
+
return update if File.exists?(filepath)
|
26
|
+
|
27
|
+
contents = File.open(scaffold_filepath).read
|
28
|
+
File.open(filepath, 'w') {|f| f.write(cleanse_content(contents)) }
|
29
|
+
log "#{'Created'.format(:green,:bold)} #{relativepath}"
|
30
|
+
return true
|
31
|
+
end
|
32
|
+
|
33
|
+
def update
|
34
|
+
if File.directory?(scaffold_filepath)
|
35
|
+
mkdir
|
36
|
+
return nil
|
37
|
+
end
|
38
|
+
puts "[[ #{filepath} ]]"
|
39
|
+
is_missing = is_missing?
|
40
|
+
if !is_missing
|
41
|
+
return if is_corrupted?
|
42
|
+
return if is_forked?
|
43
|
+
return if is_current_version?
|
44
|
+
end
|
45
|
+
|
46
|
+
content = updated_content
|
47
|
+
File.open(filepath, 'w') {|f| f.write(content) }
|
48
|
+
|
49
|
+
log "#{(is_missing ? 'Created' : 'Updated').format(:green,:bold)} #{relativepath}"
|
50
|
+
return true
|
51
|
+
end
|
52
|
+
|
53
|
+
def status
|
54
|
+
return @status unless @status.nil?
|
55
|
+
if is_missing?
|
56
|
+
@status = :missing
|
57
|
+
elsif is_corrupted?
|
58
|
+
@status = :corrupted
|
59
|
+
elsif is_forked?
|
60
|
+
@status = :forked
|
61
|
+
elsif is_previous_version?
|
62
|
+
@status = :previous
|
63
|
+
elsif is_diverged?
|
64
|
+
@status = :diverged
|
65
|
+
elsif is_current_version?
|
66
|
+
@status = :current
|
67
|
+
else
|
68
|
+
error "Unknown status for #{relativepath}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def diff_changes
|
73
|
+
return nil if scaffold_filepath =~ /\/Routes\.rb$/
|
74
|
+
return nil if is_missing?
|
75
|
+
return nil if is_image_file?
|
76
|
+
|
77
|
+
original_contents = File.open(filepath).read
|
78
|
+
Diffy::Diff.new(original_contents, updated_content).to_s(:text)
|
79
|
+
end
|
80
|
+
|
81
|
+
######################################################################################################################
|
82
|
+
|
83
|
+
def mkdir
|
84
|
+
Dir.mkdir(filepath) if !File.directory?(filepath)
|
85
|
+
end
|
86
|
+
|
87
|
+
def extension
|
88
|
+
@extension ||= scaffold_filepath.match(/([^\/\.]+)$/)[1].to_s.downcase
|
89
|
+
end
|
90
|
+
|
91
|
+
def extension_type
|
92
|
+
@extension_type ||= extension.downcase.to_sym
|
93
|
+
end
|
94
|
+
|
95
|
+
######################################################################################################################
|
96
|
+
|
97
|
+
def scaffold_type(filepath=scaffold_filepath)
|
98
|
+
# :file, :image, :partial, :items, :json, :skipped
|
99
|
+
@scaffold_types ||= {}
|
100
|
+
return @scaffold_types[filepath] unless @scaffold_types[filepath].nil?
|
101
|
+
return if !File.exists?(filepath)
|
102
|
+
|
103
|
+
if is_image_file?
|
104
|
+
type = :image
|
105
|
+
elsif filepath =~ /\/.+\.json$/
|
106
|
+
type = :json
|
107
|
+
else
|
108
|
+
first_line = File.open(filepath).read.split("\n").first
|
109
|
+
if first_line
|
110
|
+
matches = first_line.match(/\s*\S+\s*PluginFactoryScaffolding\s*:\s*(FILE|PARTIAL|ITEMS|SKIPPED)/)
|
111
|
+
type = matches[1].downcase.to_sym if matches and matches[1]
|
112
|
+
end
|
113
|
+
end
|
114
|
+
raise "scaffold_type could not be read from file: #{filepath}" if !type
|
115
|
+
raise "scaffold_type (#{type}) is unknown: #{lines.first}" if ![:file, :image, :partial, :items, :json, :skipped].include?(type)
|
116
|
+
@scaffold_types[filepath] = type
|
117
|
+
end
|
118
|
+
|
119
|
+
######################################################################################################################
|
120
|
+
|
121
|
+
def is_missing?
|
122
|
+
return @is_missing unless @is_missing.nil?
|
123
|
+
@is_missing = !File.exists?(filepath)
|
124
|
+
end
|
125
|
+
|
126
|
+
def is_corrupted?
|
127
|
+
return @is_corrupted unless @is_corrupted.nil?
|
128
|
+
scaffold_type = scaffold_type(filepath)
|
129
|
+
if !scaffold_type
|
130
|
+
error "The first line of #{relativepath} should specify an PluginFactoryScaffolding type"
|
131
|
+
elsif scaffold_type == :json
|
132
|
+
begin MultiJson.load(File.open(filepath).read)
|
133
|
+
rescue Exception => e; error "Corrupted #{relativepath}: #{e.message}"; end
|
134
|
+
elsif scaffold_type == :partial
|
135
|
+
File.open(filepath).read.match(/^\s*\S+\s*END PARTIAL/)
|
136
|
+
end
|
137
|
+
@is_corrupted = false
|
138
|
+
end
|
139
|
+
|
140
|
+
def is_previous_version?
|
141
|
+
return @is_previous_version unless @is_previous_version.nil?
|
142
|
+
return @is_previous_version = false if is_current_version?
|
143
|
+
|
144
|
+
# :file, :image, :partial, :items, :json, :skipped
|
145
|
+
if [:file,:image,:partial].include?(scaffold_type)
|
146
|
+
@is_previous_version = digest_exists_in_registry?(current_digest)
|
147
|
+
elsif [:items].include?(scaffold_type)
|
148
|
+
list_exists_in_registry?(File.open(filepath).read)
|
149
|
+
elsif [:json].include?(scaffold_type)
|
150
|
+
json_exists_in_registry?(File.open(filepath).read)
|
151
|
+
elsif [:skipped].include?(scaffold_type)
|
152
|
+
return @is_previous_version = false
|
153
|
+
else
|
154
|
+
raise 'unknown scaffold_type'
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def is_forkable?
|
159
|
+
return @is_forkable unless @is_forkable.nil?
|
160
|
+
@is_forkable = !(scaffold_filepath =~ /\/(Routes\.rb|config\.json|.gitignore)$/)
|
161
|
+
end
|
162
|
+
|
163
|
+
def is_image_file?
|
164
|
+
return @is_image_file unless @is_image_file.nil?
|
165
|
+
@is_image_file = scaffold_filepath =~ /\.(png|jpg|gif|ico)$/
|
166
|
+
end
|
167
|
+
|
168
|
+
def is_forked?
|
169
|
+
return @is_forked unless @is_forked.nil?
|
170
|
+
return @is_forked = true if is_image_file? and !is_current_version? and !is_previous_version?
|
171
|
+
return @is_forked = false if !is_forkable?
|
172
|
+
@is_forked = File.open(filepath, &:readline).include?('FORKED')
|
173
|
+
end
|
174
|
+
|
175
|
+
def is_diverged?
|
176
|
+
return @is_diverged unless @is_diverged.nil?
|
177
|
+
@is_diverged = !is_current_version?
|
178
|
+
end
|
179
|
+
|
180
|
+
def is_current_version?
|
181
|
+
return @is_current unless @is_current.nil?
|
182
|
+
|
183
|
+
# :file, :image, :partial, :items, :json, :skipped
|
184
|
+
if [:file,:image].include?(scaffold_type)
|
185
|
+
@is_current = (current_digest == scaffold_digest)
|
186
|
+
elsif [:partial].include?(scaffold_type)
|
187
|
+
@is_current = (current_digest == updated_digest)
|
188
|
+
elsif [:items].include?(scaffold_type)
|
189
|
+
@is_current = list_matches_latest_registry?(File.open(filepath).read)
|
190
|
+
elsif [:json].include?(scaffold_type)
|
191
|
+
@is_current = json_matches_latest_registry?(File.open(filepath).read)
|
192
|
+
elsif [:skipped].include?(scaffold_type)
|
193
|
+
@is_current = true
|
194
|
+
else
|
195
|
+
raise 'unknown scaffold_type'
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
######################################################################################################################
|
200
|
+
|
201
|
+
def registry_filepath
|
202
|
+
scaffold_fileparts = scaffold_filepath.split('/')
|
203
|
+
"#{scaffold_fileparts[0...-1].join('/')}/._#{scaffold_fileparts[-1]}.registry"
|
204
|
+
end
|
205
|
+
|
206
|
+
def digest_exists_in_registry?(digest)
|
207
|
+
return false if !File.exists?(registry_filepath)
|
208
|
+
|
209
|
+
File.open(registry_filepath, 'r').each do |line|
|
210
|
+
version, previous_digest = line.strip.split(/:\s?/)
|
211
|
+
return true if digest == previous_digest
|
212
|
+
end
|
213
|
+
return false
|
214
|
+
end
|
215
|
+
|
216
|
+
def list_registry_rules(&block)
|
217
|
+
return @list_registry_rules unless @list_registry_rules.nil? or block
|
218
|
+
rules = {ADD: [], REM: [], OPT: []}
|
219
|
+
File.open(registry_filepath).each_line do |line|
|
220
|
+
rule_changes = MultiJson.load(line.split(':', 2)[1], symbolize_keys: true)
|
221
|
+
|
222
|
+
rule_changes[:ADD].each do |item|
|
223
|
+
item = item.strip
|
224
|
+
rules[:ADD] << item unless rules[:ADD].include?(item)
|
225
|
+
rules[:REM].delete(item)
|
226
|
+
rules[:OPT].delete(item)
|
227
|
+
end if rule_changes[:ADD]
|
228
|
+
|
229
|
+
rule_changes[:REM].each do |item|
|
230
|
+
item = item.strip
|
231
|
+
rules[:ADD].delete(item)
|
232
|
+
rules[:REM] << item unless rules[:REM].include?(item)
|
233
|
+
rules[:OPT].delete(item)
|
234
|
+
end if rule_changes[:REM]
|
235
|
+
|
236
|
+
rule_changes[:OPT].each do |item|
|
237
|
+
item = item.strip
|
238
|
+
rules[:ADD].delete(item)
|
239
|
+
rules[:REM].delete(item)
|
240
|
+
rules[:OPT] << item unless rules[:OPT].include?(item)
|
241
|
+
end if rule_changes[:OPT]
|
242
|
+
|
243
|
+
block.call(rules) if block
|
244
|
+
end
|
245
|
+
@list_registry_rules = rules
|
246
|
+
end
|
247
|
+
|
248
|
+
def list_matches_latest_registry?(contents)
|
249
|
+
raise if scaffold_type != :items
|
250
|
+
list = []
|
251
|
+
contents = contents.is_a?(Array) ? contents : contents.split("\n")
|
252
|
+
contents.each do |line|
|
253
|
+
line = line.strip
|
254
|
+
list << line if line.present? and line !~ /^\s*#/
|
255
|
+
end
|
256
|
+
list_registry_rules[:ADD].each do |item|
|
257
|
+
return false if !list.include?(item)
|
258
|
+
end
|
259
|
+
list_registry_rules[:REM].each do |item|
|
260
|
+
return false if list.include?(item)
|
261
|
+
end
|
262
|
+
return true
|
263
|
+
end
|
264
|
+
|
265
|
+
def list_exists_in_registry?(contents)
|
266
|
+
raise if scaffold_type != :items
|
267
|
+
list = []
|
268
|
+
contents = contents.is_a?(Array) ? contents : contents.split("\n")
|
269
|
+
contents.each do |line|
|
270
|
+
line = line.strip
|
271
|
+
list << line if line.present? and line !~ /^\s*#/
|
272
|
+
end
|
273
|
+
list_registry_rules do |rules|
|
274
|
+
rules[:ADD].each do |item|
|
275
|
+
next if !list.include?(item)
|
276
|
+
end
|
277
|
+
rules[:REM].each do |item|
|
278
|
+
next if list.include?(item)
|
279
|
+
end
|
280
|
+
return true
|
281
|
+
end
|
282
|
+
return false
|
283
|
+
end
|
284
|
+
|
285
|
+
def json_registry_rules(&block)
|
286
|
+
return @json_registry_rules unless @json_registry_rules.nil? or block
|
287
|
+
rules = {ADD: {}, REM: {}, OPT: {}}
|
288
|
+
File.open(registry_filepath).each_line do |line|
|
289
|
+
rule_changes = MultiJson.load(line.split(':', 2)[1], symbolize_keys: true)
|
290
|
+
update_json_registry_rules(:ADD, rule_changes[:ADD], rules, '.') if rule_changes[:ADD]
|
291
|
+
update_json_registry_rules(:REM, rule_changes[:REM], rules, '.') if rule_changes[:REM]
|
292
|
+
update_json_registry_rules(:OPT, rule_changes[:OPT], rules, '.') if rule_changes[:OPT]
|
293
|
+
block.call(rules) if block
|
294
|
+
end
|
295
|
+
@json_registry_rules = rules
|
296
|
+
end
|
297
|
+
|
298
|
+
def update_json_registry_rules(type, rule_changes, rules, key_path)
|
299
|
+
rule_changes.each do |rule_key, rule_value|
|
300
|
+
next update_json_registry_rules(type, rule_value, rules, "#{key_path}.#{rule_key}") if rule_value.is_a?(Hash)
|
301
|
+
if type == :ADD
|
302
|
+
json_rule(rules, :ADD, key_path, true)[rule_key] = rule_value
|
303
|
+
(rule = json_rule rules, :REM, key_path) && rule.delete(rule_key)
|
304
|
+
(rule = json_rule rules, :OPT, key_path) && rule.delete(rule_key)
|
305
|
+
elsif type == :REM
|
306
|
+
(rule = json_rule rules, :ADD, key_path) && rule.delete(rule_key)
|
307
|
+
json_rule(rules, :REM, key_path, true)[rule_key] = rule_value
|
308
|
+
(rule = json_rule rules, :OPT, key_path) && rule.delete(rule_key)
|
309
|
+
elsif type == :OPT
|
310
|
+
(rule = json_rule rules, :ADD, key_path) && rule.delete(rule_key)
|
311
|
+
(rule = json_rule rules, :REM, key_path) && rule.delete(rule_key)
|
312
|
+
json_rule(rules, :OPT, key_path, true)[rule_key] = rule_value
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
def json_rule(rules, type, key_path, create_hash_if_nil=false)
|
318
|
+
rule = rules[type]
|
319
|
+
key_path.gsub(/\.\./, '.').split('.').each do |key|
|
320
|
+
next if key.blank?
|
321
|
+
rule[key.to_sym] ||= {} if create_hash_if_nil
|
322
|
+
rule = rule[key.to_sym]
|
323
|
+
end
|
324
|
+
rule
|
325
|
+
end
|
326
|
+
|
327
|
+
def json_matches_latest_registry?(json)
|
328
|
+
hash = MultiJson.load(json, symbolize_keys: true)
|
329
|
+
subtract_hash_from_hash!(json_registry_rules[:OPT], hash)
|
330
|
+
return false if !hash_keys_match_hash_keys(json_registry_rules[:ADD], hash)
|
331
|
+
return false if hash_keys_overlap_hash_keys(json_registry_rules[:REM], hash)
|
332
|
+
return true
|
333
|
+
end
|
334
|
+
|
335
|
+
def json_exists_in_registry?(json)
|
336
|
+
original_hash = MultiJson.load(json, symbolize_keys: true)
|
337
|
+
json_registry_rules do |rules|
|
338
|
+
hash = original_hash.clone
|
339
|
+
subtract_hash_from_hash!(rules[:OPT], hash)
|
340
|
+
next if !hash_keys_match_hash_keys(rules[:ADD], hash)
|
341
|
+
next if hash_keys_overlap_hash_keys(rules[:REM], hash)
|
342
|
+
return true
|
343
|
+
end
|
344
|
+
return false
|
345
|
+
end
|
346
|
+
|
347
|
+
def subtract_hash_from_hash!(hash_to_subtract, hash_to_retain)
|
348
|
+
hash_to_subtract.each do |k,v|
|
349
|
+
next subtract_hash_from_hash!(v, hash_to_retain[k]) if v.is_a?(Hash) and hash_to_retain[k].is_a?(Hash)
|
350
|
+
hash_to_retain.delete(k) if hash_to_retain.is_a?(Hash)
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
def hash_keys_match_hash_keys(hash1, hash2)
|
355
|
+
hash1.each do |k,v|
|
356
|
+
return false if !hash_keys_match_hash_keys(v, hash2[k]) if v.is_a?(Hash) and hash2[k].is_a?(Hash)
|
357
|
+
return false if v.is_a?(Hash) and !hash2[k].is_a?(Hash)
|
358
|
+
return false if !hash2.has_key?(k)
|
359
|
+
end
|
360
|
+
return true
|
361
|
+
end
|
362
|
+
|
363
|
+
def hash_keys_overlap_hash_keys(hash1, hash2)
|
364
|
+
hash1.each do |k,v|
|
365
|
+
return true if hash_keys_overlap_hash_keys(v, hash2[k]) if v.is_a?(Hash) and hash2[k].is_a?(Hash)
|
366
|
+
return true if hash2.has_key?(k)
|
367
|
+
end
|
368
|
+
return false
|
369
|
+
end
|
370
|
+
|
371
|
+
def current_digest
|
372
|
+
return @current_digest unless @current_digest.nil?
|
373
|
+
if [:image,:file,:partial].include?(scaffold_type)
|
374
|
+
@current_digest = Digest::SHA1.file(filepath).hexdigest.strip
|
375
|
+
else
|
376
|
+
raise "There is no digest scaffold type: #{scaffold_type}"
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
def scaffold_digest
|
381
|
+
return @scaffold_digest unless @scaffold_digest.nil?
|
382
|
+
if [:image,:file].include?(scaffold_type)
|
383
|
+
@scaffold_digest = Digest::SHA1.file(scaffold_filepath).hexdigest.strip
|
384
|
+
elsif [:partial].include?(scaffold_type)
|
385
|
+
@scaffold_digest = Digest::SHA1.hexdigest(extract_partial(File.open(scaffold_filepath).read, scaffold_filepath)).strip
|
386
|
+
elsif [:items].include?(scaffold_type)
|
387
|
+
@scaffold_digest = Digest::SHA1.hexdigest(extract_items_from_scaffold).strip
|
388
|
+
else
|
389
|
+
raise "There is no digest scaffold type: #{scaffold_type}"
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
def updated_digest
|
394
|
+
return @updated_digest unless @updated_digest.nil?
|
395
|
+
@updated_digest = Digest::SHA1.hexdigest(updated_content).strip
|
396
|
+
end
|
397
|
+
|
398
|
+
def plugin_factory_line_for_gemfile
|
399
|
+
line = "gem 'fanforce-plugin-factory'"
|
400
|
+
return line if !config[:plugin_factory_gem].is_a?(Hash)
|
401
|
+
|
402
|
+
line += ", '#{config[:plugin_factory_gem][:version]}'" if config[:plugin_factory_gem][:version].present?
|
403
|
+
line += ", :path => '#{config[:plugin_factory_gem][:path]}'" if config[:plugin_factory_gem][:path].present?
|
404
|
+
line += ", :git => '#{config[:plugin_factory_gem][:git]}'" if config[:plugin_factory_gem][:git].present?
|
405
|
+
line
|
406
|
+
end
|
407
|
+
|
408
|
+
######################################################################################################################
|
409
|
+
|
410
|
+
def extract_partial(content, filepath)
|
411
|
+
raise if scaffold_type != :partial
|
412
|
+
partial = ''
|
413
|
+
found_end = false
|
414
|
+
content.lines.each do |line|
|
415
|
+
break found_end = true if is_line_ending_partial?(line)
|
416
|
+
partial += line
|
417
|
+
end
|
418
|
+
raise "END PARTIAL could not be found for #{extract_relativepath(filepath)}" if !found_end
|
419
|
+
return partial
|
420
|
+
end
|
421
|
+
|
422
|
+
def extract_post_partial(content, filepath)
|
423
|
+
raise if scaffold_type != :partial
|
424
|
+
post_partial = ''
|
425
|
+
found_end = false
|
426
|
+
content.lines.each do |line|
|
427
|
+
found_end ||= is_line_ending_partial?(line) || next
|
428
|
+
post_partial += line
|
429
|
+
end
|
430
|
+
error "END PARTIAL could not be found for #{extract_relativepath(filepath)}" if !found_end
|
431
|
+
return post_partial
|
432
|
+
end
|
433
|
+
|
434
|
+
def is_line_ending_partial?(line)
|
435
|
+
return true if extension_type == :haml and line =~ /^\s*-#\s*END PARTIAL/
|
436
|
+
return true if [:css,:scss,:js].include?(extension_type) and line =~ /^\s*\/\/\s*END PARTIAL/
|
437
|
+
return true if [:gemfile,:rb,:gitignore,:ru,:rakefile,:coffee,:txt].include?(extension_type) and line =~ /^\s*#\s*END PARTIAL/
|
438
|
+
end
|
439
|
+
|
440
|
+
def updated_content
|
441
|
+
if is_missing? or [:file,:image].include?(scaffold_type)
|
442
|
+
File.open(scaffold_filepath).read
|
443
|
+
elsif [:partial].include?(scaffold_type)
|
444
|
+
scaffold_partial = extract_partial(File.open(scaffold_filepath).read, scaffold_filepath)
|
445
|
+
current_post_partial = extract_post_partial(File.open(filepath).read, filepath)
|
446
|
+
cleanse_content(scaffold_partial + current_post_partial)
|
447
|
+
elsif [:items].include?(scaffold_type)
|
448
|
+
content = ''
|
449
|
+
items_to_add = list_registry_rules[:ADD].clone
|
450
|
+
items_to_rem = list_registry_rules[:REM].clone
|
451
|
+
File.open(filepath).read.lines do |line|
|
452
|
+
item = line.strip
|
453
|
+
content += line if !items_to_rem.include?(item)
|
454
|
+
items_to_add.delete(item)
|
455
|
+
end
|
456
|
+
content += "\n" if content !~ /\n$/
|
457
|
+
items_to_add.each do |item|
|
458
|
+
content += "#{item}\n"
|
459
|
+
end
|
460
|
+
cleanse_content(content)
|
461
|
+
elsif [:json].include?(scaffold_type)
|
462
|
+
hash = MultiJson.load(File.open(filepath).read, symbolize_keys: true)
|
463
|
+
json_registry_rules[:ADD].each {|k,v| hash[k] = v if !hash.has_key?(k) }
|
464
|
+
json_registry_rules[:REM].each {|k,v| hash.delete(k) }
|
465
|
+
cleanse_content(hash)
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
469
|
+
######################################################################################################################
|
470
|
+
|
471
|
+
def cleanse_content(contents)
|
472
|
+
if scaffold_filepath =~ /\/config\.json$/
|
473
|
+
cleanup_config_json(contents)
|
474
|
+
elsif scaffold_filepath =~ /\/Gemfile$/
|
475
|
+
cleanup_gemfile(contents)
|
476
|
+
else
|
477
|
+
contents
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
def cleanup_config_json(contents)
|
482
|
+
hash = contents.is_a?(Hash) ? contents : MultiJson.load(contents, symbolize_keys: true)
|
483
|
+
hash[:_id] ||= plugin._id
|
484
|
+
hash[:name] ||= plugin._id.titleize
|
485
|
+
hash[:description] ||= 'This is where you put a short plugin description.'
|
486
|
+
hash[:fanforce_version_dependency] = config[:fanforce_version_dependency]
|
487
|
+
hash[:created_with_plugin_factory_version] = Fanforce::PluginFactory::VERSION
|
488
|
+
cleaned = JSON.pretty_generate(hash)
|
489
|
+
return cleaned
|
490
|
+
end
|
491
|
+
|
492
|
+
def cleanup_gemfile(contents)
|
493
|
+
contents.gsub('gem FANFORCE-PLUGIN-FACTORY', plugin_factory_line_for_gemfile)
|
494
|
+
end
|
495
|
+
|
496
|
+
######################################################################################################################
|
497
|
+
|
498
|
+
def filepath
|
499
|
+
@filepath || (raise 'plugin is not set' if !plugin)
|
500
|
+
end
|
501
|
+
|
502
|
+
def relativepath
|
503
|
+
@relativepath || (raise 'plugin is not set' if !plugin)
|
504
|
+
end
|
505
|
+
|
506
|
+
def extract_relativepath(filepath)
|
507
|
+
filepath.gsub("#{Fanforce::CLI::DIR}/", '')
|
508
|
+
end
|
509
|
+
|
510
|
+
end
|