Browse Source

Update to Lucky v0.28.0 (#6725)

Matthew McGarvey 4 years ago
parent
commit
7ccc96a486

+ 0 - 4
frameworks/Crystal/lucky/config/colors.cr

@@ -1,4 +0,0 @@
-# This enables the color output when in development or test
-# Check out the Colorize docs for more information
-# https://crystal-lang.org/api/Colorize.html
-Colorize.enabled = false

+ 1 - 1
frameworks/Crystal/lucky/config/database.cr

@@ -7,5 +7,5 @@ Avram.configure do |settings|
 
 
   # In production, allow lazy loading (N+1).
   # In production, allow lazy loading (N+1).
   # In development and test, raise an error if you forget to preload associations
   # In development and test, raise an error if you forget to preload associations
-  settings.lazy_load_enabled = Lucky::Env.production?
+  settings.lazy_load_enabled = false
 end
 end

+ 0 - 13
frameworks/Crystal/lucky/config/env.cr

@@ -1,13 +0,0 @@
-module Lucky::Env
-  extend self
-
-  {% for env in [:development, :test, :production] %}
-    def {{ env.id }}?
-      name == {{ env.id.stringify }}
-    end
-  {% end %}
-
-  def name
-    ENV["LUCKY_ENV"]? || "development"
-  end
-end

+ 0 - 3
frameworks/Crystal/lucky/config/html_page.cr

@@ -1,3 +0,0 @@
-Lucky::HTMLPage.configure do |settings|
-  settings.render_component_comments = false
-end

+ 1 - 1
frameworks/Crystal/lucky/lucky.dockerfile

@@ -1,4 +1,4 @@
-FROM crystallang/crystal:0.35.1
+FROM crystallang/crystal:1.1.0
 
 
 WORKDIR /lucky
 WORKDIR /lucky
 COPY shard.lock shard.lock
 COPY shard.lock shard.lock

+ 21 - 21
frameworks/Crystal/lucky/shard.lock

@@ -2,65 +2,65 @@ version: 2.0
 shards:
 shards:
   avram:
   avram:
     git: https://github.com/luckyframework/avram.git
     git: https://github.com/luckyframework/avram.git
-    version: 0.18.0
+    version: 0.21.0
 
 
-  blank:
-    git: https://github.com/kostya/blank.git
-    version: 0.1.0
+  backtracer:
+    git: https://github.com/sija/backtracer.cr.git
+    version: 1.2.1
 
 
   cry:
   cry:
     git: https://github.com/luckyframework/cry.git
     git: https://github.com/luckyframework/cry.git
-    version: 0.4.2
+    version: 0.4.3
 
 
   db:
   db:
     git: https://github.com/crystal-lang/crystal-db.git
     git: https://github.com/crystal-lang/crystal-db.git
-    version: 0.10.0
+    version: 0.10.1
 
 
   dexter:
   dexter:
     git: https://github.com/luckyframework/dexter.git
     git: https://github.com/luckyframework/dexter.git
-    version: 0.3.1
+    version: 0.3.3
 
 
   exception_page:
   exception_page:
     git: https://github.com/crystal-loot/exception_page.git
     git: https://github.com/crystal-loot/exception_page.git
-    version: 0.1.4
+    version: 0.2.0
 
 
   future:
   future:
     git: https://github.com/crystal-community/future.cr.git
     git: https://github.com/crystal-community/future.cr.git
-    version: 0.1.0
+    version: 1.0.0+git.commit.9fe168418c6884cb3552c13b004763eb4815ceb9
 
 
   habitat:
   habitat:
     git: https://github.com/luckyframework/habitat.git
     git: https://github.com/luckyframework/habitat.git
-    version: 0.4.4
+    version: 0.4.7
 
 
   lucky:
   lucky:
     git: https://github.com/luckyframework/lucky.git
     git: https://github.com/luckyframework/lucky.git
-    version: 0.25.0
-
-  lucky_cli:
-    git: https://github.com/luckyframework/lucky_cli.git
-    version: 0.25.0
+    version: 0.28.0
 
 
   lucky_router:
   lucky_router:
     git: https://github.com/luckyframework/lucky_router.git
     git: https://github.com/luckyframework/lucky_router.git
-    version: 0.4.0
+    version: 0.5.0
+
+  lucky_task:
+    git: https://github.com/luckyframework/lucky_task.git
+    version: 0.1.0
 
 
   pg:
   pg:
     git: https://github.com/will/crystal-pg.git
     git: https://github.com/will/crystal-pg.git
-    version: 0.22.1
+    version: 0.24.0
 
 
   pulsar:
   pulsar:
     git: https://github.com/luckyframework/pulsar.git
     git: https://github.com/luckyframework/pulsar.git
-    version: 0.2.1
+    version: 0.2.2
 
 
   shell-table:
   shell-table:
     git: https://github.com/luckyframework/shell-table.cr.git
     git: https://github.com/luckyframework/shell-table.cr.git
-    version: 0.9.2+git.commit.078a04ea58ead5203bb435a3b5fff448ddabaeea
+    version: 0.9.3+git.commit.fefbc8b19d18630660b2653de755217597808b1b
 
 
   teeplate:
   teeplate:
     git: https://github.com/luckyframework/teeplate.git
     git: https://github.com/luckyframework/teeplate.git
-    version: 0.8.2
+    version: 0.8.3
 
 
   wordsmith:
   wordsmith:
     git: https://github.com/luckyframework/wordsmith.git
     git: https://github.com/luckyframework/wordsmith.git
-    version: 0.2.1
+    version: 0.3.0
 
 

+ 2 - 2
frameworks/Crystal/lucky/shard.yml

@@ -8,9 +8,9 @@ targets:
   bench:
   bench:
     main: src/bench.cr
     main: src/bench.cr
 
 
-crystal: 0.35.1
+crystal: ">= 1.0.0"
 
 
 dependencies:
 dependencies:
   lucky:
   lucky:
     github: luckyframework/lucky
     github: luckyframework/lucky
-    version: ~> 0.25.0
+    version: ~> 0.28.0

+ 1 - 1
frameworks/Crystal/lucky/src/actions/db/index.cr

@@ -1,6 +1,6 @@
 class Db::Index < BaseAction
 class Db::Index < BaseAction
   get "/db" do
   get "/db" do
-    world = WorldQuery.find(rand(1..ID_MAXIMUM))
+    world = World::BaseQuery.find(rand(1..ID_MAXIMUM))
     json WorldSerializer.new(world)
     json WorldSerializer.new(world)
   end
   end
 end
 end

+ 1 - 1
frameworks/Crystal/lucky/src/actions/fortunes/index.cr

@@ -1,6 +1,6 @@
 class Fortunes::Index < BaseAction
 class Fortunes::Index < BaseAction
   get "/fortunes" do
   get "/fortunes" do
-    fortunes = FortuneQuery.all.results
+    fortunes = Fortune::BaseQuery.all.results
     fortunes << Fortune.new(id: 0, message: "Additional fortune added at request time.")
     fortunes << Fortune.new(id: 0, message: "Additional fortune added at request time.")
     fortunes.sort_by!(&.message)
     fortunes.sort_by!(&.message)
     html Fortunes::IndexPage, fortunes: fortunes
     html Fortunes::IndexPage, fortunes: fortunes

+ 0 - 5
frameworks/Crystal/lucky/src/actions/home/index.cr

@@ -1,5 +0,0 @@
-class Home::Index < BaseAction
-  get "/" do
-    html Lucky::WelcomePage
-  end
-end

+ 1 - 1
frameworks/Crystal/lucky/src/actions/queries/index.cr

@@ -3,7 +3,7 @@ class Queries::Index < BaseAction
 
 
   get "/queries" do
   get "/queries" do
     results = (1..queries_param).map do
     results = (1..queries_param).map do
-      world = WorldQuery.find(rand(1..ID_MAXIMUM))
+      world = World::BaseQuery.find(rand(1..ID_MAXIMUM))
       WorldSerializer.new(world)
       WorldSerializer.new(world)
     end
     end
 
 

+ 2 - 2
frameworks/Crystal/lucky/src/actions/updates/index.cr

@@ -3,7 +3,7 @@ class Updates::Index < BaseAction
 
 
   get "/updates" do
   get "/updates" do
     results = (1..queries_param).map do
     results = (1..queries_param).map do
-      world = WorldQuery.find(rand(1..ID_MAXIMUM))
+      world = World::BaseQuery.find(rand(1..ID_MAXIMUM))
       # Avram does not perform the update operation if no value has changed
       # Avram does not perform the update operation if no value has changed
       # so we have to keep generating random numbers until we
       # so we have to keep generating random numbers until we
       # get one that is different than the currently set one
       # get one that is different than the currently set one
@@ -11,7 +11,7 @@ class Updates::Index < BaseAction
       while random_number == world.randomnumber
       while random_number == world.randomnumber
         random_number = rand(1..ID_MAXIMUM)
         random_number = rand(1..ID_MAXIMUM)
       end
       end
-      world = SaveWorld.update!(world, randomnumber: random_number)
+      world = World::SaveOperation.update!(world, randomnumber: random_number)
       WorldSerializer.new(world)
       WorldSerializer.new(world)
     end
     end
 
 

+ 0 - 4
frameworks/Crystal/lucky/src/app.cr

@@ -3,14 +3,10 @@ require "./shards"
 require "./app_database"
 require "./app_database"
 require "./models/base_model"
 require "./models/base_model"
 require "./models/**"
 require "./models/**"
-require "./queries/**"
-require "./operations/**"
-require "./serializers/base_serializer"
 require "./serializers/**"
 require "./serializers/**"
 require "./actions/mixins/**"
 require "./actions/mixins/**"
 require "./actions/**"
 require "./actions/**"
 require "./handlers/**"
 require "./handlers/**"
 require "./pages/**"
 require "./pages/**"
-require "../config/env"
 require "../config/**"
 require "../config/**"
 require "./app_server"
 require "./app_server"

+ 0 - 10
frameworks/Crystal/lucky/src/app_database.cr

@@ -1,12 +1,2 @@
 class AppDatabase < Avram::Database
 class AppDatabase < Avram::Database
-  @@lock = Mutex.new
-
-  # added to avram in https://github.com/luckyframework/avram/commit/419cca8d25512be45766d3224e5c56deb2ce5bd2
-  private def db : DB::Database
-    @@db ||= @@lock.synchronize do
-      # check @@db again because a previous request could have set it after
-      # the first time it was checked
-      @@db || Avram::Connection.new(url, database_class: self.class).open
-    end
-  end
 end
 end

+ 0 - 2
frameworks/Crystal/lucky/src/operations/save_fortune.cr

@@ -1,2 +0,0 @@
-class SaveFortune < Fortune::SaveOperation
-end

+ 0 - 2
frameworks/Crystal/lucky/src/operations/save_world.cr

@@ -1,2 +0,0 @@
-class SaveWorld < World::SaveOperation
-end

+ 23 - 11
frameworks/Crystal/lucky/src/pages/fortunes/index_page.cr

@@ -1,18 +1,30 @@
-class Fortunes::IndexPage < MainLayout
+class Fortunes::IndexPage
+  include Lucky::HTMLPage
+
   needs fortunes : Array(Fortune)
   needs fortunes : Array(Fortune)
 
 
-  def content
-    table do
-      tr do
-        th "id"
-        th "message"
+  def render
+    html_doctype
+
+    html lang: "en" do
+      head do
+        title "Fortunes"
       end
       end
 
 
-      fortunes.each do |fortune|
-        tr do
-          td fortune.id
-          # html text escaped by default in Lucky
-          td fortune.message
+      body do
+        table do
+          tr do
+            th "id"
+            th "message"
+          end
+
+          fortunes.each do |fortune|
+            tr do
+              td fortune.id
+              # html text escaped by default in Lucky
+              td fortune.message
+            end
+          end
         end
         end
       end
       end
     end
     end

+ 0 - 19
frameworks/Crystal/lucky/src/pages/main_layout.cr

@@ -1,19 +0,0 @@
-abstract class MainLayout
-  include Lucky::HTMLPage
-
-  abstract def content
-
-  def render
-    html_doctype
-
-    html lang: "en" do
-      head do
-        title "Fortunes"
-      end
-
-      body do
-        content
-      end
-    end
-  end
-end

+ 0 - 2
frameworks/Crystal/lucky/src/queries/fortune_query.cr

@@ -1,2 +0,0 @@
-class FortuneQuery < Fortune::BaseQuery
-end

+ 0 - 2
frameworks/Crystal/lucky/src/queries/world_query.cr

@@ -1,2 +0,0 @@
-class WorldQuery < World::BaseQuery
-end

+ 0 - 7
frameworks/Crystal/lucky/src/serializers/base_serializer.cr

@@ -1,7 +0,0 @@
-abstract class BaseSerializer < Lucky::Serializer
-  def self.for_collection(collection : Enumerable, *args, **named_args)
-    collection.map do |object|
-      new(object, *args, **named_args)
-    end
-  end
-end

+ 1 - 1
frameworks/Crystal/lucky/src/serializers/world_serializer.cr

@@ -1,4 +1,4 @@
-class WorldSerializer < BaseSerializer
+class WorldSerializer < Lucky::Serializer
   def initialize(@world : World)
   def initialize(@world : World)
   end
   end