dun 0.2.1 → 0.2.2

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.
Files changed (3) hide show
  1. checksums.yaml +15 -0
  2. data/lib/dun.rb +19 -15
  3. metadata +5 -7
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTcwYjUyZDRiYmFlYmQ5MTEwMmU1NTJjY2ZlMzlmOWU5YTNmYTU2ZQ==
5
+ data.tar.gz: !binary |-
6
+ YWZjOWRmNTBlM2FmZWRiZGIwMWI1YWI5Y2M4ZjU4NGJiMTVhMDI5ZQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZDFjNTIzNDg5ZGU3YzI3OTU5YTAzMjQyNTg5NWZhOWMxZGNjOWI4NmE0YTI1
10
+ YWExYWM1NDA2ZTk0NWY3NjdkMTNjNjEwN2E2ZDkyZjgyMGYxZDMzNGIxNWU0
11
+ NjI0MTYwZjdmZThlMTZjYzlhYjdiODZjYWEzNDMxMWI4OThkYjk=
12
+ data.tar.gz: !binary |-
13
+ YzZiYzRjZjIyNGQ1ZDMzMjg1NWZhM2Y3YmJjOWEwMzY1ZjdlNjQ5ZjZkMzI4
14
+ ZDBmMTI5MWIxZmY3YjM1MmYzMDIyNzM1MGM4MjMzZThhNGEwMWIwNzk3ZmQz
15
+ OGViZDdlYmJmMWExODE1NTJiZWE5Nzk0ODVmMTRhMDFhZTlhMjQ=
data/lib/dun.rb CHANGED
@@ -4,7 +4,7 @@ module Dun
4
4
 
5
5
  def self.inherited subclass
6
6
  return if Kernel.method_defined? subclass.name
7
-
7
+
8
8
  Kernel.class_eval %Q{
9
9
  def #{subclass.name} data = {}, &p
10
10
  #{subclass.name}.new(data).call &p
@@ -12,7 +12,10 @@ module Dun
12
12
  }
13
13
 
14
14
  rescue SyntaxError, TypeError
15
-
15
+
16
+ end
17
+
18
+ class MissingPatchedMethodError < StandardError
16
19
  end
17
20
 
18
21
  class << self
@@ -22,34 +25,35 @@ module Dun
22
25
  end
23
26
 
24
27
  def data_reader *attrs
25
-
28
+
26
29
  attrs.each do |attr|
27
30
  define_method attr do
28
31
  instance_variable_get("@#{attr}") ||\
29
32
  instance_variable_set("@#{attr}", data[attr.to_sym] || data[attr.to_s])
30
33
  end
31
34
  end
32
-
33
- end
34
35
 
35
- def default attr, default_value
36
- orig_attr = "#{attr}_without_default"
37
- alias_method orig_attr, attr
38
- define_method attr do
39
- send(orig_attr) || default_value
40
- end
41
36
  end
42
37
 
43
38
  def set attr, value
44
39
  define_method(attr) {value}
45
40
  end
46
-
41
+
42
+ def patch *method_names
43
+ method_names.each do |m|
44
+ define_method m do
45
+ msg = "Need implementing the patched method :#{m} in the subclass #{self.class}"
46
+ raise MissingPatchedMethodError.new msg
47
+ end
48
+ end
49
+ end
50
+
47
51
  end
48
-
52
+
49
53
  def initialize data
50
54
  @data = data
51
55
  end
52
-
56
+
53
57
  def call
54
58
  return self
55
59
  end
@@ -70,5 +74,5 @@ module Dun
70
74
  end
71
75
 
72
76
  Activity = Land
73
-
77
+
74
78
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 0.2.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Kayak Jiang
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-12-11 00:00:00.000000000 Z
11
+ date: 2014-09-03 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Dun help ruby programers focus on the problem domain directly when programing.
15
14
  email: kayak.jiang@gmail.com
@@ -21,26 +20,25 @@ files:
21
20
  homepage: https://github.com/baya/dun
22
21
  licenses:
23
22
  - MIT
23
+ metadata: {}
24
24
  post_install_message:
25
25
  rdoc_options: []
26
26
  require_paths:
27
27
  - lib
28
28
  required_ruby_version: !ruby/object:Gem::Requirement
29
- none: false
30
29
  requirements:
31
30
  - - ! '>='
32
31
  - !ruby/object:Gem::Version
33
32
  version: '0'
34
33
  required_rubygems_version: !ruby/object:Gem::Requirement
35
- none: false
36
34
  requirements:
37
35
  - - ! '>='
38
36
  - !ruby/object:Gem::Version
39
37
  version: '0'
40
38
  requirements: []
41
39
  rubyforge_project:
42
- rubygems_version: 1.8.25
40
+ rubygems_version: 2.2.2
43
41
  signing_key:
44
- specification_version: 3
42
+ specification_version: 4
45
43
  summary: Dun help ruby programers focus on the problem domain directly when programing.
46
44
  test_files: []