Module: Card::Set
- Includes:
- Event
- Included in:
- Abstract::Attachment, Abstract::Permission, All::Account, All::Actions, All::ActiveCard, All::AllCss, All::AllCsv, All::AllJs, All::Base, All::Bootstrap::Form, All::Bootstrap::Helper, All::Bootstrap::Wrapper, All::Collection, All::Comment, All::Content, All::ContentHistory, All::EmailHtml, All::EmailText, All::Erb, All::Error, All::EventViz, All::Fetch, All::File, All::Follow, All::Haml, All::History, All::Initialize, All::Json, All::Links, All::Name, All::Notify, All::Observer, All::Pattern, All::Permissions, All::Phases, All::References, All::RichBootstrap, All::RichHtml::Content, All::RichHtml::Editing, All::RichHtml::Form, All::RichHtml::Header, All::RichHtml::Menu, All::RichHtml::Modal, All::RichHtml::Toolbar, All::RichHtml::Wrapper, All::Rss, All::Rules, All::States, All::Templating, All::Text, All::TrackedAttributes, All::Trash, All::Type, All::Utils, All::ViewCache, Right::Account, Right::AddHelp, Right::Bcc, Right::Cc, Right::Comment, Right::Create, Right::Default, Right::Delete, Right::Discussion, Right::Email, Right::Follow, Right::FollowFields, Right::Followers, Right::Following, Right::From, Right::Help, Right::HtmlMessage, Right::MachineInput, Right::MachineOutput, Right::Password, Right::Read, Right::Salt, Right::Script, Right::Stats, Right::Status, Right::Structure, Right::Style, Right::To, Right::Token, Right::Update, Right::WhenCreated, Right::WhenLastEdited, Rstar::Rules, Self::AccountLinks, Self::Accountable, Self::AddHelp, Self::Alerts, Self::All, Self::Always, Self::Autoname, Self::BootstrapCards, Self::BootstrapJs, Self::BootswatchShared, Self::Captcha, Self::Create, Self::Created, Self::Default, Self::Delete, Self::Edited, Self::Follow, Self::FollowDefaults, Self::Foot, Self::Head, Self::Help, Self::Input, Self::Layout, Self::Navbox, Self::Never, Self::Now, Self::OnCreate, Self::OnDelete, Self::OnUpdate, Self::Options, Self::OptionsLabel, Self::PerformanceLog, Self::Read, Self::Recent, Self::RecentSettings, Self::Script, Self::ScriptAce, Self::ScriptCardMenu, Self::ScriptHtml5shivPrintshiv, Self::ScriptJquery, Self::ScriptJqueryHelper, Self::ScriptSlot, Self::ScriptTinymce, Self::Search, Self::Signin, Self::SmartmenuCss, Self::SmartmenuJs, Self::Stats, Self::Structure, Self::Style, Self::StyleBootstrapCompatible, Self::StyleCards, Self::StyleJqueryUiSmoothness, Self::TableOfContents, Self::Thanks, Self::Update, Self::Version, Type::Basic, Type::Cardtype, Type::CoffeeScript, Type::Css, Type::Date, Type::EmailTemplate, Type::File, Type::Html, Type::Image, Type::JavaScript, Type::LayoutType, Type::Number, Type::Phrase, Type::PlainText, Type::Pointer, Type::Scss, Type::SearchType, Type::Session, Type::Set, Type::Setting, Type::Signup, Type::Skin, Type::Toggle, Type::Uri, Type::User, TypePlusRight::User::Follow
- Defined in:
- lib/card/set.rb,
lib/card/set/event.rb,
tmpsets/set/mod001-01_core/all/erb.rb,
tmpsets/set/mod001-01_core/all/haml.rb,
tmpsets/set/mod001-01_core/all/name.rb,
tmpsets/set/mod001-01_core/all/type.rb,
tmpsets/set/mod001-01_core/all/fetch.rb,
tmpsets/set/mod001-01_core/all/rules.rb,
tmpsets/set/mod001-01_core/all/trash.rb,
tmpsets/set/mod001-01_core/all/utils.rb,
tmpsets/set/mod006-05_email/right/cc.rb,
tmpsets/set/mod006-05_email/right/to.rb,
tmpsets/set/mod001-01_core/all/phases.rb,
tmpsets/set/mod001-01_core/all/states.rb,
tmpsets/set/mod006-05_email/right/bcc.rb,
tmpsets/set/mod001-01_core/all/content.rb,
tmpsets/set/mod001-01_core/all/pattern.rb,
tmpsets/set/mod006-05_email/all/follow.rb,
tmpsets/set/mod006-05_email/all/notify.rb,
tmpsets/set/mod006-05_email/right/from.rb,
tmpsets/set/mod006-05_email/self/never.rb,
tmpsets/set/mod004-03_machines/type/css.rb,
tmpsets/set/mod006-05_email/self/always.rb,
tmpsets/set/mod006-05_email/self/edited.rb,
tmpsets/set/mod006-05_email/self/follow.rb,
tmpsets/set/mod007-05_standard/self/all.rb,
tmpsets/set/mod007-05_standard/self/now.rb,
tmpsets/set/mod007-05_standard/type/set.rb,
tmpsets/set/mod007-05_standard/type/uri.rb,
tmpsets/set/mod004-03_machines/type/scss.rb,
tmpsets/set/mod004-03_machines/type/skin.rb,
tmpsets/set/mod005-04_settings/self/help.rb,
tmpsets/set/mod005-04_settings/self/read.rb,
tmpsets/set/mod006-05_email/all/observer.rb,
tmpsets/set/mod006-05_email/right/follow.rb,
tmpsets/set/mod006-05_email/self/created.rb,
tmpsets/set/mod007-05_standard/all/error.rb,
tmpsets/set/mod007-05_standard/all/links.rb,
tmpsets/set/mod007-05_standard/self/foot.rb,
tmpsets/set/mod007-05_standard/self/head.rb,
tmpsets/set/mod007-05_standard/type/date.rb,
tmpsets/set/mod007-05_standard/type/file.rb,
tmpsets/set/mod007-05_standard/type/user.rb,
tmpsets/set/mod001-01_core/all/collection.rb,
tmpsets/set/mod001-01_core/all/initialize.rb,
tmpsets/set/mod001-01_core/all/references.rb,
tmpsets/set/mod001-01_core/all/templating.rb,
tmpsets/set/mod001-01_core/all/view_cache.rb,
tmpsets/set/mod002-01_history/all/actions.rb,
tmpsets/set/mod002-01_history/all/history.rb,
tmpsets/set/mod003-02_basic_types/all/rss.rb,
tmpsets/set/mod005-04_settings/right/help.rb,
tmpsets/set/mod005-04_settings/right/read.rb,
tmpsets/set/mod005-04_settings/self/input.rb,
tmpsets/set/mod005-04_settings/self/style.rb,
tmpsets/set/mod007-05_standard/right/salt.rb,
tmpsets/set/mod007-05_standard/self/stats.rb,
tmpsets/set/mod007-05_standard/type/basic.rb,
tmpsets/set/mod007-05_standard/type/image.rb,
tmpsets/set/mod001-01_core/all/active_card.rb,
tmpsets/set/mod001-01_core/all/permissions.rb,
tmpsets/set/mod003-02_basic_types/all/base.rb,
tmpsets/set/mod003-02_basic_types/all/file.rb,
tmpsets/set/mod003-02_basic_types/all/json.rb,
tmpsets/set/mod003-02_basic_types/all/text.rb,
tmpsets/set/mod005-04_settings/right/style.rb,
tmpsets/set/mod005-04_settings/self/create.rb,
tmpsets/set/mod005-04_settings/self/delete.rb,
tmpsets/set/mod005-04_settings/self/layout.rb,
tmpsets/set/mod005-04_settings/self/script.rb,
tmpsets/set/mod005-04_settings/self/thanks.rb,
tmpsets/set/mod005-04_settings/self/update.rb,
tmpsets/set/mod006-05_email/all/email_html.rb,
tmpsets/set/mod006-05_email/all/email_text.rb,
tmpsets/set/mod007-05_standard/all/account.rb,
tmpsets/set/mod007-05_standard/all/comment.rb,
tmpsets/set/mod007-05_standard/right/email.rb,
tmpsets/set/mod007-05_standard/right/stats.rb,
tmpsets/set/mod007-05_standard/right/token.rb,
tmpsets/set/mod007-05_standard/rstar/rules.rb,
tmpsets/set/mod007-05_standard/self/alerts.rb,
tmpsets/set/mod007-05_standard/self/navbox.rb,
tmpsets/set/mod007-05_standard/self/recent.rb,
tmpsets/set/mod007-05_standard/self/search.rb,
tmpsets/set/mod007-05_standard/self/signin.rb,
tmpsets/set/mod007-05_standard/type/number.rb,
tmpsets/set/mod007-05_standard/type/phrase.rb,
tmpsets/set/mod007-05_standard/type/signup.rb,
tmpsets/set/mod007-05_standard/type/toggle.rb,
tmpsets/set/mod003-02_basic_types/type/html.rb,
tmpsets/set/mod005-04_settings/right/create.rb,
tmpsets/set/mod005-04_settings/right/delete.rb,
tmpsets/set/mod005-04_settings/right/script.rb,
tmpsets/set/mod005-04_settings/right/update.rb,
tmpsets/set/mod005-04_settings/self/captcha.rb,
tmpsets/set/mod005-04_settings/self/default.rb,
tmpsets/set/mod005-04_settings/self/options.rb,
tmpsets/set/mod005-04_settings/type/setting.rb,
tmpsets/set/mod006-05_email/right/followers.rb,
tmpsets/set/mod006-05_email/right/following.rb,
tmpsets/set/mod007-05_standard/right/status.rb,
tmpsets/set/mod007-05_standard/self/version.rb,
tmpsets/set/mod007-05_standard/type/session.rb,
tmpsets/set/mod003-02_basic_types/all/all_js.rb,
tmpsets/set/mod005-04_settings/right/comment.rb,
tmpsets/set/mod005-04_settings/right/default.rb,
tmpsets/set/mod005-04_settings/self/add_help.rb,
tmpsets/set/mod005-04_settings/self/autoname.rb,
tmpsets/set/mod007-05_standard/all/event_viz.rb,
tmpsets/set/mod007-05_standard/right/account.rb,
tmpsets/set/mod007-05_standard/type/cardtype.rb,
tmpsets/set/mod003-02_basic_types/all/all_css.rb,
tmpsets/set/mod003-02_basic_types/all/all_csv.rb,
tmpsets/set/mod005-04_settings/right/add_help.rb,
tmpsets/set/mod005-04_settings/self/on_create.rb,
tmpsets/set/mod005-04_settings/self/on_delete.rb,
tmpsets/set/mod005-04_settings/self/on_update.rb,
tmpsets/set/mod005-04_settings/self/structure.rb,
tmpsets/set/mod007-05_standard/right/password.rb,
tmpsets/set/mod003-02_basic_types/type/pointer.rb,
tmpsets/set/mod004-03_machines/self/script_ace.rb,
tmpsets/set/mod005-04_settings/right/structure.rb,
tmpsets/set/mod006-05_email/right/html_message.rb,
tmpsets/set/mod004-03_machines/self/script_slot.rb,
tmpsets/set/mod004-03_machines/self/style_cards.rb,
tmpsets/set/mod004-03_machines/type/java_script.rb,
tmpsets/set/mod005-04_settings/self/accountable.rb,
tmpsets/set/mod006-05_email/right/follow_fields.rb,
tmpsets/set/mod006-05_email/type/email_template.rb,
tmpsets/set/mod007-05_standard/right/discussion.rb,
tmpsets/set/mod007-05_standard/type/layout_type.rb,
tmpsets/set/mod007-05_standard/type/search_type.rb,
tmpsets/set/mod006-05_email/self/follow_defaults.rb,
tmpsets/set/mod001-01_core/all/tracked_attributes.rb,
tmpsets/set/mod002-01_history/all/content_history.rb,
tmpsets/set/mod003-02_basic_types/type/plain_text.rb,
tmpsets/set/mod004-03_machines/self/script_jquery.rb,
tmpsets/set/mod004-03_machines/type/coffee_script.rb,
tmpsets/set/mod005-04_settings/self/options_label.rb,
tmpsets/set/mod007-05_standard/all/rich_html/form.rb,
tmpsets/set/mod007-05_standard/all/rich_html/menu.rb,
tmpsets/set/mod007-05_standard/right/when_created.rb,
tmpsets/set/mod007-05_standard/self/account_links.rb,
tmpsets/set/mod008-06_bootstrap/self/bootstrap_js.rb,
tmpsets/set/mod008-06_bootstrap/self/smartmenu_js.rb,
tmpsets/set/mod004-03_machines/right/machine_input.rb,
tmpsets/set/mod004-03_machines/self/script_tinymce.rb,
tmpsets/set/mod005-04_settings/abstract/permission.rb,
tmpsets/set/mod007-05_standard/abstract/attachment.rb,
tmpsets/set/mod007-05_standard/all/rich_html/modal.rb,
tmpsets/set/mod008-06_bootstrap/all/bootstrap/form.rb,
tmpsets/set/mod008-06_bootstrap/all/rich_bootstrap.rb,
tmpsets/set/mod008-06_bootstrap/self/smartmenu_css.rb,
tmpsets/set/mod004-03_machines/right/machine_output.rb,
tmpsets/set/mod005-04_settings/self/recent_settings.rb,
tmpsets/set/mod007-05_standard/all/rich_html/header.rb,
tmpsets/set/mod007-05_standard/self/performance_log.rb,
tmpsets/set/mod004-03_machines/self/script_card_menu.rb,
tmpsets/set/mod007-05_standard/all/rich_html/content.rb,
tmpsets/set/mod007-05_standard/all/rich_html/editing.rb,
tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb,
tmpsets/set/mod007-05_standard/all/rich_html/wrapper.rb,
tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb,
tmpsets/set/mod008-06_bootstrap/self/bootstrap_cards.rb,
tmpsets/set/mod005-04_settings/self/table_of_contents.rb,
tmpsets/set/mod007-05_standard/right/when_last_edited.rb,
tmpsets/set/mod008-06_bootstrap/all/bootstrap/wrapper.rb,
tmpsets/set/mod008-06_bootstrap/self/bootswatch_shared.rb,
tmpsets/set/mod006-05_email/type_plus_right/user/follow.rb,
tmpsets/set/mod004-03_machines/self/script_jquery_helper.rb,
tmpsets/set/mod004-03_machines/self/script_html5shiv_printshiv.rb,
tmpsets/set/mod004-03_machines/self/style_bootstrap_compatible.rb,
tmpsets/set/mod004-03_machines/self/style_jquery_ui_smoothness.rb
Defined Under Namespace
Modules: Abstract, All, Event, Format, Right, Rstar, Self, Type, TypePlusRight
Constant Summary
collapse
- @@modules =
{ base: [], base_format: {}, nonbase: {}, nonbase_format: {} }
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Event
#define_event, #event
Class Method Details
.clean_empty_module_from_hash(hash) ⇒ Object
284
285
286
287
288
289
|
# File 'lib/card/set.rb', line 284
def clean_empty_module_from_hash hash
hash.each do |mod_name, modlist|
modlist.delete_if { |x| x.instance_methods.empty? }
hash.delete mod_name if modlist.empty?
end
end
|
.clean_empty_modules ⇒ Object
277
278
279
280
281
282
|
# File 'lib/card/set.rb', line 277
def clean_empty_modules
clean_empty_module_from_hash modules[:nonbase]
modules[:nonbase_format].values.each do |hash|
clean_empty_module_from_hash hash
end
end
|
.extended(mod) ⇒ Object
each set file calls ‘extend Card::Set` when loaded
217
218
219
|
# File 'lib/card/set.rb', line 217
def extended mod
register_set mod
end
|
.process_base_module_list(list, klass) ⇒ Object
268
269
270
271
272
273
274
275
|
# File 'lib/card/set.rb', line 268
def process_base_module_list list, klass
list.each do |mod|
klass.send :include, mod if mod.instance_methods.any?
if (class_methods = mod.const_get_if_defined(:ClassMethods))
klass.send :extend, class_methods
end
end
end
|
.process_base_modules ⇒ Object
‘base modules’ are modules that are permanently included on the Card or Format class ‘nonbase modules’ are included dynamically on singleton_classes
259
260
261
262
263
264
265
266
|
# File 'lib/card/set.rb', line 259
def process_base_modules
process_base_module_list modules[:base], Card
modules[:base_format].each do |format_class, modules_list|
process_base_module_list modules_list, format_class
end
modules.delete :base
modules.delete :base_format
end
|
.register_set(set_module) ⇒ Object
make the set available for use
222
223
224
225
226
227
228
229
230
231
232
233
|
# File 'lib/card/set.rb', line 222
def register_set set_module
return if set_module.abstract_set? if set_module.all_set?
modules[:base] << set_module
else
modules[:nonbase][set_module.shortname] ||= []
modules[:nonbase][set_module.shortname] << set_module
end
end
|
.write_tmp_file(from_file, to_file, rel_path) ⇒ Object
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
# File 'lib/card/set.rb', line 235
def write_tmp_file from_file, to_file, rel_path
name_parts = rel_path.gsub(/\.rb/, '').split(File::SEPARATOR)
submodules = name_parts.map { |a| "module #{a.camelize};" } * ' '
file_content = <<EOF
# -*- encoding : utf-8 -*-
class Card; module Set; #{submodules} extend Card::Set
# ~~~~~~~~~~~ above autogenerated; below pulled from #{from_file} ~~~~~~~~~~~
#{File.read from_file}
# ~~~~~~~~~~~ below autogenerated; above pulled from #{from_file} ~~~~~~~~~~~
end;end;#{'end;' * name_parts.size}
EOF
FileUtils.mkdir_p File.dirname(to_file)
File.write to_file, file_content
to_file
end
|
Instance Method Details
#abstract_set? ⇒ Boolean
317
318
319
|
# File 'lib/card/set.rb', line 317
def abstract_set?
name =~ /^Card::Set::Abstract::/
end
|
#all_set? ⇒ Boolean
321
322
323
|
# File 'lib/card/set.rb', line 321
def all_set?
name =~ /^Card::Set::All::/
end
|
#card_accessor(*args) ⇒ Object
ActiveCard support: accessing plus cards as attributes
175
176
177
178
|
# File 'lib/card/set.rb', line 175
def card_accessor *args
options = args.
add_traits args, options.merge(reader: true, writer: true)
end
|
#card_reader(*args) ⇒ Object
180
181
182
183
|
# File 'lib/card/set.rb', line 180
def card_reader *args
options = args.
add_traits args, options.merge(reader: true)
end
|
#card_writer(*args) ⇒ Object
185
186
187
188
|
# File 'lib/card/set.rb', line 185
def card_writer *args
options = args.
add_traits args, options.merge(writer: true)
end
|
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/card/set.rb', line 129
def define_on_format format_name=:base, &block
klass = Card::Format.format_class_name format_name
mod = const_get_or_set klass do
m = Module.new
register_set_format Card.const_get(klass), m
m.extend Card::Set::Format
m
end
mod.class_eval &block
end
|
#ensure_set(&block) ⇒ Object
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
# File 'lib/card/set.rb', line 190
def ensure_set &block
set_module = yield
rescue NameError => e
if e.message =~ /uninitialized constant (?:Card::Set::)?(.+)$/
Regexp.last_match(1).split('::').inject(Card::Set) do |set_mod, module_name|
set_mod.const_get_or_set module_name do
Module.new
end
end
end
ensure_set &block
else
set_module.extend Card::Set
end
|
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/card/set.rb', line 117
def format *format_names, &block
if format_names.empty?
format_names = [:base]
elsif format_names.first == :all
format_names =
Card::Format.registered.reject { |f| Card::Format.aliases[f] }
end
format_names.each do |f|
define_on_format f, &block
end
end
|
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
# File 'lib/card/set.rb', line 292
def register_set_format format_class, mod
return if abstract_set?
if all_set?
modules[:base_format][format_class] ||= []
modules[:base_format][format_class] << mod
else
format_hash = modules[:nonbase_format][format_class] ||= {}
format_hash[shortname] ||= []
format_hash[shortname] << mod
end
end
|
#shortname ⇒ Object
308
309
310
311
312
313
314
315
|
# File 'lib/card/set.rb', line 308
def shortname
parts = name.split '::'
first = 2 set_class = Card::SetPattern.find parts[first].underscore
last = first + set_class.anchor_parts_count
parts[first..last].join '::'
end
|
#stage_method(method, opts = {}, &block) ⇒ Object
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
# File 'lib/card/set.rb', line 149
def stage_method method, opts={}, &block
class_eval do
define_method "_#{method}", &block
define_method method do |*args|
error =
if !director.stage_ok? opts
if !stage
"phase method #{method} called outside of event phases"
else
"#{opts.inspect} method #{method} called in phase #{stage}"
end
elsif !on_condition_applies?(opts[:on])
"on: #{opts[:on]} method #{method} called on #{@action}"
end
if error
raise Card::Error, error
else
send "_#{method}", *args
end
end
end
end
|
#view(*args, &block) ⇒ Object
143
144
145
146
147
|
# File 'lib/card/set.rb', line 143
def view *args, &block
format do
view *args, &block
end
end
|