New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new subcards api and list/listed_by relations #513
Merged
Merged
Changes from 14 commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
a0386f0
list and listed_by cardtypes
xithan 4de490a
Merge remote-tracking branch 'upstream/master' into listedby
xithan 024a3d5
refactoring subcards
xithan fb0d1c5
.codeclimate.yml: ingnore assets
xithan 1aa90c8
subcards overhaul
xithan b0aacba
getting closer to get subcards working
xithan a043770
correct type count test
xithan 9680251
fetch.rb: refactor #fetch_from_cache_or_db
xithan ed661f1
let subcards survive #expire
xithan 14c54c5
Merge remote-tracking branch 'wagn/master' into listedby
xithan 34b48eb
.ruby-style.yml: require no parens for method definitions
xithan 9f64fc3
can almost see the green light
xithan 07b2d51
seed tick
xithan 6d3957c
:checkered_flag:
xithan aac4d61
remove unused #given_name
xithan 66f7bd1
restore wagn logo
xithan f6ecbe0
houndiness
xithan 54b4c24
check if the listed_by relation makes it to the reference table
xithan 7c5db75
add rubocop config file
xithan 495f156
.ruby-style.yml: leading dot position for multi-line method calls
xithan d38553d
:dog2:
xithan 08f2c27
:dog2::dog2:
xithan 35dcc67
get features passing
xithan 153c8bd
Merge remote-tracking branch 'wagn/master' into listedby
xithan aa5df6a
refactor card initialization
xithan ce2be16
refactor #fetch
xithan 65a274b
machine.rb: update after :expire_related instead of after :store_subc…
xithan 25cc8c1
phase.rb: preparations for phase methods
xithan 3d68e08
move specs from type_spec to initialize_spec
xithan b83120e
specs clean up
xithan cf1d443
wagn.rake: update deprecated constant
xithan 8982834
search_type.rb bug: invalid default type if WQL doesn't search for a …
xithan 8e877a5
set.rb: more phase methods
xithan 923f6e3
name.rb: #to_sym for name objects
xithan d6bc67c
houndiness
xithan 7ad511c
all/subcards.rb: move subcard methods from phases.rb here
xithan 15ccd61
subcards.rb: use local cache only
xithan b48d200
more houndiness
xithan 2c5d5dd
fetch.rb#fetch_id: treat only symbols as codenames
xithan 12a5142
auth.rb: refactor #needs_setup?
xithan 61900fd
subcards.rb: rename :filter_empty_subcards to :reject_empty_subcards
xithan 847ca40
subcards.rb: renamed #empty? to #unfilled?
xithan 0638ed6
add method for creating active accounts
xithan 06eaf92
subcards.rb: fix for subsubcards
xithan 671ce92
renamed list.rb
xithan e11bd4c
form.rb: introduce form_root
xithan 9d3ebaa
final(?) adjustments
xithan 79d3208
hound style updates
xithan 1cec401
seed update
xithan 3ec0850
Merge remote-tracking branch 'wagn/master' into listedby
xithan b1d53b5
hound
xithan 6f66c3a
:dog:
xithan 3a486e7
ruby-style: turn "unnecessary spacing" off
xithan 66977a5
:dog:
xithan 4a2b2b0
fixed phase_method API
xithan 4590c7b
:dog:
xithan 6eeb5b2
another phase_method fix
xithan 69c51cb
:dog:
xithan 5d1b178
fetch.rb: refactor #fetch
xithan d7bd5c5
phase fixes
xithan e676aac
lock selenium-webdriver gem to 2.47
xithan File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
languages: | ||
Ruby: true | ||
JavaScript: true | ||
PHP: false | ||
Python: false | ||
exclude_paths: | ||
- "wagn/rails/assets" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
card/db/migrate_core_cards/20150708224756_add_list_cards.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# -*- encoding : utf-8 -*- | ||
|
||
class AddListCards < Card::CoreMigration | ||
def up | ||
Card.create! :name=>'List', :type_code=>:cardtype, :codename=>:list | ||
Card.create! :name=>'Listed by', :type_code=>:cardtype, :codename=>:listed_by, | ||
:subcards=>{'+*right+*structure'=>'{{+type}}{{+list name}}'} | ||
Card.create! :name=>'*cached count', :codename=>:cached_count, | ||
:subcards=>{'+*right+*update'=>'[[Administrator]]', '+*right+*create'=>'[[Administrator]]', '+*right+*delete'=>'[[Administrator]]'} | ||
Card.create! :name=>'*cached content', :codename=>:cached_content, | ||
:subcards=>{'+*right+*update'=>'[[Administrator]]', '+*right+*create'=>'[[Administrator]]', '+*right+*delete'=>'[[Administrator]]'} | ||
end | ||
end |
Submodule seed
updated
from be14cb to 5bf095
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,236 @@ | ||
# -*- encoding : utf-8 -*- | ||
|
||
# API to create/update/delete additional cards together with the main card. | ||
# The most common case is for fields. For example toghether with "my address" you want to create the subcards "my address+name", "my address+street", etc. but subcards don't have to be descendants. | ||
|
||
# Subcards can be added as card objects or attribute hashes. | ||
|
||
|
||
|
||
class Card | ||
def subcards | ||
@subcards ||= Subcards.new(self) | ||
end | ||
|
||
def field tag | ||
Card[cardname.field(tag)] | ||
end | ||
|
||
def subcard card_name | ||
subcards.card card_name | ||
end | ||
|
||
def subfield field_name | ||
subcards.field field_name | ||
end | ||
|
||
def add_subcard name_or_card, args=nil | ||
subcards.add name_or_card, args | ||
end | ||
|
||
def add_subfield name, args=nil | ||
subcards.add_field name, args | ||
end | ||
|
||
def remove_subcard name_or_card | ||
subcards.remove name_or_card | ||
end | ||
|
||
def remove_subfield name_or_card | ||
subcards.remove_field name_or_card | ||
end | ||
|
||
def preserve_subcards | ||
if subcards.present? | ||
Card::Cache[Card::Subcards].write key, @subcards | ||
end | ||
end | ||
|
||
def restore_subcards | ||
if Card::Cache[Card::Subcards].exist? key | ||
@subcards = Card::Cache[Card::Subcards].fetch key | ||
end | ||
end | ||
|
||
def expire_subcards | ||
Card::Cache[Card::Subcards].delete key | ||
end | ||
|
||
|
||
class Subcards | ||
|
||
def initialize(context_card) | ||
@context_card = context_card | ||
@keys = ::Set.new | ||
end | ||
|
||
def remove name_or_card | ||
key = case name_or_card | ||
when Card | ||
name_or_card.key | ||
when Symbol | ||
fetch_subcard(name_or_card).key | ||
else | ||
name_or_card.to_name.key | ||
end | ||
|
||
@keys.include? key && @keys.delete(key) | ||
end | ||
|
||
def add name_or_card_or_attr, card_or_attr=nil | ||
if card_or_attr | ||
name = name_or_card_or_attr | ||
else | ||
card_or_attr = name_or_card_or_attr | ||
end | ||
case card_or_attr | ||
when Hash | ||
args = card_or_attr | ||
if name | ||
add_attributes name, args | ||
elsif args[:name] | ||
add_attributes args.delete(:name), args | ||
else | ||
args.each_pair do |key, val| | ||
if val.kind_of? String | ||
add_attributes key, :content => val | ||
else | ||
add_attributes key, val | ||
end | ||
end | ||
end | ||
when Card | ||
add_card card_or_attr | ||
when Symbol, String | ||
add_attributes card_or_attr, {} | ||
end | ||
end | ||
|
||
def << value | ||
add value | ||
end | ||
|
||
def method_missing method, *args | ||
if @keys.respond_to? method | ||
@keys.send method, *args | ||
end | ||
end | ||
|
||
|
||
def each_card | ||
@keys.each do |key| | ||
yield(fetch_subcard key) | ||
end | ||
end | ||
|
||
alias_method :each, :each_card | ||
|
||
def each_with_key | ||
@keys.each do |key| | ||
yield(fetch_subcard(key), key) | ||
end | ||
end | ||
|
||
def []= name, card_or_attr | ||
case card_or_attr | ||
when Hash | ||
add_attributes name, card_or_attr | ||
when Card | ||
add_card name, card_or_attr | ||
end | ||
end | ||
|
||
def [] name | ||
card name | ||
end | ||
|
||
def field name | ||
key = field_name_to_key name | ||
if @keys.include? key | ||
fetch_subcard key | ||
end | ||
end | ||
|
||
def card name | ||
if @keys.include? name.to_name.key | ||
fetch_subcard name | ||
end | ||
end | ||
|
||
def add_child name, args | ||
add prepend_plus(name), args | ||
end | ||
|
||
def remove_child name_or_card | ||
if name_or_card.kind_of? Card | ||
remove name_or_card | ||
else | ||
absolute_name = @context_card.cardname.field_name(name_or_card) | ||
if @keys.include? absolute_name.key | ||
remove absolute_name | ||
else | ||
remove @context_card.cardname.relative_field_name(name_or_card) | ||
end | ||
end | ||
end | ||
|
||
alias_method :add_field, :add_child | ||
alias_method :remove_field, :remove_child | ||
|
||
def present? | ||
@keys.present? | ||
end | ||
|
||
private | ||
|
||
def fetch_subcard key | ||
Card.fetch key, :subcard => true | ||
end | ||
|
||
|
||
def prepend_plus name | ||
case name | ||
when Symbol | ||
"+#{Card[name].name}" | ||
when /^\+/ | ||
name | ||
else | ||
"+#{name}" | ||
end | ||
end | ||
|
||
def field_name_to_key name | ||
if @context_card.name =~ /^\+/ | ||
@context_card.cardname.relative_field_name(name).key | ||
else | ||
absolute_key = @context_card.cardname.field_name(name).key | ||
if @keys.include? absolute_key | ||
absolute_key | ||
else | ||
@context_card.cardname.relative_field_name(name).key | ||
end | ||
end | ||
end | ||
|
||
def add_attributes name, attributes={} | ||
absolute_name = | ||
if @context_card.name =~ /^\+/ | ||
name | ||
else | ||
name.to_name.to_absolute_name(@context_card.name).s | ||
end | ||
card = Card.assign_or_initialize_by absolute_name, attributes | ||
add_card card | ||
end | ||
|
||
def add_card card | ||
card.supercard = @context_card | ||
if !card.cardname.simple? && card.cardname.is_a_field_of?(@context_card.cardname) | ||
card.superleft = @context_card | ||
end | ||
@keys << card.key | ||
Card.write_to_cache card | ||
card | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
above the new subcards API