github-copywriter 0.0.3 → 0.0.4
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 +4 -4
- data/bin/github-copywriter +4 -0
- data/lib/github-copywriter.rb +9 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b396521603f3abc0c5c59e95a36202035a28f13c
|
4
|
+
data.tar.gz: 3f835c331628069bd7ebdb97c286ee82344fd948
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c52bacd633c7a65f040ff860962d7073f89232bab961e9258277572c34e6cb21eefc0ee1eaf5961a886522db8d8a1bc7572ba806564ef8937ada3c8f218b1df
|
7
|
+
data.tar.gz: 741a0f59c1e960feb414189b872222d1d7231bbaaa3490fabd0e9b9dcf4f88b44b5614b8cc5020030fc3055ae62555f78d8daa3ba49c5d46d2fb8055342350cd
|
data/bin/github-copywriter
CHANGED
@@ -29,6 +29,10 @@ Usage: #{executable_name} [repos...]
|
|
29
29
|
options[:skip_forks] = true
|
30
30
|
end
|
31
31
|
|
32
|
+
opts.on("-y", "--year YEAR", "Update copyrights to a give year.") do |year|
|
33
|
+
options[:year] = year
|
34
|
+
end
|
35
|
+
|
32
36
|
opts.on_tail("-h","--help", "Show this message.") do
|
33
37
|
puts opts
|
34
38
|
exit
|
data/lib/github-copywriter.rb
CHANGED
@@ -13,13 +13,9 @@ require "pp" # debug tool
|
|
13
13
|
module Copywriter
|
14
14
|
extend self
|
15
15
|
|
16
|
-
VERSION = "0.0.
|
16
|
+
VERSION = "0.0.4"
|
17
17
|
COMMIT_MSG = "Update copyright. ♥ github-copywriter\nFor more info, visit http://ryanmjacobs.github.io/github-copywriter"
|
18
18
|
|
19
|
-
# Get time/date
|
20
|
-
time = Time.now
|
21
|
-
CUR_YEAR = time.year
|
22
|
-
|
23
19
|
def login!
|
24
20
|
# Grab username and pass
|
25
21
|
puts "Obtaining OAuth2 access_token from github."
|
@@ -83,10 +79,10 @@ module Copywriter
|
|
83
79
|
# (C) 2014
|
84
80
|
# © 2014
|
85
81
|
begin
|
86
|
-
content.gsub!(/([Cc]opyright( \([Cc]\)| ©)?|\([Cc]\)|©) \d{4}/, "\\1 #{
|
82
|
+
content.gsub!(/([Cc]opyright( \([Cc]\)| ©)?|\([Cc]\)|©) \d{4}/, "\\1 #{@cur_year}")
|
87
83
|
rescue
|
88
84
|
# try w/o "©" symbol if we had errors
|
89
|
-
content.gsub!(/([Cc]opyright( \([Cc]\))?|\([Cc]\)) \d{4}/, "\\1 #{
|
85
|
+
content.gsub!(/([Cc]opyright( \([Cc]\))?|\([Cc]\)) \d{4}/, "\\1 #{@cur_year}")
|
90
86
|
end
|
91
87
|
|
92
88
|
# Only commit if we need to
|
@@ -94,7 +90,7 @@ module Copywriter
|
|
94
90
|
@modified_files << {:path => file_path, :content => content}
|
95
91
|
puts " #{file_path} is now up-to-date.".green
|
96
92
|
else
|
97
|
-
puts " #{file_path}
|
93
|
+
puts " #{file_path} is already up-to-date."
|
98
94
|
end
|
99
95
|
end
|
100
96
|
|
@@ -142,7 +138,7 @@ module Copywriter
|
|
142
138
|
|
143
139
|
def run!(options={})
|
144
140
|
# Default options
|
145
|
-
options = {all: false, skip_forks: false}.merge(options)
|
141
|
+
options = {all: false, skip_forks: false, year: nil}.merge(options)
|
146
142
|
|
147
143
|
if options[:all] then
|
148
144
|
repos = @client.repositories()
|
@@ -159,9 +155,13 @@ module Copywriter
|
|
159
155
|
end
|
160
156
|
end
|
161
157
|
|
158
|
+
# Get copyright year
|
159
|
+
@cur_year = options[:year] || Time.now.year
|
160
|
+
|
162
161
|
# Loop through each repo
|
163
162
|
repos.each do |repo|
|
164
163
|
|
164
|
+
# Skip if repo is a fork and --skip-forks is on
|
165
165
|
next if options[:skip_forks] and repo[:fork]
|
166
166
|
|
167
167
|
# Get repo info
|