usable 1.1.0 → 1.1.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
  SHA1:
3
- metadata.gz: 4838af9eb7ede803ba0bb91bcdde9f4500db8bf9
4
- data.tar.gz: 68fb23ea8a2e2ad941f420aca9f797d7cba37e4c
3
+ metadata.gz: 066825f3c1df23a18aed5177540f36a57e163251
4
+ data.tar.gz: 1d298ec0d9ce23ab4c6850d43cbdb04cd832e591
5
5
  SHA512:
6
- metadata.gz: da020287fc46e438e2c1dfad79eb90ae4e9aca2b8dcfe0c01bc01d1be91f4f661b1d88237c4765cb487d2a316e0f74350eeb535e93ca107bb21a6539127be752
7
- data.tar.gz: 6d68fcda221aec13e6933e90612c344ec7a410b4bdeac1e59b8498d916734e2a9e55acd310566e8a4c36c66725b0205719b6e21a0fb84f856b642ac9c41de2fd
6
+ metadata.gz: 4056167e5a41c520e054f9c0e66ddee45bf3e336b5fd17b8ab8a29ff80a3a33cd9ff6eb9d79614a37632a184798301513f9b209ed22421741ba0e771374ee91e
7
+ data.tar.gz: 62438f10155e987c3e1a995ac9ccf9d42d0b7905231ccca4372dc072e26e8d51cfb038bc5066ccdd1c482b5d20255ffc194a473b9ba534ccfeddb2e0a6e6fd02
@@ -5,8 +5,13 @@ module Usable
5
5
 
6
6
  def initialize(mod, config = OpenStruct.new)
7
7
  @mod = mod
8
- @name = mod.name
9
- @copy = has_spec? ? mod.const_get(:UsableSpec).dup : mod.dup
8
+ if has_spec?
9
+ @copy = mod.const_get(:UsableSpec).dup
10
+ @name = "#{mod.name}UsableSpec"
11
+ else
12
+ @copy = mod.dup
13
+ @name = mod.name
14
+ end
10
15
  @config = config
11
16
  end
12
17
 
@@ -1,3 +1,3 @@
1
1
  module Usable
2
- VERSION = "1.1.0".freeze
2
+ VERSION = "1.1.1".freeze
3
3
  end
data/lib/usable.rb CHANGED
@@ -39,7 +39,7 @@ module Usable
39
39
  # @description Directly include a module whose methods you want made available in +usable_config.available_methods+
40
40
  # Gives the module a name when including so that it shows up properly in the list of ancestors
41
41
  def usable!(mod)
42
- mod_name = mod.name.nil? ? "UsableMod#{Time.now.strftime('%s')}" : mod.name.split('::').last
42
+ mod_name = mod.name ? mod.name.split('::').last : "UsableMod#{Time.now.strftime('%s')}"
43
43
  const_name = "#{mod_name}Used"
44
44
  mod = mod.call if mod.respond_to? :call
45
45
  remove_const const_name if const_defined? const_name
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley
@@ -99,7 +99,6 @@ files:
99
99
  - lib/usable.rb
100
100
  - lib/usable/config.rb
101
101
  - lib/usable/mod_extender.rb
102
- - lib/usable/scoped.rb
103
102
  - lib/usable/version.rb
104
103
  - usable.gemspec
105
104
  homepage: https://github.com/ridiculous/usable
data/lib/usable/scoped.rb DELETED
@@ -1,58 +0,0 @@
1
- # @note UNTESTED and not included by default
2
- module Usable
3
- class Scoped
4
- module Configurable
5
- def configs
6
- @configs ||= Hash.new do |me, key|
7
- me[key] = Usable::Config.new
8
- end
9
- end
10
- end
11
-
12
- def self.extended(base)
13
- base.extend Configurable
14
- end
15
-
16
- def usable(mod, options = {})
17
- send :include, mod
18
- if block_given?
19
- yield configs[mod]
20
- else
21
- options.each { |k, v| configs[mod].public_send "#{k}=", v }
22
- end
23
- end
24
- end
25
- end
26
-
27
- # but here's a example of how to use it
28
- =begin
29
- module Versionable
30
- def versions
31
- config = self.class.configs[Versionable]
32
- "Saving #{config.max_versions} versions to #{config.table_name}"
33
- end
34
- end
35
- module Notable
36
- def notes
37
- config = self.class.configs[Notable]
38
- "Saving #{config.max_versions} notes to #{config.table_name}"
39
- end
40
- end
41
- class Model
42
- extend Usable::Scoped
43
-
44
- # with options hash
45
- usable Versionable, table_name: 'custom_versions'
46
- # or with block
47
- usable Versionable do |config|
48
- config.max_versions = 10
49
- end
50
- usable Notable do |config|
51
- config.max_versions = 20
52
- config.table_name = 'custom_notes'
53
- end
54
- end
55
- Model.config.table_name #=> 'custom_versions'
56
- Model.new.versions #=> "Saving 10 versions to custom_versions"
57
- Model.new.notes #=> "Saving 20 notes to custom_notes"
58
- =end