favt 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/favt +12 -4
- data/lib/favt/render.rb +68 -25
- data/lib/favt/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18aa947268570843ba11da2a4639134a7c33f0e1
|
4
|
+
data.tar.gz: 4c5834327b8b39330300e330061735ba2d9dae53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 140e66aab7a0a02aaad86daec01b9eda0950f612bb29bdd940b09a9290b8de3cdf67320709b353d02e995dd7ae33ca24c517cdccfe193f3d70a18e922dcb65a7
|
7
|
+
data.tar.gz: 08dee70ade6447ed1568ea07c3e46c944a71b78092b9fbfe4183c3f9947aeb7017f4bede9b589dd26b828fef52edbfb1660c73ed0bee6bd76d142c6c0c93c902
|
data/bin/favt
CHANGED
@@ -78,10 +78,18 @@ client:
|
|
78
78
|
access_token_secret: "Your Access Token Secret"
|
79
79
|
|
80
80
|
custom_render:
|
81
|
-
users:
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
users:
|
82
|
+
template: "■"
|
83
|
+
color: "red"
|
84
|
+
screen_name:
|
85
|
+
template: "#\{post.user.screen_name}\n"
|
86
|
+
color: "green"
|
87
|
+
post_text:
|
88
|
+
template: "#\{post.text}"
|
89
|
+
color: "white"
|
90
|
+
post_url:
|
91
|
+
template: "#\{post.url}"
|
92
|
+
color: "blue"
|
85
93
|
|
86
94
|
users:
|
87
95
|
- "esehara"
|
data/lib/favt/render.rb
CHANGED
@@ -15,63 +15,106 @@ module Render
|
|
15
15
|
|
16
16
|
def repack
|
17
17
|
post = @favorite["post"]
|
18
|
-
|
19
|
-
|
20
|
-
@render[:users]
|
21
|
-
|
18
|
+
@render = @origin_render
|
19
|
+
|
20
|
+
@render[:users][:template] =
|
21
|
+
@origin_render[:users][:template] * @favorite["users"]
|
22
|
+
@render[:screen_name][:template] =
|
23
|
+
@origin_render[:screen_name][:template]
|
22
24
|
.sub('#{post.user.screen_name}', post.user.screen_name)
|
23
|
-
@render[:post_text]
|
25
|
+
@render[:post_text][:template] =
|
26
|
+
@origin_render[:post_text][:template]
|
24
27
|
.sub('#{post.text}', post.text)
|
25
|
-
@render[:post_url]
|
28
|
+
@render[:post_url][:template] =
|
29
|
+
@origin_render[:post_url][:template]
|
26
30
|
.sub('#{post.url}', post.url.to_s)
|
27
31
|
end
|
28
32
|
|
29
33
|
def init_custom_render
|
30
|
-
custom_render = @config["custom_render"]
|
34
|
+
@custom_render = @config["custom_render"]
|
31
35
|
|
32
36
|
# First Initialize Values
|
37
|
+
users_dict = {
|
38
|
+
template: '■',
|
39
|
+
color: :red
|
40
|
+
}
|
41
|
+
|
42
|
+
screen_name_dict = {
|
43
|
+
template: '[#{post.user.screen_name}]\n',
|
44
|
+
color: :green
|
45
|
+
}
|
33
46
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
47
|
+
post_text_dict = {
|
48
|
+
template: '#{post.text}\n',
|
49
|
+
color: :white
|
50
|
+
}
|
38
51
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
52
|
+
post_url_dict = {
|
53
|
+
template: '#{post.url}\n',
|
54
|
+
color: :blue
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
def build_render_dict(key, defalut_dict)
|
59
|
+
if !@custom_render[key]
|
60
|
+
defalut_dict
|
61
|
+
else
|
62
|
+
pre_dict = {
|
63
|
+
template: @custom_render[key]["template"] || defalut_dict[:template],
|
64
|
+
color: @custom_render[key]["color"] || defalut_dict[:color]
|
65
|
+
}
|
66
|
+
pre_dict[:color] = pre_dict[:color].to_sym
|
67
|
+
return pre_dict
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
if @custom_render
|
72
|
+
users_dict = build_render_dict "users", users_dict
|
73
|
+
screen_name_dict = build_render_dict "screen_name", screen_name_dict
|
74
|
+
post_text_dict = build_render_dict "post_text", post_text_dict
|
75
|
+
post_url_dict = build_render_dict "post_url", post_url_dict
|
44
76
|
end
|
45
77
|
|
46
78
|
@origin_render = {
|
47
|
-
users:
|
48
|
-
screen_name:
|
49
|
-
post_text:
|
50
|
-
post_url:
|
79
|
+
users: users_dict,
|
80
|
+
screen_name: screen_name_dict,
|
81
|
+
post_text: post_text_dict,
|
82
|
+
post_url: post_url_dict
|
51
83
|
}
|
52
84
|
return self
|
53
85
|
end
|
54
86
|
|
55
87
|
def user_colorize
|
56
88
|
if !@options["no_color"]
|
57
|
-
@render[:users]
|
89
|
+
@render[:users][:template] =
|
90
|
+
@render[:users][:template]
|
91
|
+
.colorize(@render[:users][:color])
|
58
92
|
end
|
59
93
|
return self
|
60
94
|
end
|
61
95
|
|
62
96
|
def post_colorize
|
63
97
|
if !@options["no_color"]
|
64
|
-
@render[:screen_name]
|
65
|
-
|
98
|
+
@render[:screen_name][:template] =
|
99
|
+
@render[:screen_name][:template]
|
100
|
+
.colorize(@render[:screen_name][:color])
|
101
|
+
@render[:post_url][:template] =
|
102
|
+
@render[:post_url][:template]
|
103
|
+
.colorize(@render[:post_url][:color])
|
66
104
|
end
|
67
|
-
return
|
105
|
+
return self
|
68
106
|
end
|
69
107
|
|
108
|
+
def to_only_template
|
109
|
+
return @render.values.map {|d| d[:template]}
|
110
|
+
end
|
111
|
+
|
70
112
|
def to_s
|
71
113
|
self
|
72
114
|
.user_colorize
|
73
115
|
.post_colorize
|
74
|
-
.
|
116
|
+
.to_only_template
|
117
|
+
.join
|
75
118
|
.sub("\\n", "\n")
|
76
119
|
end
|
77
120
|
end
|
data/lib/favt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: favt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- esehara shigeo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: twitter
|