ru 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: 92351cd0d4f9df90afa8ea60e92f6abc6470c90e
4
- data.tar.gz: 38256d881838535af9e122f2cdb270760c4ffca3
3
+ metadata.gz: a41f9be8b0fdd59101fe4bba93e8674995f6d871
4
+ data.tar.gz: e962cc943758d9423fefac4e8a04854e4293aba8
5
5
  SHA512:
6
- metadata.gz: 812326331d26647a18e8e9ce823f1b30bdd6a60eb91fa2940b4c07eaea916626e1562a65adfdde2fb380bd8549eabbfec7e444071861f30e91d5ac2a16184fe6
7
- data.tar.gz: 950c4e17a04764fbc845b04390cd7cfbe1a52855ef1569f0bdf90430ffa6e91910cb60df8c236e464672f4ef1fcf9334f2ad3145dd4bafa6e275af9d771e48f8
6
+ metadata.gz: 3ffec1a6d481e9cc429b3383b0f50f1cf2baae7cfdb8d354c4f70daf36f5021ea470b7366d9ebb4749ea213c9a21c0531bb046ce5d7ed7ea783586e8bf125057
7
+ data.tar.gz: 3aa63965b871d3a09012f60b4457e4950072df4b08a237b388270622e92fd781f623e69a30450280805735d37176c8d7e253ecbb3fe7d223322fd6d50f959521
data/README.md CHANGED
@@ -116,6 +116,14 @@ $ ru run sum myfile
116
116
  5
117
117
  ```
118
118
 
119
+ To see all of your saved commands, use `list`:
120
+
121
+ ```bash
122
+ $ ru list
123
+ Saved commands:
124
+ sum map(:to_i).sum
125
+ ```
126
+
119
127
  ### Options
120
128
 
121
129
  #### -h, --help
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- ru (0.1.0)
4
+ ru (0.1.1)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- ru (0.1.0)
4
+ ru (0.1.1)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -19,6 +19,10 @@ module Ru
19
19
  commands[name]
20
20
  end
21
21
 
22
+ def all
23
+ get_commands
24
+ end
25
+
22
26
  private
23
27
 
24
28
  def save_commands(commands)
data/lib/ru/process.rb CHANGED
@@ -14,11 +14,18 @@ module Ru
14
14
  args = ARGV
15
15
  first_arg = args.shift
16
16
 
17
- if first_arg == 'save'
18
- name = args[0]
19
- code = args[1]
20
- @command_manager.save(name, code)
21
- return "Saved command: #{name} is '#{code}'"
17
+ if first_arg == 'list'
18
+ commands = @command_manager.all
19
+ if commands.present?
20
+ lines = ['Saved commands:']
21
+ lines += commands.sort_by(&:first).map { |name, code| "#{name}\t#{code}" }
22
+ else
23
+ lines = [
24
+ 'No saved commands. To save a command, use `save`:',
25
+ "ru save sum 'map(:to_i).sum'"
26
+ ]
27
+ end
28
+ return lines.join("\n")
22
29
  elsif first_arg == 'run'
23
30
  name = args.shift
24
31
  @code = @command_manager.get(name)
@@ -27,6 +34,11 @@ module Ru
27
34
  exit 1
28
35
  return
29
36
  end
37
+ elsif first_arg == 'save'
38
+ name = args[0]
39
+ code = args[1]
40
+ @command_manager.save(name, code)
41
+ return "Saved command: #{name} is '#{code}'"
30
42
  elsif first_arg.blank?
31
43
  STDERR.puts @option_printer.run(:help)
32
44
  exit 1
data/lib/ru/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ru
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -80,6 +80,25 @@ describe Ru::Process do
80
80
  end
81
81
 
82
82
  describe "command management" do
83
+ describe "list" do
84
+ it "lists the commands" do
85
+ Ru::CommandManager.any_instance.stub(:get_commands).and_return({
86
+ 'product' => 'map(:to_i).reduce(:*)',
87
+ 'sum' => 'map(:to_i).sum',
88
+ })
89
+ out = run(['list'])
90
+ out.should == "Saved commands:\nproduct\tmap(:to_i).reduce(:*)\nsum\tmap(:to_i).sum"
91
+ end
92
+
93
+ context "no saved commands" do
94
+ it "shows a message" do
95
+ Ru::CommandManager.any_instance.stub(:get_commands).and_return({})
96
+ out = run(['list'])
97
+ out.should == "No saved commands. To save a command, use `save`:\nru save sum 'map(:to_i).sum'"
98
+ end
99
+ end
100
+ end
101
+
83
102
  describe "run" do
84
103
  it "runs the command" do
85
104
  Ru::CommandManager.any_instance.stub(:get_commands).and_return({ 'sum' => 'map(:to_i).sum' })
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Benner