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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22fdcc2d77b7cb92dfaf41890e77176c51b6ec12
4
- data.tar.gz: 3c52f7271410151fb3dd8711994c48ade552a22c
3
+ metadata.gz: 18aa947268570843ba11da2a4639134a7c33f0e1
4
+ data.tar.gz: 4c5834327b8b39330300e330061735ba2d9dae53
5
5
  SHA512:
6
- metadata.gz: a6bfb7625e755c048a71ccc79b9495e695b52026eb775699a4beb225e8fa25452b02899ec10c7e27f345e1e1e2b6edba2a9afa0d4e7713931ee12e22e1da5199
7
- data.tar.gz: c7e0a7d90ac006acca901e260cc2c3ec816f443012aa0ec06a0c5dcf78089550b7f79347388d2a12c7517f7d60efb09f52d4a313235f7c8bcbef8d374f9d801f
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
- screen_name: "#\{post.user.screen_name}\n"
83
- post_text: "#\{post.text}"
84
- post_url: "#\{post.url}"
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"
@@ -15,63 +15,106 @@ module Render
15
15
 
16
16
  def repack
17
17
  post = @favorite["post"]
18
-
19
- @render = {}
20
- @render[:users] = @origin_render[:users] * @favorite["users"]
21
- @render[:screen_name] = @origin_render[:screen_name]
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] = @origin_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] = @origin_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
- users_str = '■'
35
- screen_name_str = '[#{post.user.screen_name}]\n'
36
- post_text_str = '#{post.text}\n'
37
- post_url_str = '#{post.url}\n'
47
+ post_text_dict = {
48
+ template: '#{post.text}\n',
49
+ color: :white
50
+ }
38
51
 
39
- if custom_render
40
- users_str = custom_render["users"] || users_str
41
- screen_name_str = custom_render["screen_name"] || screen_name_str
42
- post_text_str = custom_render["post_text"] || post_text_str
43
- post_url_str = custom_render["post_url"] || post_url_str
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: users_str,
48
- screen_name: screen_name_str,
49
- post_text: post_text_str,
50
- post_url: post_url_str
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] = @render[:users].red
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] = @render[:screen_name].green.bold
65
- @render[:post_url] = @render[:post_url].blue
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 @render
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
- .values.join
116
+ .to_only_template
117
+ .join
75
118
  .sub("\\n", "\n")
76
119
  end
77
120
  end
@@ -1,3 +1,3 @@
1
1
  module Favt
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.0
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-08 00:00:00.000000000 Z
11
+ date: 2014-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: twitter