my_scripts 0.0.13 → 0.0.17

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.
data/lib/my_scripts.rb CHANGED
@@ -1,12 +1,12 @@
1
- # Top level namespace
2
- module MyScripts
3
-
4
- # Used to auto-require all the source files located in lib/my_scripts
5
- def self.require_libs( filename, filemask )
6
- file = ::File.expand_path(::File.join(::File.dirname(filename), filemask.gsub(/(?<!.rb)$/,'.rb')))
7
- require file if File.exist?(file) && !File.directory?(file)
8
- Dir.glob(file).sort.each {|rb| require rb}
9
- end
10
- end # module MyScripts
11
-
12
- %W[my_scripts/script my_scripts/cli **/*].each {|rb| MyScripts.require_libs(__FILE__, rb)}
1
+ # Top level namespace
2
+ module MyScripts
3
+
4
+ # Used to auto-require all the source files located in lib/my_scripts
5
+ def self.require_libs( filename, filemask )
6
+ file = ::File.expand_path(::File.join(::File.dirname(filename), filemask.gsub(/(?<!.rb)$/,'.rb')))
7
+ require file if File.exist?(file) && !File.directory?(file)
8
+ Dir.glob(file).sort.each {|rb| require rb}
9
+ end
10
+ end # module MyScripts
11
+
12
+ %W[my_scripts/script my_scripts/cli **/*].each {|rb| MyScripts.require_libs(__FILE__, rb)}
data/my_scripts.gemspec CHANGED
@@ -1,79 +1,82 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{my_scripts}
8
- s.version = "0.0.13"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["arvicco"]
12
- s.date = %q{2010-03-11}
13
- s.description = %q{Simple framework for writing command-line scripts and collection of my own scripts (mostly dev-related)}
14
- s.email = %q{arvitallian@gmail.com}
15
- s.executables = ["citi", "dummy", "gitto", "jew", "mybones", "rabbit"]
16
- s.extra_rdoc_files = [
17
- "LICENSE",
18
- "README.rdoc"
19
- ]
20
- s.files = [
21
- ".document",
22
- ".gitignore",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "bin/citi",
28
- "bin/dummy",
29
- "bin/gitto",
30
- "bin/jew",
31
- "bin/mybones",
32
- "bin/rabbit",
33
- "features/my_scripts.feature",
34
- "features/step_definitions/my_scripts_steps.rb",
35
- "features/support/env.rb",
36
- "lib/my_scripts.rb",
37
- "lib/my_scripts/citi.rb",
38
- "lib/my_scripts/cli.rb",
39
- "lib/my_scripts/dummy.rb",
40
- "lib/my_scripts/extensions.rb",
41
- "lib/my_scripts/gitto.rb",
42
- "lib/my_scripts/jew.rb",
43
- "lib/my_scripts/mybones.rb",
44
- "lib/my_scripts/rabbit.rb",
45
- "lib/my_scripts/script.rb",
46
- "my_scripts.gemspec",
47
- "spec/my_scripts/extensions_spec.rb",
48
- "spec/my_scripts_spec.rb",
49
- "spec/spec.opts",
50
- "spec/spec_helper.rb"
51
- ]
52
- s.homepage = %q{http://github.com/arvicco/my_scripts}
53
- s.rdoc_options = ["--charset=UTF-8"]
54
- s.require_paths = ["lib"]
55
- s.rubygems_version = %q{1.3.5}
56
- s.summary = %q{Simple framework for writing command-line scripts}
57
- s.test_files = [
58
- "spec/my_scripts/extensions_spec.rb",
59
- "spec/my_scripts_spec.rb",
60
- "spec/spec_helper.rb"
61
- ]
62
-
63
- if s.respond_to? :specification_version then
64
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
65
- s.specification_version = 3
66
-
67
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
68
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
69
- s.add_development_dependency(%q<cucumber>, [">= 0"])
70
- else
71
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
72
- s.add_dependency(%q<cucumber>, [">= 0"])
73
- end
74
- else
75
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
76
- s.add_dependency(%q<cucumber>, [">= 0"])
77
- end
78
- end
79
-
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{my_scripts}
8
+ s.version = "0.0.17"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["arvicco"]
12
+ s.date = %q{2010-04-08}
13
+ s.description = %q{Simple framework for writing command-line scripts and collection of my own scripts (mostly dev-related)}
14
+ s.email = %q{arvitallian@gmail.com}
15
+ s.executables = ["citi", "dummy", "gitto", "jew", "mybones", "newscript", "rabbit", "wake"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".gitignore",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "bin/citi",
28
+ "bin/dummy",
29
+ "bin/gitto",
30
+ "bin/jew",
31
+ "bin/mybones",
32
+ "bin/newscript",
33
+ "bin/rabbit",
34
+ "bin/wake",
35
+ "features/my_scripts.feature",
36
+ "features/step_definitions/my_scripts_steps.rb",
37
+ "features/support/env.rb",
38
+ "lib/my_scripts.rb",
39
+ "lib/my_scripts/citi.rb",
40
+ "lib/my_scripts/cli.rb",
41
+ "lib/my_scripts/dummy.rb",
42
+ "lib/my_scripts/extensions.rb",
43
+ "lib/my_scripts/gitto.rb",
44
+ "lib/my_scripts/jew.rb",
45
+ "lib/my_scripts/mybones.rb",
46
+ "lib/my_scripts/rabbit.rb",
47
+ "lib/my_scripts/script.rb",
48
+ "lib/my_scripts/wake.rb",
49
+ "my_scripts.gemspec",
50
+ "spec/my_scripts/extensions_spec.rb",
51
+ "spec/my_scripts_spec.rb",
52
+ "spec/spec.opts",
53
+ "spec/spec_helper.rb"
54
+ ]
55
+ s.homepage = %q{http://github.com/arvicco/my_scripts}
56
+ s.rdoc_options = ["--charset=UTF-8"]
57
+ s.require_paths = ["lib"]
58
+ s.rubygems_version = %q{1.3.6}
59
+ s.summary = %q{Simple framework for writing command-line scripts}
60
+ s.test_files = [
61
+ "spec/my_scripts/extensions_spec.rb",
62
+ "spec/my_scripts_spec.rb",
63
+ "spec/spec_helper.rb"
64
+ ]
65
+
66
+ if s.respond_to? :specification_version then
67
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
68
+ s.specification_version = 3
69
+
70
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
71
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
72
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
73
+ else
74
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
75
+ s.add_dependency(%q<cucumber>, [">= 0"])
76
+ end
77
+ else
78
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
79
+ s.add_dependency(%q<cucumber>, [">= 0"])
80
+ end
81
+ end
82
+
@@ -1,61 +1,61 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
-
5
- module MyScriptsTest
6
- module A
7
- class B
8
- class C
9
- end
10
- end
11
- end
12
-
13
- describe String do
14
- context '#snake_case' do
15
- it 'transforms CamelCase strings' do
16
- 'GetCharWidth32'.snake_case.should == 'get_char_width_32'
17
- end
18
-
19
- it 'leaves snake_case strings intact' do
20
- 'keybd_event'.snake_case.should == 'keybd_event'
21
- end
22
- end
23
-
24
- context '#camel_case' do
25
- it 'transforms underscore strings to CamelCase' do
26
- 'get_char_width_32'.camel_case.should == 'GetCharWidth32'
27
- end
28
-
29
- it 'leaves CamelCase strings intact' do
30
- 'GetCharWidth32'.camel_case.should == 'GetCharWidth32'
31
- end
32
- end
33
-
34
- context '#to_class' do
35
- it 'converts string into appropriate Class constant' do
36
- "Fixnum".to_class.should == Fixnum
37
- "MyScriptsTest::A::B::C".to_class.should == MyScriptsTest::A::B::C
38
- end
39
-
40
- it 'returns nil if string is not convertible into class' do
41
- "Math".to_class.should == nil
42
- "Math::PI".to_class.should == nil
43
- "Something".to_class.should == nil
44
- end
45
-
46
- it 'deals with leading colons' do
47
- "::MyScriptsTest::A::B::C".to_class.should == MyScriptsTest::A::B::C
48
- end
49
- end
50
-
51
- context '#translit!' do
52
- it 'converts string from Cyrillic to Latin translit' do
53
- "Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства".translit!.
54
- should == "SHirokaya elektrifikatsiya yuzhnykh gubernij dast moshchnyj tolchok pod\"emu sel'skogo khozyajstva"
55
- "ШИРОКАЯ ЭЛЕКТРИФИКАЦИЯ ЮЖНЫХ ГУБЕРНИЙ ДАСТ МОЩНЫЙ ТОЛЧОК ПОДЪЁМУ СЕЛЬСКОГО ХОЗЯЙСТВА".translit!.
56
- should == "SHIROKAYA ELEKTRIFIKATSIYA YUZHNYKH GUBERNIJ DAST MOSHCHNYJ TOLCHOK POD\"EMU SEL'SKOGO KHOZYAJSTVA"
57
- end
58
- end
59
-
60
- end
1
+ # encoding: UTF-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+
5
+ module MyScriptsTest
6
+ module A
7
+ class B
8
+ class C
9
+ end
10
+ end
11
+ end
12
+
13
+ describe String do
14
+ context '#snake_case' do
15
+ it 'transforms CamelCase strings' do
16
+ 'GetCharWidth32'.snake_case.should == 'get_char_width_32'
17
+ end
18
+
19
+ it 'leaves snake_case strings intact' do
20
+ 'keybd_event'.snake_case.should == 'keybd_event'
21
+ end
22
+ end
23
+
24
+ context '#camel_case' do
25
+ it 'transforms underscore strings to CamelCase' do
26
+ 'get_char_width_32'.camel_case.should == 'GetCharWidth32'
27
+ end
28
+
29
+ it 'leaves CamelCase strings intact' do
30
+ 'GetCharWidth32'.camel_case.should == 'GetCharWidth32'
31
+ end
32
+ end
33
+
34
+ context '#to_class' do
35
+ it 'converts string into appropriate Class constant' do
36
+ "Fixnum".to_class.should == Fixnum
37
+ "MyScriptsTest::A::B::C".to_class.should == MyScriptsTest::A::B::C
38
+ end
39
+
40
+ it 'returns nil if string is not convertible into class' do
41
+ "Math".to_class.should == nil
42
+ "Math::PI".to_class.should == nil
43
+ "Something".to_class.should == nil
44
+ end
45
+
46
+ it 'deals with leading colons' do
47
+ "::MyScriptsTest::A::B::C".to_class.should == MyScriptsTest::A::B::C
48
+ end
49
+ end
50
+
51
+ context '#translit!' do
52
+ it 'converts string from Cyrillic to Latin translit' do
53
+ "Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства".translit!.
54
+ should == "SHirokaya elektrifikatsiya yuzhnykh gubernij dast moshchnyj tolchok pod\"emu sel'skogo khozyajstva"
55
+ "ШИРОКАЯ ЭЛЕКТРИФИКАЦИЯ ЮЖНЫХ ГУБЕРНИЙ ДАСТ МОЩНЫЙ ТОЛЧОК ПОДЪЁМУ СЕЛЬСКОГО ХОЗЯЙСТВА".translit!.
56
+ should == "SHIROKAYA ELEKTRIFIKATSIYA YUZHNYKH GUBERNIJ DAST MOSHCHNYJ TOLCHOK POD\"EMU SEL'SKOGO KHOZYAJSTVA"
57
+ end
58
+ end
59
+
60
+ end
61
61
  end
@@ -1,82 +1,82 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
-
3
- module MyScriptsTest
4
-
5
- # creates new CLI object with mock stdin and stdout,
6
- # stdin optionally preloaded with fake user input
7
- def create_cli( opts={} )
8
- @stdout = options[:stdout] || mock('stdout').as_null_object
9
- @stdin = options[:stdin] || mock('stdin')
10
- @stdin.stub(:gets).and_return(*options[:input]) if options[:input]
11
- @cli = MyScripts::CLI.new @stdin, @stdout
12
- end
13
-
14
- # sets expectation for stdout to receive strictly ordered sequence of exact messages
15
- def stdout_should_receive(*messages)
16
- messages.each do |message|
17
- @stdout.should_receive(:puts).with(message).once.ordered
18
- end
19
- end
20
-
21
- # sets expectation for stdout to receive message(s) containing all of the patterns (unordered)
22
- def stdout_should_include(*patterns)
23
- patterns.each do |pattern|
24
- re = Regexp === pattern ? pattern : Regexp.new(Regexp.escape(pattern))
25
- @stdout.should_receive(:puts).with(re).at_least(:once)
26
- end
27
- end
28
-
29
- describe 'Script Execution' do
30
-
31
- context 'trying to execute undefined script' do
32
- it 'fails' do
33
- cli = create_cli
34
- proc{cli.run( :undefined, [])}.should raise_error "Script MyScripts::Undefined not found"
35
- end
36
- end
37
-
38
- context 'executing pre-defined scripts' do
39
- MyScripts.module_eval "
40
- # Stub script that just puts 'OK' to stdout
41
- class Scriptest < Script
42
- def run
43
- puts 'OK'
44
- 1
45
- end
46
- end"
47
-
48
- it 'executes pre-defined script without args' do
49
- cli = create_cli
50
- stdout_should_receive('OK')
51
- cli.run( :scriptest, [])
52
- end
53
-
54
- it 'executes pre-defined script with args' do
55
- cli = create_cli
56
- stdout_should_receive('OK')
57
- cli.run( :scriptest, [1, 2, 3, :four, 'five'])
58
- end
59
-
60
- it 'returns return value of Script#run() when running pre-defined script' do
61
- cli = create_cli
62
- cli.run( :scriptest, []).should == 1
63
- end
64
- end
65
-
66
- context 'executing scripts with snake_case names' do
67
- MyScripts.module_eval "
68
- # Stub script that just puts 'OK' to stdout
69
- class SnakeScript < Script
70
- def run
71
- puts 'OK'
72
- end
73
- end"
74
-
75
- it 'executes scripts with snake_case name' do
76
- cli = create_cli
77
- stdout_should_receive('OK')
78
- cli.run( :snake_script, [])
79
- end
80
- end
81
- end
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
+
3
+ module MyScriptsTest
4
+
5
+ # creates new CLI object with mock stdin and stdout,
6
+ # stdin optionally preloaded with fake user input
7
+ def create_cli( opts={} )
8
+ @stdout = options[:stdout] || mock('stdout').as_null_object
9
+ @stdin = options[:stdin] || mock('stdin')
10
+ @stdin.stub(:gets).and_return(*options[:input]) if options[:input]
11
+ @cli = MyScripts::CLI.new @stdin, @stdout
12
+ end
13
+
14
+ # sets expectation for stdout to receive strictly ordered sequence of exact messages
15
+ def stdout_should_receive(*messages)
16
+ messages.each do |message|
17
+ @stdout.should_receive(:puts).with(message).once.ordered
18
+ end
19
+ end
20
+
21
+ # sets expectation for stdout to receive message(s) containing all of the patterns (unordered)
22
+ def stdout_should_include(*patterns)
23
+ patterns.each do |pattern|
24
+ re = Regexp === pattern ? pattern : Regexp.new(Regexp.escape(pattern))
25
+ @stdout.should_receive(:puts).with(re).at_least(:once)
26
+ end
27
+ end
28
+
29
+ describe 'Script Execution' do
30
+
31
+ context 'trying to execute undefined script' do
32
+ it 'fails' do
33
+ cli = create_cli
34
+ proc{cli.run( :undefined, [])}.should raise_error "Script MyScripts::Undefined not found"
35
+ end
36
+ end
37
+
38
+ context 'executing pre-defined scripts' do
39
+ MyScripts.module_eval "
40
+ # Stub script that just puts 'OK' to stdout
41
+ class Scriptest < Script
42
+ def run
43
+ puts 'OK'
44
+ 1
45
+ end
46
+ end"
47
+
48
+ it 'executes pre-defined script without args' do
49
+ cli = create_cli
50
+ stdout_should_receive('OK')
51
+ cli.run :scriptest, []
52
+ end
53
+
54
+ it 'executes pre-defined script with args' do
55
+ cli = create_cli
56
+ stdout_should_receive('OK')
57
+ cli.run :scriptest, [1, 2, 3, :four, 'five']
58
+ end
59
+
60
+ it 'returns return value of Script#run() when running pre-defined script' do
61
+ cli = create_cli
62
+ cli.run( :scriptest, []).should == 1
63
+ end
64
+ end
65
+
66
+ context 'executing scripts with snake_case names' do
67
+ MyScripts.module_eval "
68
+ # Stub script that just puts 'OK' to stdout
69
+ class SnakeScript < Script
70
+ def run
71
+ puts 'OK'
72
+ end
73
+ end"
74
+
75
+ it 'executes scripts with snake_case name' do
76
+ cli = create_cli
77
+ stdout_should_receive('OK')
78
+ cli.run :snake_script, []
79
+ end
80
+ end
81
+ end
82
82
  end
data/spec/spec.opts CHANGED
@@ -1,2 +1,2 @@
1
- --color
1
+ --color
2
2
  --format nested
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,9 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib my_scripts]))
4
- require 'spec'
5
- require 'spec/autorun'
6
-
7
- Spec::Runner.configure do |config|
8
-
9
- end
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib my_scripts]))
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_scripts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 17
9
+ version: 0.0.17
5
10
  platform: ruby
6
11
  authors:
7
12
  - arvicco
@@ -9,29 +14,35 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-03-11 00:00:00 +03:00
17
+ date: 2010-04-08 00:00:00 +04:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rspec
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 9
23
31
  version: 1.2.9
24
- version:
32
+ type: :development
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: cucumber
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
33
43
  version: "0"
34
- version:
44
+ type: :development
45
+ version_requirements: *id002
35
46
  description: Simple framework for writing command-line scripts and collection of my own scripts (mostly dev-related)
36
47
  email: arvitallian@gmail.com
37
48
  executables:
@@ -40,7 +51,9 @@ executables:
40
51
  - gitto
41
52
  - jew
42
53
  - mybones
54
+ - newscript
43
55
  - rabbit
56
+ - wake
44
57
  extensions: []
45
58
 
46
59
  extra_rdoc_files:
@@ -58,7 +71,9 @@ files:
58
71
  - bin/gitto
59
72
  - bin/jew
60
73
  - bin/mybones
74
+ - bin/newscript
61
75
  - bin/rabbit
76
+ - bin/wake
62
77
  - features/my_scripts.feature
63
78
  - features/step_definitions/my_scripts_steps.rb
64
79
  - features/support/env.rb
@@ -72,6 +87,7 @@ files:
72
87
  - lib/my_scripts/mybones.rb
73
88
  - lib/my_scripts/rabbit.rb
74
89
  - lib/my_scripts/script.rb
90
+ - lib/my_scripts/wake.rb
75
91
  - my_scripts.gemspec
76
92
  - spec/my_scripts/extensions_spec.rb
77
93
  - spec/my_scripts_spec.rb
@@ -90,18 +106,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
106
  requirements:
91
107
  - - ">="
92
108
  - !ruby/object:Gem::Version
109
+ segments:
110
+ - 0
93
111
  version: "0"
94
- version:
95
112
  required_rubygems_version: !ruby/object:Gem::Requirement
96
113
  requirements:
97
114
  - - ">="
98
115
  - !ruby/object:Gem::Version
116
+ segments:
117
+ - 0
99
118
  version: "0"
100
- version:
101
119
  requirements: []
102
120
 
103
121
  rubyforge_project:
104
- rubygems_version: 1.3.5
122
+ rubygems_version: 1.3.6
105
123
  signing_key:
106
124
  specification_version: 3
107
125
  summary: Simple framework for writing command-line scripts