get rid of Struct.new (locomotivecms/wagon#254, locomotivecms/wagon#255, #39)
did
committed Sep 16, 2015
commit 5a17a7bcdd329402b6926e4ef96eec997698c07b
Showing 27
changed files with
81 additions
and 31 deletions
Gemfile.lock
+9
-4
| @@ | @@ -11,7 +11,7 @@ PATH |
| httparty (~> 0.13.5) | |
| kramdown (~> 1.8.0) | |
| locomotivecms-solid (~> 4.0.0.alpha2) | |
| - | locomotivecms_common (~> 0.0.4) |
| + | locomotivecms_common (~> 0.0.5) |
| mime-types (~> 2.6.1) | |
| mimetype-fu (~> 0.1.2) | |
| moneta (~> 0.8.0) | |
| @@ | @@ -35,6 +35,7 @@ GEM |
| thread_safe (~> 0.3, >= 0.3.4) | |
| tzinfo (~> 1.1) | |
| addressable (2.3.8) | |
| + | attr_extras (4.4.0) |
| bson (3.1.0) | |
| byebug (4.0.5) | |
| columnize (= 0.9.0) | |
| @@ | @@ -74,7 +75,7 @@ GEM |
| docile (1.1.5) | |
| domain_name (0.5.24) | |
| unf (>= 0.0.5, < 1.0.0) | |
| - | dragonfly (1.0.10) |
| + | dragonfly (1.0.11) |
| addressable (~> 2.3) | |
| multi_json (~> 1.0) | |
| rack (>= 1.3.0) | |
| @@ | @@ -108,8 +109,9 @@ GEM |
| locomotivecms-liquid (4.0.0.alpha2) | |
| locomotivecms-solid (4.0.0.alpha2) | |
| locomotivecms-liquid (~> 4.0.0.alpha2) | |
| - | locomotivecms_common (0.0.4) |
| + | locomotivecms_common (0.0.5) |
| activesupport (~> 4.2.1) | |
| + | attr_extras (~> 4.4.0) |
| colorize | |
| stringex (~> 2.5.2) | |
| memory_profiler (0.9.4) | |
| @@ | @@ -154,7 +156,7 @@ GEM |
| rake (10.4.2) | |
| rake-compiler (0.9.5) | |
| rake | |
| - | rb-fsevent (0.9.5) |
| + | rb-fsevent (0.9.6) |
| rb-inotify (0.9.5) | |
| ffi (>= 0.5.0) | |
| rest-client (1.8.0) | |
| @@ | @@ -235,3 +237,6 @@ DEPENDENCIES |
| stackprof | |
| timecop (~> 0.7.4) | |
| yui-compressor (~> 0.12.0) | |
| + | |
| + | BUNDLED WITH |
| + | 1.10.6 |
locomotive/steam/adapters/filesystem.rb b/lib/locomotive/steam/adapters/filesystem.rb
+3
-1
| @@ | @@ -10,11 +10,13 @@ require_relative_all 'filesystem/sanitizers' |
| module Locomotive::Steam | |
| - | class FilesystemAdapter < Struct.new(:options) |
| + | class FilesystemAdapter |
| include Morphine | |
| include Locomotive::Steam::Adapters::Concerns::Key | |
| + | attr_accessor_initialize :options |
| + | |
| register :cache do | |
| Locomotive::Steam::Adapters::Filesystem::SimpleCacheStore.new | |
| end | |
locomotive/steam/adapters/memory.rb b/lib/locomotive/steam/adapters/memory.rb
+3
-1
| @@ | @@ -9,7 +9,9 @@ module Locomotive::Steam |
| module Memory | |
| end | |
| - | MemoryAdapter = Struct.new(:collection) do |
| + | class MemoryAdapter |
| + | |
| + | attr_accessor_initialize :collection |
| include Locomotive::Steam::Adapters::Concerns::Key | |
locomotive/steam/adapters/mongodb.rb b/lib/locomotive/steam/adapters/mongodb.rb
+3
-1
| @@ | @@ -8,7 +8,9 @@ require_relative 'mongodb/command' |
| module Locomotive::Steam | |
| - | class MongoDBAdapter < Struct.new(:options) |
| + | class MongoDBAdapter |
| + | |
| + | attr_accessor_initialize :options |
| def all(mapper, query) | |
| dataset(mapper, query) | |
locomotive/steam/entities/content_entry.rb b/lib/locomotive/steam/entities/content_entry.rb
+3
-1
| @@ | @@ -146,7 +146,9 @@ module Locomotive::Steam |
| end | |
| # Represent a file | |
| - | class FileField < Struct.new(:filename, :base, :updated_at) |
| + | class FileField |
| + | |
| + | attr_accessor_initialize :filename, :base, :updated_at |
| def url | |
| return if filename.blank? | |
locomotive/steam/middlewares/default_env.rb b/lib/locomotive/steam/middlewares/default_env.rb
+3
-1
| @@ | @@ -1,7 +1,9 @@ |
| module Locomotive::Steam | |
| module Middlewares | |
| - | class DefaultEnv < Struct.new(:app) |
| + | class DefaultEnv |
| + | |
| + | attr_accessor_initialize :app |
| def call(env) | |
| request = Rack::Request.new(env) | |
locomotive/steam/middlewares/favicon.rb b/lib/locomotive/steam/middlewares/favicon.rb
+3
-1
| @@ | @@ -1,7 +1,9 @@ |
| module Locomotive::Steam | |
| module Middlewares | |
| - | class Favicon < Struct.new(:app) |
| + | class Favicon |
| + | |
| + | attr_accessor_initialize :app |
| include Helpers | |
locomotive/steam/middlewares/logging.rb b/lib/locomotive/steam/middlewares/logging.rb
+3
-1
| @@ | @@ -3,10 +3,12 @@ module Locomotive::Steam |
| # Track the request into the current logger | |
| # | |
| - | class Logging < Struct.new(:app) |
| + | class Logging |
| include Helpers | |
| + | attr_accessor_initialize :app |
| + | |
| def call(env) | |
| now = Time.now | |
locomotive/steam/middlewares/path.rb b/lib/locomotive/steam/middlewares/path.rb
+3
-1
| @@ | @@ -4,7 +4,9 @@ module Locomotive::Steam |
| # Sanitize the path from the previous middleware in order | |
| # to make it work for the renderer. | |
| # | |
| - | class Path < Struct.new(:app) |
| + | class Path |
| + | |
| + | attr_accessor_initialize :app |
| def call(env) | |
| set_path!(env) | |
locomotive/steam/middlewares/robots.rb b/lib/locomotive/steam/middlewares/robots.rb
+3
-1
| @@ | @@ -1,10 +1,12 @@ |
| module Locomotive::Steam | |
| module Middlewares | |
| - | class Robots < Struct.new(:app, :options) |
| + | class Robots |
| include Helpers | |
| + | attr_accessor_initialize :app |
| + | |
| def call(env) | |
| if env['PATH_INFO'] == '/robots.txt' | |
| site = env['steam.site'] | |
locomotive/steam/middlewares/thread_safe.rb b/lib/locomotive/steam/middlewares/thread_safe.rb
+2
-1
| @@ | @@ -1,7 +1,8 @@ |
| module Locomotive::Steam::Middlewares | |
| - | ThreadSafe = Struct.new(:app) do |
| + | class ThreadSafe |
| + | attr_accessor_initialize :app |
| attr_accessor :env | |
| def call(env) | |
locomotive/steam/repositories.rb b/lib/locomotive/steam/repositories.rb
+3
-1
| @@ | @@ -3,10 +3,12 @@ require_relative_all 'repositories' |
| module Locomotive | |
| module Steam | |
| - | class Repositories < Struct.new(:current_site, :locale, :configuration) |
| + | class Repositories |
| include Morphine | |
| + | attr_accessor_initialize :current_site, :locale, :configuration |
| + | |
| register :adapter do | |
| build_adapter(configuration.adapter) | |
| end | |
locomotive/steam/services.rb b/lib/locomotive/steam/services.rb
+4
-2
| @@ | @@ -1,4 +1,4 @@ |
| - | require 'morphine' |
| + | require 'morphine' |
| require_relative_all %w(concerns .), 'services' | |
| @@ | @@ -28,10 +28,12 @@ module Locomotive |
| end | |
| end | |
| - | class Instance < Struct.new(:request) |
| + | class Instance |
| include Morphine | |
| + | attr_accessor_initialize :request |
| + | |
| register :current_site do | |
| repositories.current_site = Defer.new { site_finder.find } | |
| end | |
locomotive/steam/services/csrf_protection_service.rb b/lib/locomotive/steam/services/csrf_protection_service.rb
+3
-1
| @@ | @@ -1,7 +1,9 @@ |
| module Locomotive | |
| module Steam | |
| - | class CsrfProtectionService < Struct.new(:enabled, :field, :token) |
| + | class CsrfProtectionService |
| + | |
| + | attr_accessor_initialize :enabled, :field, :token |
| def enabled? | |
| !!enabled | |
locomotive/steam/services/editable_element_service.rb b/lib/locomotive/steam/services/editable_element_service.rb
+3
-1
| @@ | @@ -1,10 +1,12 @@ |
| module Locomotive | |
| module Steam | |
| - | class EditableElementService < Struct.new(:repository, :locale) |
| + | class EditableElementService |
| include Locomotive::Steam::Services::Concerns::Decorator | |
| + | attr_accessor_initialize :repository, :locale |
| + | |
| def find(page, block, slug) | |
| decorate(Decorators::I18nDecorator) do | |
| repository.editable_element_for(page, block, slug).tap do |element| | |
locomotive/steam/services/entry_submission_service.rb b/lib/locomotive/steam/services/entry_submission_service.rb
+3
-1
| @@ | @@ -3,10 +3,12 @@ require 'sanitize' |
| module Locomotive | |
| module Steam | |
| - | class EntrySubmissionService < Struct.new(:content_type_repository, :repository, :locale) |
| + | class EntrySubmissionService |
| include Locomotive::Steam::Services::Concerns::Decorator | |
| + | attr_accessor_initialize :content_type_repository, :repository, :locale |
| + | |
| def submit(slug, attributes = {}) | |
| type = get_type(slug) | |
locomotive/steam/services/image_resizer_service.rb b/lib/locomotive/steam/services/image_resizer_service.rb
+3
-1
| @@ | @@ -1,7 +1,9 @@ |
| module Locomotive | |
| module Steam | |
| - | class ImageResizerService < Struct.new(:resizer, :asset_path) |
| + | class ImageResizerService |
| + | |
| + | attr_accessor_initialize :resizer, :asset_path |
| def resize(source, geometry) | |
| return nil if disabled? || geometry.blank? | |
locomotive/steam/services/liquid_parser_service.rb b/lib/locomotive/steam/services/liquid_parser_service.rb
+3
-1
| @@ | @@ -1,7 +1,9 @@ |
| module Locomotive | |
| module Steam | |
| - | class LiquidParserService < Struct.new(:parent_finder, :snippet_finder) |
| + | class LiquidParserService |
| + | |
| + | attr_accessor_initialize :parent_finder, :snippet_finder |
| def parse(page) | |
| _parse(page, | |
locomotive/steam/services/page_finder_service.rb b/lib/locomotive/steam/services/page_finder_service.rb
+3
-1
| @@ | @@ -1,10 +1,12 @@ |
| module Locomotive | |
| module Steam | |
| - | class PageFinderService < Struct.new(:repository) |
| + | class PageFinderService |
| include Locomotive::Steam::Services::Concerns::Decorator | |
| + | attr_accessor_initialize :repository |
| + | |
| def find(path) | |
| decorate do | |
| repository.by_fullpath(path) | |
locomotive/steam/services/site_finder_service.rb b/lib/locomotive/steam/services/site_finder_service.rb
+3
-1
| @@ | @@ -1,7 +1,9 @@ |
| module Locomotive | |
| module Steam | |
| - | class SiteFinderService < Struct.new(:repository, :request) |
| + | class SiteFinderService |
| + | |
| + | attr_accessor_initialize :repository, :request |
| def find | |
| repository.by_domain(request.host) | |
locomotive/steam/services/snippet_finder_service.rb b/lib/locomotive/steam/services/snippet_finder_service.rb
+3
-1
| @@ | @@ -1,10 +1,12 @@ |
| module Locomotive | |
| module Steam | |
| - | class SnippetFinderService < Struct.new(:repository) |
| + | class SnippetFinderService |
| include Locomotive::Steam::Services::Concerns::Decorator | |
| + | attr_accessor_initialize :repository |
| + | |
| def find(slug) | |
| decorate do | |
| repository.by_slug(slug) | |
locomotive/steam/services/theme_asset_url_service.rb b/lib/locomotive/steam/services/theme_asset_url_service.rb
+3
-1
| @@ | @@ -1,7 +1,9 @@ |
| module Locomotive | |
| module Steam | |
| - | class ThemeAssetUrlService < Struct.new(:repository, :asset_host, :checksum) |
| + | class ThemeAssetUrlService |
| + | |
| + | attr_accessor_initialize :repository, :asset_host, :checksum |
| def build(path) | |
| # keep the query string safe | |
locomotive/steam/services/translator_service.rb b/lib/locomotive/steam/services/translator_service.rb
+3
-1
| @@ | @@ -1,7 +1,9 @@ |
| module Locomotive | |
| module Steam | |
| - | class TranslatorService < Struct.new(:repository, :current_locale) |
| + | class TranslatorService |
| + | |
| + | attr_accessor_initialize :repository, :current_locale |
| # Return the translation described by a key. | |
| # | |
locomotive/steam/services/url_builder_service.rb b/lib/locomotive/steam/services/url_builder_service.rb
+3
-1
| @@ | @@ -1,7 +1,9 @@ |
| module Locomotive | |
| module Steam | |
| - | class UrlBuilderService < Struct.new(:site, :current_locale, :request) |
| + | class UrlBuilderService |
| + | |
| + | attr_accessor_initialize :site, :current_locale, :request |
| def url_for(page, locale = nil) | |
| prefix(_url_for(page, locale)) | |
locomotivecms_steam.gemspec
+1
-1
| @@ | @@ -45,7 +45,7 @@ Gem::Specification.new do |spec| |
| spec.add_dependency 'mime-types', '~> 2.6.1' | |
| spec.add_dependency 'locomotivecms-solid', '~> 4.0.0.alpha2' | |
| - | spec.add_dependency 'locomotivecms_common', '~> 0.0.4' |
| + | spec.add_dependency 'locomotivecms_common', '~> 0.0.5' |
| spec.required_ruby_version = '>= 2.0' | |
| end | |
spec/unit/liquid/tags/extends_spec.rb
+1
-1
| @@ | @@ -7,7 +7,7 @@ describe Locomotive::Steam::Liquid::Tags::Extends do |
| let(:site) { instance_double('Site', default_locale: :en) } | |
| let!(:listener) { Liquid::SimpleEventsListener.new } | |
| let(:finder) { Locomotive::Steam::ParentFinderService.new(instance_double('PageRepository', site: site, locale: :en)) } | |
| - | let(:parser) { Locomotive::Steam::LiquidParserService.new } |
| + | let(:parser) { Locomotive::Steam::LiquidParserService.new(nil, nil) } |
| let(:options) { { parent_finder: finder, page: page, parser: parser } } | |
| before do | |
spec/unit/liquid/tags/inherited_block_spec.rb
+1
-1
| @@ | @@ -9,7 +9,7 @@ describe Locomotive::Steam::Liquid::Tags::InheritedBlock do |
| let!(:listener) { Liquid::SimpleEventsListener.new } | |
| let(:finder) { instance_double('Finder', find: parent) } | |
| - | let(:options) { { page: page, parent_finder: finder, parser: Locomotive::Steam::LiquidParserService.new } } |
| + | let(:options) { { page: page, parent_finder: finder, parser: Locomotive::Steam::LiquidParserService.new(nil, nil) } } |
| let!(:template) { parse_template(source, options) } | |