lws 7.1.2 → 7.1.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: a6ddf096778ba5030a935df95f904a65776bbd8b2dd30602e3c9d912124fb5cd
4
- data.tar.gz: 739154dc2c9598eef580f9a562cff9ddccde3a0828e985c55429ceed74f03a5d
3
+ metadata.gz: b61e005e4e0e7bf19e2d9299e5444e914c5aac6df6cfd3084cd63ff5fd75bb87
4
+ data.tar.gz: 0fa6b75fa04c5b9823052e79a74283fcb1de031ca3312cd921f942100cb32248
5
5
  SHA512:
6
- metadata.gz: c6f4e39e00a7277ed012c6d4a2a846dae249edf892db185d17c5a62efa012902bc388ed4e652a26e25eb30ea07e208fbe4ef08b19671c750a0e3f33aa719f8a5
7
- data.tar.gz: 696ae43f1ed90d4674365f86d63d411fc21544cce16ba250079e0bcefef1143c9d908c6e01b18773b006fa9a704e45ebc85795ff044c28948bf16fb79f4da042
6
+ metadata.gz: 2619b5d60dc8a3df39b8d739b364832d63025b5eca9024b42619308e753ee51fcbd14dda437a1a1d3269eef2eee3e8acea30841c020b6bfc7da1b9dbd277af94
7
+ data.tar.gz: 97f62b08426cdbbeae331d10254f8b12e58147074cbecee642d1a4cbe179d4ebd1fd70080cda730d003ec10a2799499f626bc97d5ce92f3ab91189adb3d63d00
@@ -87,13 +87,11 @@ begin
87
87
  if @options[:cfg_file]
88
88
  cfg_file = @options[:cfg_file]
89
89
  raise "config file does not exist: #{cfg_file}" unless File.exist? cfg_file
90
- config.load_config_file(cfg_file)
90
+ config.load_config_file(cfg_file, @options[:environment])
91
91
  else
92
- config.load_config_file(GLOBAL_CONFIG_FILE)
93
- config.load_config_file(USER_CONFIG_FILE)
92
+ config.load_config_file(GLOBAL_CONFIG_FILE, @options[:environment])
93
+ config.load_config_file(USER_CONFIG_FILE, @options[:environment])
94
94
  end
95
-
96
- config.environment = @options[:environment] if @options[:environment]
97
95
  end
98
96
  if @options[:app]
99
97
  @app_module = LWS.app_module(@options[:app].downcase)
@@ -158,7 +156,7 @@ if LWS.config.http_debug
158
156
  end
159
157
  end
160
158
  debug_outputs << "JSON" if LWS.config.json_debug
161
- unless debug_outputs.present?
159
+ if debug_outputs.present?
162
160
  puts "- Debug output: #{debug_outputs.join(', ')}"
163
161
  end
164
162
  puts
data/lib/lws.rb CHANGED
@@ -77,7 +77,11 @@ module LWS
77
77
  # @return [LWS] the module itself
78
78
  def self.setup(&block)
79
79
  @@config = Config.new
80
- yield @@config
80
+
81
+ # Override the environment if needed
82
+ if ENV["LC_LWS_ENV"].present?
83
+ @@config.environment = ENV["LC_LWS_ENV"].to_sym
84
+ end
81
85
 
82
86
  # Override the API token if needed (and no custom API token middleware
83
87
  # is used)
@@ -85,10 +89,7 @@ module LWS
85
89
  @@config.api_token = ENV["LC_LWS_API_TOKEN"]
86
90
  end
87
91
 
88
- # Override the environment if needed
89
- if ENV["LC_LWS_ENV"].present?
90
- @@config.environment = ENV["LC_LWS_ENV"].to_sym
91
- end
92
+ yield @@config
92
93
 
93
94
  if config.api_token.blank? and config.api_token_middleware.blank?
94
95
  raise LWS::Errors::ConfigError,
@@ -107,8 +108,8 @@ module LWS
107
108
  # Sets up the Faraday API object with the current LWS configuration for
108
109
  # the given API URL.
109
110
  #
110
- # @param api_url The endpoint URL of the API
111
- # @return [Faraday] A Faraday connection that makes requests to the API
111
+ # @param api_url [String] The endpoint URL of the API
112
+ # @return [Faraday::Connection] A Faraday connection that makes requests to the API
112
113
  def self.setup_api(api_url)
113
114
  api = Faraday.new(url: api_url) do |c|
114
115
  # Request
@@ -497,6 +497,11 @@ module LWS::DigitalSignage
497
497
  class Layout < LWS::Generic::Model
498
498
  use_api LWS::DigitalSignage.api
499
499
 
500
+ # @!attribute category_ids
501
+ # @return [Array<Integer>] the IDs of the categories assoicated with
502
+ # the layout
503
+ attribute :category_ids
504
+
500
505
  # @!attribute categories
501
506
  # @return [Array<Layout::Category>] the categories associated with
502
507
  # the layout
@@ -504,13 +509,19 @@ module LWS::DigitalSignage
504
509
  has_many :categories, class_name: "LWS::DigitalSignage::Layout::Category",
505
510
  uri: "layout/:layout_id/categories(/:id)"
506
511
 
507
- # @!attribute company
508
- # @return [LWS::Auth::Company] the company the layout belongs to
509
- belongs_to :company, class_name: "LWS::Auth::Company"
512
+ # @!attribute company_owner
513
+ # @return [LWS::Auth::Company] the company that owns the layout
514
+ belongs_to :company_owner, class_name: "LWS::Auth::Company",
515
+ foreign_key: :company_owner_id,
516
+ uri: "companies/:id"
510
517
 
511
- # @!attribute company_id
512
- # @return [Integer] the ID of the company the layout belongs to
513
- attribute :company_id
518
+ # @!attribute company_owner_id
519
+ # @return [Integer] the ID of the company that owns the layout
520
+ attribute :company_owner_id
521
+
522
+ # @!attribute company_shared_ids
523
+ # @return [Array<Integer>] the IDs of the company the layout is shared with
524
+ attribute :company_shared_ids
514
525
 
515
526
  # @!attribute default_duration
516
527
  # @return [5..3600] the default duration of a slide created from the layout
@@ -520,6 +531,14 @@ module LWS::DigitalSignage
520
531
  # @return [String, nil] the description of the layout
521
532
  attribute :description
522
533
 
534
+ # @!attribute description_html
535
+ # @return [String, nil] an HTML version of the description of the layout
536
+ attribute :description_html
537
+
538
+ # @!attribute duration_kind
539
+ # @return ["variable", "fixed", "kind"] the duration kind of the layout
540
+ attribute :duration_kind
541
+
523
542
  # @!attribute favorite
524
543
  # @return [Boolean] whether the layout is a favorite for the current account
525
544
  attribute :favorite
@@ -547,11 +566,25 @@ module LWS::DigitalSignage
547
566
  # @return [Boolean] whether the layout has priority over others
548
567
  attribute :priority
549
568
 
569
+ # @!attribute public
570
+ # @return [Boolean] whether the layout is public (i.e. shared with all
571
+ # companies)
572
+ attribute :public
573
+
574
+ # @!attribute rotation
575
+ # @return ["landscape", "portrait"] the rotation (orientation) of the
576
+ # layout
577
+ attribute :rotation
578
+
550
579
  # @!attribute slides
551
580
  # @return [Array<Slide>] the slides using the layout
552
581
  has_many :slides, class_name: "LWS::DigitalSignage::Slide",
553
582
  uri: "layouts/:layout_id/slides(/:id)"
554
583
 
584
+ # @!attribute thumbnail_url
585
+ # @return [String, nil] the URL of the thumbnail of the layout
586
+ attribute :thumbnail_url
587
+
555
588
  # @!attribute trans
556
589
  # @return ["cut", "fadein", "zoomin", "slidein"] the transition of the
557
590
  # entire layout
@@ -801,9 +834,9 @@ module LWS::DigitalSignage
801
834
  # @return [Integer] the ID of the configuration of the player
802
835
  attribute :configuration_id
803
836
 
804
- # @!attribute feedbacks
837
+ # @!attribute feedback
805
838
  # @return [Hash{String=>String}] a mapping of player feedback key/values
806
- attribute :feedbacks
839
+ attribute :feedback
807
840
 
808
841
  # @!attribute [r] health_percentage
809
842
  # @return [Fixnum] the health of the player (percentage)
@@ -834,13 +867,17 @@ module LWS::DigitalSignage
834
867
  # @return [Integer] the ID of the model of the player
835
868
  attribute :model_id
836
869
 
870
+ # @!attribute name
871
+ # @return [String] the name of the player
872
+ attribute :name
873
+
837
874
  # @!attribute notifications
838
875
  # @return [Array<Player::Notification>] the notifications for the player
839
876
  has_many :notifications, class_name: "LWS::DigitalSignage::Player::Notification"
840
877
 
841
- # @!attribute operational_hours [r]
878
+ # @!attribute operation_hours [r]
842
879
  # @return [String, nil] the number of hours the player has been operational
843
- attribute :operational_hours
880
+ attribute :operation_hours
844
881
 
845
882
  # @!attribute operational_since [r]
846
883
  # @return [String, nil] the date/time when the player became operational
@@ -891,9 +928,14 @@ module LWS::DigitalSignage
891
928
  attribute :status
892
929
 
893
930
  # @!attribute status_reason [r]
894
- # @return [String] the reason for the current player status
931
+ # @return ["unknown", "hardware_failure", "outdated_os", "good", "connection_inactive_short",
932
+ # "connection_inactive_long"] the reason for the current player status
895
933
  attribute :status_reason
896
934
 
935
+ # @!attribute status_updated_at [r]
936
+ # @return [String] the date/time the status was last updated
937
+ attribute :status_updated_at
938
+
897
939
  # @!attribute tags
898
940
  # @return [Array<Player::Tag>] the tags of the player
899
941
  has_many :tags, class_name: "LWS::DigitalSignage::Player::Tag"
@@ -1685,6 +1727,10 @@ module LWS::DigitalSignage
1685
1727
  # scheduled on
1686
1728
  has_many :channel_groups, class_name: "LWS::DigitalSignage::Channel::Group"
1687
1729
 
1730
+ # @!attribute comments
1731
+ # @return [String, nil] the comments/remarks for the slide
1732
+ attribute :comments
1733
+
1688
1734
  # @!attribute company
1689
1735
  # @return [LWS::Auth::Company] the company the slide belongs to
1690
1736
  belongs_to :company, class_name: "LWS::Auth::Company"
@@ -1693,6 +1739,19 @@ module LWS::DigitalSignage
1693
1739
  # @return [Integer] the ID of the company the slide belongs to
1694
1740
  attribute :company_id
1695
1741
 
1742
+ # @!attribute duration
1743
+ # @return [Integer, nil] the duration of the slide (for fixed or content-bound durations
1744
+ # in the layout)
1745
+ attribute :duration
1746
+
1747
+ # @!attribute edit_account_ids
1748
+ # @return [Array<Integer>] the IDs of the accounts that can edit the slide
1749
+ attribute :edit_account_ids
1750
+
1751
+ # @!attribute editable_by_me
1752
+ # @return [Boolean] whether the authenticated user can edit the slide
1753
+ attribute :editable_by_me
1754
+
1696
1755
  # @!attribute layout
1697
1756
  # @return [LWS::Layout] the layout the slide uses
1698
1757
  belongs_to :layout
@@ -1711,13 +1770,16 @@ module LWS::DigitalSignage
1711
1770
 
1712
1771
  # @!attribute schedules
1713
1772
  # @return [Array<Schedule>] the slide schedules that apply for the slide
1714
- # FIXME: Missing endpoint in LWS
1715
1773
  has_many :schedules, class_name: "LWS::DigitalSignage::Slide::Schedule"
1716
1774
 
1717
1775
  # @!attribute status [r]
1718
1776
  # @return ["initializing", "waiting_content", "available", "error"]
1719
1777
  # the status of the slide
1720
1778
  attribute :status
1779
+
1780
+ # @!attribute thumbnail_url
1781
+ # @return [String, nil] the URL of the thumbnail of the slide
1782
+ attribute :thumbnail_url
1721
1783
  end
1722
1784
 
1723
1785
  # = The slide schedule class
@@ -79,8 +79,10 @@ module LWS::Generic
79
79
  # Sets the Faraday API object used for this class. This will used by
80
80
  # Spyke.
81
81
  #
82
- # @param api The Faraday connection that makes requests to the API
83
- # @return [Faraday] A Faraday connection that makes requests to the API
82
+ # @param [Faraday::Connection] api A Faraday connection that makes
83
+ # requests to the API
84
+ # @return [Faraday::Connection] The Faraday connection that makes requests
85
+ # to the API
84
86
  def self.use_api(api)
85
87
  self.connection = api
86
88
  self.include_root_in_json self.name.split("::").last.underscore.to_sym
@@ -107,11 +107,15 @@ module LWS
107
107
  # http_debug: true
108
108
  # json_debug: true
109
109
  #
110
+ # @param config_file [String] the path to the config file to load
111
+ # @param force_environment [Symbol, nil] the environment to enforce (if
112
+ # any)
110
113
  # @return [Boolean] whether the config file was used
111
- def load_config_file(config_file)
114
+ def load_config_file(config_file, force_environment = nil)
112
115
  return false unless File.exist? config_file
113
116
  config_data = YAML.load_file(config_file)
114
- environment = ENV["LC_LWS_ENV"] ||
117
+ environment = force_environment ||
118
+ ENV["LC_LWS_ENV"] ||
115
119
  config_data.dig("default", "environment") ||
116
120
  self.environment
117
121
  self.environment = environment.to_sym
@@ -122,20 +126,26 @@ module LWS
122
126
  raise "encountered an invalid config property \"#{key}\" " +
123
127
  "in config file #{config_file}!"
124
128
  end
129
+ configure(key, value)
130
+ end
131
+ true
132
+ end
133
+
134
+ private
125
135
 
126
- case key
127
- when "endpoints"
128
- if self.endpoints.empty?
129
- self.endpoints = value.inject({}) do |h, (k, v)|
130
- h[k.to_sym] = v
131
- h
132
- end
133
- end
134
- else
135
- self[key.to_sym] = value unless self[key.to_sym]
136
+ def configure(key, value)
137
+ case key
138
+ when "endpoints"
139
+ if self.endpoints.empty?
140
+ configure_endpoints(value)
136
141
  end
142
+ else
143
+ self[key.to_sym] ||= value
137
144
  end
138
- true
145
+ end
146
+
147
+ def configure_endpoints(endpoints)
148
+ self.endpoints = endpoints.transform_keys(&:to_sym)
139
149
  end
140
150
 
141
151
  end
@@ -13,6 +13,6 @@ module LWS
13
13
 
14
14
  # The LWS library version.
15
15
  # @note The major and minor version parts match the LWS API version!
16
- VERSION = "7.1.2".freeze
16
+ VERSION = "7.1.3".freeze
17
17
 
18
18
  end
@@ -261,6 +261,7 @@ class TestDigitalSignageLayout < MiniTest::Test
261
261
  def test_valid_associations
262
262
  # FIXME: Missing endpoint in LWS
263
263
  #assert_instance_of(Layout::Category, @layout.categories.first)
264
+ assert_instance_of(LWS::Auth::Company, @layout.company_owner)
264
265
  # FIXME: Missing parent_id field in LWS
265
266
  #assert_instance_of(Layout, @layout.parent)
266
267
  # FIXME: Missing endpoint in LWS
@@ -950,6 +951,7 @@ class TestDigitalSignageSlide < MiniTest::Test
950
951
  assert_instance_of(Channel::Group, @slide.channel_groups.first)
951
952
  assert_instance_of(LWS::Auth::Company, @slide.company)
952
953
  assert_instance_of(Layout, @slide.layout)
954
+ assert_instance_of(Slide::Schedule, @slide.schedules.first)
953
955
  end
954
956
 
955
957
  end
@@ -961,20 +963,17 @@ class TestDigitalSignageSlideSchedule < MiniTest::Test
961
963
  def setup
962
964
  @slide = Slide.find(1)
963
965
  # Slide schedules only exist as decendant objects of players
964
- # FIXME: Endpoint is missing in LWS
965
966
  @slide_schedule = @slide.schedules.first
966
967
  end
967
968
 
968
- # FIXME: Endpoint is missing in LWS
969
- #def test_valid
970
- # refute_nil(@slide_schedule)
971
- # assert_instance_of(Slide::Schedule, @slide_schedule)
972
- # refute_nil(@slide_schedule.id)
973
- #end
969
+ def test_valid
970
+ refute_nil(@slide_schedule)
971
+ assert_instance_of(Slide::Schedule, @slide_schedule)
972
+ refute_nil(@slide_schedule.id)
973
+ end
974
974
 
975
- # FIXME: Endpoint is missing in LWS
976
975
  #def test_valid_associations
977
- # assert_instance_of(Slide, @slide_schedules.slides.first)
976
+ # assert_instance_of(Slide, @slide_schedule.slides.first)
978
977
  #end
979
978
 
980
979
  end
@@ -71,7 +71,6 @@ class TestSetup < MiniTest::Test
71
71
 
72
72
  def test_load_config_files
73
73
  orig_config = LWS.config.dup
74
-
75
74
  reconfigure do |config|
76
75
  assert config.load_config_file(File.join(@test_config_dir, "empty.yml"))
77
76
  end
@@ -113,6 +112,20 @@ class TestSetup < MiniTest::Test
113
112
  assert_equal(true, LWS.config.http_debug)
114
113
  assert_equal(true, LWS.config.http_debug_headers)
115
114
  assert_equal(true, LWS.config.json_debug)
115
+
116
+ with_env("LC_LWS_ENV" => "production") do
117
+ reconfigure do |config|
118
+ assert config.load_config_file(File.join(@test_config_dir, "empty.yml"),
119
+ :development)
120
+ end
121
+ assert_equal(:development, LWS.config.environment)
122
+ end
123
+
124
+ reconfigure do |config|
125
+ assert config.load_config_file(File.join(@test_config_dir, "switch_env.yml"),
126
+ :development)
127
+ end
128
+ assert_equal(:development, LWS.config.environment)
116
129
  end
117
130
 
118
131
  end
@@ -49,14 +49,18 @@ raise "Test token not set" if ENV["LC_LWS_TEST_TOKEN"].blank?
49
49
 
50
50
  def reconfigure(options = {}, &block)
51
51
  LWS.setup do |config|
52
- config.api_token = ENV["LC_LWS_TEST_TOKEN"]
52
+ if ENV["LC_LWS_API_TOKEN"].blank?
53
+ config.api_token = ENV["LC_LWS_TEST_TOKEN"]
54
+ end
53
55
  if ENV["LC_LWS_TEST_DEBUG"].present?
54
56
  config.logger = Logger.new($stdout)
55
57
  config.http_debug = true
56
58
  config.http_debug_headers = false
57
59
  config.json_debug = true
58
60
  end
59
- config.environment = :development
61
+ if ENV["LC_LWS_ENV"].blank?
62
+ config.environment = :development
63
+ end
60
64
 
61
65
  # Override the config with the given options.
62
66
  options.each do |key, value|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lws
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.2
4
+ version: 7.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - LeftClick B.V.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-07 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday_middleware