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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af16d57720d83ee0b395072959c952c8a5d8dd72
4
- data.tar.gz: 69460cfa156ab923d8e9ea2bde6535ed25d25aae
3
+ metadata.gz: 61d69e9af886721cad6812ce8f012792c417b5f1
4
+ data.tar.gz: 567084f5a33186d17a9163c23aab5eced220430a
5
5
  SHA512:
6
- metadata.gz: cfb037fd5da89d7c463feefccafc4b240cb4f9316eb17f48df85f14efd0b70ad29abab496fffd2bcd4c1286e9dfed237fb1e1cca95e7b1057f6c38696719ad4c
7
- data.tar.gz: 1d589cb571d046765cf004c3d3730c91bc5a88a6fc3443147193eed51f5168c43695f5e93744b104a9a6a2e5aace2463bfed98b4c35cf01852d010fe44c0c456
6
+ metadata.gz: 9ac546470eae25e72ad37b10b4b993fff90c852fd34e884f330323aa19df3cdfee5d3796294a8407b72d678732e7a927117f682c6f8bd7587f351412eeb78709
7
+ data.tar.gz: 41c7639b249330394d9a1673764740d64463cb2a893f94d3646750e92beba32f60b74cab2f0c715c8f761b657a48c259139e80602109753690fbb0d00862d12d
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - ruby-head
6
+ script:
7
+ - bundle exec rspec specs/
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- JustInclude
1
+ JustInclude [![Build Status](https://travis-ci.org/kubenstein/just_include.svg)](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
- include JustInclude
37
- just_include do
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
- end
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 = ['kubenstein']
9
- s.email = ['kubenstein@gmail.com']
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(included_module)
8
- included_module.extend(IncludedModuleClassMethods)
9
- end
8
+ def self.included(including_module)
9
+ class << including_module; attr_accessor :just_include_block; end
10
10
 
11
- module IncludedModuleClassMethods
12
- def just_include(&block)
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 included(including_class)
18
- including_class.class_eval(&self.block)
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
@@ -1,3 +1,3 @@
1
1
  module JustInclude
2
- VERSION = '1.0.0'
2
+ VERSION = '2.0.0'
3
3
  end
@@ -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) do
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(:class_method)
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(:class_method)
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: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - kubenstein
7
+ - Jakub Niewczas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-26 00:00:00.000000000 Z
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
- - kubenstein@gmail.com
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.2.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