put_rake 0.1.2 → 0.1.5

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
  SHA256:
3
- metadata.gz: d5dfaaa375b4a3fcb639e8af684476bd5694f8b7c675a955d14d2f88037f7b98
4
- data.tar.gz: f28cfda8ba1c625c3b5cd4c037a125b0f4785bb2924183904a830f83ae807387
3
+ metadata.gz: dab232f839de21bea557cbdfdffbd8f274b1a200f3920fbad9ec3e3c22cabf4b
4
+ data.tar.gz: 38a0219457b0888ba8b6224f44b8bbaa723dfb29481c4c12d67f4239325ae17e
5
5
  SHA512:
6
- metadata.gz: dc40a566ebc2824ed94723a7af046c08e88b499c5f78a8eea1c955449a09cf499283ca2b0c2393bfc7c501dc9f22c1a705adb76283c9fdc318886fae62f95a51
7
- data.tar.gz: f6bc94d4eca5b6b31120136e27363e8db55a71c9918d129b0008cbc5f4cada39c6fada71235790c7ac6440c809094575f79801720a3d9e82abf27509b716f340
6
+ metadata.gz: 2beb7bb3a9d083f29f83221813cd574704f25fd13e180806574a60b7439f876f869ad1290e94addb5ad8828f1128ad4902d471e3fd5be3c2883cde657569ec60
7
+ data.tar.gz: 749699dad4fe56c1c4f1c440435674d17978e97708006a33a4a94b976d0b2eb75d87d0f503ac35f9eaa57410cdf956d16335db4672c838352b3696cce2f61b9f
data/.rspec_status ADDED
@@ -0,0 +1,4 @@
1
+ example_id | status | run_time |
2
+ ---------------------------- | ------ | --------------- |
3
+ ./spec/put_rake_spec.rb[1:1] | passed | 0.00026 seconds |
4
+ ./spec/put_rake_spec.rb[1:2] | failed | 0.00697 seconds |
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- put_rake (0.1.1)
4
+ put_rake (0.1.4)
5
5
  colorize
6
6
  command_line
7
7
  thor
data/README.org CHANGED
@@ -1,13 +1,12 @@
1
+ [[https://badge.fury.io/rb/put_rake.svg]]
2
+
1
3
  * PutRake
2
4
  :PROPERTIES:
3
5
  :CUSTOM_ID: putrake
4
6
  :END:
5
- Put the Rakefile on the local directory
7
+ Put a template of Rakefile for the specific tasks on the local directory
6
8
 
7
9
  ** Installation
8
- :PROPERTIES:
9
- :CUSTOM_ID: installation
10
- :END:
11
10
  Install the gem and add to the application's Gemfile by executing:
12
11
 
13
12
  #+begin_example
@@ -22,18 +21,31 @@ $ gem install put_rake
22
21
  #+end_example
23
22
 
24
23
  ** Usage
25
- :PROPERTIES:
26
- :CUSTOM_ID: usage
27
- :END:
28
-
29
24
  #+begin_src bash
30
25
  put_rake commands:
26
+ put_rake add PATH # add Rakefile template PATH
31
27
  put_rake for [EXT] # put Rakefile for [EXT]
32
28
  put_rake help [COMMAND] # Describe available commands or one specific command
33
29
  put_rake list # list available Rakefiles
30
+ put_rake path # show Rakefile template path
34
31
  put_rake version # show version
35
32
  #+end_src
36
33
 
34
+ Put a Rakefile [for] a specific tasks.
35
+ The default templates are located on the install directory of libs,
36
+ #+begin_src bash
37
+ > put_rake path
38
+ * Rakefile template paths
39
+ /Users/hoge/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/put_rake-0.1.3/lib/templates
40
+ #+end_src
41
+ and the additionals can be located any path which is specified
42
+ by the following command:
43
+ #+begin_src bash
44
+ put_rake add /Users/hoge/bin/Rakefiles
45
+ #+end_src
46
+
47
+ Happy Ruby.
48
+
37
49
  ** Development
38
50
  :PROPERTIES:
39
51
  :CUSTOM_ID: development
data/Rakefile.backup ADDED
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ # task default: :spec
9
+
10
+ require "colorize"
11
+ require 'command_line/global'
12
+
13
+ task :default do
14
+ system "rake -T"
15
+ end
16
+
17
+ desc 'git auto'
18
+ task :git_auto do
19
+ print "Input comments: "
20
+ comment = STDIN.gets.chomp
21
+ comment = comment == "" ? "auto pull and push" : comment.gsub("\'", "\\'")
22
+ ["git add -A",
23
+ "git commit -m '#{comment}'",
24
+ "git pull origin main",
25
+ "git push origin main"].each do |comm|
26
+ puts comm.cyan
27
+ res = command_line comm
28
+ puts res.stdout.green
29
+ end
30
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PutRake
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.5"
5
5
  end
data/lib/put_rake.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  require "thor"
3
3
  require "fileutils"
4
+ require 'command_line/global'
4
5
 
5
6
  require_relative "put_rake/version"
6
7
  #require_relative "put_rake/cli"
@@ -8,9 +9,10 @@ require_relative "put_rake/version"
8
9
 
9
10
  module PutRake
10
11
  class Error < StandardError; end
12
+
11
13
  # Your code goes here...
12
14
  class CLI < Thor
13
- package_name 'put_rake'
15
+ package_name "put_rake"
14
16
  map "-v" => :version
15
17
  map "--version" => :version
16
18
 
@@ -20,38 +22,87 @@ module PutRake
20
22
  print "put_rake #{VERSION}"
21
23
  end
22
24
 
25
+ desc "path", "show Rakefile template path"
26
+
27
+ def path
28
+ additional_path = ENV["PUT_RAKE_PATH"].split(":")
29
+ @gem_template_dirs = [
30
+ File.join(File.dirname(__FILE__), "templates"), additional_path,
31
+ ].flatten
32
+ puts "* Rakefile template paths\n #{@gem_template_dirs.join("\n ")}"
33
+ end
34
+
35
+ desc "add PATH", "add Rakefile template PATH"
36
+
37
+ def add(*args)
38
+ add = args[0]
39
+ puts "Additional template paths are obtained from ENV['PUT_RAKE_PATH']."
40
+ puts "Add default paths, put 'setenv PUT_RAKE_PATH ...' on ~/.config/fish/fishconfig.fish."
41
+ p additional_path = [ENV["PUT_RAKE_PATH"].split(":"), add].join(":")
42
+ p comm = "setenv #{additional_path}"
43
+ system comm
44
+ end
45
+
23
46
  desc "for [EXT]", "put Rakefile for [EXT]"
24
47
  method_option :force, :type => :boolean, :default => false,
25
- :aliases => "-f", :desc => "forcely replace"
48
+ :aliases => "-f", :desc => "forcely replace"
26
49
  # method_option :force => false, :aliases => "-f", :desc => "forcely replace"
27
50
  method_option :add, :type => :boolean, :default => false,
28
- :aliases => "-a", :desc => "add to the Rakefile"
51
+ :aliases => "-a", :desc => "add to the Rakefile"
52
+
29
53
  def for(*args)
30
- gem_template_dir = File.join(File.dirname(__FILE__), 'templates')
31
54
  file = "Rakefile_#{args[0]}"
32
- if File.exists?("./Rakefile")
55
+ list()
56
+ @file_path = @rake_file_path.collect do |path|
57
+ path if File.basename(path) == file
58
+ end.compact!
59
+ if @file_path.size != 1 #check multiple name
60
+ comment = <<~"HEREDOC"
61
+ Multiple file name #{args}: edit source Rakefile name first.\n
62
+ #{@file_path.join("\n")}
63
+ HEREDOC
64
+ puts comment
65
+ exit
66
+ end
67
+ @file_path = @file_path[0]
68
+ if File.exists?("./Rakefile") # check exist and -a -f
33
69
  if options[:force]
34
- comm = "cp #{File.join(gem_template_dir,file)} ./Rakefile"
70
+ comm = "cp #{@file_path} ./Rakefile"
35
71
  elsif options[:add]
36
- comm = "cat #{File.join(gem_template_dir,file)} >> ./Rakefile"
72
+ comm = "cat #{@file_path} >> ./Rakefile"
37
73
  else
38
- comm = "echo 'Rakefile exists. -f(orce) or -a(dd) available.'"
74
+ comm = "echo 'Rakefile exists. -f(orce) or -a(dd) option is available.'"
39
75
  end
40
76
  else
41
- comm = "cp #{File.join(gem_template_dir,file)} ./Rakefile"
77
+ comm = "cp #{@file_path} ./Rakefile"
42
78
  end
43
79
  puts comm
44
80
  system comm
45
81
  end
46
82
 
47
83
  desc "list", "list available Rakefiles"
84
+
48
85
  def list
49
- gem_template_dir = File.join(File.dirname(__FILE__), 'templates')
50
- files = File.join(gem_template_dir,'*')
51
- Dir.glob(files).each do |file|
52
- puts File.basename(file)
86
+ path()
87
+ @rake_file_path = []
88
+ puts "* Available Rakefiles"
89
+ puts "%10s: %s" % ["EXT", "full path"]
90
+ @gem_template_dirs.each do |gem_template_dir|
91
+ puts "** #{gem_template_dir}"
92
+ files = File.join(gem_template_dir, "*")
93
+ Dir.glob(files).each do |file|
94
+ next if file[-1] == "~"
95
+ @rake_file_path << file
96
+ key = file.match(/Rakefile_(.*)/)[1]
97
+ res = command_line "rake -T -f #{file}"
98
+ command = res.stdout.split("\n")[0]
99
+ if command
100
+ puts "%20s: %s" % [key, command.scan(/#.+/)[0]]
101
+ else
102
+ puts "%20s: %s" % [key, File.basename(file)]
103
+ end
104
+ end
53
105
  end
54
106
  end
55
-
56
107
  end
57
108
  end
@@ -6,7 +6,7 @@ task :default do
6
6
  system "rake -T"
7
7
  end
8
8
 
9
- desc 'git auto'
9
+ desc 'git automatic pull and push'
10
10
  task :git_auto do
11
11
  print "Input comments: "
12
12
  comment = STDIN.gets.chomp
@@ -17,7 +17,12 @@ task :git_auto do
17
17
  "git push origin main"].each do |comm|
18
18
  puts comm.cyan
19
19
  res = command_line comm
20
- puts res.stdout.green
20
+ if res.stderr != ''
21
+ puts res.stderr.red
22
+ exit
23
+ else
24
+ puts res.stdout.green
25
+ end
21
26
  end
22
27
  end
23
28
 
@@ -0,0 +1,14 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "colorize"
3
+ require 'command_line/global'
4
+
5
+ task :default do
6
+ system "rake -T"
7
+ end
8
+
9
+ namespace :some_name_space do
10
+ desc "task desciption" #desc → descriptio
11
+ task task_name: do # any name on task_name
12
+ # your code goes
13
+ end
14
+ end
data/put_rake.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Shigeto R. Nishiani"]
9
9
  spec.email = ["daddygongon@users.noreply.github.com"]
10
10
 
11
- spec.summary = "Put templates of Rakefile at the local dir."
12
- spec.description = "Put templates of Rakefile at the local dir."
11
+ spec.summary = "Put a template of Rakefiles on the local dir."
12
+ spec.description = "Put a template of Rakefiles on the local dir."
13
13
  spec.license = "MIT"
14
14
  spec.required_ruby_version = ">= 2.6.0"
15
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: put_rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shigeto R. Nishiani
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-13 00:00:00.000000000 Z
11
+ date: 2023-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: Put templates of Rakefile at the local dir.
69
+ description: Put a template of Rakefiles on the local dir.
70
70
  email:
71
71
  - daddygongon@users.noreply.github.com
72
72
  executables:
@@ -75,6 +75,7 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - ".rspec"
78
+ - ".rspec_status"
78
79
  - CHANGELOG.md
79
80
  - CODE_OF_CONDUCT.md
80
81
  - Gemfile
@@ -82,10 +83,12 @@ files:
82
83
  - LICENSE.txt
83
84
  - README.org
84
85
  - Rakefile
86
+ - Rakefile.backup
85
87
  - exe/put_rake
86
88
  - lib/put_rake.rb
87
89
  - lib/put_rake/version.rb
88
90
  - lib/templates/Rakefile_git_auto
91
+ - lib/templates/Rakefile_template
89
92
  - put_rake.gemspec
90
93
  - sig/put_rake.rbs
91
94
  homepage:
@@ -111,5 +114,5 @@ requirements: []
111
114
  rubygems_version: 3.2.22
112
115
  signing_key:
113
116
  specification_version: 4
114
- summary: Put templates of Rakefile at the local dir.
117
+ summary: Put a template of Rakefiles on the local dir.
115
118
  test_files: []