twinkle 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/twinkle/appcast_controller.rb +6 -2
- data/app/models/twinkle/event.rb +2 -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: 1a7a2c25498981d89895eafa384e47eeb0d920c9b98e50abf93fc2faf8582725
|
4
|
+
data.tar.gz: 01b7bd69a10e38ad01f737e22c5553530cccf9fc8273b413c599fb18bb4b1b6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f782193eb3343bd4631acf821ad3a2fb0c8e43ee8019533689853d9b2830c26d88557c80f8e501bf8f30b020f285a82b88139dde986694b8fb43c301b7c1646
|
7
|
+
data.tar.gz: 4c7e5ec8d2e463ff47b60ac802c3e255a5665ac1b8056d7cc11d112df54f9bc8bf716b27267b44fa3ae399daa9ffc76bba75bcd20a3e5e3c73a99adca338727e
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module Twinkle
|
2
2
|
class AppcastController < ApplicationController
|
3
3
|
def show
|
4
|
-
@app = App.includes(:versions)
|
4
|
+
@app = App.includes(:versions)
|
5
|
+
.where(versions: { published: true })
|
6
|
+
.order('versions.build DESC')
|
7
|
+
.find_by!(slug: params[:slug])
|
5
8
|
Event.create(app: @app, **event_params)
|
6
9
|
render layout: false, formats: :xml
|
7
10
|
end
|
@@ -18,7 +21,8 @@ module Twinkle
|
|
18
21
|
:cpusubtype,
|
19
22
|
:ramMB,
|
20
23
|
:osVersion,
|
21
|
-
:lang
|
24
|
+
:lang,
|
25
|
+
:model
|
22
26
|
)
|
23
27
|
end
|
24
28
|
end
|
data/app/models/twinkle/event.rb
CHANGED
@@ -4,9 +4,10 @@ module Twinkle
|
|
4
4
|
|
5
5
|
scope :created_between, -> (start_date, end_date) {where("created_at >= ? AND created_at <= ?", start_date, end_date )}
|
6
6
|
|
7
|
-
alias_attribute :
|
7
|
+
alias_attribute :appVersion, :version
|
8
8
|
alias_attribute :cpuFreqMHz, :cpu_freq_mhz
|
9
9
|
alias_attribute :osVersion, :os_version
|
10
|
+
alias_attribute :ramMB, :ram_mb
|
10
11
|
|
11
12
|
def self.fields
|
12
13
|
attribute_names.select{ |name| !['id', 'twinkle_app_id', 'created_at', 'updated_at'].include?(name) }
|
@@ -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