twinkle 0.2.1 → 0.2.2

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: 745ebe3beb30463d26dc3801ec74938b03ae089d267586d90ff736872a5bcbca
4
- data.tar.gz: 678c0fadd35d1798fd7f1f69fc1ba9d170f7f12c3b3099311d96a1fd56f7bae8
3
+ metadata.gz: c5b5dff3d492b803241ceaec6bc2bc6077c6417a380e6e820404d40d55afa51d
4
+ data.tar.gz: '0291795717e1e61e813d1fef69a5f59b4c4bbf62c57c5efae3ef0674a325d736'
5
5
  SHA512:
6
- metadata.gz: a80e569a9be8977f3447583de2e030ccf45341a25bc60a845b02766be74b7dadf19f4aa5314d6dcdd2f935d44efadf2c668ea5f43c55cc0ce7c10115bd3d14d3
7
- data.tar.gz: a11ac6363d06444ef8aa07ca5173e8c1770ce44295ab89ca32505c0140565244b2a118a2bdac1ccccf546cd04d9ac1e8dea0040c33649691846bbad606c4de1c
6
+ metadata.gz: 1a17c906e4d0c6a24bc6c0788fb0add3b7f592574e23b94ea2be004444c2245017d2af875931ff4da86b00a025bb5966f900a586bcd4ad30e09e5f73f7079f07
7
+ data.tar.gz: dd2b2eebaf6599917fb830739b8e67ff1990c8f2fe0cc7e5f194baec828334cab6eb67bc68a9f33c1ac6cb39cf299c8ed2158a5f8c98ccb6d192d6cf2c9eb1ae
@@ -1,7 +1,7 @@
1
1
  module Twinkle
2
2
  class AppcastController < ApplicationController
3
3
  def show
4
- @app = App.includes(:versions).find_by!(slug: params[:slug])
4
+ @app = App.includes(:versions).where(versions: { published: true }).find_by!(slug: params[:slug])
5
5
  Event.create(app: @app, **event_params)
6
6
  render layout: false, formats: :xml
7
7
  end
@@ -4,6 +4,10 @@ module Twinkle
4
4
  class Version < ApplicationRecord
5
5
  belongs_to :app, foreign_key: 'twinkle_app_id', class_name: 'Twinkle::App'
6
6
 
7
+ scope :published, -> { where(published: true) }
8
+
9
+ before_save :set_published_at
10
+
7
11
  validates :number, presence: true
8
12
  validates :build, numericality: { only_integer: true, greater_than: 0 }
9
13
  validates :description, presence: true, if: -> { published }
@@ -47,12 +51,19 @@ module Twinkle
47
51
  end
48
52
  end
49
53
 
50
- private
51
54
  def is_url?(url)
52
55
  uri = URI.parse(url)
53
56
  uri.is_a?(URI::HTTP) && uri.host.present?
54
57
  rescue URI::InvalidURIError
55
58
  false
56
59
  end
60
+
61
+ def set_published_at
62
+ if published && published_at.nil?
63
+ self.published_at = Time.now
64
+ elsif !published && published_at.present?
65
+ self.published_at = nil
66
+ end
67
+ end
57
68
  end
58
69
  end
@@ -1,3 +1,3 @@
1
1
  module Twinkle
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twinkle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Marks