magic-report 0.2.0 → 0.3.0

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: 44873b50d04637fb2399066a73450da8572fcbdece144c679d024692e436d155
4
- data.tar.gz: cc0e332d579ed96f7aa2fa511039c55b727887729e2c49481b6bb1dd00ce6ad0
3
+ metadata.gz: f213aa09ce963abf162471ccdae3a9aecbbbfce8d6aed1dfabf673eb88bebedf
4
+ data.tar.gz: cf763202fc99278741b64898a6809929d7dfac3ea08b7c25f48870e11e4729a1
5
5
  SHA512:
6
- metadata.gz: 65166e27d443bef84cd1fa581cf6da78fbc2359668190cc5c9cfc877fa1caf81274981c92f2f20da4ccdc3c1d5990ec463c08c6fd761ee912dd2f4716b90faa5
7
- data.tar.gz: 37fb6590fa41adb3d48396ecaad42a9ae57893c64a109cf93281a7e64cbed5ea87d17b1494d28670a59dad2252afdf64bbf2d7ba444c3d3e3bc7c0f867b9e5a9
6
+ metadata.gz: aea3c759c88f5381ce9df62ca88ef8242d7307a16d06f1340578f2856896f087f4dfc5d31e7aed08490910301b89450fb704d3a0cdc05802c7fb16109d5047bd
7
+ data.tar.gz: 0dac70e8c03ec49759b1f1f462b787c304d8a33acdc1885213cc52a0e9d2f646592caf4c69bd692ae371f88bc7f4e54301bcdc256b05aed5abf927ed28f6e557
@@ -67,8 +67,10 @@ module MagicReport
67
67
 
68
68
  klass = ::MagicReport::Utils.derive_class(opts, &block)
69
69
 
70
+ opts[:name] = ::MagicReport::Utils.underscore(opts[:name].to_s) if opts[:name]
71
+
70
72
  if (prefix = opts[:prefix])
71
- opts[:prefix] = new.instance_exec(&prefix)
73
+ opts[:prefix] = new(name: ::MagicReport::Utils.underscore(name.to_s)).instance_exec(&prefix)
72
74
  end
73
75
 
74
76
  @has_one << Configuration::HasOne.new(klass: klass, opts: opts, key: coerced_attribute)
@@ -81,8 +83,10 @@ module MagicReport
81
83
 
82
84
  klass = ::MagicReport::Utils.derive_class(opts, &block)
83
85
 
86
+ opts[:name] = ::MagicReport::Utils.underscore(opts[:name].to_s) if opts[:name]
87
+
84
88
  if (prefix = opts[:prefix])
85
- opts[:prefix] = new.instance_exec(&prefix)
89
+ opts[:prefix] = new(name: ::MagicReport::Utils.underscore(name.to_s)).instance_exec(&prefix)
86
90
  end
87
91
 
88
92
  @has_many << Configuration::HasMany.new(klass: klass, opts: opts, key: coerced_attribute)
@@ -3,6 +3,8 @@
3
3
  module MagicReport
4
4
  module Utils
5
5
  def underscore(klass)
6
+ return "ded" unless klass
7
+
6
8
  klass.gsub(/::/, "/")
7
9
  .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
8
10
  .gsub(/([a-z\d])([A-Z])/, '\1_\2')
@@ -15,6 +17,7 @@ module MagicReport
15
17
  raise "name option must be provided" unless opts[:name]
16
18
 
17
19
  cloned_klass = ::MagicReport::Report.clone
20
+ cloned_klass.define_singleton_method(:name) { opts[:name] }
18
21
  cloned_klass.class_eval(&block)
19
22
  cloned_klass
20
23
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MagicReport
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magic-report
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Pankratev