twinkle 0.1.1 → 0.2.2

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: 11aec611ab42595799ef8573c3c4531ddc4de266cc493f6e489259d14c0bb4be
4
- data.tar.gz: 47e2fb84ddc979e4cd5c9389c578f71c28d4c080c8732ae5368638352b4bbaea
3
+ metadata.gz: c5b5dff3d492b803241ceaec6bc2bc6077c6417a380e6e820404d40d55afa51d
4
+ data.tar.gz: '0291795717e1e61e813d1fef69a5f59b4c4bbf62c57c5efae3ef0674a325d736'
5
5
  SHA512:
6
- metadata.gz: 8459279d6a1ee5d1f4ad47df0da68948024ef60d95cdf86ded42ac77f54c636149de394dbb69fd23b78fe2f9764d7cea8f10dad066d3d159047de96ce222092b
7
- data.tar.gz: adf1ab532210ac62d886c5a769c03d282aecef5bb25714bfa51af27293c1bc516f7c5dc483c5dcd984e90faea8c7895eea9705bc3cfbccc369ad2febc07e11f7
6
+ metadata.gz: 1a17c906e4d0c6a24bc6c0788fb0add3b7f592574e23b94ea2be004444c2245017d2af875931ff4da86b00a025bb5966f900a586bcd4ad30e09e5f73f7079f07
7
+ data.tar.gz: dd2b2eebaf6599917fb830739b8e67ff1990c8f2fe0cc7e5f194baec828334cab6eb67bc68a9f33c1ac6cb39cf299c8ed2158a5f8c98ccb6d192d6cf2c9eb1ae
data/README.md CHANGED
@@ -63,6 +63,13 @@ end
63
63
 
64
64
  Pull requests welcome.
65
65
 
66
+ ## Testing
67
+
68
+ ```bash
69
+ bin/rails db:test:prepare
70
+ bin/test
71
+ ```
72
+
66
73
  ## Building the gem
67
74
 
68
75
  ```bash
@@ -1,7 +1,7 @@
1
1
  module Twinkle
2
2
  class AppcastController < ApplicationController
3
3
  def show
4
- @app = App.with_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,17 +4,27 @@ 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
- validates :build, presence: true
12
+ validates :build, numericality: { only_integer: true, greater_than: 0 }
9
13
  validates :description, presence: true, if: -> { published }
10
14
  validates :binary_url, presence: true, if: -> { published }
11
15
  validates :length, presence: true, if: -> { published }
12
16
  validates :length, numericality: { only_integer: true, greater_than: 0 }, allow_blank: true
13
-
17
+ validates :phased_rollout_interval, numericality: { only_integer: true, greater_than: 0 }, allow_blank: true
14
18
 
15
19
  # validates that the binary_url is a valid URL
16
20
  validate :binary_url_is_url
17
21
 
22
+ # validates that the release_notes_link is a valid URL
23
+ validate :release_notes_link_is_url
24
+
25
+ # validates that the full_release_notes_link is a valid URL
26
+ validate :full_release_notes_link_is_url
27
+
18
28
  # validates that one of the two signatures is present
19
29
  validate :signature_present, if: -> { published }
20
30
 
@@ -22,12 +32,17 @@ module Twinkle
22
32
 
23
33
  def binary_url_is_url
24
34
  return true if binary_url.blank?
25
- begin
26
- uri = URI.parse(binary_url)
27
- raise URI::InvalidURIError unless uri.is_a?(URI::HTTP) && uri.host.present?
28
- rescue URI::InvalidURIError
29
- errors.add(:binary_url, "is not a valid URL")
30
- end
35
+ errors.add(:binary_url, "is not a valid URL") unless is_url?(binary_url)
36
+ end
37
+
38
+ def release_notes_link_is_url
39
+ return true if release_notes_link.blank?
40
+ errors.add(:release_notes_link, "is not a valid URL") unless is_url?(release_notes_link)
41
+ end
42
+
43
+ def full_release_notes_link_is_url
44
+ return true if full_release_notes_link.blank?
45
+ errors.add(:full_release_notes_link, "is not a valid URL") unless is_url?(full_release_notes_link)
31
46
  end
32
47
 
33
48
  def signature_present
@@ -35,5 +50,20 @@ module Twinkle
35
50
  errors.add(:base, "At least one of the two signatures must be present")
36
51
  end
37
52
  end
53
+
54
+ def is_url?(url)
55
+ uri = URI.parse(url)
56
+ uri.is_a?(URI::HTTP) && uri.host.present?
57
+ rescue URI::InvalidURIError
58
+ false
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
38
68
  end
39
69
  end
@@ -5,14 +5,54 @@
5
5
  <% @app.versions.each do |version| %>
6
6
  <item>
7
7
  <title><%= version.number %></title>
8
- <pubDate><%= version.inserted_at %></pubDate>
8
+ <pubDate><%= version.published_at.strftime("%a, %d %b %Y %H:%M:%S %z") %></pubDate>
9
9
  <sparkle:version><%= version.build %></sparkle:version>
10
10
  <sparkle:shortVersionString><%= version.number %></sparkle:shortVersionString>
11
+ <% if version.link.present? %>
12
+ <link><%= version.link %></link>
13
+ <% end %>
14
+ <% if version.channel.present? %>
15
+ <sparkle:channel><%= version.channel %></sparkle:channel>
16
+ <% end %>
17
+ <% if version.release_notes_link.present? %>
18
+ <sparkle:releaseNotesLink><%= version.release_notes_link %></sparkle:releaseNotesLink>
19
+ <% end %>
20
+ <% if version.full_release_notes_link.present? %>
21
+ <sparkle:fullReleaseNotesLink><%= version.full_release_notes_link %></sparkle:fullReleaseNotesLink>
22
+ <% end %>
23
+ <% if version.min_system_version.present? %>
11
24
  <sparkle:minimumSystemVersion><%= version.min_system_version %></sparkle:minimumSystemVersion>
25
+ <% end %>
26
+ <% if version.max_system_version.present? %>
27
+ <sparkle:maximumSystemVersion><%= version.max_system_version %></sparkle:maximumSystemVersion>
28
+ <% end %>
29
+ <% if version.minimum_auto_update_version.present? %>
30
+ <sparkle:minimumAutoupdateVersion><%= version.minimum_auto_update_version %></sparkle:minimumAutoupdateVersion>
31
+ <% end %>
32
+ <% if version.ignore_skipped_upgrades_below_version.present? %>
33
+ <sparkle:ignoreSkippedUpgradesBelowVersion><%= version.ignore_skipped_upgrades_below_version %></sparkle:ignoreSkippedUpgradesBelowVersion>
34
+ <% end %>
35
+ <% if version.informational_update_below_version.present? %>
36
+ <sparkle:informationalUpdate>
37
+ <sparkle:belowVersion><%= version.informational_update_below_version %></sparkle:belowVersion>
38
+ </sparkle:informationalUpdate>
39
+ <% end %>
40
+ <% if version.critical %>
41
+ <% if version.sparkle_two %>
42
+ <sparkle:criticalUpdate<%= version.critical_version.present? ? raw(" sparkle:version=\"#{version.critical_version}\"") : "" %>></sparkle:criticalUpdate>
43
+ <% else %>
44
+ <sparkle:tags>
45
+ <sparkle:criticalUpdate></sparkle:criticalUpdate>
46
+ </sparkle:tags>
47
+ <% end %>
48
+ <% end %>
49
+ <% if version.phased_rollout_interval.present? %>
50
+ <sparkle:phasedRolloutInterval><%= version.phased_rollout_interval %></sparkle:phasedRolloutInterval>
51
+ <% end %>
12
52
  <description>
13
53
  <%= version.description %>
14
54
  </description>
15
- <enclosure url="<%= version.url %>" length="<%= version.length %>" type="application/octet-stream" sparkle:dsaSignature="<%= version.dsa_signature %>" sparkle:edSignature="<%= version.ed_signature %>"/>
55
+ <enclosure url="<%= version.binary_url %>" length="<%= version.length %>" type="application/octet-stream" sparkle:dsaSignature="<%= version.dsa_signature %>" sparkle:edSignature="<%= version.ed_signature %>"/>
16
56
  </item>
17
57
  <% end %>
18
58
  </channel>
@@ -0,0 +1,19 @@
1
+ class AddFieldsToTwinkleVersions < ActiveRecord::Migration[7.1]
2
+ def change
3
+ add_column :twinkle_versions, :sparkle_two, :boolean, default: true
4
+ add_column :twinkle_versions, :link, :string
5
+ add_column :twinkle_versions, :min_system_version, :string
6
+ add_column :twinkle_versions, :max_system_version, :string
7
+ add_column :twinkle_versions, :minimum_auto_update_version, :string
8
+ add_column :twinkle_versions, :ignore_skipped_upgrades_below_version, :string
9
+ add_column :twinkle_versions, :informational_update_below_version, :string
10
+ add_column :twinkle_versions, :critical, :boolean, default: false
11
+ add_column :twinkle_versions, :critical_version, :string
12
+ add_column :twinkle_versions, :phased_rollout_interval, :integer
13
+ add_column :twinkle_versions, :channel, :string
14
+ add_column :twinkle_versions, :release_notes_link, :string
15
+ add_column :twinkle_versions, :full_release_notes_link, :string
16
+ add_column :twinkle_versions, :published_at, :datetime
17
+ change_column :twinkle_versions, :build, :integer, using: 'build::integer'
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Twinkle
2
- VERSION = "0.1.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.1.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Marks
@@ -58,6 +58,7 @@ files:
58
58
  - db/migrate/20240517234016_create_twinkle_summaries.rb
59
59
  - db/migrate/20240518000405_create_twinkle_datapoints.rb
60
60
  - db/migrate/20240530023848_add_published_to_twinkle_versions.rb
61
+ - db/migrate/20240626232135_add_fields_to_twinkle_versions.rb
61
62
  - lib/tasks/twinkle_tasks.rake
62
63
  - lib/twinkle.rb
63
64
  - lib/twinkle/concerns/models/app.rb
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  - !ruby/object:Gem::Version
87
88
  version: '0'
88
89
  requirements: []
89
- rubygems_version: 3.3.26
90
+ rubygems_version: 3.5.9
90
91
  signing_key:
91
92
  specification_version: 4
92
93
  summary: Twinkle is a Rails engine for hosting appcast and collecting anonymous sparkle-project