card 1.16.13 → 1.16.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/db/migrate_core_cards/20150501010515_responsive_sidebar.rb +11 -0
- data/db/schema.rb +1 -1
- data/lib/card/auth.rb +3 -2
- data/lib/card/env.rb +1 -1
- data/lib/card/loader.rb +79 -40
- data/lib/card/query.rb +5 -5
- data/lib/card/query/sql_statement.rb +10 -4
- data/lib/card/query/value.rb +5 -8
- data/lib/card/set.rb +0 -1
- data/lib/cardio.rb +18 -22
- data/mod/01_core/chunk/link.rb +37 -34
- data/mod/01_core/chunk/query_reference.rb +1 -1
- data/mod/01_core/set/all/fetch.rb +66 -58
- data/mod/01_core/set/all/permissions.rb +84 -83
- data/mod/01_core/set/all/templating.rb +6 -5
- data/mod/01_core/set/all/type.rb +16 -14
- data/mod/02_basic_types/set/all/base.rb +3 -3
- data/mod/02_basic_types/set/type/pointer.rb +4 -4
- data/mod/02_basic_types/spec/set/all/base_spec.rb +16 -1
- data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +65 -0
- data/mod/05_email/set/all/follow.rb +6 -10
- data/mod/05_email/set/type/email_template.rb +1 -1
- data/mod/05_standard/lib/file_uploader.rb +39 -41
- data/mod/05_standard/set/all/account.rb +18 -20
- data/mod/05_standard/set/all/rich_html/toolbar.rb +1 -1
- data/mod/05_standard/set/right/account.rb +2 -2
- data/mod/05_standard/set/right/email.rb +14 -13
- data/mod/05_standard/set/right/password.rb +20 -12
- data/mod/05_standard/set/right/status.rb +2 -2
- data/mod/05_standard/set/self/head.rb +66 -53
- data/mod/05_standard/set/type/search_type.rb +3 -2
- data/mod/05_standard/set/type/set.rb +3 -3
- data/mod/06_bootstrap/lib/stylesheets/bootstrap_cards.scss +50 -0
- data/spec/lib/card/query_spec.rb +7 -0
- data/spec/spec_helper.rb +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 5bff967a00719608171fe172a88f9e1d6771217a
         | 
| 4 | 
            +
              data.tar.gz: 4d71791152c3662e0412e41986a395171bd457e3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 86f5d9f8cb45509e260ffc05f38c2fb6af60c5f855ef90d285df72ffe18b4ce94aeeb4a4e8bb89397bec239bc97aecfd1026a758c1fa16e388156866019c1e63
         | 
| 7 | 
            +
              data.tar.gz: 4fc615ab61f11cbe7afba28a165430e8bc833651e1cf537181963fffaf74cafea1f90a89a01b87658d0f7579ea659102cb9980f7bb7860c50ec3a74573d6413a
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            1.16. | 
| 1 | 
            +
            1.16.14
         | 
| @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            # -*- encoding : utf-8 -*-
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class ResponsiveSidebar < Card::CoreMigration
         | 
| 4 | 
            +
              def up
         | 
| 5 | 
            +
                if (layout = Card.fetch 'Default Layout') &&
         | 
| 6 | 
            +
                   layout.updater.id == Card::WagnBotID
         | 
| 7 | 
            +
                  new_content = layout.content.gsub '<body>', '<body class="right-sidebar">'
         | 
| 8 | 
            +
                  layout.update_attributes! content: new_content
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
            end
         | 
    
        data/db/schema.rb
    CHANGED
    
    
    
        data/lib/card/auth.rb
    CHANGED
    
    | @@ -5,7 +5,6 @@ class Card | |
| 5 5 | 
             
                @@as_card = @@as_id = @@current_id = @@current = nil
         | 
| 6 6 | 
             
                @@simulating_setup_need = nil
         | 
| 7 7 |  | 
| 8 | 
            -
                NON_CREATEABLE_TYPES = %w{ signup setting set } # NEED API
         | 
| 9 8 | 
             
                SETUP_COMPLETED_KEY = 'SETUP_COMPLETED'
         | 
| 10 9 |  | 
| 11 10 | 
             
                # after_save :reset_instance_cache
         | 
| @@ -214,7 +213,9 @@ class Card | |
| 214 213 | 
             
                  def createable_types
         | 
| 215 214 | 
             
                    type_names = Auth.as_bot do
         | 
| 216 215 | 
             
                      Card.search type: Card::CardtypeID, return: :name,
         | 
| 217 | 
            -
                                  not: { | 
| 216 | 
            +
                                  not: {
         | 
| 217 | 
            +
                                    codename: ['in'] + Card.config.non_createable_types
         | 
| 218 | 
            +
                                  }
         | 
| 218 219 | 
             
                    end
         | 
| 219 220 | 
             
                    type_names.select do |name|
         | 
| 220 221 | 
             
                      Card.new(type: name).ok? :create
         | 
    
        data/lib/card/env.rb
    CHANGED
    
    
    
        data/lib/card/loader.rb
    CHANGED
    
    | @@ -15,12 +15,53 @@ class Card | |
| 15 15 | 
             
              end
         | 
| 16 16 |  | 
| 17 17 | 
             
              module Loader
         | 
| 18 | 
            -
             | 
| 19 18 | 
             
                class << self
         | 
| 20 19 | 
             
                  def load_mods
         | 
| 21 20 | 
             
                    load_set_patterns
         | 
| 22 21 | 
             
                    load_formats
         | 
| 23 22 | 
             
                    load_sets
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                    if ENV['RAILS_ENV'] == 'development'
         | 
| 25 | 
            +
                      update_machine_output_hack
         | 
| 26 | 
            +
                    end
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  def update_machine_output_hack
         | 
| 30 | 
            +
                    update_script_output
         | 
| 31 | 
            +
                    update_style_output
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  def update_script_output
         | 
| 35 | 
            +
                    script = Card['*all+*script']
         | 
| 36 | 
            +
                    return unless (mtime_output = script.machine_output_card.updated_at)
         | 
| 37 | 
            +
                    ['wagn_mod.js.coffee', 'wagn.js.coffee',
         | 
| 38 | 
            +
                     'script_card_menu.js.coffee'].each do |name|
         | 
| 39 | 
            +
                      mtime_file = File.mtime(
         | 
| 40 | 
            +
                        "#{Cardio.gem_root}/mod/03_machines/lib/javascript/#{name}"
         | 
| 41 | 
            +
                      )
         | 
| 42 | 
            +
                      if mtime_file > mtime_output
         | 
| 43 | 
            +
                        script.update_machine_output
         | 
| 44 | 
            +
                        break
         | 
| 45 | 
            +
                      end
         | 
| 46 | 
            +
                    end
         | 
| 47 | 
            +
                  end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                  def update_style_output
         | 
| 50 | 
            +
                    style = Card['*all+*style']
         | 
| 51 | 
            +
                    return unless (mtime_output = style.machine_output_card.updated_at)
         | 
| 52 | 
            +
                    style.machine_input_card.item_cards.each do |i_card|
         | 
| 53 | 
            +
                      next unless i_card.codename
         | 
| 54 | 
            +
                      ['03_machines', '06_bootstrap'].each do |mod|
         | 
| 55 | 
            +
                        style_dir = "#{Cardio.gem_root}/mod/#{mod}/lib/stylesheets"
         | 
| 56 | 
            +
                        file_path = "#{style_dir}/#{i_card.codename}.scss"
         | 
| 57 | 
            +
                        next unless File.exist? file_path
         | 
| 58 | 
            +
                        mtime_file = File.mtime file_path
         | 
| 59 | 
            +
                        if mtime_file > mtime_output
         | 
| 60 | 
            +
                          style.update_machine_output
         | 
| 61 | 
            +
                          break
         | 
| 62 | 
            +
                        end
         | 
| 63 | 
            +
                      end
         | 
| 64 | 
            +
                    end
         | 
| 24 65 | 
             
                  end
         | 
| 25 66 |  | 
| 26 67 | 
             
                  def load_chunks
         | 
| @@ -33,9 +74,10 @@ class Card | |
| 33 74 | 
             
                    mod_dirs.inject({}) do |hash, mod|
         | 
| 34 75 | 
             
                      dirname = "#{mod}/layout"
         | 
| 35 76 | 
             
                      if File.exists? dirname
         | 
| 36 | 
            -
                        Dir.foreach( | 
| 77 | 
            +
                        Dir.foreach(dirname) do |filename|
         | 
| 37 78 | 
             
                          next if filename =~ /^\./
         | 
| 38 | 
            -
                          hash[ | 
| 79 | 
            +
                          hash[filename.gsub /\.html$/, ''] =
         | 
| 80 | 
            +
                            File.read([dirname, filename] * '/')
         | 
| 39 81 | 
             
                        end
         | 
| 40 82 | 
             
                      end
         | 
| 41 83 | 
             
                      hash
         | 
| @@ -45,7 +87,7 @@ class Card | |
| 45 87 | 
             
                  def mod_dirs
         | 
| 46 88 | 
             
                    @@mod_dirs ||= begin
         | 
| 47 89 | 
             
                      Card.paths['mod'].existent.map do |dirname|
         | 
| 48 | 
            -
                        Dir.entries( | 
| 90 | 
            +
                        Dir.entries(dirname).sort.map do |filename|
         | 
| 49 91 | 
             
                          "#{dirname}/#{filename}" if filename !~ /^\./
         | 
| 50 92 | 
             
                        end.compact
         | 
| 51 93 | 
             
                      end.flatten.compact
         | 
| @@ -67,19 +109,21 @@ class Card | |
| 67 109 | 
             
                    mod_dirs.each do |mod|
         | 
| 68 110 | 
             
                      dirname = "#{mod}/set_pattern"
         | 
| 69 111 | 
             
                      if Dir.exists? dirname
         | 
| 70 | 
            -
                        Dir.entries( | 
| 71 | 
            -
                           | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 75 | 
            -
                           | 
| 112 | 
            +
                        Dir.entries(dirname).sort.each do |filename|
         | 
| 113 | 
            +
                          m = filename.match(/^(\d+_)?([^\.]*).rb/)
         | 
| 114 | 
            +
                          key = m && m[2]
         | 
| 115 | 
            +
                          next unless key
         | 
| 116 | 
            +
                          filename = [dirname, filename] * '/'
         | 
| 117 | 
            +
                          SetPattern.write_tmp_file key, filename, seq
         | 
| 118 | 
            +
                          seq = seq + 1
         | 
| 76 119 | 
             
                        end
         | 
| 77 120 | 
             
                      end
         | 
| 78 121 | 
             
                    end
         | 
| 79 122 | 
             
                  end
         | 
| 80 123 |  | 
| 81 124 | 
             
                  def load_formats
         | 
| 82 | 
            -
                    #cheating on load issues now by putting all inherited-from formats in | 
| 125 | 
            +
                    # cheating on load issues now by putting all inherited-from formats in
         | 
| 126 | 
            +
                    # core mod.
         | 
| 83 127 | 
             
                    mod_dirs.each do |mod|
         | 
| 84 128 | 
             
                      load_dir "#{mod}/format/*.rb"
         | 
| 85 129 | 
             
                    end
         | 
| @@ -92,26 +136,24 @@ class Card | |
| 92 136 | 
             
                    Set.clean_empty_modules
         | 
| 93 137 | 
             
                  end
         | 
| 94 138 |  | 
| 95 | 
            -
             | 
| 96 139 | 
             
                  def generate_tmp_set_modules
         | 
| 97 | 
            -
                     | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 103 | 
            -
             | 
| 104 | 
            -
             | 
| 105 | 
            -
                        end
         | 
| 106 | 
            -
                        seq = seq + 1
         | 
| 140 | 
            +
                    return unless prepare_tmp_dir 'tmp/set'
         | 
| 141 | 
            +
                    seq = 1
         | 
| 142 | 
            +
                    mod_dirs.each do |mod_dir|
         | 
| 143 | 
            +
                      mod_tmp_dir = make_set_module_tmp_dir mod_dir, seq
         | 
| 144 | 
            +
                      Dir.glob("#{mod_dir}/set/**/*.rb").each do |abs_filename|
         | 
| 145 | 
            +
                        rel_filename = abs_filename.gsub "#{mod_dir}/set/", ''
         | 
| 146 | 
            +
                        tmp_filename = "#{mod_tmp_dir}/#{rel_filename}"
         | 
| 147 | 
            +
                        Set.write_tmp_file abs_filename, tmp_filename, rel_filename
         | 
| 107 148 | 
             
                      end
         | 
| 149 | 
            +
                      seq = seq + 1
         | 
| 108 150 | 
             
                    end
         | 
| 109 151 | 
             
                  end
         | 
| 110 152 |  | 
| 111 | 
            -
             | 
| 112 153 | 
             
                  def load_tmp_set_modules
         | 
| 113 | 
            -
                    patterns = Card.set_patterns.reverse.map(&:pattern_code) | 
| 114 | 
            -
             | 
| 154 | 
            +
                    patterns = Card.set_patterns.reverse.map(&:pattern_code)
         | 
| 155 | 
            +
                      .unshift 'abstract'
         | 
| 156 | 
            +
                    Dir.glob("#{Card.paths['tmp/set'].first}/*").sort.each do |tmp_mod|
         | 
| 115 157 | 
             
                      patterns.each do |pattern|
         | 
| 116 158 | 
             
                        pattern_dir = "#{tmp_mod}/#{pattern}"
         | 
| 117 159 | 
             
                        if Dir.exists? pattern_dir
         | 
| @@ -122,40 +164,37 @@ class Card | |
| 122 164 | 
             
                  end
         | 
| 123 165 |  | 
| 124 166 | 
             
                  def make_set_module_tmp_dir mod_dir, seq
         | 
| 125 | 
            -
                    modname = mod_dir.match( | 
| 126 | 
            -
                    mod_tmp_dir = "#{Card.paths['tmp/set'].first}/mod#{ | 
| 167 | 
            +
                    modname = mod_dir.match(%r{[^/]+$})[0]
         | 
| 168 | 
            +
                    mod_tmp_dir = "#{Card.paths['tmp/set'].first}/mod#{'%03d' % seq}-#{modname}"
         | 
| 127 169 | 
             
                    Dir.mkdir mod_tmp_dir
         | 
| 128 170 | 
             
                    mod_tmp_dir
         | 
| 129 171 | 
             
                  end
         | 
| 130 172 |  | 
| 131 | 
            -
             | 
| 132 173 | 
             
                  def prepare_tmp_dir path
         | 
| 133 | 
            -
                     | 
| 134 | 
            -
             | 
| 135 | 
            -
             | 
| 136 | 
            -
             | 
| 137 | 
            -
                      end
         | 
| 138 | 
            -
                      Dir.mkdir p.first
         | 
| 174 | 
            +
                    return unless rewrite_tmp_files?
         | 
| 175 | 
            +
                    p = Card.paths[path]
         | 
| 176 | 
            +
                    if p.existent.first
         | 
| 177 | 
            +
                      FileUtils.rm_rf p.first, secure: true
         | 
| 139 178 | 
             
                    end
         | 
| 179 | 
            +
                    Dir.mkdir p.first
         | 
| 140 180 | 
             
                  end
         | 
| 141 181 |  | 
| 142 182 | 
             
                  def rewrite_tmp_files?
         | 
| 143 | 
            -
                    if defined?( | 
| 183 | 
            +
                    if defined?(@@rewrite)
         | 
| 144 184 | 
             
                      @@rewrite
         | 
| 145 185 | 
             
                    else
         | 
| 146 | 
            -
                      @@rewrite = !( | 
| 186 | 
            +
                      @@rewrite = !(Rails.env.production? &&
         | 
| 187 | 
            +
                                  Card.paths['tmp/set'].existent.first)
         | 
| 147 188 | 
             
                    end
         | 
| 148 189 | 
             
                  end
         | 
| 149 190 |  | 
| 150 191 | 
             
                  def load_dir dir
         | 
| 151 192 | 
             
                    Dir[dir].sort.each do |file|
         | 
| 152 | 
            -
            # | 
| 193 | 
            +
                      # puts Benchmark.measure("from #load_dir: rd: #{file}") {
         | 
| 153 194 | 
             
                      require_dependency file
         | 
| 154 | 
            -
            # | 
| 195 | 
            +
                      # }.format('%n: %t %r')
         | 
| 155 196 | 
             
                    end
         | 
| 156 197 | 
             
                  end
         | 
| 157 198 | 
             
                end
         | 
| 158 199 | 
             
              end
         | 
| 159 | 
            -
             | 
| 160 200 | 
             
            end
         | 
| 161 | 
            -
             | 
    
        data/lib/card/query.rb
    CHANGED
    
    | @@ -70,11 +70,12 @@ class Card | |
| 70 70 |  | 
| 71 71 | 
             
                DEFAULT_ORDER_DIRS =  { :update => "desc", :relevance => "desc" }
         | 
| 72 72 |  | 
| 73 | 
            -
                attr_reader :statement, :mods, :conditions,
         | 
| 73 | 
            +
                attr_reader :statement, :mods, :conditions, :comment,
         | 
| 74 74 | 
             
                  :subqueries, :superquery
         | 
| 75 75 | 
             
                attr_accessor :joins, :table_seq, :unjoined, :conditions_on_join
         | 
| 76 76 |  | 
| 77 | 
            -
                def initialize statement
         | 
| 77 | 
            +
                def initialize statement, comment=nil
         | 
| 78 | 
            +
                  @comment = comment
         | 
| 78 79 | 
             
                  @subqueries = []
         | 
| 79 80 | 
             
                  @conditions = []
         | 
| 80 81 | 
             
                  @joins = []
         | 
| @@ -96,9 +97,8 @@ class Card | |
| 96 97 | 
             
                # a card identifier from SQL and then hooking into our caching system (see
         | 
| 97 98 | 
             
                # Card::Fetch)
         | 
| 98 99 |  | 
| 99 | 
            -
                def self.run statement
         | 
| 100 | 
            -
                   | 
| 101 | 
            -
                  query.run
         | 
| 100 | 
            +
                def self.run statement, comment=nil
         | 
| 101 | 
            +
                  new(statement, comment).run
         | 
| 102 102 | 
             
                end
         | 
| 103 103 |  | 
| 104 104 | 
             
                # run the current query
         | 
| @@ -18,7 +18,8 @@ class Card | |
| 18 18 | 
             
                  end
         | 
| 19 19 |  | 
| 20 20 | 
             
                  def to_s
         | 
| 21 | 
            -
                    [ | 
| 21 | 
            +
                    [comment,
         | 
| 22 | 
            +
                     "SELECT DISTINCT #{@fields}",
         | 
| 22 23 | 
             
                     "FROM #{@tables}",
         | 
| 23 24 | 
             
                     @joins,
         | 
| 24 25 | 
             
                     @where,
         | 
| @@ -28,6 +29,11 @@ class Card | |
| 28 29 | 
             
                    ].compact * "\n"
         | 
| 29 30 | 
             
                  end
         | 
| 30 31 |  | 
| 32 | 
            +
                  def comment
         | 
| 33 | 
            +
                    return nil unless Card.config.sql_comments && @query.comment
         | 
| 34 | 
            +
                    "/* #{@query.comment} */"
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
             | 
| 31 37 | 
             
                  def tables
         | 
| 32 38 | 
             
                    "cards #{@query.table_alias}"
         | 
| 33 39 | 
             
                  end
         | 
| @@ -150,7 +156,7 @@ class Card | |
| 150 156 | 
             
                  def permission_conditions query
         | 
| 151 157 | 
             
                    return if Auth.always_ok?
         | 
| 152 158 | 
             
                    read_rules = Auth.as_card.read_rules
         | 
| 153 | 
            -
                    read_rule_list = read_rules. | 
| 159 | 
            +
                    read_rule_list = read_rules.present? ? read_rules.join(',') : 1
         | 
| 154 160 | 
             
                    "#{query.table_alias}.read_rule_id IN (#{read_rule_list})"
         | 
| 155 161 | 
             
                  end
         | 
| 156 162 |  | 
| @@ -210,7 +216,7 @@ class Card | |
| 210 216 | 
             
                    "#{order_field} #{dir}"
         | 
| 211 217 | 
             
                  end
         | 
| 212 218 |  | 
| 213 | 
            -
                  def safe_sql | 
| 219 | 
            +
                  def safe_sql txt
         | 
| 214 220 | 
             
                    txt = txt.to_s
         | 
| 215 221 | 
             
                    if txt.match(/[^\w\*\(\)\s\.\,]/)
         | 
| 216 222 | 
             
                      fail "WQL contains disallowed characters: #{txt}"
         | 
| @@ -219,7 +225,7 @@ class Card | |
| 219 225 | 
             
                    end
         | 
| 220 226 | 
             
                  end
         | 
| 221 227 |  | 
| 222 | 
            -
                  def cast_type | 
| 228 | 
            +
                  def cast_type type
         | 
| 223 229 | 
             
                    cxn ||= ActiveRecord::Base.connection
         | 
| 224 230 | 
             
                    (val = cxn.cast_types[type.to_sym]) ? val[:name] : safe_sql(type)
         | 
| 225 231 | 
             
                  end
         | 
    
        data/lib/card/query/value.rb
    CHANGED
    
    | @@ -13,14 +13,11 @@ class Card | |
| 13 13 | 
             
                  end
         | 
| 14 14 |  | 
| 15 15 | 
             
                  def parse_value rawvalue
         | 
| 16 | 
            -
                     | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
                      else raise("Invalid Condition Clause #{rawvalue}.inspect}")
         | 
| 22 | 
            -
                      end
         | 
| 23 | 
            -
                    [operator, rawvalue]
         | 
| 16 | 
            +
                    case rawvalue
         | 
| 17 | 
            +
                    when String, Integer then ['=', rawvalue]
         | 
| 18 | 
            +
                    when Array           then [rawvalue[0], rawvalue[1..-1]]
         | 
| 19 | 
            +
                    else raise("Invalid Condition Clause #{rawvalue}.inspect}")
         | 
| 20 | 
            +
                    end
         | 
| 24 21 | 
             
                  end
         | 
| 25 22 |  | 
| 26 23 | 
             
                  def canonicalize_operator
         | 
    
        data/lib/card/set.rb
    CHANGED
    
    
    
        data/lib/cardio.rb
    CHANGED
    
    | @@ -2,16 +2,14 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            require 'active_support/core_ext/numeric/time'
         | 
| 4 4 |  | 
| 5 | 
            -
             | 
| 6 5 | 
             
            module Cardio
         | 
| 7 | 
            -
             | 
| 8 6 | 
             
              CARD_GEM_ROOT = File.expand_path('../..', __FILE__)
         | 
| 9 7 |  | 
| 10 8 | 
             
              ActiveSupport.on_load :card do
         | 
| 11 9 | 
             
                if Card.take
         | 
| 12 10 | 
             
                  Card::Loader.load_mods
         | 
| 13 11 | 
             
                else
         | 
| 14 | 
            -
                  Rails.logger.warn  | 
| 12 | 
            +
                  Rails.logger.warn 'empty database'
         | 
| 15 13 | 
             
                end
         | 
| 16 14 | 
             
              end
         | 
| 17 15 |  | 
| @@ -36,7 +34,7 @@ module Cardio | |
| 36 34 | 
             
                  set_default_value config, :recaptcha_private_key,  nil
         | 
| 37 35 | 
             
                  set_default_value config, :recaptcha_proxy,        nil
         | 
| 38 36 |  | 
| 39 | 
            -
                  set_default_value config, :cache_store, | 
| 37 | 
            +
                  set_default_value config, :cache_store,           :file_store, 'tmp/cache'
         | 
| 40 38 | 
             
                  set_default_value config, :override_host,          nil
         | 
| 41 39 | 
             
                  set_default_value config, :override_protocol,      nil
         | 
| 42 40 |  | 
| @@ -52,6 +50,7 @@ module Cardio | |
| 52 50 | 
             
                  set_default_value config, :space_last_in_multispace, true
         | 
| 53 51 | 
             
                  set_default_value config, :closed_search_limit,    50
         | 
| 54 52 |  | 
| 53 | 
            +
                  set_default_value config, :non_createable_types,  %w{ signup setting set }
         | 
| 55 54 | 
             
                  set_default_value config, :view_cache,             false
         | 
| 56 55 | 
             
                end
         | 
| 57 56 |  | 
| @@ -62,7 +61,6 @@ module Cardio | |
| 62 61 | 
             
                  config.send("#{setting}=", *value) unless config.respond_to? setting
         | 
| 63 62 | 
             
                end
         | 
| 64 63 |  | 
| 65 | 
            -
             | 
| 66 64 | 
             
                def set_paths paths
         | 
| 67 65 | 
             
                  @@paths = paths
         | 
| 68 66 | 
             
                  add_path 'tmp/set', root: root
         | 
| @@ -70,20 +68,18 @@ module Cardio | |
| 70 68 |  | 
| 71 69 | 
             
                  add_path 'mod'
         | 
| 72 70 |  | 
| 73 | 
            -
                  add_path  | 
| 71 | 
            +
                  add_path 'db'
         | 
| 74 72 | 
             
                  add_path 'db/migrate'
         | 
| 75 | 
            -
                  add_path  | 
| 76 | 
            -
                  add_path  | 
| 77 | 
            -
                  add_path  | 
| 73 | 
            +
                  add_path 'db/migrate_core_cards'
         | 
| 74 | 
            +
                  add_path 'db/migrate_deck_cards', root: root, with: 'db/migrate_cards'
         | 
| 75 | 
            +
                  add_path 'db/seeds', with: 'db/seeds.rb'
         | 
| 78 76 |  | 
| 79 77 | 
             
                  add_path 'config/initializers',  glob: '**/*.rb'
         | 
| 80 | 
            -
             | 
| 81 78 | 
             
                end
         | 
| 82 79 |  | 
| 83 | 
            -
             | 
| 84 80 | 
             
                def set_mod_paths
         | 
| 85 81 | 
             
                  each_mod_path do |mod_path|
         | 
| 86 | 
            -
                    Dir.glob( | 
| 82 | 
            +
                    Dir.glob("#{mod_path}/*/initializers").each do |initializers_dir|
         | 
| 87 83 | 
             
                      paths['config/initializers'] << initializers_dir
         | 
| 88 84 | 
             
                    end
         | 
| 89 85 | 
             
                  end
         | 
| @@ -105,13 +101,13 @@ module Cardio | |
| 105 101 |  | 
| 106 102 | 
             
                def add_path path, options={}
         | 
| 107 103 | 
             
                  root = options.delete(:root) || gem_root
         | 
| 108 | 
            -
                  options[:with] = File.join(root, (options[:with] || path) | 
| 104 | 
            +
                  options[:with] = File.join(root, (options[:with] || path))
         | 
| 109 105 | 
             
                  paths.add path, options
         | 
| 110 106 | 
             
                end
         | 
| 111 107 |  | 
| 112 108 | 
             
                def future_stamp
         | 
| 113 | 
            -
                   | 
| 114 | 
            -
                  @@future_stamp ||= Time.local 2020,1,1,0,0,0
         | 
| 109 | 
            +
                  # # used in test data
         | 
| 110 | 
            +
                  @@future_stamp ||= Time.zone.local 2020, 1, 1, 0, 0, 0
         | 
| 115 111 | 
             
                end
         | 
| 116 112 |  | 
| 117 113 | 
             
                def migration_paths type
         | 
| @@ -126,7 +122,9 @@ module Cardio | |
| 126 122 |  | 
| 127 123 | 
             
                def assume_migrated_upto_version type
         | 
| 128 124 | 
             
                  Cardio.schema_mode(type) do
         | 
| 129 | 
            -
                    ActiveRecord::Schema.assume_migrated_upto_version | 
| 125 | 
            +
                    ActiveRecord::Schema.assume_migrated_upto_version(
         | 
| 126 | 
            +
                      Cardio.schema(type), Cardio.migration_paths(type)
         | 
| 127 | 
            +
                    )
         | 
| 130 128 | 
             
                  end
         | 
| 131 129 | 
             
                end
         | 
| 132 130 |  | 
| @@ -143,7 +141,7 @@ module Cardio | |
| 143 141 | 
             
                  dir += "/#{id}" if id
         | 
| 144 142 | 
             
                  FileUtils.rm_rf dir, secure: true
         | 
| 145 143 | 
             
                rescue
         | 
| 146 | 
            -
                  Rails.logger.info  | 
| 144 | 
            +
                  Rails.logger.info 'failed to remove tmp files'
         | 
| 147 145 | 
             
                end
         | 
| 148 146 |  | 
| 149 147 | 
             
                def schema_mode type
         | 
| @@ -157,16 +155,14 @@ module Cardio | |
| 157 155 | 
             
                end
         | 
| 158 156 |  | 
| 159 157 | 
             
                def schema type=nil
         | 
| 160 | 
            -
                  File.read( | 
| 158 | 
            +
                  File.read(schema_stamp_path type).strip
         | 
| 161 159 | 
             
                end
         | 
| 162 160 |  | 
| 163 161 | 
             
                def schema_stamp_path type
         | 
| 164 | 
            -
                  root_dir = ( | 
| 165 | 
            -
                  stamp_dir = ENV['SCHEMA_STAMP_PATH'] || File.join( | 
| 162 | 
            +
                  root_dir = (type == :deck_cards ? root : gem_root)
         | 
| 163 | 
            +
                  stamp_dir = ENV['SCHEMA_STAMP_PATH'] || File.join(root_dir, 'db')
         | 
| 166 164 |  | 
| 167 165 | 
             
                  File.join stamp_dir, "version#{ schema_suffix(type) }.txt"
         | 
| 168 166 | 
             
                end
         | 
| 169 | 
            -
             | 
| 170 167 | 
             
              end
         | 
| 171 168 | 
             
            end
         | 
| 172 | 
            -
             |