rake_i_task 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,27 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea/.name
19
+ .idea/.rakeTasks
20
+ .idea/221_rake_i_task.iml
21
+ .idea/encodings.xml
22
+ .idea/misc.xml
23
+ .idea/modules.xml
24
+ .idea/scopes/scope_settings.xml
25
+ .idea/vcs.xml
26
+ .idea/workspace.xml
27
+ .rake_history
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rake_i_task.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Bernhard Weichel
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # RakeITask
2
+
3
+ This gem provided a rake taks named 'i' making rake interactive:
4
+
5
+
6
+ it opens a REPL shell with the following commands
7
+
8
+ * *help* - provide help
9
+ * *rake* - perform rake tasks
10
+ * *exit* - leave the hell
11
+
12
+ It provides
13
+
14
+ * TAB completion for the rake tasks
15
+ * History even across sessions
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ gem 'rake_i_task'
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install rake_i_task
30
+
31
+ ## Usage
32
+
33
+ add the following line to your rake file
34
+
35
+ require 'rake_i_task'
36
+
37
+ you then can run
38
+
39
+ rake i
40
+
41
+ ## credits
42
+
43
+ * https://github.com/exploid/rake-repl
44
+ * http://stackoverflow.com/a/22545297/2092206
45
+
46
+ ## license
47
+
48
+ MIT
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create new Pull Request
57
+
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "./lib/rake_i_task.rb"
2
+
3
+ require "bundler/gem_tasks"
@@ -0,0 +1,127 @@
1
+
2
+ #
3
+ # this is an interactive rake task
4
+ #
5
+ # (c) 2014 Bernhard Weichel
6
+ #
7
+ # todo: handle task arguments
8
+ #
9
+
10
+ Rake::TaskManager.record_task_metadata = true
11
+
12
+
13
+ require 'readline'
14
+
15
+ desc "Interactive rake console"
16
+ task :i do |t, args|
17
+
18
+ begin
19
+ File.open(".rake_history").readlines.each{|l|
20
+ Readline::HISTORY.push(l.strip)
21
+ }
22
+ rescue
23
+ nil
24
+ end
25
+
26
+ tasks = Rake.application.tasks.select{|t|t.is_a? Rake::Task}
27
+ tasks = tasks.select{|t| t.comment }
28
+ tasknames = tasks.map{|t| t.name }
29
+
30
+ name_width = tasks.map { |t| t.name_with_args.length }.max || 10
31
+ max_column = Rake.application.terminal_width - 7
32
+
33
+
34
+ show_tasks = lambda{
35
+ tasks.each do |t|
36
+ printf("%-#{name_width}s # %s\n",
37
+ "rake #{t.name_with_args}",
38
+ max_column ? Rake.application.truncate(t.comment, max_column) : t.comment)
39
+ end
40
+ }
41
+
42
+ show_help = lambda{
43
+ puts %Q{This is interactive Rake
44
+
45
+ exit : end the session
46
+ help : show help
47
+ }
48
+ }
49
+
50
+ comp = proc { |s|
51
+ completions = tasknames.map{|taskname| taskname }
52
+ completions = completions.grep( /^#{Regexp.escape(s)}/ )
53
+ if completions.count == 1
54
+ completions = [completions.first]
55
+ end
56
+ completions
57
+ }
58
+
59
+
60
+ unless args[:script].nil?
61
+ commands = args[:script].split("&&")
62
+ commands.each do |command|
63
+ command.strip!
64
+ begin
65
+ STDOUT.puts "Executing: #{command}"
66
+ Rake::Task[command].invoke
67
+ rescue RuntimeError => e
68
+ STDOUT.puts "Don't know how to build task '#{command}'"
69
+ end
70
+ end
71
+ end
72
+
73
+
74
+
75
+ str = ''
76
+
77
+ while str != 'exit'
78
+ Readline.completion_proc = comp
79
+ Readline.completion_append_character = ''
80
+ current_dir_short = File.basename(pwd)
81
+
82
+ str = Readline.readline("#{current_dir_short} rake> ", true)
83
+
84
+ Readline::HISTORY.pop if /^\s*$/ =~ str
85
+ begin
86
+ if Readline::HISTORY[-2] == str
87
+ Readline::HISTORY.pop
88
+ end
89
+ rescue IndexError
90
+ end
91
+
92
+
93
+ str = 'help' if str.nil?
94
+
95
+ tokens = str.split(" ")
96
+
97
+ if tokens.first == 'exit' || str.nil?
98
+ File.open(".rake_history", "w"){|f|
99
+ Readline::HISTORY.each{|l| f.puts l
100
+ }
101
+ }
102
+ break
103
+
104
+ elsif (tokens.first == "help") or (tokens.empty?)
105
+ show_help.call
106
+ show_tasks.call
107
+
108
+ elsif tokens.first == 'rake'
109
+ begin
110
+ Rake.application.tasks.each{|task|
111
+ Rake::Task[task].reenable()
112
+ }
113
+ tokens[1 .. -1].each{|token|
114
+ task_name, args = Rake.application.parse_task_string(token)
115
+ puts "invoking #{task_name}";Rake::Task[task_name].invoke(*args)
116
+ }
117
+ rescue RuntimeError => e
118
+ STDOUT.puts "Don't know how to build task '#{e.message}'"
119
+ end
120
+
121
+ elsif
122
+ a = `#{str}` rescue "#{$!}"
123
+ puts a
124
+ end
125
+ end
126
+ end
127
+
@@ -0,0 +1,3 @@
1
+ module RakeITask
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,43 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rake_i_task/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rake_i_task"
8
+ spec.version = RakeITask::VERSION
9
+ spec.authors = ["Bernhard Weichel"]
10
+ spec.email = ["github.com@nospam.weichel21.de"]
11
+ spec.description = %q{This gem provided a rake taks named 'i' making rake interactive:
12
+
13
+ usage: add the following line to your rake file
14
+
15
+ require 'rake_i_task'
16
+
17
+ rake i
18
+
19
+ it opens a REPL shell with the following commands
20
+
21
+ *help* - provide help
22
+ *reke* - perform rake tasks
23
+ *exit* - leave the hell
24
+
25
+ It provides
26
+
27
+ * TAB completion for the rake tasks
28
+ * History even across sessions
29
+ * pass unknown commands to the underlying operation system
30
+
31
+ }
32
+ spec.summary = %q{Interactive rake task}
33
+ spec.homepage = "https://github.com/bwl21/rake_i_task"
34
+ spec.license = "MIT"
35
+
36
+ spec.files = `git ls-files`.split($/)
37
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
38
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
39
+ spec.require_paths = ["lib"]
40
+
41
+ spec.add_development_dependency "bundler", "~> 1.3"
42
+ spec.add_development_dependency "rake"
43
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rake_i_task
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Bernhard Weichel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-08-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: ! "This gem provided a rake taks named 'i' making rake interactive:\n\n
47
+ \ usage: add the following line to your rake file\n\n require 'rake_i_task'\n\n
48
+ \ rake i\n\n it opens a REPL shell with the following commands\n\n *help* - provide
49
+ help\n *reke* - perform rake tasks\n *exit* - leave the hell\n\n It provides\n\n
50
+ \ * TAB completion for the rake tasks\n * History even across sessions\n * pass
51
+ unknown commands to the underlying operation system\n\n"
52
+ email:
53
+ - github.com@nospam.weichel21.de
54
+ executables: []
55
+ extensions: []
56
+ extra_rdoc_files: []
57
+ files:
58
+ - .gitignore
59
+ - Gemfile
60
+ - LICENSE.txt
61
+ - README.md
62
+ - Rakefile
63
+ - lib/rake_i_task.rb
64
+ - lib/rake_i_task/version.rb
65
+ - rake_i_task.gemspec
66
+ homepage: https://github.com/bwl21/rake_i_task
67
+ licenses:
68
+ - MIT
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 1.8.25
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Interactive rake task
91
+ test_files: []