decko 0.14.2 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c6db755b2db7ac79e35bb2b9d5f2b8b38edaeb528985cd00631c5b0e6f883e2
4
- data.tar.gz: 7a6b0e083047509d211e77a8fd68e5c22bc2bc081d40c933f3777ee17e498aa3
3
+ metadata.gz: 248a2dc0a741869d8f08dac5d37fe27836bf0e1739fb07753718700ede5af334
4
+ data.tar.gz: cd47e990d0affdc1d4555f18601a9d69a1e8fa1c366f95610c4b1a1774dae563
5
5
  SHA512:
6
- metadata.gz: 04ad5d539b80b8c5ae27f2c1bcc8d716c6a4a5ec36283410797320896f861a8124e141901bcdd0cc7e45522c46d516840c155e20b0812f6182353cd131c8c50c
7
- data.tar.gz: bb637881c97f37183f475c952ee2af0ef71b5cc8089bbd854d729d72a9963c54038ace067b2ec238a9215daab02d97bd41114d1356d1a55c6830af905114ce8a
6
+ metadata.gz: 8d59e274fdf05490bde9e154b0c9888273575bb0a5d8887e79bd25fc6bdd1db5ba8a10c2eb17398db945e80bdb9cbf0abf36ec7d165671bf689cdc8916f4ac30
7
+ data.tar.gz: e316371fb24578a2879c1eb5f2d13225175dfe0b2f79cf6ed3a1a69f9a799663c69f2b690aedafb078d078a6d0c9a7c692694a0a11dff6440a0f218de1a505f5
@@ -4,6 +4,7 @@ Decko.application.class.configure do
4
4
  # Edit at your own peril - it's recommended to regenerate this file
5
5
  # in the future when you upgrade to a newer version of Cucumber.
6
6
 
7
+ config.seed_type = :test
7
8
  config.eager_load = false
8
9
 
9
10
  config.asset_refresh = :never
@@ -29,7 +29,7 @@ class CardController
29
29
  private
30
30
 
31
31
  def setup
32
- Card::Assets.refresh_assets unless params[:explicit_file]
32
+ Card::Assets.refresh unless params[:explicit_file]
33
33
  Card::Cache.renew
34
34
  Card::Env.reset self
35
35
  end
data/lib/decko/cli.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  require "rbconfig"
2
- require "decko/script_decko_loader"
2
+ require "cardio/script_loader"
3
3
 
4
+ Cardio::ScriptLoader.script_name = "decko"
4
5
  # If we are inside a Decko application this method performs an exec and thus
5
6
  # the rest of this script is not run.
6
- Decko::ScriptDeckoLoader.exec!
7
+ Cardio::ScriptLoader.exec!
7
8
 
8
9
  require "rails/ruby_version_check"
9
10
  Signal.trap("INT") { exit(1) }
@@ -1,10 +1,5 @@
1
1
  require "rails/generators"
2
2
  require File.expand_path("../../../generators/deck/deck_generator", __FILE__)
3
+ require "cardio/command"
3
4
 
4
- if ARGV.first != "new"
5
- ARGV[0] = "--help"
6
- else
7
- ARGV.shift
8
- end
9
-
10
- Cardio::Generators::Deck::DeckGenerator.start
5
+ Cardio::Command.run_non_deck_command ARGV.first, "decko/commands"
@@ -1,11 +1,11 @@
1
1
  # load the application so we can look in mods
2
2
  require APP_PATH
3
- require "cardio/commands/command"
3
+ require "cardio/command/command_base"
4
4
  require "cardio/mod/dirs"
5
5
 
6
6
  module Decko
7
7
  class Commands
8
- class CucumberCommand < Cardio::Commands::Command
8
+ class CucumberCommand < Cardio::Command::CommandBase
9
9
  require "decko/commands/cucumber_command/parser"
10
10
 
11
11
  def initialize args
@@ -17,7 +17,7 @@ module Decko
17
17
  def command
18
18
  @cmd ||=
19
19
  "#{env_args} #{@opts[:executer] || 'bundle exec'} " \
20
- "cucumber #{require_args} #{feature_args}"
20
+ "cucumber #{require_args} #{feature_args} #{@cucumber_args.shelljoin}"
21
21
  end
22
22
 
23
23
  private
@@ -26,12 +26,9 @@ module Decko
26
26
  @opts[:env].join " "
27
27
  end
28
28
 
29
+ # use implicit features unless feature made explicit (in FIRST arg!)
29
30
  def feature_args
30
- if @cucumber_args.empty?
31
- feature_paths.join(" ")
32
- else
33
- @cucumber_args.shelljoin
34
- end
31
+ feature_paths.join(" ") unless @cucumber_args.first&.match?(/^\s*[^-]/)
35
32
  end
36
33
 
37
34
  def require_args
@@ -1,9 +1,11 @@
1
1
  ENV["CARDIO_COMMANDS"] = "NO_RUN"
2
2
 
3
- require "cardio/commands"
3
+ require "cardio/command"
4
4
 
5
5
  module Decko
6
- class Commands < Cardio::Commands
6
+ class Commands < Cardio::Command
7
+ Cardio::Command.bin_name = "decko"
8
+
7
9
  def map
8
10
  @map ||= super.merge(
9
11
  server: { desc: "start a local web server", group: :shark, alias: :s },
@@ -11,7 +11,6 @@ CardSpecLoader.prefork do
11
11
  Bundler.require(:test)
12
12
  # if simplecov is activated in the Gemfile, it has to be required here
13
13
  end
14
- # Cardio::Seed.test_path = File.dirname(__FILE__) + '/../fixtures'
15
14
  CardSpecLoader.rspec_config
16
15
  end
17
16
 
@@ -4,7 +4,7 @@ info:
4
4
  Decko organizes data into "cards." Decko's API supports retrieval and alteration of card data.
5
5
 
6
6
  To get the JSON responses as described below, do _any_ of the following:
7
- 1. Set the http access header to `application/json` in your request
7
+ 1. Set the http Accept header to `application/json` in your request
8
8
  2. Add `.json` to the url, or
9
9
  3. Add `format=json` to the query params.
10
10
 
@@ -4,7 +4,7 @@ info:
4
4
  description: |-
5
5
  Decko organizes data into "cards." Decko's API supports retrieval and alteration of card data.
6
6
  To get the JSON responses as described below, do _any_ of the following:
7
- 1. Set the http access header to `application/json` in your request
7
+ 1. Set the http Accept header to `application/json` in your request
8
8
  2. Add `.json` to the url, or
9
9
  3. Add `format=json` to the query params.
10
10
  version: 0.8.0
@@ -3,7 +3,7 @@ require "benchmark"
3
3
 
4
4
  namespace :decko do
5
5
  namespace :benchmark do
6
- desc "measure time for script generation"
6
+ desc "(for platypuses) measure time for script generation"
7
7
  task machines: :environment do
8
8
  Benchmark.bm do |x|
9
9
  regenerate x, :style
@@ -23,10 +23,6 @@ def regenerate benchmarker, all_field
23
23
  i_card.expire_machine_cache
24
24
  end
25
25
 
26
- %w[machine_output machine_cache].each do |code|
27
- Card.search(right: { codename: code }).each(&:delete)
28
- end
29
-
30
26
  Card::Cache.reset_all
31
27
 
32
28
  benchmarker.report(all_field) do
@@ -1,26 +1,36 @@
1
1
  # rake decko:docs:...
2
2
 
3
3
  # NOTE: for the moment these are Platypus tasks.
4
- # Until they're more monkey friendly, let's not write descriptions
4
+ # Until they're more monkey friendly, let's not write `desc` descriptions.
5
+ # Without those they won't show up when folks run `rake -T`
5
6
  #
6
7
  # Make sure: you're:
7
8
  # (A) running in a development environment, and
8
9
  # (B) pointing to a repo gem
9
10
  namespace :decko do
10
11
  namespace :docs do
11
- # trigger tmpsets and then run yardoc
12
+ # Triggers tmpsets and then runs yardoc
13
+ #
14
+ # IMPORTANT: Only works if using source code from github.
12
15
  task :update do
13
- Rake::Task["decko:tmpsets:trigger"].invoke
16
+ Cardio.config.load_strategy = :tmp_files
17
+ Rake::Task["decko:docs:dummy"].invoke
14
18
  Rake::Task["decko:docs:yardoc"].invoke
15
19
  end
16
20
 
17
- # run yardoc command, which generates the docs content in the repo root
21
+ # Runs yardoc command, which generates the docs content in the repo root.
18
22
  #
23
+ # IMPORTANT: Only works if using source code from github.
19
24
  # If you run this while using decko as a built gem, you could get some funky docs in
20
25
  # your gems directory...
21
26
  task :yardoc do
22
27
  doc_dir = File.expand_path "..", Decko.gem_root
23
28
  system %(cd #{doc_dir}; yardoc)
24
29
  end
30
+
31
+ # just load environment and trigger Card load (used to generate tmpsets)
32
+ task dummy: :environment do
33
+ Card
34
+ end
25
35
  end
26
36
  end
@@ -1,147 +1,12 @@
1
1
  require "decko/application"
2
2
  require_relative "alias"
3
3
 
4
- CARD_TASKS =
5
- [
6
- :migrate,
7
- { migrate: %i[cards structure core_cards deck_cards redo stamp] },
8
- :reset_cache
9
- ].freeze
4
+ CARD_TASKS = (
5
+ %i[eat migrate reset_cache reset_tmp seed setup sow update] +
6
+ [{ assets: %i[refresh code wipe] },
7
+ { migrate: %i[cards structure core_cards deck_cards redo stamp] },
8
+ { mod: %i[list symlink missing uninstall install] },
9
+ { seed: %i[build clean dump plow polish replant update] }]
10
+ ).freeze
10
11
 
11
12
  link_task CARD_TASKS, from: :decko, to: :card
12
-
13
- decko_namespace = namespace :decko do
14
- desc "create a decko database from scratch, load initial data"
15
- task :seed do
16
- failing_loudly "decko seed" do
17
- seed
18
- end
19
- end
20
-
21
- desc "create a decko database from scratch, load initial data, don't reset the cache"
22
- task :seed_without_reset do
23
- # This variant is needed to generate test databases for decks
24
- # with custom codenames.
25
- # The cache reset loads the environment. That tends to fail
26
- # because of missing codenames that are added after the intial decko seed.
27
- seed with_cache_reset: false
28
- end
29
-
30
- desc "clear and load fixtures with existing tables"
31
- task reseed: :environment do
32
- ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
33
-
34
- decko_namespace["clear"].invoke
35
- decko_namespace["load"].invoke
36
- end
37
-
38
- desc "empty the card tables"
39
- task :clear do
40
- conn = ActiveRecord::Base.connection
41
-
42
- puts "delete all data in bootstrap tables"
43
- Cardio::Seed::TABLES.each do |table|
44
- conn.delete "delete from #{table}"
45
- end
46
- end
47
-
48
- desc "Load seed data into database"
49
- task :load do
50
- decko_namespace["load_without_reset"].invoke
51
- puts "reset cache"
52
- system "bundle exec rake decko:reset_cache" # needs loaded environment
53
- end
54
-
55
- desc "Load seed data into database but don't reset cache"
56
- task :load_without_reset do
57
- require "decko/engine"
58
- # puts "update card_migrations"
59
- # decko_namespace["assume_card_migrations"].invoke
60
-
61
- if Rails.env == "test" && !ENV["GENERATE_FIXTURES"]
62
- puts "loading test fixtures"
63
- Rake::Task["db:fixtures:load"].invoke
64
- else
65
- puts "loading seed data"
66
- # db:seed checks for pending migrations. We don't want that because
67
- # as part of the seeding process we update the migration table
68
- ActiveRecord::Tasks::DatabaseTasks.load_seed
69
- # :Rake::Task["db:seed"].invoke
70
- end
71
-
72
- puts "set symlink for assets"
73
- decko_namespace["card:mod:symlink"].invoke
74
- end
75
-
76
- desc "reset with an empty tmp directory"
77
- task :reset_tmp do
78
- tmp_dir = Decko.paths["tmp"].first
79
- if Decko.paths["tmp"].existent
80
- Dir.foreach(tmp_dir) do |filename|
81
- next if filename.starts_with? "."
82
-
83
- FileUtils.rm_rf File.join(tmp_dir, filename), secure: true
84
- end
85
- else
86
- Dir.mkdir tmp_dir
87
- end
88
- end
89
-
90
- desc "update decko gems and database"
91
- task :update do
92
- failing_loudly "decko update" do
93
- ENV["NO_RAILS_CACHE"] = "true"
94
- decko_namespace["migrate"].invoke
95
- decko_namespace["reset_tmp"].invoke
96
- Card::Cache.reset_all
97
- Rake::Task["card:mod:uninstall"].invoke
98
- Rake::Task["card:mod:install"].invoke
99
- Rake::Task["card:mod:symlink"].invoke
100
- end
101
- end
102
-
103
- %i[list symlink missing uninstall install].each do |task|
104
- alias_task "mod:#{task}", "card:mod:#{task}"
105
- end
106
- alias_task :migrate, "card:migrate"
107
-
108
- desc "insert existing card migrations into schema_migrations_cards " \
109
- "to avoid re-migrating"
110
- task :assume_card_migrations do
111
- require "decko/engine"
112
- Cardio::Schema.assume_migrated_upto_version :core_cards
113
- end
114
-
115
- def seed with_cache_reset: true
116
- ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
117
- # FIXME: this should be an option, but should not happen on standard creates!
118
- begin
119
- Rake::Task["db:drop"].invoke
120
- rescue StandardError
121
- puts "not dropped"
122
- end
123
-
124
- puts "creating"
125
- Rake::Task["db:create"].invoke
126
-
127
- puts "loading schema"
128
- Rake::Task["db:schema:load"].invoke
129
-
130
- load_task = "decko:load"
131
- load_task << "_without_reset" unless with_cache_reset
132
- Rake::Task[load_task].invoke
133
- end
134
- end
135
-
136
- def failing_loudly task
137
- yield
138
- rescue StandardError
139
- # TODO: fix this so that message appears *after* the errors.
140
- # Solution should ensure that rake still exits with error code 1!
141
- raise "\n>>>>>> FAILURE! #{task} did not complete successfully." \
142
- "\n>>>>>> Please address errors and re-run:\n\n\n"
143
- end
144
-
145
- def version
146
- ENV["VERSION"] ? ENV["VERSION"].to_i : nil
147
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decko
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.2
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-01-08 00:00:00.000000000 Z
13
+ date: 2023-01-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: actionpack
@@ -32,28 +32,28 @@ dependencies:
32
32
  requirements:
33
33
  - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 1.104.2
35
+ version: 1.105.0
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 1.104.2
42
+ version: 1.105.0
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: card-mod-defaults
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - '='
48
48
  - !ruby/object:Gem::Version
49
- version: 0.14.2
49
+ version: 0.15.0
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - '='
55
55
  - !ruby/object:Gem::Version
56
- version: 0.14.2
56
+ version: 0.15.0
57
57
  description: a wiki approach to structured data, dynamic interaction, and web design
58
58
  email:
59
59
  - info@decko.org
@@ -107,19 +107,15 @@ files:
107
107
  - lib/decko/mods_spec_helper.rb
108
108
  - lib/decko/railtie.rb
109
109
  - lib/decko/rest_spec_helper.rb
110
- - lib/decko/script_decko_loader.rb
111
110
  - lib/decko/swagger.rb
112
111
  - lib/decko/swagger/input_yml/layout.yml
113
112
  - lib/decko/swagger/output.yml
114
113
  - lib/generators/deck/deck_generator.rb
115
114
  - lib/rake_tasks/alias.rb
116
115
  - lib/rake_tasks/cucumber.rake
117
- - lib/rake_tasks/db.rake
118
116
  - lib/rake_tasks/decko.rake
119
117
  - lib/rake_tasks/decko/benchmark.rake
120
118
  - lib/rake_tasks/decko/docs.rake
121
- - lib/rake_tasks/decko/seed.rake
122
- - lib/rake_tasks/decko/tmpsets.rake
123
119
  homepage: https://decko.org
124
120
  licenses:
125
121
  - GPL-3.0
@@ -144,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
140
  - !ruby/object:Gem::Version
145
141
  version: '0'
146
142
  requirements: []
147
- rubygems_version: 3.2.15
143
+ rubygems_version: 3.3.11
148
144
  signing_key:
149
145
  specification_version: 4
150
146
  summary: structured wiki web platform
@@ -1,13 +0,0 @@
1
- require "pathname"
2
-
3
- require "cardio/script_loader"
4
-
5
- module Decko
6
- module ScriptDeckoLoader
7
- extend Cardio::ScriptLoader::ClassMethods
8
-
9
- def self.script
10
- File.join("script", "decko")
11
- end
12
- end
13
- end
@@ -1,63 +0,0 @@
1
- require "rake"
2
-
3
- # This code lets us redefine existing Rake tasks, which is extremely
4
- # handy for modifying existing Rails rake tasks.
5
- # Credit for the original snippet of code goes to Jeremy Kemper
6
- # http://pastie.caboo.se/9620
7
- unless Rake::TaskManager.methods.include?(:redefine_task)
8
- module Rake
9
- module TaskManager
10
- def redefine_task task_class, args, &block
11
- task_name, _arg_names, deps = resolve_args(args)
12
- task_name = task_class.scope_name(@scope, task_name)
13
- deps = [deps] unless deps.respond_to?(:to_ary)
14
- deps = deps.map(&:to_s)
15
- task = @tasks[task_name.to_s] = task_class.new(task_name, self)
16
- task.application = self
17
- @last_comment = nil
18
- task.enhance(deps, &block)
19
- task
20
- end
21
- end
22
-
23
- class Task
24
- class << self
25
- def redefine_task args, &block
26
- Rake.application.redefine_task(self, [args], &block)
27
- end
28
- end
29
- end
30
- end
31
- end
32
-
33
- namespace :db do
34
- namespace :fixtures do
35
- desc "Load fixtures into the current environment's database. " \
36
- "Load specific fixtures using FIXTURES=x,y"
37
- task load: :environment do
38
- require "active_record/fixtures"
39
- fixture_path = File.join(Cardio.gem_root, "db", "seed", "test", "fixtures")
40
- ActiveRecord::Base.establish_connection(::Rails.env.to_sym)
41
- (if ENV["FIXTURES"]
42
- ENV["FIXTURES"].split(/,/)
43
- else
44
- Dir.glob(File.join(fixture_path,
45
- "*.{yml,csv}"))
46
- end).each do |fixture_file|
47
- ActiveRecord::FixtureSet.create_fixtures(fixture_path,
48
- File.basename(fixture_file, ".*"))
49
- end
50
- end
51
- end
52
-
53
- namespace :test do
54
- desc "Prepare the test database and load the schema"
55
- Rake::Task.redefine_task(prepare: :environment) do
56
- if ENV["RELOAD_TEST_DATA"] == "true" || ENV["RUN_CODE_RUN"]
57
- puts `env RAILS_ENV=test rake decko:seed`
58
- else
59
- puts "skipping loading test data. to force, run `env RELOAD_TEST_DATA=true rake db:test:prepare`"
60
- end
61
- end
62
- end
63
- end
@@ -1,139 +0,0 @@
1
- require "cardio/seed"
2
-
3
- namespace :decko do
4
- namespace :seed do
5
- desc "reseed, migrate, re-clean, and re-dump"
6
- task update: :environment do
7
- ENV["STAMP_MIGRATIONS"] = "true"
8
- ENV["GENERATE_FIXTURES"] = "true"
9
- %w[reseed update
10
- mod:uninstall mod:install seed:make_asset_output_coded
11
- seed:clean seed:supplement seed:dump].each do |task|
12
- Rake::Task["decko:#{task}"].invoke
13
- end
14
- end
15
-
16
- desc "remove unneeded cards, acts, actions, changes, and references"
17
- task clean: :environment do
18
- Card::Cache.reset_all
19
- clean_cards
20
- clean_acts_and_actions
21
- Card::Cache.reset_all
22
- end
23
-
24
- def clean_cards
25
- puts "clean cards"
26
- # change actors so we can delete unwanted user cards that made changes
27
- Card::Act.update_all actor_id: Card::WagnBotID
28
- delete_ignored_cards
29
- refresh_assets
30
- Card::Assets.make_output_coded
31
- # clean_unwanted_cards
32
- Card.empty_trash
33
- end
34
-
35
- def clean_unwanted_cards
36
- Card.search(right: { codename: "all" }).each(&:delete!)
37
- end
38
-
39
- def delete_ignored_cards
40
- return unless (ignore = Card["*ignore"])
41
-
42
- Card::Auth.as_bot do
43
- ignore.item_cards.each(&:delete!)
44
- end
45
- end
46
-
47
- task refresh_assets: :environment do
48
- refresh_assets
49
- end
50
-
51
- def refresh_assets
52
- puts "refresh assets"
53
- Card::Auth.as_bot do
54
- Card.where(right_id: :asset_input.card_id).delete_all
55
- end
56
- Card::Cache.reset_all
57
- Cardio.config.compress_assets = true
58
- Card::Assets.refresh_assets force: true
59
- end
60
-
61
- task make_asset_output_coded: :environment do
62
- Card::Assets.make_output_coded
63
- end
64
-
65
- # def clean_files
66
- # puts "clean files"
67
- # Card::Cache.reset_all
68
- # # TODO: generalize to all unnecessary files
69
- # remove_old_machine_files
70
- # end
71
-
72
- def clean_acts_and_actions
73
- clean_history
74
- clean_time_and_user_stamps
75
- end
76
-
77
- def clean_history
78
- puts "clean history"
79
- act = Card::Act.create! actor_id: Card::WagnBotID, card_id: Card::WagnBotID
80
- Card::Action.make_current_state_the_initial_state act
81
- # conn.execute("truncate card_acts")
82
- ActiveRecord::Base.connection.execute("truncate sessions")
83
- end
84
-
85
- def clean_time_and_user_stamps
86
- puts "clean time and user stamps"
87
- conn = ActiveRecord::Base.connection
88
- who_and_when = [Card::WagnBotID, Time.now.utc.to_s(:db)]
89
- conn.update "UPDATE cards SET " \
90
- "creator_id=%1$s, created_at='%2$s', " \
91
- "updater_id=%1$s, updated_at='%2$s'" % who_and_when
92
- conn.update "UPDATE card_acts SET actor_id=%s, acted_at='%s'" % who_and_when
93
- end
94
-
95
- desc "add test data"
96
- task supplement: :environment do
97
- add_test_data
98
- end
99
-
100
- def add_test_data
101
- return unless Rails.env == "test"
102
-
103
- load Cardio::Seed.test_script_path
104
- SharedData.add_test_data
105
- end
106
-
107
- desc "dump db to bootstrap fixtures"
108
- task dump: :environment do
109
- Card::Cache.reset_all
110
- Cardio::Seed::TABLES.each do |table|
111
- i = "000"
112
- write_seed_file table do
113
- yamlize_records table do |record, hash|
114
- hash["#{table}_#{i.succ!}"] = record
115
- end
116
- end
117
- end
118
- end
119
-
120
- def write_seed_file table
121
- path = Rails.env == "test" ? Cardio::Seed.test_path : Cardio::Seed.path
122
- filename = File.join path, "#{table}.yml"
123
- File.open filename, "w" do |file|
124
- file.write yield
125
- end
126
- end
127
-
128
- def yamlize_records table
129
- data = ActiveRecord::Base.connection.select_all "select * from #{table}"
130
- YAML.dump(
131
- data.each_with_object({}) do |record, hash|
132
- record["trash"] = false if record.key? "trash"
133
- record["draft"] = false if record.key? "draft"
134
- yield record, hash
135
- end
136
- )
137
- end
138
- end
139
- end
@@ -1,25 +0,0 @@
1
- namespace :decko do
2
- namespace :tmpsets do
3
- # We have to load the environment with `env REPO_TMPSETS=true` in
4
- # development mode to trigger the tmpset generation.
5
- # There's probably a more elegant way?
6
- task :trigger do
7
- ENV["REPO_TMPSETS"] = "true"
8
- Rake::Task["decko:tmpsets:dummy"].invoke
9
- end
10
-
11
- # just load environment and trigger Card load
12
- task dummy: :environment do
13
- Card
14
- end
15
-
16
- task :copy do
17
- require "fileutils"
18
- require "cardio"
19
-
20
- target = "#{Cardio.gem_root}/tmpsets"
21
- FileUtils.rm_r Dir["#{target}/set*"]
22
- FileUtils.cp_r Dir["#{Cardio.root}/tmpsets/set*"], "#{Cardio.gem_root}/tmpsets"
23
- end
24
- end
25
- end