some night cleaning
did
committed Feb 28, 2015
commit 09dd60b2d361f3291be6a8169b27f3de0172a991
Showing 20
changed files with
19 additions
and 469 deletions
Rakefile
+12
-2
| @@ | @@ -13,6 +13,17 @@ Bundler::GemHelper.install_tasks |
| require_relative 'lib/locomotive/steam' | |
| + | namespace :mongodb do |
| + | namespace :test do |
| + | desc 'Seed the MongoDB database with the dump of the Sample website' |
| + | task :seed do |
| + | path = File.join(File.expand_path(File.dirname(__FILE__)), 'spec', 'fixtures', 'mongodb') |
| + | `mongo steam_test --eval "db.dropDatabase()"` |
| + | `mongorestore -d steam_test #{path}` |
| + | end |
| + | end |
| + | end |
| + | |
| require 'rspec/core/rake_task' | |
| RSpec::Core::RakeTask.new('spec') do |spec| | |
| spec.exclude_pattern = 'spec/unit/liquid/**/*_spec.rb,spec/integration/server/**/*_spec.rb' | |
| @@ | @@ -26,7 +37,6 @@ end |
| RSpec::Core::RakeTask.new('spec:unit') do |spec| | |
| # spec.pattern = 'spec/unit/**/*_spec.rb' | |
| spec.pattern = 'spec/unit/{services,core_ext,middlewares,decorators,adapters,entities,models,repositories}/**/*_spec.rb' | |
| - | # spec.pattern = 'spec/unit/{adapters,entities,models,repositories}/**/*_spec.rb' |
| end | |
| - | task default: :spec |
| + | task default: ['mongodb:test:seed', :spec] |
locomotive/steam.rb b/lib/locomotive/steam.rb
+1
-11
| @@ | @@ -13,17 +13,7 @@ require_relative 'steam/liquid' |
| require_relative 'steam/models' | |
| require_relative_all 'steam/entities' | |
| - | |
| - | # TODO |
| - | require_relative 'steam/repositories/site_repository' |
| - | require_relative 'steam/repositories/page_repository' |
| - | require_relative 'steam/repositories/editable_element_repository' |
| - | require_relative 'steam/repositories/snippet_repository' |
| - | require_relative 'steam/repositories/translation_repository' |
| - | require_relative 'steam/repositories/theme_asset_repository' |
| - | require_relative 'steam/repositories/content_type_repository' |
| - | require_relative 'steam/repositories/content_type_field_repository' |
| - | require_relative 'steam/repositories/content_type_field_select_option_repository' |
| + | require_relative_all 'steam/repositories' |
| require_relative 'steam/services' | |
locomotive/steam/repositories.rb b/lib/locomotive/steam/repositories.rb
+0
-82
| @@ | @@ -1,82 +0,0 @@ |
| - | raise 'NOT GOOD' |
| - | |
| - | # module Locomotive |
| - | # module Steam |
| - | # module Repository |
| - | |
| - | # extend ActiveSupport::Concern |
| - | |
| - | # class RecordNotFound < StandardError; end |
| - | |
| - | # attr_accessor :adapter, :current_site, :current_locale |
| - | |
| - | # def initialize(adapter, current_site = nil, current_locale = nil) |
| - | # @adapter = adapter |
| - | # @current_site = current_site |
| - | # @current_locale = current_locale |
| - | # end |
| - | |
| - | # def all |
| - | # adapter.all(mapper) |
| - | # end |
| - | |
| - | # # def find(id) |
| - | # # adapter.find(mapper, id) |
| - | # # end |
| - | |
| - | # def query(&block) |
| - | # adapter.query(mapper, current_locale, &block) |
| - | # end |
| - | |
| - | # # def create(entity) |
| - | # # entity.id = adapter.create(collection_name, entity) |
| - | # # end |
| - | |
| - | # # def persisted?(entity) |
| - | # # !!entity.id && adapter.persisted?(collection_name, entity) |
| - | # # end |
| - | |
| - | # # def update(entity) |
| - | # # adapter.update(collection_name, entity) |
| - | # # end |
| - | |
| - | # # def destroy(entity) |
| - | # # adapter.destroy(collection_name, entity) |
| - | # # end |
| - | |
| - | # def mapper |
| - | # name, options, block = mapper_options |
| - | # @mapper ||= Steam::Mapper.new(name, options, &block) |
| - | # end |
| - | |
| - | # def scope |
| - | # Steam:: |
| - | # end |
| - | |
| - | # # def collection_name |
| - | # # mapper.name |
| - | # # end |
| - | |
| - | # module ClassMethods |
| - | |
| - | # def mapping(name, options = {}, &block) |
| - | # class_eval do |
| - | # define_method(:mapper_options) { [name, options, block] } |
| - | # end |
| - | # end |
| - | |
| - | # end |
| - | |
| - | # end |
| - | # end |
| - | # end |
| - | |
| - | # module Locomotive |
| - | # module Steam |
| - | # module Repositories |
| - | # end |
| - | # end |
| - | # end |
| - | |
| - | # require_relative 'repositories/site_repository' |
| - | # require_relative 'repositories/page_repository' |
locomotive/steam/repositories/editable_element_repository.rb b/lib/locomotive/steam/repositories/editable_element_repository.rb
+0
-2
| @@ | @@ -14,8 +14,6 @@ module Locomotive |
| default_attribute :page, -> (repository) { repository.page } | |
| end | |
| - | # TODO |
| - | |
| end | |
| end | |
locomotive/steam/repositories/filesystem/content_type.rb b/lib/locomotive/steam/repositories/filesystem/content_type.rb
+0
-57
| @@ | @@ -1,57 +0,0 @@ |
| - | # module Locomotive |
| - | # module Steam |
| - | # module Repositories |
| - | # module Filesystem |
| - | |
| - | # class ContentType < Struct.new(:loader, :site, :current_locale) |
| - | |
| - | # include Concerns::Queryable |
| - | |
| - | # set_collection model: Filesystem::Models::ContentType, sanitizer: Filesystem::Sanitizers::ContentType |
| - | |
| - | # # Engine: site.where(slug: slug_or_content_type).first |
| - | # def by_slug(slug_or_content_type) |
| - | # if slug_or_content_type.is_a?(String) |
| - | # query { where(slug: slug_or_content_type) }.first |
| - | # else |
| - | # slug_or_content_type |
| - | # end |
| - | # end |
| - | |
| - | # # Engine: content_type.entries_custom_fields.where(unique: true) |
| - | # def look_for_unique_fields(content_type) |
| - | # return nil if content_type.nil? |
| - | |
| - | # {}.tap do |hash| |
| - | # content_type.query_fields { where(unique: true) }.each do |field| |
| - | # hash[field.name] = field |
| - | # end |
| - | # end |
| - | # end |
| - | |
| - | # # Engine: content_type.entries_custom_fields |
| - | # def fields_for(content_type) |
| - | # return nil if content_type.nil? |
| - | |
| - | # content_type.fields |
| - | # end |
| - | |
| - | # # Engine: content_type.entries.klass.send(:"#{name}_options").map { |option| option['name'] } |
| - | # def select_options(content_type, name) |
| - | # return nil if content_type.nil? || name.nil? |
| - | |
| - | # field = content_type.fields_by_name[name] |
| - | |
| - | # if field.type == :select |
| - | # localized_attribute(field, :select_options) |
| - | # else |
| - | # nil |
| - | # end |
| - | # end |
| - | |
| - | # end |
| - | |
| - | # end |
| - | # end |
| - | # end |
| - | # end |
locomotive/steam/repositories/filesystem/models/base.rb b/lib/locomotive/steam/repositories/filesystem/models/base.rb
+0
-50
| @@ | @@ -1,50 +0,0 @@ |
| - | # module Locomotive |
| - | # module Steam |
| - | # module Repositories |
| - | # module Filesystem |
| - | # module Models |
| - | |
| - | # class Base |
| - | |
| - | # include Concerns::Validation |
| - | |
| - | # attr_accessor :attributes |
| - | |
| - | # def initialize(attributes) |
| - | # @attributes = attributes |
| - | # end |
| - | |
| - | # def method_missing(name, *args, &block) |
| - | # if attributes.include?(name) |
| - | # self[name] |
| - | # else |
| - | # super |
| - | # end |
| - | # end |
| - | |
| - | # def []=(name, value) |
| - | # attributes[name.to_sym] = value |
| - | # end |
| - | |
| - | # def [](name) |
| - | # attributes[name.to_sym] |
| - | # end |
| - | |
| - | # def self.set_localized_attributes(list) |
| - | # singleton = class << self; self; end |
| - | # singleton.class_eval do |
| - | # define_method(:localized_attributes) { list } |
| - | # end |
| - | |
| - | # class_eval do |
| - | # define_method(:localized_attributes) { list } |
| - | # end |
| - | # end |
| - | |
| - | # end |
| - | |
| - | # end |
| - | # end |
| - | # end |
| - | # end |
| - | # end |
locomotive/steam/repositories/filesystem/models/concerns/validation.rb b/lib/locomotive/steam/repositories/filesystem/models/concerns/validation.rb
+0
-62
| @@ | @@ -1,62 +0,0 @@ |
| - | require 'forwardable' |
| - | |
| - | module Locomotive |
| - | module Steam |
| - | module Repositories |
| - | module Filesystem |
| - | module Models |
| - | module Concerns |
| - | |
| - | module Validation |
| - | |
| - | def errors |
| - | @errors ||= Errors.new(self) |
| - | end |
| - | |
| - | def valid? |
| - | true |
| - | end |
| - | |
| - | class Errors |
| - | |
| - | include Enumerable |
| - | extend Forwardable |
| - | |
| - | attr_accessor :messages |
| - | |
| - | def_delegators :@messages, :[], :clear, :empty?, :each, :size |
| - | |
| - | alias_method :blank?, :empty? |
| - | |
| - | def initialize(base) |
| - | @base = base |
| - | @messages = HashWithIndifferentAccess.new({}) |
| - | end |
| - | |
| - | def add_on_blank(attribute) |
| - | value = @base.send(attribute) |
| - | add(attribute, :blank) if value.blank? |
| - | end |
| - | |
| - | def add(attribute, message) |
| - | (@messages[attribute] ||= []) << generate_message(message) |
| - | end |
| - | |
| - | def generate_message(message) |
| - | case message |
| - | when :blank, :unique then I18n.t(message, scope: 'errors.messages') |
| - | else |
| - | message |
| - | end |
| - | end |
| - | |
| - | end |
| - | |
| - | end |
| - | |
| - | end |
| - | end |
| - | end |
| - | end |
| - | end |
| - | end |
locomotive/steam/repositories/filesystem/models/content_type_field.rb b/lib/locomotive/steam/repositories/filesystem/models/content_type_field.rb
+0
-0
locomotive/steam/repositories/filesystem/models/page.rb b/lib/locomotive/steam/repositories/filesystem/models/page.rb
+0
-56
| @@ | @@ -1,56 +0,0 @@ |
| - | # module Locomotive |
| - | # module Steam |
| - | # module Repositories |
| - | # module Filesystem |
| - | # module Models |
| - | |
| - | # class Page < Base |
| - | |
| - | # set_localized_attributes [:title, :slug, :permalink, :editable_elements, :template, :template_path, :redirect_url, :fullpath, :seo_title, :meta_description, :meta_keywords] |
| - | |
| - | # attr_accessor :depth, :_fullpath, :content_entry |
| - | |
| - | # def initialize(attributes) |
| - | # super({ |
| - | # handle: nil, |
| - | # listed: false, |
| - | # published: true, |
| - | # fullpath: {}, |
| - | # content_type: nil, |
| - | # position: 99, |
| - | # template: {}, |
| - | # editable_elements: {}, |
| - | # redirect_url: {} |
| - | # }.merge(attributes)) |
| - | # end |
| - | |
| - | # def listed?; !!listed; end |
| - | # def published?; !!published; end |
| - | |
| - | # def templatized? |
| - | # !!content_type |
| - | # end |
| - | |
| - | # def depth_and_position |
| - | # depth * 100 + position |
| - | # end |
| - | |
| - | # def index? |
| - | # attributes[:fullpath].values.first == 'index' |
| - | # end |
| - | |
| - | # def not_found? |
| - | # attributes[:fullpath].values.first == '404' |
| - | # end |
| - | |
| - | # def to_liquid |
| - | # Steam::Liquid::Drops::Page.new(self) |
| - | # end |
| - | |
| - | # end |
| - | |
| - | # end |
| - | # end |
| - | # end |
| - | # end |
| - | # end |
locomotive/steam/repositories/filesystem/sanitizers/content_type.rb b/lib/locomotive/steam/repositories/filesystem/sanitizers/content_type.rb
+0
-49
| @@ | @@ -1,49 +0,0 @@ |
| - | # module Locomotive |
| - | # module Steam |
| - | # module Repositories |
| - | # module Filesystem |
| - | # module Sanitizers |
| - | |
| - | # class ContentType < Struct.new(:default_locale, :locales) |
| - | |
| - | # def apply_to(collection) |
| - | # collection.each do |content_type| |
| - | # if list = content_type.attributes[:fields] |
| - | # content_type[:slug] = content_type[:slug].to_s |
| - | # content_type.fields = build_fields(list) |
| - | # end |
| - | # build_fields_by_name_shortcut(content_type) |
| - | # end |
| - | # end |
| - | |
| - | # def build_fields(list) |
| - | # list.map do |attributes| |
| - | # name, _attributes = attributes.keys.first, attributes.values.first |
| - | |
| - | # _attributes[:name] = name.to_sym |
| - | |
| - | # if _attributes[:label].blank? |
| - | # _attributes[:label] = name.to_s.humanize |
| - | # end |
| - | |
| - | # _attributes[:type] = _attributes[:type].try(:to_sym) |
| - | |
| - | # Filesystem::Models::ContentTypeField.new(_attributes) |
| - | # end |
| - | # end |
| - | |
| - | # def build_fields_by_name_shortcut(content_type) |
| - | # content_type.fields_by_name = {} |
| - | |
| - | # (content_type.fields || []).each do |field| |
| - | # content_type.fields_by_name[field.name] = field |
| - | # end |
| - | # end |
| - | |
| - | # end |
| - | |
| - | # end |
| - | # end |
| - | # end |
| - | # end |
| - | # end |
locomotive/steam/repositories/filesystem/yaml_loaders/concerns/common.rb b/lib/locomotive/steam/repositories/filesystem/yaml_loaders/concerns/common.rb
+0
-39
| @@ | @@ -1,39 +0,0 @@ |
| - | # module Locomotive |
| - | # module Steam |
| - | # module Repositories |
| - | # module Filesystem |
| - | # module YAMLLoaders |
| - | # module Concerns |
| - | |
| - | # module Common |
| - | |
| - | # def load(path, frontmatter = false, &block) |
| - | # if File.exists?(path) |
| - | # yaml = File.open(path).read.force_encoding('utf-8') |
| - | # template = nil |
| - | |
| - | # if frontmatter && match = yaml.match(FRONTMATTER_REGEXP) |
| - | # yaml, template = match[:yaml], match[:template] |
| - | # end |
| - | |
| - | # HashConverter.to_sym(YAML.load(yaml)).tap do |attributes| |
| - | # block.call(attributes, template) if block_given? |
| - | # end |
| - | # else |
| - | # Locomotive::Common::Logger.error "No #{path} file found" |
| - | # {} |
| - | # end |
| - | # end |
| - | |
| - | # def template_extensions |
| - | # @extensions ||= %w(liquid haml) |
| - | # end |
| - | |
| - | # end |
| - | |
| - | # end |
| - | # end |
| - | # end |
| - | # end |
| - | # end |
| - | # end |
locomotive/steam/repositories/filesystem/yaml_loaders/content_type.rb b/lib/locomotive/steam/repositories/filesystem/yaml_loaders/content_type.rb
+0
-42
| @@ | @@ -1,42 +0,0 @@ |
| - | # module Locomotive |
| - | # module Steam |
| - | # module Repositories |
| - | # module Filesystem |
| - | # module YAMLLoaders |
| - | |
| - | # class ContentType < Struct.new(:root_path, :cache) |
| - | |
| - | # include YAMLLoaders::Concerns::Common |
| - | |
| - | # def list_of_attributes |
| - | # cache.fetch('app/content_types') { load_list } |
| - | # end |
| - | |
| - | # private |
| - | |
| - | # def load_list |
| - | # [].tap do |array| |
| - | # each_file do |filepath, slug| |
| - | # array << { slug: slug }.merge(load(filepath)) |
| - | # end |
| - | # end |
| - | # end |
| - | |
| - | # def each_file(&block) |
| - | # Dir.glob(File.join(path, "*.yml")).each do |filepath| |
| - | # slug = File.basename(filepath, '.yml') |
| - | # yield(filepath, slug) |
| - | # end |
| - | # end |
| - | |
| - | # def path |
| - | # File.join(root_path, 'app', 'content_types') |
| - | # end |
| - | |
| - | # end |
| - | |
| - | # end |
| - | # end |
| - | # end |
| - | # end |
| - | # end |
spec/integration/mongodb_helper.rb
+0
-5
| @@ | @@ -1,5 +0,0 @@ |
| - | require File.join(File.dirname(__FILE__), '..', 'spec_helper') |
| - | |
| - | # RSpec.configure do |config| |
| - | # config.before(:all) { restore_mongodb } |
| - | # end |
spec/integration/repositories/content_type_repository_spec.rb
+1
-1
| @@ | @@ -1,4 +1,4 @@ |
| - | require File.join(File.dirname(__FILE__), '..', 'mongodb_helper') |
| + | require 'spec_helper' |
| require_relative '../../../lib/locomotive/steam/adapters/filesystem.rb' | |
| require_relative '../../../lib/locomotive/steam/adapters/mongodb.rb' | |
spec/integration/repositories/page_repository_spec.rb
+1
-1
| @@ | @@ -1,4 +1,4 @@ |
| - | require File.join(File.dirname(__FILE__), '..', 'mongodb_helper') |
| + | require 'spec_helper' |
| require_relative '../../../lib/locomotive/steam/adapters/filesystem.rb' | |
| require_relative '../../../lib/locomotive/steam/adapters/mongodb.rb' | |
spec/integration/repositories/site_repository_spec.rb
+1
-1
| @@ | @@ -1,4 +1,4 @@ |
| - | require File.join(File.dirname(__FILE__), '..', 'mongodb_helper') |
| + | require 'spec_helper' |
| require_relative '../../../lib/locomotive/steam/adapters/filesystem.rb' | |
| require_relative '../../../lib/locomotive/steam/adapters/mongodb.rb' | |
spec/integration/repositories/snippet_repository_spec.rb
+1
-1
| @@ | @@ -1,4 +1,4 @@ |
| - | require File.join(File.dirname(__FILE__), '..', 'mongodb_helper') |
| + | require 'spec_helper' |
| require_relative '../../../lib/locomotive/steam/adapters/filesystem.rb' | |
| require_relative '../../../lib/locomotive/steam/adapters/mongodb.rb' | |
spec/integration/repositories/theme_asset_repository_spec.rb
+1
-1
| @@ | @@ -1,4 +1,4 @@ |
| - | require File.join(File.dirname(__FILE__), '..', 'mongodb_helper') |
| + | require 'spec_helper' |
| require_relative '../../../lib/locomotive/steam/adapters/filesystem.rb' | |
| require_relative '../../../lib/locomotive/steam/adapters/mongodb.rb' | |
spec/integration/repositories/translation_repository_spec.rb
+1
-1
| @@ | @@ -1,4 +1,4 @@ |
| - | require File.join(File.dirname(__FILE__), '..', 'mongodb_helper') |
| + | require 'spec_helper' |
| require_relative '../../../lib/locomotive/steam/adapters/filesystem.rb' | |
| require_relative '../../../lib/locomotive/steam/adapters/mongodb.rb' | |
spec/support/helpers.rb
+0
-6
| @@ | @@ -18,12 +18,6 @@ module Spec |
| end | |
| end | |
| - | def restore_mongodb |
| - | path = File.join(File.expand_path(File.dirname(__FILE__)), '..', 'fixtures', 'mongodb') |
| - | `mongo steam_test --eval "db.dropDatabase()"` |
| - | `mongorestore -d steam_test #{path}` |
| - | end |
| - | |
| def run_server | |
| output = ENV['STEAM_VERBOSE'] ? nil : File.join(default_fixture_site_path, 'log/steam.log') | |
| setup_common(output) | |