Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions Move2mods.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# decko stuff, leave for now
#./decko/spec/cypress/app_commands/factory_bot.rb: # ARDEP: exception RecordInvalid
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments here ...

#./decko/spec/cypress/app_commands/log_fail.rb:# ARDEP defined? protected
#./decko/lib/decko/engine.rb: # ARDEP should be safe, only on-load, maybe also defined?(ActiveRecord) protection needed?
#./decko/lib/decko/generators/decko/templates/config/puma.rb: # ARDEP: maybe register storage managers with establish_connection action?
#./decko/lib/decko/tasks/db.rake: # ARDEP: this is all Rails -> AR standard usages, need alternatives in loading data to storage models
#./decko/lib/decko/tasks/decko/seed.rake: # ARDEP: this is all Rails -> AR standard usages, need alternatives in loading data to storage models
#./decko/lib/decko/tasks/decko.rake: # ARDEP: this is all Rails -> AR standard usages, need alternatives in loading data to storage models
#./decko/rails/controllers/card_controller.rb: # ARDEP: exceptions RecordInvalid

#
# I'm setting up to run a series of git mv's after the subdirs are ready in
# my working directory. The original paths with a comment about the nature of
# of the ActiveRecord dependency, and then the pattern is:
#git mv <targ directory> <source directory> <list of files to move>
# I'll edit the list into git mv commands and run them on this branch.

#./card/config/initializers/02_patches/active_record.rb: # ARDEP: configuration (in filename)
#./card/config/initializers/patches.rb:# ARDEP: need to isolate this to named and optionally included place
git mv card/config/initializers/patches.rb card/mod/active_record/config/initializers
git mv card/config/initializers/02_patches/active_record.rb card/mod/active_record/config/initializers/02_patches


#./card/spec/lib/card/subcards_spec.rb: # ARDEP: exception RecordInvalid
#./card/spec/lib/card/set/required_field_spec.rb: # ARDEP: exception RecordInvalid (apparently can't depend on it defined?)
git mv card/spec/lib/card/subcards_spec.rb card/mod/active_record/spec/lib/card
git mv card/spec/lib/card/set/required_field_spec.rb card/mod/active_record/set

# card/mod/core/set/all/collection.rb: # ARDEP: ::Relation
# card/mod/core/set/all/states.rb: # ARDEP: new_record? in storage API
# card/mod/core/set/all/abort.rb: # ARDEP: need a storage API to do this
git mv card/mod/core/set/all/collection.rb card/mod/active_record/set/all
git mv card/mod/core/set/all/states.rb card/mod/active_record/set/all
git mv card/mod/core/set/all/abort.rb card/mod/active_record/set/all

git mv card/mod/core/spec/set/all/subcards_spec.rb card/mod/active_record/spec/set/all
git mv card/mod/pointer/spec/set/type/mirror_list_spec.rb card/mod/active_record/spec/set/type

# leave in history
#./card/mod/history/set/all/history/act_listing.rb: # ARDEP: Relation
#./card/mod/history/lib/card/act.rb: # ARDEP: Relation

# card/mod/carrierwave/spec/set/abstract/attachment/cloud_spec.rb: # ARDEP: exceptions RecordInvalid
# card/mod/carrierwave/spec/set/type/file_spec.rb: # ARDEP: exceptions RecordInvalid
#git mv card/mod/carrierwave/spec/set/abstract/cloud_spec.rb card/mod/active_record/spec/set/abstract
#git mv card/mod/carrierwave/spec/set/type/mirror_list_spec.rb card/mod/active_record/spec/set/type

#./card/lib/generators/card.rb: # ARDEP: migration generators
#./card/lib/application_record.rb:# ARDEP: refactor this to a factory for configured storage modules that can store and use ActiveModel

#./card/lib/cardio.rb: # ARDEP: connection object
#./card/lib/cardio/schema.rb: # ARDEP: migrations

#./card/lib/card/model/save_helper.rb: # ARDEP: note how ! methods here should be the complete interface from Card::Model < ActiveModel when it needs AR methods and features. I think the solution is to have a 'naked' card that is just a Model, and a Card::Storage class that works like formatters to do view stuff. You need to card.to_storage to get the mutation functions used here
git mv card/lib/card/model/save_helper.rb card/mod/active_record/lib/card/model

#./card/lib/card/cache/persistent.rb: # ARDEP: should be ActiveModel and only create AR object to manage storage process
git mv card/lib/card/cache/persistent.rb card/mod/fetch/lib/card/cache

#./card/lib/card/migration.rb: # ARDEP: migration
git mv card/lib/card/migration.rb card/mod/active_record/lib/card
#./card/lib/card/codename.rb: # ARDEP: connection
git mv card/lib/card/codename.rb card/mod/fetch/lib/card

#./card/lib/card/director/phases.rb: # ARDEP: exception RecordInvalid
#./card/lib/card/director/store.rb: # ARDEP: comments reflect Card::Storage class
git mv card/lib/card/director/phases.rb card/mod/storage/lib/card/director
git mv card/lib/card/director/store.rb card/mod/storage/lib/card/director

#./card/lib/card/tasks/card/migrate.rake:#ARDEP: migrations
git mv card/lib/card/tasks/card/migrate.rake card/mod/rails/lib/card/tasks/card

#./card/lib/card/query/sql_statement.rb: # ARDEP: connection
#./card/lib/card/query/clause.rb: # ARDEP: connection
#./card/lib/card/query/card_query/run.rb: # ARDEP: connection
git mv card/lib/card/query card/mod/active_record/lib/card

# ./card/lib/card/error.rb: # ARDEP: exceptions RecordNotFound, RecordInvalid
# ./card/lib/card/error.rb: # ARDEP ActionController: exceptions BadRequest, MissingFile
git mv card/lib/card/error.rb card/mod/active_record/lib/card

After the moving, we have these stats:
content
4807 total
fetch
957 total
storage
129 total
rails
111 rails/lib/card/tasks/card/migrate.rake
active_record
3297 total
utility
99 total
admin
363 total
core
4931 total
virtual
167 total
history
1878 total
basic_formats
1086 total
item
199 total
pointer
2164 total
solid_cache
278 total
basic_types
137 total
machines
50018 total
settings
947 total
email
309 total
follow
2280 total
developer
202 total
carrierwave
2324 total
media
188 total
search
1232 total
standard
5702 total
rules
1204 total
account
1754 total
navbar
432 total
bootstrap
874110 total
google_analytics
39 google_analytics/set/all/google_analytics.rb
2 changes: 1 addition & 1 deletion card/README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ When you install and seed a new Decko project, you have a working "deck" right a

Ruby-on-Rails developers reading this will find lots of familiar patterns in Decko, which indeed depends upon rails gems. <b>Although Decko is a Rails descendant and owes a ton to the Rails community, it is not Rails.</b> Unlike Rails, Decko is not an implementation of the "MVC" (Model-View-Controller) architectural pattern (see Architecture below). More concretely, while Rails' core pattern is adding new things (especially models, views, and controllers), Decko's core pattern is subdividing existing things into new Sets.

Deck-coders do create lots of card views (though they're quite different from Rails views), but we rarely if ever create new controllers or ActiveRecord models. In the Decko gem there is one controller (CardController) and one main model ({Card}). Other models optimize the Card model and track its history: (See {Card::Reference references}, {Card::Act acts}, {Card::Action actions}, and {Card::Change changes}).
Deck-coders do create lots of card views (though they're quite different from Rails views), but we rarely if ever create new controllers or ActiveModel/ActiveRecord models. In the Decko gem there is one controller (CardController) and one main model ({Card}). Other models optimize the Card model and track its history: (See {Card::Reference references}, {Card::Act acts}, {Card::Action actions}, and {Card::Change changes}).


===Cards, Sets, and Rules
Expand Down
1 change: 1 addition & 0 deletions card/lib/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ARDEP: refactor this to a factory for configured storage modules that can store and use ActiveModel
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
1 change: 1 addition & 0 deletions card/lib/card/set/pattern/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def left_type card
card.superleft&.type_name || quick_type(card.name.left_name)
end

# FIXME: why not make this a fetch method to use more generally too
def quick_type name
if name.present?
card = Card.fetch name, skip_modules: true, new: {}
Expand Down
1 change: 1 addition & 0 deletions card/lib/card/tasks/card/migrate.rake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def load_mod_lib
Dir.glob(Cardio.root.join("mod/*/lib/*.rb")).each { |x| require x }
end

#ARDEP: migrations
def without_dumping
ActiveRecord::Base.dump_schema_after_migration = false
yield
Expand Down
1 change: 1 addition & 0 deletions card/lib/cardio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def card_defined?
end

def load_card?
# ARDEP: connection object
ActiveRecord::Base.connection && !card_defined?
rescue
false
Expand Down
1 change: 1 addition & 0 deletions card/lib/cardio/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Cardio
module Schema
def assume_migrated_upto_version type
Cardio.schema_mode(type) do
# ARDEP: migrations
ActiveRecord::Schema.assume_migrated_upto_version(Cardio.schema(type),
Cardio.migration_paths(type))
end
Expand Down
1 change: 1 addition & 0 deletions card/lib/generators/card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def mod_path
end
end

# ARDEP: migration generators
class MigrationBase < ::ActiveRecord::Generators::Base
extend ClassMethods
end
Expand Down
4 changes: 4 additions & 0 deletions card/mod/Modfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
mod 'content'
mod 'fetch'
mod 'storage'
mod 'active_record'
mod 'utility'
mod 'admin'
mod 'core'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# nothing is returned from the function

module Patches
# ARDEP: configuration (in filename)
module ActiveRecord
module Relation
def pluck_in_batches *columns, batch_size: 1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class StackFrame
end
end

# ARDEP: need to isolate this to named and optionally included place
module ActiveRecord #:nodoc: all
class Relation
include Patches::ActiveRecord::Relation
Expand Down Expand Up @@ -72,4 +73,4 @@ module Zeitwerk #:nodoc: all
class Loader
prepend Patches::Zeitwerk
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def report
end

# error whose message can be shown to any user
# ARDEP: exceptions RecordNotFound, RecordInvalid
# ARDEP ActionController: exceptions BadRequest, MissingFile
class UserError < Error
cattr_accessor :user_error_classes
self.user_error_classes = [self,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- encoding : utf-8 -*-

class Card
# ARDEP: migration
class Migration < ActiveRecord::Migration[4.2]
include Card::Model::SaveHelper
@type = :deck_cards
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Model
# somethings fails.
# All !-methods in this module rename existing cards
# to resolve name conflicts)
# ARDEP: note how ! methods here should be the complete interface from Card::Model < ActiveModel when it needs AR methods and features. I think the solution is to have a 'naked' card that is just a Model, and a Card::Storage class that works like formatters to do view stuff. You need to card.to_storage to get the mutation functions used here
module SaveHelper
def with_user user_name
Card::Auth.with current_id: Card.fetch_id(user_name) do
Expand All @@ -16,6 +17,7 @@ def with_user user_name
end

def create_card name_or_args, content_or_args=nil
# ARDEP: is there an AM create?
Card.create! create_args(name_or_args, content_or_args)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def fetch_or_instantiate record
card
end

# ARDEP: connection
def run_sql
# puts "\nSQL = #{sql}"
ActiveRecord::Base.connection.select_all sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def quote v
connection.quote(v)
end

# ARDEP: connection
def connection
@connection ||= ActiveRecord::Base.connection
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def safe_sql txt
end

def cast_type type
# ARDEP: connection
cxn ||= ActiveRecord::Base.connection
(val = cxn.cast_types[type.to_sym]) ? val[:name] : safe_sql(type)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def with_transaction_returning_status
add_to_transaction
remember_transaction_record_state
status = abortable { yield }
# ARDEP: need a storage API to do this
raise ActiveRecord::Rollback unless status
end
status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def count_by_cql spec
def find_each options={}
# this is a copy from rails (3.2.16) and is needed because this
# is performed by a relation (ActiveRecord::Relation)
# ARDEP: ::Relation
find_in_batches(options) do |records|
records.each { |record| yield record }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def known?

# @return [True/False]
def new?
# ARDEP: new_record? in storage API
new_record? || # not yet in db (from ActiveRecord)
!@from_trash.nil? # in process of restoration from trash
end
Expand All @@ -81,4 +82,4 @@ def pristine?

def user_changes?
actions.joins(:act).where("card_acts.actor_id != ?", WagnBotID).exists?
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
card = Card.new name: "reader", "+*read" => "me"
card.set_with { require_field :read }

# ARDEP: exception RecordInvalid (apparently can't depend on it defined?)
expect { card.save! }.not_to raise_error #ActiveRecord::RecordInvalid
end
end
Expand All @@ -30,6 +31,7 @@
card
end

# ARDEP: exception RecordInvalid
it "can't be deleted" do
card_with_required_field
expect { field.delete! }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def with_subcard_validation_error_in_rename
end
end

# ARDEP: exception RecordInvalid
it "works on rename (update!)" do
with_subcard_validation_error_in_rename do
expect{ referee.update! name: "Tea", update_referers: true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
end

describe "add subcards" do
# ARDEP: storage transaction (storage connection API)
let(:transact) { ActiveRecord::Base.connection.current_transaction }
let(:record_names) { transact.records.map(&:name) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
end
end
it "doesn't allow non-cardtype as right part" do
# ARDEP: exceptions RecordInvalid
expect do
Card["Parry Hotter+authors"].update!(name: "Parry Hotter+hidden")
end.to raise_error(ActiveRecord::RecordInvalid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def file_path

it "copies file to local file system" do
# not yet supported
# ARDEP: exceptions RecordInvalid
expect { Card[file_card.name].update!(storage_type: :local) }
.to raise_error(ActiveRecord::RecordInvalid)
end
Expand Down
1 change: 1 addition & 0 deletions card/mod/carrierwave/spec/set/type/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def source_view card

context "creating" do
it "fails if no file given" do
# ARDEP: exceptions RecordInvalid
expect do
Card::Auth.as_bot do
Card.create! name: "hide and seek", type_id: Card::FileID
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion card/mod/core/set/all/initialize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def initialize args={}

handle_set_modules args do
handle_type args do
super args # ActiveRecord #initialize
super args # ActiveRecord (storage classes) #initialize
end
end
self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def reset
# @param opts [Hash]
# @option opts [Rails::Cache] :store
# @option opts [ruby Class] :class, typically ActiveRecord descendant
# ARDEP: should be ActiveModel and only create AR object to manage storage process
# @option opts [String] :database
def initialize opts
@store = opts[:store]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def generate_id_constants
# @yieldparam id [Integer]
def each_codenamed_card
sql = "select id, codename from cards where codename is not NULL"
# ARDEP: connection
ActiveRecord::Base.connection.select_all(sql).each do |row|
yield row["codename"].to_sym, row["id"].to_i
end
Expand Down
File renamed without changes.
Loading