dun 0.0.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 +7 -0
- data/lib/dun.rb +56 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: be96d64a400bd0569f989004e3303656ec7ed4b1
|
4
|
+
data.tar.gz: eccc63f5429e716e912954106ee1d54c18240057
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b4c87e517a12b827aa9a3723ead7fb89a1e7a03d4fa7d81418ef4aa17ebfcd7402de052d736d52c30855c9d207113033764e4a27af5d6bf495e5f251f387bcf8
|
7
|
+
data.tar.gz: d3044bfdbdfc7951f42a824f0d26c67130b0b18cfa2ebe3a20e879c1b2dfa0588592ced3b16fc4229a8713b0b7ea3e1ab8858529aa94df9d7acf001d9a589fde
|
data/lib/dun.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
module Dun
|
2
|
+
class Activity
|
3
|
+
attr_reader :data
|
4
|
+
|
5
|
+
def self.inherited(subclass)
|
6
|
+
return if Kernel.method_defined? subclass.name
|
7
|
+
|
8
|
+
Kernel.class_eval %Q{
|
9
|
+
def #{subclass.name}(data = {}, &p)
|
10
|
+
#{subclass.name}.new(data).call(&p)
|
11
|
+
end
|
12
|
+
}
|
13
|
+
|
14
|
+
rescue SyntaxError, TypeError
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.<<(data = {})
|
19
|
+
new(data).call
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.data_reader *attrs
|
23
|
+
|
24
|
+
attrs.each do |attr|
|
25
|
+
define_method attr do
|
26
|
+
instance_variable_get("@#{attr}") || \
|
27
|
+
instance_variable_set("@#{attr}", data[attr.to_sym])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.set name, value
|
34
|
+
define_method(name) { value }
|
35
|
+
end
|
36
|
+
|
37
|
+
def initialize(data)
|
38
|
+
@data = data
|
39
|
+
end
|
40
|
+
|
41
|
+
def call
|
42
|
+
'dun'
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def get_or_set(name)
|
48
|
+
value = instance_variable_get("@#{name}")
|
49
|
+
return value if value
|
50
|
+
value = yield
|
51
|
+
instance_variable_set("@#{name}", value)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dun
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kayak Jiang
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: 帮助程序员以面向过程的方式解决问题
|
14
|
+
email: kayak.jiang@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/dun.rb
|
20
|
+
homepage: https://github.com/baya/dun
|
21
|
+
licenses: []
|
22
|
+
metadata: {}
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
requirements: []
|
38
|
+
rubyforge_project:
|
39
|
+
rubygems_version: 2.0.3
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: 钝
|
43
|
+
test_files: []
|