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 +4 -4
- data/app/controllers/twinkle/appcast_controller.rb +1 -1
- data/app/models/twinkle/version.rb +12 -1
- data/lib/twinkle/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5b5dff3d492b803241ceaec6bc2bc6077c6417a380e6e820404d40d55afa51d
|
4
|
+
data.tar.gz: '0291795717e1e61e813d1fef69a5f59b4c4bbf62c57c5efae3ef0674a325d736'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/twinkle/version.rb
CHANGED