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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 745ebe3beb30463d26dc3801ec74938b03ae089d267586d90ff736872a5bcbca
4
- data.tar.gz: 678c0fadd35d1798fd7f1f69fc1ba9d170f7f12c3b3099311d96a1fd56f7bae8
3
+ metadata.gz: 1a7a2c25498981d89895eafa384e47eeb0d920c9b98e50abf93fc2faf8582725
4
+ data.tar.gz: 01b7bd69a10e38ad01f737e22c5553530cccf9fc8273b413c599fb18bb4b1b6f
5
5
  SHA512:
6
- metadata.gz: a80e569a9be8977f3447583de2e030ccf45341a25bc60a845b02766be74b7dadf19f4aa5314d6dcdd2f935d44efadf2c668ea5f43c55cc0ce7c10115bd3d14d3
7
- data.tar.gz: a11ac6363d06444ef8aa07ca5173e8c1770ce44295ab89ca32505c0140565244b2a118a2bdac1ccccf546cd04d9ac1e8dea0040c33649691846bbad606c4de1c
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).find_by!(slug: params[:slug])
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
@@ -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 :app_version, :version
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
@@ -1,3 +1,3 @@
1
1
  module Twinkle
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.3"
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Marks