just_include 1.0.0 → 2.0.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 +4 -4
- data/.travis.yml +7 -0
- data/README.md +12 -4
- data/just_include.gemspec +2 -2
- data/lib/just_include/just_include.rb +8 -9
- data/lib/just_include/version.rb +1 -1
- data/specs/just_include_spec.rb +23 -31
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61d69e9af886721cad6812ce8f012792c417b5f1
|
4
|
+
data.tar.gz: 567084f5a33186d17a9163c23aab5eced220430a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ac546470eae25e72ad37b10b4b993fff90c852fd34e884f330323aa19df3cdfee5d3796294a8407b72d678732e7a927117f682c6f8bd7587f351412eeb78709
|
7
|
+
data.tar.gz: 41c7639b249330394d9a1673764740d64463cb2a893f94d3646750e92beba32f60b74cab2f0c715c8f761b657a48c259139e80602109753690fbb0d00862d12d
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
JustInclude
|
1
|
+
JustInclude [](https://travis-ci.org/kubenstein/just_include)
|
2
2
|
=============
|
3
3
|
|
4
4
|
JustInclude changes the way you define methods in included modules. Now you write stuff in your module as you would ctrl+c ctrl+v from class. No more ClassMethods nor Instance Methods. See Usage section for better understanding.
|
@@ -33,8 +33,9 @@ Usage
|
|
33
33
|
Create a module with functionality you want to be part of other class
|
34
34
|
|
35
35
|
module FunctionalityA
|
36
|
-
|
37
|
-
|
36
|
+
# use Simply or JustInclude
|
37
|
+
# (include JustInclude)::this_code do
|
38
|
+
(include Simply)::this_code do
|
38
39
|
|
39
40
|
extend FriendlyId
|
40
41
|
|
@@ -50,11 +51,18 @@ Create a module with functionality you want to be part of other class
|
|
50
51
|
end
|
51
52
|
|
52
53
|
end
|
53
|
-
|
54
|
+
end
|
54
55
|
|
55
56
|
Then simply include this module inside other class
|
56
57
|
|
57
58
|
class OtherClass < ActiveRecord::Base
|
58
59
|
include FunctionalityA
|
59
60
|
end
|
61
|
+
|
62
|
+
|
63
|
+
Old Syntax
|
64
|
+
-----
|
65
|
+
If you prefer old, less fancy syntax, check out [version v.1.0.0](https://github.com/kubenstein/just_include/tree/v1.0.0).
|
66
|
+
|
67
|
+
|
60
68
|
|
data/just_include.gemspec
CHANGED
@@ -5,8 +5,8 @@ require 'just_include/version'
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'just_include'
|
7
7
|
s.version = JustInclude::VERSION
|
8
|
-
s.authors = ['
|
9
|
-
s.email = ['
|
8
|
+
s.authors = ['Jakub Niewczas']
|
9
|
+
s.email = ['niewczas.jakub@gmail.com']
|
10
10
|
s.homepage = 'https://github.com/kubenstein/just_include'
|
11
11
|
s.summary = %q{Simplify including functionality from module to class}
|
12
12
|
s.description = %q{With JustInclude you can include all kind of things from module to class, such as: methods, class methods, callbacks, relation definitions, act_as_*, constans, extends/includes, etc...}
|
@@ -2,21 +2,20 @@
|
|
2
2
|
# see homepage for more info:
|
3
3
|
# https://github.com/kubenstein/just_include
|
4
4
|
|
5
|
+
|
5
6
|
module JustInclude
|
6
7
|
|
7
|
-
def self.included(
|
8
|
-
|
9
|
-
end
|
8
|
+
def self.included(including_module)
|
9
|
+
class << including_module; attr_accessor :just_include_block; end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
class << self; attr_accessor :block; end
|
14
|
-
self.block = block
|
11
|
+
def including_module.included(including_class)
|
12
|
+
including_class.class_eval(&(self.just_include_block))
|
15
13
|
end
|
16
14
|
|
17
|
-
def
|
18
|
-
|
15
|
+
def including_module.this_code(&block)
|
16
|
+
self.just_include_block = block
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
22
20
|
end
|
21
|
+
Simply = JustInclude
|
data/lib/just_include/version.rb
CHANGED
data/specs/just_include_spec.rb
CHANGED
@@ -5,41 +5,13 @@ describe JustInclude do
|
|
5
5
|
|
6
6
|
let(:empty_module) { Module.new }
|
7
7
|
let(:empty_class) { Class.new }
|
8
|
-
let(:functionality_module)
|
8
|
+
let(:functionality_module) { Functionality }
|
9
9
|
|
10
10
|
|
11
|
-
module OtherModule
|
12
|
-
def class_method_from_other_module
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
Module.new do
|
17
|
-
include JustInclude
|
18
|
-
just_include do
|
19
|
-
|
20
|
-
extend OtherModule
|
21
|
-
|
22
|
-
def self.class_method
|
23
|
-
end
|
24
|
-
|
25
|
-
def instance_method
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'allows class to include module using just_include DSL' do
|
34
|
-
expect(empty_module).not_to respond_to(:just_include)
|
35
|
-
empty_module.send :include, JustInclude
|
36
|
-
expect(empty_module).to respond_to(:just_include)
|
37
|
-
end
|
38
|
-
|
39
11
|
it 'adds class methods to class' do
|
40
|
-
expect(empty_class).not_to respond_to(:
|
12
|
+
expect(empty_class.new).not_to respond_to(:instance_method)
|
41
13
|
empty_class.send :include, functionality_module
|
42
|
-
expect(empty_class).to respond_to(:
|
14
|
+
expect(empty_class.new).to respond_to(:instance_method)
|
43
15
|
end
|
44
16
|
|
45
17
|
it 'adds instance methods to class' do
|
@@ -54,4 +26,24 @@ describe JustInclude do
|
|
54
26
|
expect(empty_class).to respond_to(:class_method_from_other_module)
|
55
27
|
end
|
56
28
|
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
module OtherModule
|
33
|
+
def class_method_from_other_module
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module Functionality
|
38
|
+
(include Simply)::this_code do
|
39
|
+
|
40
|
+
extend OtherModule
|
41
|
+
|
42
|
+
def self.class_method
|
43
|
+
end
|
44
|
+
|
45
|
+
def instance_method
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
57
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: just_include
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Jakub Niewczas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -28,12 +28,13 @@ description: 'With JustInclude you can include all kind of things from module to
|
|
28
28
|
such as: methods, class methods, callbacks, relation definitions, act_as_*, constans,
|
29
29
|
extends/includes, etc...'
|
30
30
|
email:
|
31
|
-
-
|
31
|
+
- niewczas.jakub@gmail.com
|
32
32
|
executables: []
|
33
33
|
extensions: []
|
34
34
|
extra_rdoc_files: []
|
35
35
|
files:
|
36
36
|
- .gitignore
|
37
|
+
- .travis.yml
|
37
38
|
- Gemfile
|
38
39
|
- README.md
|
39
40
|
- Rakefile
|
@@ -63,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
64
|
version: '0'
|
64
65
|
requirements: []
|
65
66
|
rubyforge_project: just_include
|
66
|
-
rubygems_version: 2.
|
67
|
+
rubygems_version: 2.4.6
|
67
68
|
signing_key:
|
68
69
|
specification_version: 4
|
69
70
|
summary: Simplify including functionality from module to class
|