furichan 0.1.2 → 0.1.3

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: bb9bd4672a1070aa7934db422a6dc81ce6e015cc
4
- data.tar.gz: ff5553323465db72514a8fa2ca1323ed5a1f5218
3
+ metadata.gz: e874b72f85df62026a8e7379eeed26e57401675c
4
+ data.tar.gz: e6a702e8fa7c7edda6441022556ec025bc08b6da
5
5
  SHA512:
6
- metadata.gz: 42cf586d98a08f97969f097543a5121b00376f7ba2b8152f26816a2adb91d0922ce1e42252d569c51988003f485af915c43dee7bfa11511a6a150dcc871f5a4f
7
- data.tar.gz: 19c2ca1506c0b9adb4267b022b43734bd88345203d38105b58a01bbba94170fc2d46d264dc5709e21fd5ae26f3a09028120e19b186ee5381e239dcb7a3071be6
6
+ metadata.gz: '091adb876f3e335e9e777aeb92037817da66955ee676d1998402af58c5825d6e781044e8adcb83f0feb05422646b820bc1d2780db2e33dacfca548f7536bf1dd'
7
+ data.tar.gz: 31fba80bde85e0b06f3f0e803c45bc475dc5faffb8a25000b53dff232eb77d7adebaff0e01044d57132ab505b580992c9ae80bf4cd7e0fe5148556c25c8ba703
data/.travis.yml CHANGED
@@ -2,4 +2,6 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.4.1
5
- before_install: gem install bundler -v 1.15.3
5
+ bundler_args: "-j4"
6
+ cache: bundler
7
+ script: 'bundle exec rspec'
data/README.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Furichan
2
2
 
3
+ [![ruby gem](https://img.shields.io/gem/v/furichan.svg?style=flat)][gem]
4
+ [![Build Status](https://travis-ci.org/Asuforce/furichan.svg?branch=master)][travis]
5
+ [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
6
+
7
+ [gem]: https://rubygems.org/gems/furichan
8
+ [travis]: https://travis-ci.org/Asuforce/furichan
9
+
3
10
  Hi, My name is Furichan. Nice to see you.
4
11
  I can print your GitHub and GH:E achievement on every week.
5
12
 
@@ -21,7 +28,7 @@ Or install it yourself as:
21
28
 
22
29
  ## Usage
23
30
 
24
- You can say `$ furichan`.
31
+ You can say `$ furichan`. You can see your GitHub and GH:E achievement.
25
32
 
26
33
  ## Development
27
34
 
data/lib/furichan/cli.rb CHANGED
@@ -1,73 +1,32 @@
1
- # coding: utf-8
2
-
3
1
  require 'thor'
4
- require 'date'
5
- require 'active_support/time'
6
- require 'furik/cli'
2
+ require "furichan/furichan_util"
7
3
 
8
4
  module Furichan
9
5
  class CLI < Thor
6
+ include FurichanUtil
7
+
10
8
  default_command :furichan
11
9
 
12
- desc 'furichan', 'Do the all of week task'
10
+ desc 'furichan', "Create file and write about this week's reflection"
13
11
  def furichan
14
12
  invoke :init
15
- invoke :furik
13
+ invoke :reflection
16
14
  end
17
15
 
18
16
  desc 'init', 'initialize of week setting'
19
17
  def init
20
- wmonth = Time.now().strftime('%Y-%m-') + week_of_month
21
- `git checkout -b #{wmonth}`
22
- `mkdir -p #{wmonth}`
23
- `cp template.md #{wmonth}/README.md`
18
+ #init_branch
19
+ init_file
24
20
  end
25
21
 
26
- desc 'furik', 'this week"s furik'
27
- def furik
28
- wmonth = Time.now().strftime('%Y-%m-') + week_of_month
29
- dest = Pathname(wmonth + '/README.md')
30
- dest.open('w') { |f| f.puts furik_init }
22
+ desc 'reflection', "write file about this week's furik"
23
+ def reflection
24
+ set_template(create_template)
31
25
  end
32
26
 
33
- private
34
-
35
- def week_of_month
36
- today = Date.today()
37
- beginning_of_month = today.beginning_of_month
38
- cweek = today.cweek - beginning_of_month.cweek
39
-
40
- # It should be first week.
41
- # Don't add when begining of month is saturday or sunday
42
- # ex 2017/07/07(Fri) -> 1
43
- unless beginning_of_month.saturday? or beginning_of_month.sunday?
44
- cweek += 1
45
- end
46
-
47
- cweek.to_s
48
- end
49
-
50
- def furik_init
51
- week = Date.today.beginning_of_week
52
- furik = Furik::Cli.new
53
- furik.options = {
54
- gh: true,
55
- ghe: true,
56
- from: week.to_s,
57
- to: week.end_of_week.to_s,
58
- since: 0,
59
- }
60
- activity = capture_stdout { furik.activity }
61
- activity.gsub!('7days Activities', '## 7days Activity')
62
- end
63
-
64
- def capture_stdout
65
- out = StringIO.new
66
- $stdout = out
67
- yield
68
- return out.string
69
- ensure
70
- $stdout = STDOUT
27
+ desc 'furik', "write stdout this week's furik"
28
+ def furik
29
+ init_furik
71
30
  end
72
31
  end
73
32
  end
@@ -0,0 +1,77 @@
1
+ require 'date'
2
+ require 'erb'
3
+ require 'fileutils'
4
+ require 'furik/cli'
5
+ require 'active_support/time'
6
+
7
+ module FurichanUtil
8
+ private
9
+
10
+ def get_wmonth
11
+ Time.now().strftime('%Y-%m-') + week_of_month
12
+ end
13
+
14
+ def week_of_month
15
+ today = Date.today()
16
+ beginning_of_month = today.beginning_of_month
17
+ cweek = today.cweek - beginning_of_month.cweek
18
+
19
+ # It should be first week.
20
+ # Don't add when begining of month is saturday or sunday
21
+ # ex 2017/07/07(Fri) -> 1
22
+ cweek += 1 unless weekend?(beginning_of_month)
23
+
24
+ cweek.to_s
25
+ end
26
+
27
+ def weekend?(day)
28
+ day.saturday? or day.sunday?
29
+ end
30
+
31
+ def write_reflection
32
+ activity = capture_stdout { init_furik }
33
+ activity.gsub!('7days Activities', '## 7days Activity')
34
+ end
35
+
36
+ def init_furik
37
+ week = Date.today.beginning_of_week
38
+ furik = Furik::Cli.new
39
+ furik.options = {
40
+ gh: true,
41
+ ghe: true,
42
+ from: week.to_s,
43
+ to: week.end_of_week.to_s,
44
+ since: 0,
45
+ }
46
+ furik.activity
47
+ end
48
+
49
+ def capture_stdout
50
+ out = StringIO.new
51
+ $stdout = out
52
+ yield
53
+ return out.string
54
+ ensure
55
+ $stdout = STDOUT
56
+ end
57
+
58
+ def init_branch
59
+ `git checkout -b #{get_wmonth}`
60
+ end
61
+
62
+ def init_file
63
+ wmonth = get_wmonth
64
+ FileUtils.mkdir("#{wmonth}")
65
+ FileUtils.touch("#{wmonth}/README.md")
66
+ end
67
+
68
+ def create_template
69
+ template = File.read(File.expand_path('../templates/template.md.erb', __FILE__))
70
+ ERB.new(template).result(binding)
71
+ end
72
+
73
+ def set_template(result)
74
+ dest = Pathname("#{get_wmonth}/README.md")
75
+ dest.open('a') { |f| f.puts result }
76
+ end
77
+ end
@@ -0,0 +1,5 @@
1
+ ## Keep
2
+
3
+ ## Problem
4
+
5
+ <%= write_reflection %>
@@ -1,3 +1,3 @@
1
1
  module Furichan
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: furichan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - asuforce
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-23 00:00:00.000000000 Z
11
+ date: 2017-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -116,6 +116,8 @@ files:
116
116
  - furichan.gemspec
117
117
  - lib/furichan.rb
118
118
  - lib/furichan/cli.rb
119
+ - lib/furichan/furichan_util.rb
120
+ - lib/furichan/templates/template.md.erb
119
121
  - lib/furichan/version.rb
120
122
  homepage: https://github.com/Asuforce/furichan
121
123
  licenses: