usable 3.4.0 → 3.5.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
  SHA1:
3
- metadata.gz: eb11e2617182a394ba2fcf207926152e7cb93606
4
- data.tar.gz: 2d7c5698ddd7a8984a791c29cad205f65a0ab6ab
3
+ metadata.gz: bfe5fb1828e71f868ce8e7e5b6dd28c53ae83297
4
+ data.tar.gz: c805110e6ce80fe03dd10121a02c4ca4642f0e97
5
5
  SHA512:
6
- metadata.gz: 7d0835d8eff617914a7968af009e307804f638191f7025dc06a54bd8b89cdf205ea2c13a14ac92de4471f96e91ebfc1d8990d08df5ea78f5d33a42d1c7f05546
7
- data.tar.gz: 485649445fcbc569624de03000756b61fe972686432d14c6b67db88b3f8988afc1db0109f1e6750f56b7f6c5f68b4aafeb23873b45218dc78cbf181f4aaa905b
6
+ metadata.gz: 38054c2946e9a2a35462955f718a7884dcb62ec6a16e95e44fc17ed7b9a386c52be3fd2a7500b1e2c6603bae0f919426b0c2b4e7a15c3fa0d6f284edd9689793
7
+ data.tar.gz: 60ec033a5d2e7d080ad387e6b564735bf0f24300a413afceb8634b198a3c51e0c3ce2d5c7bc843e052878bcb275cdc1218234d694bfc8d3204dc0b92a64b7a79
data/.travis.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.10
4
3
  - 2.2.5
5
- - 2.3.1
4
+ - 2.3.3
5
+ - 2.4.0
6
6
  before_install: gem install bundler -v 1.10.5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 3.5.0 (1/18/2016)
2
+ =================
3
+
4
+ * FIX - Can marshal Usable configs
5
+ * NEW - Track extended modules and constants so they can be eagerloaded and frozen in certain environments
6
+
1
7
  3.4.0 (12/22/2016)
2
8
  ==================
3
9
 
data/lib/usable/config.rb CHANGED
@@ -8,11 +8,10 @@ module Usable
8
8
  include ConfigRegister
9
9
  include ConfigMulti
10
10
 
11
- # @todo Maybe keep a list of all attributes (lazy and regular)?
11
+ # @todo Maybe keep a list of all attributes (lazy and regular)? e.g @attributes = Set.new attributes.keys.map(&:to_s)
12
12
  def initialize(attributes = {})
13
13
  @spec = OpenStruct.new(attributes)
14
14
  @lazy_loads = Set.new
15
- # @attributes = Set.new attributes.keys.map(&:to_s)
16
15
  end
17
16
 
18
17
  def spec
@@ -37,13 +36,13 @@ module Usable
37
36
  end
38
37
 
39
38
  alias to_hash to_h
39
+ alias marshal_dump to_h
40
40
 
41
41
  def merge(other)
42
42
  to_h.merge(other)
43
43
  end
44
44
 
45
45
  def method_missing(key, *args, &block)
46
- # @attributes << key.to_s
47
46
  if block
48
47
  @lazy_loads << key
49
48
  @spec.define_singleton_method(key) { yield }
@@ -78,6 +77,10 @@ module Usable
78
77
  super
79
78
  end
80
79
 
80
+ def marshal_load(attributes = {})
81
+ initialize(attributes)
82
+ end
83
+
81
84
  private
82
85
 
83
86
  # @note Handles the case where the value may be defined with a block, in which case it's a method
@@ -0,0 +1,7 @@
1
+ class Usable::Railtie < Rails::Railtie
2
+ config.after_initialize do
3
+ if Rails.env !~ /test|development/
4
+ Usable.extended_constants.map { |const| const.usables.freeze }
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Usable
2
- VERSION = "3.4.0".freeze
2
+ VERSION = "3.5.0".freeze
3
3
  end
data/lib/usable.rb CHANGED
@@ -6,6 +6,11 @@ require 'usable/mod_extender'
6
6
  require 'usable/config'
7
7
 
8
8
  module Usable
9
+ # Keep track of extended classes and modules so we can freeze all usables on boot in production environments
10
+ def self.extended_constants
11
+ @extended_constants ||= Set.new
12
+ end
13
+
9
14
  def self.extended(base)
10
15
  if base.is_a? Class
11
16
  # Define an instance level version of +usables+
@@ -31,6 +36,7 @@ module Usable
31
36
  end
32
37
  end
33
38
  end
39
+ extended_constants << base
34
40
  end
35
41
 
36
42
  def usables
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usable
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-22 00:00:00.000000000 Z
11
+ date: 2017-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,6 +82,7 @@ files:
82
82
  - lib/usable/config_multi.rb
83
83
  - lib/usable/config_register.rb
84
84
  - lib/usable/mod_extender.rb
85
+ - lib/usable/railtie.rb
85
86
  - lib/usable/struct.rb
86
87
  - lib/usable/version.rb
87
88
  - usable.gemspec