mediawiki_tool 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5be8cad3971fcc70d5ed14f2e4cac0370e2e5a9d
4
+ data.tar.gz: 45bdd1cb0a51a9967c63c4268c548a972574db9f
5
+ SHA512:
6
+ metadata.gz: e8cc65482f4fb74b20fb59bc1ca38212d9dfc2a9f311419adf92baf5ac0a8fc0c007968847ad445207ace983494b5d9c8ca887d07574f6ee5d33509d04150c03
7
+ data.tar.gz: 24f8d50c7208c64500b427f0b3b64fb607bc0c36193c2532cce6b40a6e74062288ea34b47f6df8a2caa4dd81ebea7cd96a3a82702f65fa9621b7e003bfe5db31
@@ -4,5 +4,5 @@
4
4
  require 'mediawiki_tool'
5
5
 
6
6
  puts 'Type your name: '
7
- MediawikiTool.user_name = gets.strip
8
- puts MediawikiTool::Calendar.month
7
+ username = gets.strip
8
+ puts MediawikiTool::Calendar.month(username: username)
@@ -1,15 +1 @@
1
- class MediawikiTool
2
- def self.user_name
3
- @@user_name
4
- end
5
-
6
- def self.user_name=(name)
7
- @@user_name = name unless name.blank?
8
- end
9
-
10
- private
11
-
12
- @@user_name = 'USER_NAME'
13
- end
14
-
15
1
  require 'mediawiki_tool/calendar'
@@ -4,31 +4,33 @@ require 'date'
4
4
  require 'active_support/core_ext'
5
5
  require 'ext/string'
6
6
 
7
- class MediawikiTool::Calendar
8
- def self.month(month = Time.now.month, year = Time.now.year)
9
- calendar_first = Date.new(year,month).beginning_of_week
10
- calendar_last = Date.new(year,month,-1).end_of_week
11
-
12
- table_head = Date::ABBR_DAYNAMES.rotate.map(&:upcase).unshift('').map(&:wiki_th).join("\n")
13
-
14
- table_lines = (calendar_first..calendar_last).group_by(&:cweek).map do |_, days|
15
- line_head = week_link(days.first).wiki_th
16
- line_elements = days.map do |day|
17
- ((day.month==month) ? day_link(day) : '').wiki_td(align: 'middle')
7
+ module MediawikiTool
8
+ module Calendar
9
+ def self.month(username: 'USERNAME', month: Time.now.month, year: Time.now.year)
10
+ calendar_first = Date.new(year,month).beginning_of_week
11
+ calendar_last = Date.new(year,month,-1).end_of_week
12
+
13
+ table_head = Date::ABBR_DAYNAMES.rotate.map(&:upcase).unshift('').map(&:wiki_th).join("\n")
14
+
15
+ table_lines = (calendar_first..calendar_last).group_by(&:cweek).map do |_, days|
16
+ line_head = week_link(username, days.first).wiki_th
17
+ line_elements = days.map do |day|
18
+ ((day.month==month) ? day_link(username, day) : '').wiki_td(align: 'middle')
19
+ end
20
+ line_elements.unshift(line_head).join("\n")
18
21
  end
19
- line_elements.unshift(line_head).join("\n")
20
- end
21
22
 
22
- "{|\n" + table_lines.unshift(table_head).join("\n|-\n") + "\n|}"
23
- end
23
+ "{|\n" + table_lines.unshift(table_head).join("\n|-\n") + "\n|}"
24
+ end
24
25
 
25
- private
26
+ private
26
27
 
27
- def self.day_link(date)
28
- "[[#{MediawikiTool.user_name} 日志 %04d.%02d.%02d|%02d]]" % [date.year, date.month, date.day, date.day]
29
- end
28
+ def self.day_link(username, date)
29
+ "[[#{username} 日志 %04d.%02d.%02d|%02d]]" % [date.year, date.month, date.day, date.day]
30
+ end
30
31
 
31
- def self.week_link(date)
32
- "[[#{MediawikiTool.user_name} 周报 %04d 第%02d周|Week%02d]]" % [date.cwyear, date.cweek, date.cweek]
32
+ def self.week_link(username, date)
33
+ "[[#{username} 周报 %04d 第%02d周|Week%02d]]" % [date.cwyear, date.cweek, date.cweek]
34
+ end
33
35
  end
34
36
  end
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediawiki_tool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jun Zhou
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-10 00:00:00.000000000 Z
11
+ date: 2013-04-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: i18n
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description: Generate calendar in MediaWiki syntax
@@ -50,32 +45,31 @@ executables:
50
45
  extensions: []
51
46
  extra_rdoc_files: []
52
47
  files:
48
+ - ./lib/mediawiki_tool/calendar.rb
53
49
  - ./lib/mediawiki_tool.rb
54
50
  - ./lib/ext/string.rb
55
- - ./lib/mediawiki_tool/calendar.rb
56
51
  - bin/wikicalendar
57
52
  homepage: http://rubygems.org/gems/mediawiki_tool
58
53
  licenses: []
54
+ metadata: {}
59
55
  post_install_message:
60
56
  rdoc_options: []
61
57
  require_paths:
62
58
  - lib
63
59
  required_ruby_version: !ruby/object:Gem::Requirement
64
- none: false
65
60
  requirements:
66
- - - ! '>='
61
+ - - '>='
67
62
  - !ruby/object:Gem::Version
68
63
  version: '0'
69
64
  required_rubygems_version: !ruby/object:Gem::Requirement
70
- none: false
71
65
  requirements:
72
- - - ! '>='
66
+ - - '>='
73
67
  - !ruby/object:Gem::Version
74
68
  version: '0'
75
69
  requirements: []
76
70
  rubyforge_project:
77
- rubygems_version: 1.8.24
71
+ rubygems_version: 2.0.3
78
72
  signing_key:
79
- specification_version: 3
73
+ specification_version: 4
80
74
  summary: Toolkits to help formatting text in MediaWiki syntax
81
75
  test_files: []