usable 1.2.0 → 1.2.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: 8e995dd364713419052b4643dcc4c3fd32ad3f65
4
- data.tar.gz: 133be5883cae3533d8bbd483f63afa53aa950b62
3
+ metadata.gz: 0e971571c1349c6977b3e0d8050536a2d1d75f76
4
+ data.tar.gz: cc1dcf9e4678b7ae565e3a4e8bcb111b5253b853
5
5
  SHA512:
6
- metadata.gz: fa11820e33b0cf6ffdf9eeb83772dd70de4794296e7ca85039e96885d57cdf21edaef12ac7271b906ca7dba666eb2ad0ee531d11fa8ac8e86ed1d12de6d4a70a
7
- data.tar.gz: d5c339c6300345698e10b7cac58a827f06caa55e1f683691520de0785738fdba9c592b766a2ed361843b575ee87c734b74ff2729f808ff8af16e3ef6e8b5b499
6
+ metadata.gz: c2c23c4aefe50a4cec3a8ee7232ecaf7f84f5f1d71a5f1f33fe7212cb08581c4301ebd6143fa3ccaa839691c0f2ce171d88d39af9bb6f0ff035733c07d6d3bec
7
+ data.tar.gz: 5cce2ae60678d9ce8cd1ac1230d84c27d53ca77338cedc31cd5ab3fbb676d0bb840cf1ea8e7cff3edaa1b983172d319655292d7a76091cc3fda2661c9e6179b3
data/.travis.yml CHANGED
@@ -1,4 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.1
4
- before_install: gem install bundler -v 1.10.4
3
+ - 2.0.0
4
+ - 2.1.0
5
+ - 2.1.5
6
+ - 2.2.0
7
+ - 2.2.2
8
+ - 2.2.3
9
+ - 2.3.0
10
+ before_install: gem install bundler -v 1.10.5
data/Gemfile CHANGED
@@ -3,5 +3,8 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in usable.gemspec
4
4
  gemspec
5
5
 
6
- gem 'object_tracker'
7
- gem 'byebug'
6
+ if RUBY_VERSION >= '2.0'
7
+ # gem 'object_tracker'
8
+ gem 'byebug'
9
+ end
10
+
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Usable [![Gem Version](https://badge.fury.io/rb/usable.svg)](http://badge.fury.io/rb/usable)
1
+ # Usable [![Gem Version](https://badge.fury.io/rb/usable.svg)](http://badge.fury.io/rb/usable) [![Build Status](https://travis-ci.org/ridiculous/usable.svg)](https://travis-ci.org/ridiculous/usable) [![Code Climate](https://codeclimate.com/github/ridiculous/usable/badges/gpa.svg)](https://codeclimate.com/github/ridiculous/usable)
2
2
 
3
3
  A simple way to mount and configure your modules. Usable gives you control over which methods are included, and a simple
4
4
  interface to help you call dynamic methods with confidence.
@@ -31,13 +31,13 @@ model = Model.new
31
31
  model.save_version # => "Saving up to 10 versions to custom_versions"
32
32
  model.destroy_version # => NoMethodError: undefined method `destroy_version' for #<Model:...
33
33
  ```
34
- You'll notice that `#save_versions` is now included on `Model`, but `#destroy_version` isn't defined.
34
+ `Model` now has a `#save_versions` method but no `#destroy_version` method.
35
35
 
36
36
  ## Confidently calling methods
37
37
 
38
- We should all be writing [confident code](http://www.confidentruby.com/). That's why it is encouraged
39
- to reference methods through the `usable_method` class level function. Methods passed in with the `:only` option
40
- will always return `nil` when called.
38
+ We should all be writing [confident code](http://www.confidentruby.com/), which is why you might want to call configurable
39
+ methods through the `usable_method` class level function. Methods passed in with the `:only` option
40
+ will _always_ return `nil` when called. Thus, the confidence.
41
41
 
42
42
  Here's the same example as above, rewritten to call methods through the Usable interface:
43
43
 
@@ -46,11 +46,11 @@ Model.usable_method(model, :save_version).call # => "Saving up to 10 versions
46
46
  Model.usable_method(model, :destroy_version).call # => nil
47
47
  ```
48
48
 
49
- ## Separate included module from configurable methods
49
+ ## Separate the _included_ module from the _configurable_ methods
50
50
 
51
- Sometimes you want to define methods on the module but not have them be configurable. Define a module within the usable
52
- module namespace and name it `UsableSpec`, and `Usable` will use that module to configure the available methods. Any naming
53
- conflicts will be resolved by giving precedence to the parent module.
51
+ Sometimes you want to define methods on a module and have them always be included. To do this, define a module named
52
+ `UsableSpec` in the scope of the module you are mounting. `Usable` will detect this and use he "spec" module to configure
53
+ the available methods. Any naming conflicts will be resolved by giving precedence to the parent module.
54
54
 
55
55
  For example:
56
56
 
@@ -64,7 +64,7 @@ module Mixin
64
64
  "always here"
65
65
  end
66
66
 
67
- # @description Usable will apply the :only to just the methods defined by this module
67
+ # @description Usable will apply the :only option to just the methods defined by this module
68
68
  module UsableSpec
69
69
  def from_spec
70
70
  "can be excluded"
@@ -87,7 +87,7 @@ Example.new.name # => "defined by Mixin"
87
87
  Example.ancestors # => [Example, Mixin, Example::MixinUsableSpecUsed, Object, Kernel, BasicObject] (ruby -v 2.3.0)
88
88
  ```
89
89
 
90
- Noticed that Usable assigns the modified module to a constant with the same name as the given module, but with "Used" appended.
90
+ Notice that Usable assigns the modified module to a constant with the same name as the given module, but with "Used" appended.
91
91
  The main module and the spec were both included, but `Mixin` was not modified, so it didn't need a new name.
92
92
 
93
93
  ## Installation
data/Rakefile CHANGED
@@ -1,6 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
2
  require 'rspec/core/rake_task'
3
- require 'rspec/scaffold'
3
+ begin
4
+ require 'rspec/scaffold'
5
+ rescue LoadError
6
+ nil
7
+ end
4
8
 
5
9
  RSpec::Core::RakeTask.new(:spec)
6
10
  task default: :spec
@@ -1,3 +1,3 @@
1
1
  module Usable
2
- VERSION = "1.2.0".freeze
2
+ VERSION = "1.2.1".freeze
3
3
  end
data/lib/usable.rb CHANGED
@@ -1,12 +1,11 @@
1
- require "ostruct"
2
- require "delegate"
3
- require "usable/version"
1
+ require 'ostruct'
2
+ require 'delegate'
3
+ require 'usable/version'
4
+ require 'usable/mod_extender'
5
+ require 'usable/config'
4
6
 
5
7
  module Usable
6
8
 
7
- autoload :ModExtender, 'usable/mod_extender'
8
- autoload :Config, 'usable/config'
9
-
10
9
  def usable_config
11
10
  @usable_config ||= Config.new
12
11
  end
@@ -42,7 +41,7 @@ module Usable
42
41
  mod_name = mod.name ? mod.name.split('::').last : "UsableMod#{Time.now.strftime('%s')}"
43
42
  const_name = "#{mod_name}Used"
44
43
  mod = mod.call if mod.respond_to? :call
45
- remove_const const_name if const_defined? const_name
44
+ remove_const const_name if const_defined? const_name, false
46
45
  const_set const_name, mod
47
46
  usable_config.modules << mod
48
47
  send :include, mod
data/usable.gemspec CHANGED
@@ -19,8 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
+ spec.required_ruby_version = '>= 2.0.0'
23
+
22
24
  spec.add_development_dependency 'bundler', '~> 1.10'
23
25
  spec.add_development_dependency 'rake', '~> 10.0'
24
26
  spec.add_development_dependency 'rspec', '>= 3.2', '< 4'
25
- spec.add_development_dependency 'rspec-scaffold', '>= 1.0', '< 2'
27
+ # spec.add_development_dependency 'rspec-scaffold', '>= 1.0', '< 2'
26
28
  end
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.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley
@@ -58,26 +58,6 @@ dependencies:
58
58
  - - "<"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '4'
61
- - !ruby/object:Gem::Dependency
62
- name: rspec-scaffold
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '1.0'
68
- - - "<"
69
- - !ruby/object:Gem::Version
70
- version: '2'
71
- type: :development
72
- prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: '1.0'
78
- - - "<"
79
- - !ruby/object:Gem::Version
80
- version: '2'
81
61
  description: A simple way to mount and configure your modules. Usable gives you control
82
62
  over which methods are included.
83
63
  email:
@@ -113,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
93
  requirements:
114
94
  - - ">="
115
95
  - !ruby/object:Gem::Version
116
- version: '0'
96
+ version: 2.0.0
117
97
  required_rubygems_version: !ruby/object:Gem::Requirement
118
98
  requirements:
119
99
  - - ">="