noir 0.0.1 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba0f4b6e225d9fd7b76ac11a2880ea68e6f07f63
4
- data.tar.gz: a9f636f6d453963747b276222fb16c35a1589b6a
3
+ metadata.gz: e0a981055827741b98263f272970c2a76ba53c2b
4
+ data.tar.gz: 42e09ce72746a6b8381f36bfc687cbd86a4aa19e
5
5
  SHA512:
6
- metadata.gz: 4d80e2b8ba59dde0ce9e726368f5123ae5ca0c836fb0e3cc0649dac7db1699dcb3e46ff276417aa23416707d923fedccdba7661a58a7e0510bc8df9029f4341d
7
- data.tar.gz: 09fd81daeaa775c0a75a8742fac986047cfd084df5a77e67e495106ac049f1155f232bb872ba582048735fdfd3524d4f9fee82c99abb06f11d857827cfc654c6
6
+ metadata.gz: 3ea4f8bd2daabba6eecde179adae24beeb81c83ce77a6b0e5df53ba2484bcc900e61d0ac05a62dde9750073994d572491397c6babf317687762874d9d8cbe0a8
7
+ data.tar.gz: 5413ee5c9777dd811391a4b64a959e18b9967e512a534b4dfcfe8ecd0a1f38d46d1a2fbe46f30c114be9020857ce39d25f1f0af2e20e2f124f0b8869fc371c57
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in iris.gemspec
3
+ # Specify your gem's dependencies in noir.gemspec
4
4
  gemspec
@@ -12,3 +12,4 @@ require 'noir/command/init'
12
12
  require 'noir/command/completion'
13
13
  require 'noir/command/help'
14
14
  require 'noir/command/new'
15
+ require 'noir/command/edit'
@@ -0,0 +1,5 @@
1
+ class Noir::Command::Edit < Noir::Base::Command
2
+ @description = 'edit files'
3
+ end
4
+
5
+ require 'noir/command/edit/weekly_report.rb'
@@ -0,0 +1,47 @@
1
+ class Noir::Command::Edit::WeeklyReport < Noir::Base::Command
2
+ @description = 'edit weekly report'
3
+
4
+ class << self
5
+ # time utilities
6
+
7
+ TimeOfADay = (24 * 60 * 60)
8
+ TimeFormat = '%Y%m%d'
9
+
10
+ def end_of_week_separeted separator_day_of_week, week_diff
11
+ check_method_name = "#{separator_day_of_week}?"
12
+ unless Time.instance_methods(false).include?(check_method_name.to_sym)
13
+ raise "a day of week name is incorrect! : #{separator_day_of_week}"
14
+ end
15
+
16
+ week_end = Time.now + (week_diff * 7 * TimeOfADay)
17
+ week_end += TimeOfADay
18
+ while !week_end.send(check_method_name)
19
+ week_end += TimeOfADay
20
+ end
21
+ week_end - TimeOfADay
22
+ end
23
+
24
+ def begin_of_week_separeted separator_day_of_week, week_diff
25
+ end_of_week_separeted(separator_day_of_week, week_diff) - (6*TimeOfADay)
26
+ end
27
+
28
+
29
+ # main methods
30
+ def edit_report separator_day_of_week, week_diff=0
31
+ system("vim #{report_name(separator_day_of_week, week_diff)}.txt")
32
+ end
33
+
34
+ def report_name separator_day_of_week, week_diff=0
35
+ [begin_of_week_separeted(separator_day_of_week, week_diff).strftime(TimeFormat),
36
+ end_of_week_separeted(separator_day_of_week, week_diff).strftime(TimeFormat)].join('_')
37
+ end
38
+ end
39
+ end
40
+
41
+ require 'noir/command/edit/weekly_report/monday'
42
+ require 'noir/command/edit/weekly_report/tuesday'
43
+ require 'noir/command/edit/weekly_report/wednesday'
44
+ require 'noir/command/edit/weekly_report/thursday'
45
+ require 'noir/command/edit/weekly_report/friday'
46
+ require 'noir/command/edit/weekly_report/saturday'
47
+ require 'noir/command/edit/weekly_report/sunday'
@@ -0,0 +1,10 @@
1
+ class Noir::Command::Edit::WeeklyReport::Friday < Noir::Base::TerminalCommand
2
+ @describe = 'edit weekly report separated by friday'
3
+
4
+ class << self
5
+ def execute *args
6
+ week_diff = args.first.to_i || 0
7
+ Noir::Command::Edit::WeeklyReport.edit_report :friday, week_diff
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class Noir::Command::Edit::WeeklyReport::Monday < Noir::Base::TerminalCommand
2
+ @describe = 'edit weekly report separated by monday'
3
+
4
+ class << self
5
+ def execute *args
6
+ week_diff = args.first.to_i || 0
7
+ Noir::Command::Edit::WeeklyReport.edit_report :monday, week_diff
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class Noir::Command::Edit::WeeklyReport::Saturday < Noir::Base::TerminalCommand
2
+ @describe = 'edit weekly report separated by saturday'
3
+
4
+ class << self
5
+ def execute *args
6
+ week_diff = args.first.to_i || 0
7
+ Noir::Command::Edit::WeeklyReport.edit_report :saturday, week_diff
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class Noir::Command::Edit::WeeklyReport::Sunday < Noir::Base::TerminalCommand
2
+ @describe = 'edit weekly report separated by sunday'
3
+
4
+ class << self
5
+ def execute *args
6
+ week_diff = args.first.to_i || 0
7
+ Noir::Command::Edit::WeeklyReport.edit_report :sunday, week_diff
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class Noir::Command::Edit::WeeklyReport::Thursday < Noir::Base::TerminalCommand
2
+ @describe = 'edit weekly report separated by thursday'
3
+
4
+ class << self
5
+ def execute *args
6
+ week_diff = args.first.to_i || 0
7
+ Noir::Command::Edit::WeeklyReport.edit_report :thursday, week_diff
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class Noir::Command::Edit::WeeklyReport::Tuesday < Noir::Base::TerminalCommand
2
+ @describe = 'edit weekly report separated by tuesday'
3
+
4
+ class << self
5
+ def execute *args
6
+ week_diff = args.first.to_i || 0
7
+ Noir::Command::Edit::WeeklyReport.edit_report :tuesday, week_diff
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class Noir::Command::Edit::WeeklyReport::Wednesday < Noir::Base::TerminalCommand
2
+ @describe = 'edit weekly report separated by wednesday'
3
+
4
+ class << self
5
+ def execute *args
6
+ week_diff = args.first.to_i || 0
7
+ Noir::Command::Edit::WeeklyReport.edit_report :wednesday, week_diff
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Noir
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,8 @@
1
+ require 'noir'
2
+ require 'spec_helper'
3
+
4
+ describe 'Noir::Command::Edit::WeeklyReport::Friday' do
5
+ it 'is inherited Noir::Base::TerminalCommand' do
6
+ expect(Noir::Command::Edit::WeeklyReport::Friday.superclass).to eq(Noir::Base::TerminalCommand)
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'noir'
2
+ require 'spec_helper'
3
+
4
+ describe 'Noir::Command::Edit::WeeklyReport::Monday' do
5
+ it 'is inherited Noir::Base::TerminalCommand' do
6
+ expect(Noir::Command::Edit::WeeklyReport::Monday.superclass).to eq(Noir::Base::TerminalCommand)
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'noir'
2
+ require 'spec_helper'
3
+
4
+ describe 'Noir::Command::Edit::WeeklyReport::Saturday' do
5
+ it 'is inherited Noir::Base::TerminalCommand' do
6
+ expect(Noir::Command::Edit::WeeklyReport::Saturday.superclass).to eq(Noir::Base::TerminalCommand)
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'noir'
2
+ require 'spec_helper'
3
+
4
+ describe 'Noir::Command::Edit::WeeklyReport::Sunday' do
5
+ it 'is inherited Noir::Base::TerminalCommand' do
6
+ expect(Noir::Command::Edit::WeeklyReport::Sunday.superclass).to eq(Noir::Base::TerminalCommand)
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'noir'
2
+ require 'spec_helper'
3
+
4
+ describe 'Noir::Command::Edit::WeeklyReport::Thursday' do
5
+ it 'is inherited Noir::Base::TerminalCommand' do
6
+ expect(Noir::Command::Edit::WeeklyReport::Thursday.superclass).to eq(Noir::Base::TerminalCommand)
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'noir'
2
+ require 'spec_helper'
3
+
4
+ describe 'Noir::Command::Edit::WeeklyReport::Tuesday' do
5
+ it 'is inherited Noir::Base::TerminalCommand' do
6
+ expect(Noir::Command::Edit::WeeklyReport::Tuesday.superclass).to eq(Noir::Base::TerminalCommand)
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'noir'
2
+ require 'spec_helper'
3
+
4
+ describe 'Noir::Command::Edit::WeeklyReport::Wednesday' do
5
+ it 'is inherited Noir::Base::TerminalCommand' do
6
+ expect(Noir::Command::Edit::WeeklyReport::Wednesday.superclass).to eq(Noir::Base::TerminalCommand)
7
+ end
8
+ end
@@ -0,0 +1,96 @@
1
+ require 'noir'
2
+ require 'spec_helper'
3
+
4
+ describe 'Noir::Command::Edit::WeeklyReport' do
5
+ it 'is inherited Noir::Base::Command' do
6
+ expect(Noir::Command::Edit::WeeklyReport.superclass).to eq(Noir::Base::Command)
7
+ end
8
+
9
+ describe '.report_name' do
10
+ before do
11
+ class Time
12
+ def self.now
13
+ Time.new(2014, 4, 1) # test date is 2014/04/01
14
+ end
15
+ end
16
+ end
17
+
18
+ it 'is raise invalid weekly separator' do
19
+ expect{Noir::Command::Edit::WeeklyReport.report_name :unknown}.to raise_error
20
+ end
21
+
22
+ describe 'in no week diff' do
23
+ it 'is return report_name by monday' do
24
+ expect(Noir::Command::Edit::WeeklyReport.report_name :monday).to eq('20140331_20140406')
25
+ end
26
+
27
+ it 'is return report_name by tuesday' do
28
+ expect(Noir::Command::Edit::WeeklyReport.report_name :tuesday).to eq('20140401_20140407')
29
+ end
30
+
31
+ it 'is return report_name by wednesday' do
32
+ expect(Noir::Command::Edit::WeeklyReport.report_name :wednesday).to eq('20140326_20140401')
33
+ end
34
+
35
+ it 'is return report_name by thursday' do
36
+ expect(Noir::Command::Edit::WeeklyReport.report_name :thursday).to eq('20140327_20140402')
37
+ end
38
+
39
+ it 'is return report_name by friday' do
40
+ expect(Noir::Command::Edit::WeeklyReport.report_name :friday).to eq('20140328_20140403')
41
+ end
42
+
43
+ it 'is return report_name by saturday' do
44
+ expect(Noir::Command::Edit::WeeklyReport.report_name :saturday).to eq('20140329_20140404')
45
+ end
46
+
47
+ it 'is return report_name by sunday' do
48
+ expect(Noir::Command::Edit::WeeklyReport.report_name :sunday).to eq('20140330_20140405')
49
+ end
50
+ end
51
+
52
+ describe 'in has week diff' do
53
+
54
+ it '-1 week diff' do
55
+ expect(Noir::Command::Edit::WeeklyReport.report_name :tuesday, -1).to eq('20140325_20140331')
56
+ end
57
+
58
+ it '-2 week diff' do
59
+ expect(Noir::Command::Edit::WeeklyReport.report_name :tuesday, -2).to eq('20140318_20140324')
60
+ end
61
+
62
+ it '-3 week diff' do
63
+ expect(Noir::Command::Edit::WeeklyReport.report_name :tuesday, -3).to eq('20140311_20140317')
64
+ end
65
+
66
+ it '-4 week diff' do
67
+ expect(Noir::Command::Edit::WeeklyReport.report_name :tuesday, -4).to eq('20140304_20140310')
68
+ end
69
+
70
+ it '-5 week diff' do
71
+ expect(Noir::Command::Edit::WeeklyReport.report_name :tuesday, -5).to eq('20140225_20140303')
72
+ end
73
+
74
+ it '+1 week diff' do
75
+ expect(Noir::Command::Edit::WeeklyReport.report_name :tuesday, 1).to eq('20140408_20140414')
76
+ end
77
+
78
+ it '+2 week diff' do
79
+ expect(Noir::Command::Edit::WeeklyReport.report_name :tuesday, 2).to eq('20140415_20140421')
80
+ end
81
+
82
+ it '+3 week diff' do
83
+ expect(Noir::Command::Edit::WeeklyReport.report_name :tuesday, 3).to eq('20140422_20140428')
84
+ end
85
+
86
+ it '+4 week diff' do
87
+ expect(Noir::Command::Edit::WeeklyReport.report_name :tuesday, 4).to eq('20140429_20140505')
88
+ end
89
+
90
+ it '+4 week diff' do
91
+ expect(Noir::Command::Edit::WeeklyReport.report_name :tuesday, 5).to eq('20140506_20140512')
92
+ end
93
+ end
94
+
95
+ end
96
+ end
@@ -0,0 +1,9 @@
1
+ require 'noir'
2
+ require 'spec_helper'
3
+
4
+ describe 'Noir::Command::Edit' do
5
+ it 'is inherited Noir::Base::Command' do
6
+ expect(Noir::Command::Edit.superclass).to eq(Noir::Base::Command)
7
+ end
8
+ end
9
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - atton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-04 00:00:00.000000000 Z
11
+ date: 2014-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,6 +72,15 @@ files:
72
72
  - lib/noir/base/terminal_command.rb
73
73
  - lib/noir/command.rb
74
74
  - lib/noir/command/completion.rb
75
+ - lib/noir/command/edit.rb
76
+ - lib/noir/command/edit/weekly_report.rb
77
+ - lib/noir/command/edit/weekly_report/friday.rb
78
+ - lib/noir/command/edit/weekly_report/monday.rb
79
+ - lib/noir/command/edit/weekly_report/saturday.rb
80
+ - lib/noir/command/edit/weekly_report/sunday.rb
81
+ - lib/noir/command/edit/weekly_report/thursday.rb
82
+ - lib/noir/command/edit/weekly_report/tuesday.rb
83
+ - lib/noir/command/edit/weekly_report/wednesday.rb
75
84
  - lib/noir/command/help.rb
76
85
  - lib/noir/command/init.rb
77
86
  - lib/noir/command/init/zsh.rb
@@ -82,6 +91,15 @@ files:
82
91
  - lib/noir/version.rb
83
92
  - noir.gemspec
84
93
  - spec/noir/command/completion_spec.rb
94
+ - spec/noir/command/edit/weekly_report/friday_spec.rb
95
+ - spec/noir/command/edit/weekly_report/monday_spec.rb
96
+ - spec/noir/command/edit/weekly_report/saturday_spec.rb
97
+ - spec/noir/command/edit/weekly_report/sunday_spec.rb
98
+ - spec/noir/command/edit/weekly_report/thursday_spec.rb
99
+ - spec/noir/command/edit/weekly_report/tuesday_spec.rb
100
+ - spec/noir/command/edit/weekly_report/wednesday_spec.rb
101
+ - spec/noir/command/edit/weekly_report_spec.rb
102
+ - spec/noir/command/edit_spec.rb
85
103
  - spec/noir/command/help_spec.rb
86
104
  - spec/noir/command/init/zsh_spec.rb
87
105
  - spec/noir/command/init_spec.rb
@@ -121,6 +139,15 @@ specification_version: 4
121
139
  summary: Utilities for atton.
122
140
  test_files:
123
141
  - spec/noir/command/completion_spec.rb
142
+ - spec/noir/command/edit/weekly_report/friday_spec.rb
143
+ - spec/noir/command/edit/weekly_report/monday_spec.rb
144
+ - spec/noir/command/edit/weekly_report/saturday_spec.rb
145
+ - spec/noir/command/edit/weekly_report/sunday_spec.rb
146
+ - spec/noir/command/edit/weekly_report/thursday_spec.rb
147
+ - spec/noir/command/edit/weekly_report/tuesday_spec.rb
148
+ - spec/noir/command/edit/weekly_report/wednesday_spec.rb
149
+ - spec/noir/command/edit/weekly_report_spec.rb
150
+ - spec/noir/command/edit_spec.rb
124
151
  - spec/noir/command/help_spec.rb
125
152
  - spec/noir/command/init/zsh_spec.rb
126
153
  - spec/noir/command/init_spec.rb