decko 0.8.3 → 0.9.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
  SHA1:
3
- metadata.gz: e5d97bf5746fea2ca22cbbc1498cc9aa4cc82141
4
- data.tar.gz: 1967e966949ff744935fd5791125a1525357595d
3
+ metadata.gz: 3bfe665a6798cb6d119bb776e202dce24979bf5f
4
+ data.tar.gz: abb5cb4c0a969cdbbc16c8dd4db5ad56ac0525c2
5
5
  SHA512:
6
- metadata.gz: 122893f178aa72dc0e5dcd12d3eec005d9aae3087647be70fa9df73d1ccd521045c1b08efc1032d331c3ab37eb3a382176467e6cdb149cbddb847d04c8705ee0
7
- data.tar.gz: 0f51e06ae726e1467f60b28bda92ab7e08da3e6edcb99806a8e53f066a015f3acc93096b0ab431c621dde0008a66cb05dfa87d0cda48df446fba7f782437f2cf
6
+ metadata.gz: ac95d083126c0a2aad3b617f17791b7598fa774ee86ff967c972307a09a7541f2a7729f55a5a1fc70a4845aac613e89d976014445bef24ae0be6980a998a5f7b
7
+ data.tar.gz: 8c2fa80ddceb0366c36fceebf0b445dc53c92286b6f7bf1c976f2ab078c420d9bb5218439dc16a9845221a217c7c765e0fc499ab1b216638aef38c7505f82ed3
@@ -21,7 +21,7 @@ module Decko
21
21
  end
22
22
 
23
23
  initializer :load_card, after: :load_config_initializers, group: :all do
24
- Card
24
+ Card if Cardio.load_card?
25
25
  end
26
26
 
27
27
  class << self
@@ -1,3 +1,5 @@
1
+ # require "English" # needed for CHILD_STATUS, but not sure this is the best place for this.
2
+
1
3
  module Decko
2
4
  module Commands
3
5
  class Command
@@ -1,4 +1,5 @@
1
1
  require File.expand_path("../command", __FILE__)
2
+ # require "pry"
2
3
 
3
4
  module Decko
4
5
  module Commands
@@ -15,13 +16,18 @@ module Decko
15
16
  end
16
17
 
17
18
  def run
18
- command.each do |cmd|
19
+ commands.each do |cmd|
19
20
  puts cmd
20
- puts `#{cmd}`
21
+ # exit_with_child_status cmd
22
+
23
+ result = `#{cmd}`
24
+ process = $?
25
+ puts result
26
+ exit process.exitstatus unless process.success?
21
27
  end
22
28
  end
23
29
 
24
- def command
30
+ def commands
25
31
  task_cmd = "bundle exec rake #{@task}"
26
32
  return [task_cmd] if !@envs || @envs.empty?
27
33
  @envs.map do |env|
@@ -49,7 +49,7 @@ module Decko
49
49
  end
50
50
  ActiveSupport.on_load(:after_initialize) do
51
51
  begin
52
- require_dependency "card" unless defined?(Card)
52
+ require_dependency "card" if Cardio.load_card?
53
53
  rescue ActiveRecord::StatementInvalid => e
54
54
  ::Rails.logger.warn "database not available[#{::Rails.env}] #{e}"
55
55
  end
@@ -88,7 +88,7 @@ class DeckoGenerator < Rails::Generators::AppBase
88
88
  template "boot.rb"
89
89
  template "databases/#{options[:database]}.yml", "database.yml"
90
90
  template "cucumber.yml" if options["core-dev"]
91
- template "initializers/cypress_dev.rb" if options["core-dev"]
91
+ template "initializers/cypress_on_rails.rb" if options["core-dev"]
92
92
  end
93
93
  end
94
94
 
@@ -38,7 +38,7 @@ group :test do
38
38
  end
39
39
 
40
40
  group :test, :cypress do
41
- gem 'cypress-on-rails', '~> 1.2'
41
+ gem 'cypress-on-rails', '~> 1.4'
42
42
  end
43
43
 
44
44
  group :test, :development do
@@ -0,0 +1,10 @@
1
+ if defined?(CypressOnRails)
2
+ CypressOnRails.configure do |c|
3
+ c.cypress_folder = File.join Decko.gem_root, "spec", "cypress"
4
+ # WARNING!! CypressOnRails can execute arbitrary ruby code
5
+ # please use with extra caution if enabling on hosted servers or starting your
6
+ # local server on 0.0.0.0
7
+ c.use_middleware = Rails.env.cypress? || ENV["CYPRESS_DEV"]
8
+ c.logger = Rails.logger
9
+ end
10
+ end
@@ -3,7 +3,7 @@ module Decko
3
3
  module Response
4
4
  private
5
5
  def respond format, result, status
6
- if status == 302
6
+ if status.in? [302, 303]
7
7
  hard_redirect result
8
8
  elsif format.is_a?(Card::Format::FileFormat) && status == 200
9
9
  send_file(*result)
@@ -16,6 +16,20 @@ module Decko
16
16
  render body: body, status: status, content_type: content_type
17
17
  end
18
18
 
19
+ def redirect_cud_success success
20
+ redirect_type = success.redirect || default_cud_success_redirect_type
21
+ if redirect_type.to_s == "soft"
22
+ success.target ||= self
23
+ soft_redirect success
24
+ else
25
+ hard_redirect success.to_url, 303
26
+ end
27
+ end
28
+
29
+ def default_cud_success_redirect_type
30
+ Card::Env.ajax? ? "soft" : "hard"
31
+ end
32
+
19
33
  # return a redirect response
20
34
  def hard_redirect url, status=302
21
35
  url = card_url url # make sure we have absolute url
@@ -32,6 +46,7 @@ module Decko
32
46
  # return a standard GET response directly.
33
47
  # Used in AJAX situations where PRG pattern is unwieldy
34
48
  def soft_redirect success
49
+ # Card::Cache.renew
35
50
  @card = success.target
36
51
  require_card_for_soft_redirect!
37
52
  self.params = Card::Env[:params] = soft_redirect_params
@@ -87,7 +102,10 @@ module Decko
87
102
  end
88
103
 
89
104
  def format_name_from_params
90
- explicit_file_format? ? :file : request.format.to_sym
105
+ if explicit_file_format? then :file
106
+ elsif params[:format].present? then params[:format].to_sym
107
+ else request.format.to_sym
108
+ end
91
109
  end
92
110
 
93
111
  def explicit_file_format?
@@ -3,8 +3,11 @@
3
3
  module Decko
4
4
  # for use in REST API specs
5
5
  module RestSpecMethods
6
- def with_token_for usermark
7
- yield Card[usermark].account.reset_token
6
+ def with_api_key_for usermark
7
+ key_card = Card.fetch [usermark, :account, :api_key], new: {}
8
+ key_card.content = "asdkfjh1023498203jdfs"
9
+ Card::Auth.as_bot { key_card.save! }
10
+ yield key_card.content
8
11
  end
9
12
  end
10
13
 
@@ -61,7 +61,7 @@ class CardController < ActionController::Base
61
61
  end
62
62
 
63
63
  def authenticate
64
- Card::Auth.set_current params[:token], params[:current]
64
+ Card::Auth.set_current token: params[:token], api_key: params[:api_key]
65
65
  end
66
66
 
67
67
  def load_mark
@@ -101,11 +101,9 @@ class CardController < ActionController::Base
101
101
  def cud_success
102
102
  success = Card::Env.success.in_context card.name
103
103
  if success.reload?
104
- reload
105
- elsif Card::Env.ajax? && !success.hard_redirect?
106
- soft_redirect success
104
+ reload # instruct JSON to reload
107
105
  else
108
- hard_redirect success.to_url, 303
106
+ redirect_cud_success success
109
107
  end
110
108
  end
111
109
 
@@ -20,6 +20,7 @@ Decko::Engine.routes.draw do
20
20
 
21
21
  # Alternate GET requests
22
22
  get "new/:type" => "card#read", view: "new" # common case for card without mark
23
+ get "type/:type" => "card#read"
23
24
  get ":mark/view/:view(.:format)" => "card#read" # simplifies API documentation
24
25
  get "card/:view(/:mark(.:format))" => "card#read", view: /new|edit/ # legacy
25
26
 
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decko
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
8
+ - Philipp Kühl
8
9
  - Lewis Hoffman
9
10
  - Gerry Gleason
10
- - Philipp Kühl
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2019-09-08 00:00:00.000000000 Z
14
+ date: 2019-10-02 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: card
@@ -19,14 +19,14 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 1.98.3
22
+ version: 1.99.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 1.98.3
29
+ version: 1.99.0
30
30
  description: a wiki approach to stuctured data, dynamic interaction, and web design
31
31
  email:
32
32
  - info@decko.org
@@ -103,6 +103,7 @@ files:
103
103
  - lib/decko/generators/decko/templates/config/deck.yml
104
104
  - lib/decko/generators/decko/templates/config/environment.rb
105
105
  - lib/decko/generators/decko/templates/config/initializers/cypress_dev.rb
106
+ - lib/decko/generators/decko/templates/config/initializers/cypress_on_rails.rb
106
107
  - lib/decko/generators/decko/templates/config/puma.rb
107
108
  - lib/decko/generators/decko/templates/config/routes.erb
108
109
  - lib/decko/generators/decko/templates/gitignore