mini-pro-pkg 0.0.1
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 -0
- data/mini-pro-pkg.gemspec +12 -0
- data/stringex-2.8.6/Gemfile +51 -0
- data/stringex-2.8.6/MIT-LICENSE +20 -0
- data/stringex-2.8.6/README.md +162 -0
- data/stringex-2.8.6/Rakefile +57 -0
- data/stringex-2.8.6/VERSION +1 -0
- data/stringex-2.8.6/init.rb +3 -0
- data/stringex-2.8.6/lib/stringex/acts_as_url/adapter/active_record.rb +23 -0
- data/stringex-2.8.6/lib/stringex/acts_as_url/adapter/base.rb +240 -0
- data/stringex-2.8.6/lib/stringex/acts_as_url/adapter/data_mapper.rb +61 -0
- data/stringex-2.8.6/lib/stringex/acts_as_url/adapter/mongoid.rb +37 -0
- data/stringex-2.8.6/lib/stringex/acts_as_url/adapter.rb +26 -0
- data/stringex-2.8.6/lib/stringex/acts_as_url.rb +107 -0
- data/stringex-2.8.6/lib/stringex/configuration/acts_as_url.rb +50 -0
- data/stringex-2.8.6/lib/stringex/configuration/base.rb +58 -0
- data/stringex-2.8.6/lib/stringex/configuration/configurator.rb +25 -0
- data/stringex-2.8.6/lib/stringex/configuration/string_extensions.rb +20 -0
- data/stringex-2.8.6/lib/stringex/configuration.rb +4 -0
- data/stringex-2.8.6/lib/stringex/configuration_lite.rb +3 -0
- data/stringex-2.8.6/lib/stringex/core_ext.rb +10 -0
- data/stringex-2.8.6/lib/stringex/localization/backend/base.rb +13 -0
- data/stringex-2.8.6/lib/stringex/localization/backend/i18n.rb +86 -0
- data/stringex-2.8.6/lib/stringex/localization/backend/internal.rb +47 -0
- data/stringex-2.8.6/lib/stringex/localization/conversion_expressions.rb +154 -0
- data/stringex-2.8.6/lib/stringex/localization/converter.rb +129 -0
- data/stringex-2.8.6/lib/stringex/localization/default_conversions.rb +89 -0
- data/stringex-2.8.6/lib/stringex/localization.rb +112 -0
- data/stringex-2.8.6/lib/stringex/rails/railtie.rb +10 -0
- data/stringex-2.8.6/lib/stringex/string_extensions.rb +228 -0
- data/stringex-2.8.6/lib/stringex/unidecoder.rb +82 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x00.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x01.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x02.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x03.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x04.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x05.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x06.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x07.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x09.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x0a.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x0b.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x0c.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x0d.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x0e.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x0f.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x10.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x11.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x12.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x13.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x14.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x15.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x16.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x17.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x18.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x1e.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x1f.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x20.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x21.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x22.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x23.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x24.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x25.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x26.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x27.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x28.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x2e.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x2f.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x30.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x31.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x32.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x33.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x4d.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x4e.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x4f.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x50.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x51.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x52.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x53.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x54.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x55.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x56.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x57.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x58.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x59.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x5a.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x5b.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x5c.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x5d.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x5e.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x5f.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x60.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x61.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x62.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x63.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x64.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x65.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x66.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x67.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x68.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x69.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x6a.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x6b.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x6c.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x6d.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x6e.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x6f.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x70.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x71.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x72.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x73.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x74.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x75.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x76.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x77.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x78.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x79.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x7a.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x7b.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x7c.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x7d.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x7e.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x7f.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x80.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x81.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x82.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x83.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x84.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x85.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x86.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x87.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x88.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x89.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x8a.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x8b.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x8c.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x8d.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x8e.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x8f.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x90.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x91.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x92.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x93.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x94.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x95.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x96.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x97.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x98.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x99.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x9a.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x9b.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x9c.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x9d.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x9e.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/x9f.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xa0.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xa1.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xa2.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xa3.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xa4.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xac.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xad.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xae.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xaf.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xb0.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xb1.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xb2.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xb3.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xb4.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xb5.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xb6.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xb7.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xb8.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xb9.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xba.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xbb.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xbc.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xbd.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xbe.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xbf.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xc0.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xc1.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xc2.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xc3.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xc4.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xc5.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xc6.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xc7.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xc8.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xc9.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xca.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xcb.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xcc.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xcd.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xce.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xcf.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xd0.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xd1.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xd2.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xd3.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xd4.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xd5.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xd6.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xd7.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xf9.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xfa.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xfb.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xfc.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xfd.yml +256 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xfe.yml +257 -0
- data/stringex-2.8.6/lib/stringex/unidecoder_data/xff.yml +257 -0
- data/stringex-2.8.6/lib/stringex/version.rb +8 -0
- data/stringex-2.8.6/lib/stringex.rb +17 -0
- data/stringex-2.8.6/lib/stringex_lite.rb +15 -0
- data/stringex-2.8.6/locales/da.yml +76 -0
- data/stringex-2.8.6/locales/de.yml +77 -0
- data/stringex-2.8.6/locales/en.yml +69 -0
- data/stringex-2.8.6/locales/fr.yml +72 -0
- data/stringex-2.8.6/locales/nb.yml +76 -0
- data/stringex-2.8.6/locales/nl.yml +69 -0
- data/stringex-2.8.6/locales/no.yml +76 -0
- data/stringex-2.8.6/locales/pl.yml +88 -0
- data/stringex-2.8.6/locales/pt-BR.yml +69 -0
- data/stringex-2.8.6/locales/ru.yml +69 -0
- data/stringex-2.8.6/locales/sv.yml +76 -0
- data/stringex-2.8.6/stringex.gemspec +290 -0
- data/stringex-2.8.6/test/performance/localization_performance_test.rb +24 -0
- data/stringex-2.8.6/test/test_helper.rb +2 -0
- data/stringex-2.8.6/test/unit/acts_as_url/adapter/activerecord.rb +71 -0
- data/stringex-2.8.6/test/unit/acts_as_url/adapter/datamapper.rb +83 -0
- data/stringex-2.8.6/test/unit/acts_as_url/adapter/mongoid.rb +82 -0
- data/stringex-2.8.6/test/unit/acts_as_url_configuration_test.rb +51 -0
- data/stringex-2.8.6/test/unit/acts_as_url_integration_test.rb +425 -0
- data/stringex-2.8.6/test/unit/localization/da_test.rb +118 -0
- data/stringex-2.8.6/test/unit/localization/de_test.rb +118 -0
- data/stringex-2.8.6/test/unit/localization/default_test.rb +115 -0
- data/stringex-2.8.6/test/unit/localization/en_test.rb +118 -0
- data/stringex-2.8.6/test/unit/localization/fr_test.rb +118 -0
- data/stringex-2.8.6/test/unit/localization/nl_test.rb +118 -0
- data/stringex-2.8.6/test/unit/localization/pl_test.rb +118 -0
- data/stringex-2.8.6/test/unit/localization/pt_br_test.rb +118 -0
- data/stringex-2.8.6/test/unit/localization/ru_test.rb +130 -0
- data/stringex-2.8.6/test/unit/localization/sv_test.rb +118 -0
- data/stringex-2.8.6/test/unit/localization_18n_failure_test.rb +40 -0
- data/stringex-2.8.6/test/unit/localization_test.rb +162 -0
- data/stringex-2.8.6/test/unit/string_extensions_configuration_test.rb +17 -0
- data/stringex-2.8.6/test/unit/string_extensions_test.rb +321 -0
- data/stringex-2.8.6/test/unit/unicode_point_suite/basic_greek_test.rb +113 -0
- data/stringex-2.8.6/test/unit/unicode_point_suite/basic_latin_test.rb +144 -0
- data/stringex-2.8.6/test/unit/unicode_point_suite/codepoint_test_helper.rb +32 -0
- data/stringex-2.8.6/test/unit/unidecoder/bad_localization.yml +1 -0
- data/stringex-2.8.6/test/unit/unidecoder/localization.yml +4 -0
- data/stringex-2.8.6/test/unit/unidecoder_test.rb +104 -0
- data/stringex-2.8.6/test/unit/version_test.rb +12 -0
- metadata +294 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: '09fd35d121be2acfcf3c8d2e8ba4ebaedcce655d8abf5ee131b130fd9d5783c2'
|
|
4
|
+
data.tar.gz: f94dba04b71b8a327deca207ae7b77f17bcbe758eed686dc045fdf3227fc1179
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 345704c422c236cb4cb2fc44c9dbf6d6a1782d6425b32cbb66ff5e47fce2127d668af52c1efdbc2bc753218e7592e0474ecbb496c190ebc2435a35e23313d067
|
|
7
|
+
data.tar.gz: b482d68a418b4f3c5abdaf4af42b39fef65645f0057f96a2469d7cbd14a6698e103468083b2216b200a6d4348e1bdfcdb9492571038ce13ecc5f68b0b546417b
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Gem::Specification.new do |s|
|
|
2
|
+
s.name = "mini-pro-pkg"
|
|
3
|
+
s.version = "0.0.1"
|
|
4
|
+
s.summary = "Research test"
|
|
5
|
+
s.description = "University research based on stringex"
|
|
6
|
+
s.authors = ["Andrey78"]
|
|
7
|
+
s.email = ["cakoc614@gmail.com"]
|
|
8
|
+
s.files = Dir.glob("**/*").reject { |f| f.end_with?('.gem') }
|
|
9
|
+
s.homepage = "https://rubygems.org/profiles/Andrey78"
|
|
10
|
+
s.license = "MIT"
|
|
11
|
+
s.metadata = { "source_code_uri" => "https://github.com/Andrey78/mini-pro-pkg" }
|
|
12
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# A sample Gemfile
|
|
2
|
+
source 'https://rubygems.org'
|
|
3
|
+
|
|
4
|
+
def activerecord?
|
|
5
|
+
adapter.nil? || adapter == 'activerecord'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def datamapper?
|
|
9
|
+
adapter == 'datamapper'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def mongoid?
|
|
13
|
+
if RUBY_VERSION > '1.8.x'
|
|
14
|
+
adapter == 'mongoid'
|
|
15
|
+
else
|
|
16
|
+
puts 'Mongoid requires Ruby higher than 1.8.x'
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def adapter
|
|
21
|
+
ENV['ADAPTER']
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
group :development do
|
|
25
|
+
# Standard gems across gemfiles
|
|
26
|
+
gem 'jeweler', '2.3.7'
|
|
27
|
+
gem 'travis-lint', '1.7.0'
|
|
28
|
+
# Can I state that I really dislike camelcased gem names?
|
|
29
|
+
gem 'RedCloth', '4.2.9'
|
|
30
|
+
gem 'sqlite3', '1.3.10'
|
|
31
|
+
gem 'test-unit', '3.0.9'
|
|
32
|
+
|
|
33
|
+
if activerecord?
|
|
34
|
+
gem 'activerecord', '5.1.4'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
if datamapper?
|
|
38
|
+
gem 'dm-core', '1.2.1'
|
|
39
|
+
gem 'dm-migrations', '1.2.0'
|
|
40
|
+
gem 'dm-sqlite-adapter', '1.2.0'
|
|
41
|
+
gem 'dm-validations', '1.2.0'
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
if mongoid?
|
|
45
|
+
gem 'mongoid', '3.1.6'
|
|
46
|
+
gem 'i18n', '0.6.1'
|
|
47
|
+
else
|
|
48
|
+
# Everyone else can get the most up-to-date I18n
|
|
49
|
+
gem 'i18n', '0.7.0'
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2008-2014 Lucky Sneaks
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Stringex [<img src="https://codeclimate.com/github/rsl/stringex.svg" />](https://codeclimate.com/github/rsl/stringex) [<img src="https://travis-ci.org/rsl/stringex.svg?branch=master" alt="Build Status" />](https://travis-ci.org/rsl/stringex) [<img src="https://badge.fury.io/rb/stringex.svg" alt="Gem Version" />](http://badge.fury.io/rb/stringex)
|
|
2
|
+
|
|
3
|
+
Some [hopefully] useful extensions to Ruby's String class. It is made up of three libraries: ActsAsUrl, Unidecoder, and StringExtensions.
|
|
4
|
+
|
|
5
|
+
*NOTE: Stringex 2.0 [and beyond] drops support for Rails 2. If you need support for that version, use 1.5.1 instead.*
|
|
6
|
+
|
|
7
|
+
## ActsAsUrl
|
|
8
|
+
|
|
9
|
+
*NOTE: You can now require 'stringex_lite' instead of 'stringex' and skip loading ActsAsUrl functionality if you don't need it.*
|
|
10
|
+
|
|
11
|
+
This library is designed to create URI-friendly representations of an attribute, for use in generating urls from your attributes. Basic usage is just calling the method:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
# Inside your model
|
|
15
|
+
acts_as_url :title
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
which will populate the `url` attribute on the object with the converted contents of the `title` attribute. `acts_as_url` takes the following options:
|
|
19
|
+
|
|
20
|
+
| | |
|
|
21
|
+
|---|---|
|
|
22
|
+
| `:url_attribute` | The name of the attribute to use for storing the generated url string. Default is `:url` |
|
|
23
|
+
| `:scope` | The name of model attribute to scope unique urls to. There is no default here. |
|
|
24
|
+
| `:only_when_blank` | If set to true, the url generation will only happen when `:url_attribute` is blank. Default is false (meaning url generation will happen always). |
|
|
25
|
+
| `:sync_url` | If set to true, the url field will be updated when changes are made to the attribute it is based on. Default is false. |
|
|
26
|
+
| `:allow_slash` | If set to true, the url field will not convert slashes. Default is false. |
|
|
27
|
+
| `:allow_duplicates` | If set to true, unique urls will not be enforced. Default is false. *NOTE: This is strongly not recommended if you are routing solely on the generated slug as you will no longer be guaranteed to lookup the expected record based on a duplicate slug.* |
|
|
28
|
+
| `:limit` | If set, will limit length of url generated. Default is nil. |
|
|
29
|
+
| `:truncate_words` | Used with :limit. If set to false, the url will be truncated to the last whole word before the limit was reached. Default is true. |
|
|
30
|
+
| `:blacklist` | List of urls that should not be allowed. Default is `%w{new}` [which avoids confusion on urls like `/documents/new`]. |
|
|
31
|
+
| `:blacklist_policy` | Proc or lambda defining new naming behavior when blacklisted urls are encountered. Default converts `/documents/new` to `/documents/new-document`. |
|
|
32
|
+
|
|
33
|
+
In order to use the generated url attribute, you will probably want to
|
|
34
|
+
override `to_param` like so, in your Model:
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
# Inside your model
|
|
38
|
+
def to_param
|
|
39
|
+
url # or whatever you set :url_attribute to
|
|
40
|
+
end
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Routing called via named routes like `foo_path(@foo)` will automatically use the url. In your controllers you will need to call
|
|
44
|
+
`Foo.find_by_url(params[:id])` instead of the regular find. Don't look for `params[:url]` unless you set it explicitly in the routing, `to_param` will generate `params[:id]`.
|
|
45
|
+
|
|
46
|
+
Note that if you add `acts_as_url` to an existing model, the `url` database column will initially be blank. To set this column for your existing instances, you can use the `initialize_urls` method. So if your class is `Post`, just say `Post.initialize_urls`.
|
|
47
|
+
|
|
48
|
+
Unlike other permalink solutions, ActsAsUrl doesn't rely on Iconv (which is inconsistent across platforms and doesn't provide great transliteration as is) but instead uses a transliteration scheme (see the code for Unidecoder) which produces much better results for Unicode characters. It also mixes in some custom helpers to translate common characters into a more URI-friendly format rather than just dump them completely. Examples:
|
|
49
|
+
|
|
50
|
+
```ruby
|
|
51
|
+
# A simple prelude
|
|
52
|
+
"simple English".to_url => "simple-english"
|
|
53
|
+
"it's nothing at all".to_url => "its-nothing-at-all"
|
|
54
|
+
"rock & roll".to_url => "rock-and-roll"
|
|
55
|
+
|
|
56
|
+
# Let's show off
|
|
57
|
+
"$12 worth of Ruby power".to_url => "12-dollars-worth-of-ruby-power"
|
|
58
|
+
"10% off if you act now".to_url => "10-percent-off-if-you-act-now"
|
|
59
|
+
|
|
60
|
+
# You dont EVEN wanna rely on Iconv for this next part
|
|
61
|
+
"kick it en Français".to_url => "kick-it-en-francais"
|
|
62
|
+
"rock it Español style".to_url => "rock-it-espanol-style"
|
|
63
|
+
"tell your readers 你好".to_url => "tell-your-readers-ni-hao"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Compare those results with the ones produced on my Intel Mac by a leading permalink plugin:
|
|
67
|
+
|
|
68
|
+
```ruby
|
|
69
|
+
"simple English" # => "simple-english"
|
|
70
|
+
"it's nothing at all" # => "it-s-nothing-at-all"
|
|
71
|
+
"rock & roll" # => "rock-roll"
|
|
72
|
+
|
|
73
|
+
"$12 worth of Ruby power" # => "12-worth-of-ruby-power"
|
|
74
|
+
"10% off if you act now" # => "10-off-if-you-act-now"
|
|
75
|
+
|
|
76
|
+
"kick it en Français" # => "kick-it-en-francais"
|
|
77
|
+
"rock it Español style" # => "rock-it-espan-ol-style"
|
|
78
|
+
"tell your readers 你好" # => "tell-your-readers"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Not so great, actually.
|
|
82
|
+
|
|
83
|
+
Note: No offense is intended to the author(s) of whatever plugins might produce such results. It's not your faults Iconv sucks.
|
|
84
|
+
|
|
85
|
+
## Unidecoder
|
|
86
|
+
|
|
87
|
+
This library converts Unicode [and accented ASCII] characters to their plain-text ASCII equivalents. This is a port of Perl's Unidecode and provides eminently superior and more reliable results than Iconv. (Seriously, Iconv... A plague on both your houses! [sic])
|
|
88
|
+
|
|
89
|
+
You may require only the unidecoder (and its dependent localization) via
|
|
90
|
+
|
|
91
|
+
```ruby
|
|
92
|
+
require "stringex/unidecoder"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
You probably won't ever need to run Unidecoder by itself. Thus, you probably would want to add String#to_ascii which wraps all of Unidecoder's functionality, by requiring:
|
|
96
|
+
|
|
97
|
+
```ruby
|
|
98
|
+
require "stringex/core_ext"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
For anyone interested, details of the implementation can be read about in the original implementation of [Text::Unidecode](http://interglacial.com/~sburke/tpj/as_html/tpj22.html). Extensive examples can be found in the tests.
|
|
102
|
+
|
|
103
|
+
## StringExtensions
|
|
104
|
+
|
|
105
|
+
A small collection of extensions on Ruby's String class. Please see the documentation for StringExtensions module for more information. There's not much to explain about them really.
|
|
106
|
+
|
|
107
|
+
## Localization
|
|
108
|
+
|
|
109
|
+
With Stringex version 2.0 and higher, you can localize the different conversions in Stringex. Read more [here](https://github.com/rsl/stringex/wiki/Localization-of-Stringex-conversions). If you add a new language, please submit a pull request so we can make it available to other users also.
|
|
110
|
+
|
|
111
|
+
## Ruby on Rails Usage
|
|
112
|
+
|
|
113
|
+
When using Stringex with Ruby on Rails, you automatically get built-in translations for miscellaneous characters, HTML entities, and vulgar fractions. You can see Stringex's standard translations [here](https://github.com/rsl/stringex/tree/master/locales).
|
|
114
|
+
|
|
115
|
+
Currently, built-in translations are available for the following languages:
|
|
116
|
+
|
|
117
|
+
* English (en)
|
|
118
|
+
* Danish (da)
|
|
119
|
+
* Swedish (sv)
|
|
120
|
+
* Dutch (nl)
|
|
121
|
+
* German (de)
|
|
122
|
+
* Polish (pl)
|
|
123
|
+
* Portuguese Brazilian (pt-BR)
|
|
124
|
+
* Russian (ru)
|
|
125
|
+
|
|
126
|
+
You can easily add your own or customize the built-in translations - read [here](https://github.com/rsl/stringex/wiki/Localization-of-Stringex-conversions). If you add a new language, please submit a pull request so we can make it available to other users also.
|
|
127
|
+
|
|
128
|
+
If you don't want to use the Stringex built-in translations, you can force Stringex to use English (or another language), regardless what is in your `I18n.locale`. In an initializer, e.g. `config/initializers/stringex.rb`:
|
|
129
|
+
|
|
130
|
+
```ruby
|
|
131
|
+
Stringex::Localization.locale = :en
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## CanCan Usage Note
|
|
135
|
+
|
|
136
|
+
You'll need to add a `:find_by => :url` to your `load_and_authorize_resource`. Here's an example:
|
|
137
|
+
|
|
138
|
+
```ruby
|
|
139
|
+
load_and_authorize_resource :class => "Whatever", :message => "Not authorized", :find_by => :url
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Semantic Versioning
|
|
143
|
+
|
|
144
|
+
This project conforms to [semver](http://semver.org/). As a result of this policy, you can (and should) specify a dependency on this gem using the [Pessimistic Version Constraint](http://guides.rubygems.org/patterns/) with two digits of precision. For example:
|
|
145
|
+
|
|
146
|
+
```ruby
|
|
147
|
+
spec.add_dependency 'stringex', '~> 1.0'
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
This means your project is compatible with licensee 1.0 up until 2.0. You can also set a higher minimum version:
|
|
151
|
+
|
|
152
|
+
```ruby
|
|
153
|
+
spec.add_dependency 'stringex', '~> 1.1'
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Thanks & Acknowledgements
|
|
157
|
+
|
|
158
|
+
If it's not obvious, some of the code for ActsAsUrl is based on Rick Olsen's [permalink_fu](http://svn.techno-weenie.net/projects/plugins/permalink_fu/) plugin. Unidecoder is a Ruby port of Sean Burke's [Text::Unidecode](http://interglacial.com/~sburke/tpj/as_html/tpj22.html) module for Perl. And, finally, the bulk of [strip_html_tags](classes/Stringex/StringExtensions.html#M000005) in StringExtensions was stolen from Tobias Lütke's Regex in [Typo](http://typosphere.org/).
|
|
159
|
+
|
|
160
|
+
GIANT thanks to the many contributors who have helped make Stringex better and better: http://github.com/rsl/stringex/contributors
|
|
161
|
+
|
|
162
|
+
Copyright (c) 2008-2018 Lucky Sneaks, released under the MIT license
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'rake'
|
|
4
|
+
require 'rake/testtask'
|
|
5
|
+
require 'rdoc/task'
|
|
6
|
+
|
|
7
|
+
begin
|
|
8
|
+
require 'jeweler'
|
|
9
|
+
Jeweler::Tasks.new do |gem|
|
|
10
|
+
gem.name = "stringex"
|
|
11
|
+
gem.authors = ["Russell Norris"]
|
|
12
|
+
gem.email = "rsl@luckysneaks.com"
|
|
13
|
+
gem.homepage = "http://github.com/rsl/stringex"
|
|
14
|
+
gem.summary = "Some [hopefully] useful extensions to Ruby's String class"
|
|
15
|
+
gem.description = "Some [hopefully] useful extensions to Ruby's String class. Stringex is made up of three libraries: ActsAsUrl [permalink solution with better character translation], Unidecoder [Unicode to ASCII transliteration], and StringExtensions [miscellaneous helper methods for the String class]."
|
|
16
|
+
gem.files.exclude '.travis.yml'
|
|
17
|
+
gem.files.exclude '.ruby-gemset'
|
|
18
|
+
gem.files.exclude '.ruby-version'
|
|
19
|
+
gem.has_rdoc = true
|
|
20
|
+
gem.rdoc_options = %w{--main README.rdoc --charset utf-8 --line-numbers}
|
|
21
|
+
gem.extra_rdoc_files = %w{MIT-LICENSE README.rdoc}
|
|
22
|
+
gem.licenses = ['MIT']
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
Jeweler::RubygemsDotOrgTasks.new
|
|
26
|
+
rescue LoadError
|
|
27
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
Rake::TestTask.new do |t|
|
|
31
|
+
t.libs << 'lib' << 'test'
|
|
32
|
+
t.pattern = 'test/unit/**/*_test.rb'
|
|
33
|
+
t.verbose = false
|
|
34
|
+
t.warning = false
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
namespace :test do
|
|
38
|
+
Rake::TestTask.new(:performance) do |t|
|
|
39
|
+
t.libs << 'lib' << 'test'
|
|
40
|
+
t.pattern = 'test/performance/**/*_test.rb'
|
|
41
|
+
t.verbose = false
|
|
42
|
+
t.warning = false
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
task :default => :test
|
|
47
|
+
|
|
48
|
+
desc 'Generate RDoc for Stringex'
|
|
49
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
50
|
+
version = File.read('VERSION')
|
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
52
|
+
rdoc.title = "Stringex: A String Extension Pack [Version #{version}]"
|
|
53
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
|
54
|
+
rdoc.options << '--charset' << 'utf-8'
|
|
55
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
56
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
57
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.8.6
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Stringex
|
|
2
|
+
module ActsAsUrl
|
|
3
|
+
module Adapter
|
|
4
|
+
class ActiveRecord < Base
|
|
5
|
+
def self.load
|
|
6
|
+
ensure_loadable
|
|
7
|
+
orm_class.send :include, ActsAsUrlInstanceMethods
|
|
8
|
+
orm_class.send :extend, ActsAsUrlClassMethods
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def klass_previous_instances(&block)
|
|
14
|
+
klass.where(settings.url_attribute => [nil, '']).find_each(&block)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.orm_class
|
|
18
|
+
::ActiveRecord::Base
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
module Stringex
|
|
2
|
+
module ActsAsUrl
|
|
3
|
+
module Adapter
|
|
4
|
+
class Base
|
|
5
|
+
attr_accessor :base_url, :callback_options, :configuration, :instance, :klass, :settings
|
|
6
|
+
|
|
7
|
+
def initialize(configuration)
|
|
8
|
+
ensure_loadable
|
|
9
|
+
self.configuration = configuration
|
|
10
|
+
self.settings = configuration.settings
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def create_callbacks!(klass)
|
|
14
|
+
self.klass = klass
|
|
15
|
+
self.callback_options = {}
|
|
16
|
+
create_method_to_callback
|
|
17
|
+
create_callback
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def ensure_unique_url!(instance)
|
|
21
|
+
@url_owners = nil
|
|
22
|
+
self.instance = instance
|
|
23
|
+
|
|
24
|
+
handle_url!
|
|
25
|
+
handle_blacklisted_url!
|
|
26
|
+
handle_duplicate_url! unless settings.allow_duplicates
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def initialize_urls!(klass)
|
|
30
|
+
self.klass = klass
|
|
31
|
+
klass_previous_instances do |instance|
|
|
32
|
+
ensure_unique_url_for! instance
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def url_attribute(instance)
|
|
37
|
+
# Retrieve from database record if there are errors on attribute_to_urlify
|
|
38
|
+
if !is_new?(instance) && is_present?(instance.errors[settings.attribute_to_urlify])
|
|
39
|
+
self.instance = instance
|
|
40
|
+
read_attribute instance_from_db, settings.url_attribute
|
|
41
|
+
else
|
|
42
|
+
read_attribute instance, settings.url_attribute
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.ensure_loadable
|
|
47
|
+
raise "The #{self} adapter cannot be loaded" unless loadable?
|
|
48
|
+
Stringex::ActsAsUrl::Adapter.add_loaded_adapter self
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def self.loadable?
|
|
52
|
+
orm_class
|
|
53
|
+
rescue NameError
|
|
54
|
+
false
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
def add_new_record_url_owner_conditions
|
|
60
|
+
return if is_new?(instance)
|
|
61
|
+
@url_owner_conditions.first << " and #{primary_key} != ?"
|
|
62
|
+
@url_owner_conditions << instance.id
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def add_scoped_url_owner_conditions
|
|
66
|
+
[settings.scope_for_url].flatten.compact.each do |scope|
|
|
67
|
+
@url_owner_conditions.first << " and #{scope} = ?"
|
|
68
|
+
@url_owner_conditions << instance.send(scope)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def create_callback
|
|
73
|
+
klass.send(
|
|
74
|
+
klass_callback_method,
|
|
75
|
+
:ensure_unique_url,
|
|
76
|
+
**callback_options
|
|
77
|
+
)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def klass_callback_method
|
|
81
|
+
settings.sync_url ? klass_sync_url_callback_method : klass_non_sync_url_callback_method
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def klass_sync_url_callback_method
|
|
85
|
+
configuration.settings.callback_method
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def klass_non_sync_url_callback_method
|
|
89
|
+
case configuration.settings.callback_method
|
|
90
|
+
when :before_save
|
|
91
|
+
:before_create
|
|
92
|
+
else # :before_validation
|
|
93
|
+
callback_options[:on] = :create
|
|
94
|
+
configuration.settings.callback_method
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def create_method_to_callback
|
|
99
|
+
klass.class_eval <<-"END"
|
|
100
|
+
def #{settings.url_attribute}
|
|
101
|
+
acts_as_url_configuration.adapter.url_attribute self
|
|
102
|
+
end
|
|
103
|
+
END
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def duplicate_for_base_url(n)
|
|
107
|
+
"#{base_url}#{settings.duplicate_count_separator}#{n}"
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def ensure_loadable
|
|
111
|
+
self.class.ensure_loadable
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# NOTE: The <tt>instance</tt> here is not the cached instance but a block variable
|
|
115
|
+
# passed from <tt>klass_previous_instances</tt>, just to be clear
|
|
116
|
+
def ensure_unique_url_for!(instance)
|
|
117
|
+
instance.send :ensure_unique_url
|
|
118
|
+
instance.save
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def get_base_url_owner_conditions
|
|
122
|
+
@url_owner_conditions = ["#{settings.url_attribute} LIKE ?", base_url + '%']
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def handle_duplicate_url!
|
|
126
|
+
return if !url_taken?(base_url)
|
|
127
|
+
n = nil
|
|
128
|
+
sequence = duplicate_url_sequence.tap(&:rewind)
|
|
129
|
+
loop do
|
|
130
|
+
n = sequence.next
|
|
131
|
+
break unless url_taken?(duplicate_for_base_url(n))
|
|
132
|
+
end
|
|
133
|
+
write_url_attribute duplicate_for_base_url(n)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def duplicate_url_sequence
|
|
137
|
+
settings.duplicate_sequence ||
|
|
138
|
+
Enumerator.new do |enum|
|
|
139
|
+
n = 1
|
|
140
|
+
loop do
|
|
141
|
+
enum.yield n
|
|
142
|
+
n += 1
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def url_taken?(url)
|
|
148
|
+
if settings.url_taken_method
|
|
149
|
+
instance.send(settings.url_taken_method, url)
|
|
150
|
+
else
|
|
151
|
+
url_owners.any?{|owner| url_attribute_for(owner) == url}
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def handle_url!
|
|
156
|
+
self.base_url = instance.send(settings.url_attribute)
|
|
157
|
+
modify_base_url if is_blank?(base_url) || !settings.only_when_blank
|
|
158
|
+
write_url_attribute base_url
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def handle_blacklisted_url!
|
|
162
|
+
return unless settings.blacklist.to_set.include?(base_url)
|
|
163
|
+
self.base_url = settings.blacklist_policy.call(instance, base_url)
|
|
164
|
+
write_url_attribute base_url
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def instance_from_db
|
|
168
|
+
instance.class.find(instance.id)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def is_blank?(object)
|
|
172
|
+
object.blank?
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def is_new?(object)
|
|
176
|
+
object.new_record?
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def is_present?(object)
|
|
180
|
+
object.present?
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def loadable?
|
|
184
|
+
self.class.loadable?
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def modify_base_url
|
|
188
|
+
root = instance.send(settings.attribute_to_urlify).to_s
|
|
189
|
+
self.base_url = root.to_url(configuration.string_extensions_settings)
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def orm_class
|
|
193
|
+
self.class.orm_class
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def primary_key
|
|
197
|
+
instance.class.primary_key
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def read_attribute(instance, attribute)
|
|
201
|
+
instance.read_attribute attribute
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def url_attribute_for(object)
|
|
205
|
+
object.send settings.url_attribute
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def url_owner_conditions
|
|
209
|
+
get_base_url_owner_conditions
|
|
210
|
+
add_new_record_url_owner_conditions
|
|
211
|
+
add_scoped_url_owner_conditions
|
|
212
|
+
|
|
213
|
+
@url_owner_conditions
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def url_owners
|
|
217
|
+
@url_owners ||= url_owners_class.unscoped.where(url_owner_conditions).to_a
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def url_owners_class
|
|
221
|
+
return instance.class unless settings.enforce_uniqueness_on_sti_base_class
|
|
222
|
+
|
|
223
|
+
klass = instance.class
|
|
224
|
+
while klass.superclass < orm_class
|
|
225
|
+
klass = klass.superclass
|
|
226
|
+
end
|
|
227
|
+
klass
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def write_attribute(instance, attribute, value)
|
|
231
|
+
instance.send :write_attribute, attribute, value
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def write_url_attribute(value)
|
|
235
|
+
write_attribute instance, settings.url_attribute, value
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
module Stringex
|
|
2
|
+
module ActsAsUrl
|
|
3
|
+
module Adapter
|
|
4
|
+
class DataMapper < Base
|
|
5
|
+
def self.load
|
|
6
|
+
ensure_loadable
|
|
7
|
+
orm_class.send :include, Stringex::ActsAsUrl::ActsAsUrlInstanceMethods
|
|
8
|
+
::DataMapper::Model.send :include, Stringex::ActsAsUrl::ActsAsUrlClassMethods
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def create_callback
|
|
14
|
+
klass.class_eval do
|
|
15
|
+
before acts_as_url_configuration.settings.sync_url ? :save : :create, :ensure_unique_url
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def instance_from_db
|
|
20
|
+
instance.class.get(instance.id)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def is_blank?(object)
|
|
24
|
+
object.nil? || object == '' || object == []
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def is_new?(object)
|
|
28
|
+
object.new?
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def is_present?(object)
|
|
32
|
+
!is_blank? object
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def klass_previous_instances(&block)
|
|
36
|
+
klass.all(conditions: {settings.url_attribute => [nil]}).each(&block)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def primary_key
|
|
40
|
+
instance.class.key.first.instance_variable_get '@name'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def url_owners
|
|
44
|
+
@url_owners ||= url_owners_class.all(conditions: url_owner_conditions)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def read_attribute(instance, name)
|
|
48
|
+
instance.attribute_get name
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def write_attribute(instance, name, value)
|
|
52
|
+
instance.attribute_set name, value
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def self.orm_class
|
|
56
|
+
::DataMapper::Resource
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Stringex
|
|
2
|
+
module ActsAsUrl
|
|
3
|
+
module Adapter
|
|
4
|
+
class Mongoid < Base
|
|
5
|
+
def self.load
|
|
6
|
+
ensure_loadable
|
|
7
|
+
orm_class.send :extend, Stringex::ActsAsUrl::ActsAsUrlClassMethods
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def add_new_record_url_owner_conditions
|
|
13
|
+
return if instance.new_record?
|
|
14
|
+
@url_owner_conditions.merge! id: {'$ne' => instance.id}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def add_scoped_url_owner_conditions
|
|
18
|
+
[settings.scope_for_url].flatten.compact.each do |scope|
|
|
19
|
+
@url_owner_conditions.merge! scope => instance.send(scope)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def get_base_url_owner_conditions
|
|
24
|
+
@url_owner_conditions = {settings.url_attribute => /^#{Regexp.escape(base_url)}/}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def klass_previous_instances(&block)
|
|
28
|
+
klass.all(settings.url_attribute => [nil]).to_a.each(&block)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.orm_class
|
|
32
|
+
::Mongoid::Document
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|