pennylane 1.0.0 → 1.0.1

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: 1b079bfa7d777a0adb18de2cb8b02c4b5b3f7a20ef14ee3be35ccc56c4fc5714
4
- data.tar.gz: 417d611044b5329eb04040ffaab0c1e78e609b6dc5613deeeac35994aab88012
3
+ metadata.gz: d39d39c57d464e5c95acf6535e0e80508e9836fcbd8dd3afe49373283d965438
4
+ data.tar.gz: f4339e0fda690f67625aefb006f3964fdeefd8f125d9ff68ef26408cbb30caef
5
5
  SHA512:
6
- metadata.gz: 8d1e5ec1c7aacb11921d8d7490c8bfcfd626fb185a74c6199b1ac9b75e4b4cae03dc8f66be2e70effada0cc21a1d563b1aef205beca5d906bc522637d76b429c
7
- data.tar.gz: fbec4d19969a69390de3903fcb7a1e9e372fcdc4d6bb9b3f735ac09e3a31b7bbea14963e0e35d0c0815d42140385e168e21f21e764caae06d6fdbea08ebec21c
6
+ metadata.gz: 745d583286f8eeb20da9acb324ae2b7b0e2ca9611537c4aa340d674ad8c380428ee337e03c70c823940e61748520c7b5a267fa09a34493af4a6234a7ebded501
7
+ data.tar.gz: 4e671e89e28b95717eb5a800c4463896349eadf5756a1ebb11a69a645391881bb51f247960d9f6bd6e118a3386542796cf6646defaf7baafaa36a4d6152a8fc3
data/CHANGELOG.md CHANGED
@@ -1,4 +1,5 @@
1
- ## [Unreleased]
1
+ ## [1.0.1] - 2024-04-29
2
+ - Fixed gem initialization issue (resources/*.rb) from a Rails app.
2
3
 
3
4
  ## [1.0.0] - 2024-04-29
4
5
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pennylane (1.0.0)
4
+ pennylane (1.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -16,9 +16,22 @@ Install the gem and add to the application's Gemfile by executing:
16
16
  $ bundle add pennylane
17
17
 
18
18
  If bundler is not being used to manage dependencies, install the gem by executing:
19
+ ```ruby
20
+ # Add to gemfile
21
+ gem 'pennylane'
22
+ ```
19
23
 
20
- $ gem install pennylane
24
+ For Rails app :
25
+ ```ruby
26
+ # Create initializers/pennylane.rb
27
+ Pennylane.api_key = Rails.application.credentials.dig(:pennylane, :api_key)
21
28
 
29
+ # Add credentials to config/credentials.yml.enc
30
+ $ EDITOR=vim bin/rails credentials:edit
31
+
32
+ pennylane:
33
+ api_key: 'x0fd....'
34
+ ```
22
35
  ## Requirements
23
36
  Ruby 2.3+.
24
37
 
@@ -19,7 +19,7 @@ module Pennylane
19
19
  end
20
20
 
21
21
  def key_for(resp)
22
- resp.keys.find { |k| Pennylane::API_RESOURCES.keys.include?(Util.singularize(k.to_s)) } || resp.keys.find { |k| resp[k].is_a? Array }
22
+ resp.keys.find { |k| Pennylane::ObjectTypes.object_names_to_classes.keys.include?(Util.singularize(k.to_s)) } || resp.keys.find { |k| resp[k].is_a? Array }
23
23
  end
24
24
 
25
25
  end
@@ -0,0 +1,15 @@
1
+ module Pennylane
2
+ module ObjectTypes
3
+ def self.object_names_to_classes
4
+ {
5
+ ListObject.object_name => ListObject,
6
+ Category.object_name => Category,
7
+ CategoryGroup.object_name => CategoryGroup,
8
+ Customer.object_name => Customer,
9
+ CustomerInvoice.object_name => CustomerInvoice,
10
+ Product.object_name => Product,
11
+ Supplier.object_name => Supplier
12
+ }.freeze
13
+ end
14
+ end
15
+ end
@@ -85,7 +85,7 @@ module Pennylane
85
85
  end
86
86
 
87
87
  def klass_for(object)
88
- Pennylane::API_RESOURCES[singularize(object)] || Pennylane::Object
88
+ Pennylane::ObjectTypes.object_names_to_classes[singularize(object)] || Pennylane::Object
89
89
  rescue
90
90
  Pennylane::Object
91
91
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pennylane
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
data/lib/pennylane.rb CHANGED
@@ -11,8 +11,9 @@ require 'forwardable'
11
11
  require 'uri'
12
12
  require 'net/http'
13
13
 
14
- Dir["./lib/pennylane/resources/*.rb"].each {|file| require file }
14
+ Dir[File.join(__dir__, 'pennylane/resources/*.rb')].each {|file| require file }
15
15
 
16
+ require 'pennylane/object_types'
16
17
 
17
18
  module Pennylane
18
19
  class Error < StandardError; end
@@ -20,16 +21,6 @@ module Pennylane
20
21
  class ConfigurationError < Error; end
21
22
  class NotFoundError < Error; end
22
23
 
23
- API_RESOURCES = {
24
- ListObject.object_name => ListObject,
25
- Category.object_name => Category,
26
- CategoryGroup.object_name => CategoryGroup,
27
- Customer.object_name => Customer,
28
- CustomerInvoice.object_name => CustomerInvoice,
29
- Product.object_name => Product,
30
- Supplier.object_name => Supplier
31
- }.freeze
32
-
33
24
  @config = Pennylane::Configuration.new
34
25
  # So we can have a module Pennylane that can be a class as well Pennylane.api_key = '1234'
35
26
  class << self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pennylane
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephane Bounmy
@@ -87,6 +87,7 @@ files:
87
87
  - lib/pennylane/configuration.rb
88
88
  - lib/pennylane/list_object.rb
89
89
  - lib/pennylane/object.rb
90
+ - lib/pennylane/object_types.rb
90
91
  - lib/pennylane/resources/base.rb
91
92
  - lib/pennylane/resources/category.rb
92
93
  - lib/pennylane/resources/category_group.rb