the_dude 0.0.2

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.
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe TheDude::Http do
4
+ describe '#initialize' do
5
+ context 'when a url is passed' do
6
+ it 'should start a visit to that url' do
7
+
8
+ end
9
+ end
10
+ end
11
+
12
+ describe '#url' do
13
+ it 'should be nil' do
14
+ TheDude::Http.new.url.should be_nil
15
+ end
16
+
17
+ context 'when a visit has been started' do
18
+ before :each do
19
+ @http = TheDude::Http.new
20
+ @http.visit 'http://example.org'
21
+ end
22
+
23
+ it 'should be the current url' do
24
+ @http.url.should == 'http://example.org'
25
+ end
26
+ end
27
+ end
28
+
29
+ describe '#source' do
30
+ context 'when there is a current url' do
31
+ before :each do
32
+ @url = 'https://www.google.co.uk'
33
+ @http = TheDude::Http.new @url
34
+ end
35
+
36
+ it 'should fetch the url and return the source' do
37
+ #@http.source.should == WEBMOCKS[@url]
38
+ end
39
+ end
40
+ end
41
+
42
+ describe '#visit' do
43
+ context 'when passed a url' do
44
+ it 'should set the url property' do
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe TheDude::Variable do
4
+ describe '#initialize' do
5
+ context 'when passed a symbol and a regexp' do
6
+ it 'should return a new instance of TheDude::Variable' do
7
+ TheDude::Variable.new :var1, /\S+/
8
+ end
9
+ end
10
+
11
+ describe '#register' do
12
+ before :each do
13
+ @var = TheDude::Variable.new :var1, /\S+/
14
+ @var.register
15
+ end
16
+
17
+ describe 'TheDude.variables' do
18
+ subject {TheDude.variables}
19
+ its(:length) {should == 1}
20
+ end
21
+
22
+ describe 'TheDude.variables[:var1]' do
23
+ subject {TheDude.variables[:var1]}
24
+ it {should be_kind_of TheDude::Variable}
25
+ its(:name) {should == :var1}
26
+ its(:pattern) {should == /\S+/}
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe TheDude do
4
+ describe '.ask' do
5
+ context 'when there is a matching regex question and proc command with params' do
6
+ before :each do
7
+ TheDude::Command.new /what is (\d+)\s*\+\s*(\d+)/, ->(v1, v2){ v1.to_i + v2.to_i }
8
+ end
9
+
10
+ describe 'the answer' do
11
+ subject {TheDude.ask 'what is 4 + 3'}
12
+
13
+ it {should == 7}
14
+ end
15
+ end
16
+ end
17
+
18
+ describe '.register_command' do
19
+ context 'when passed a command' do
20
+ it 'should add the command to the commands collection' do
21
+ @command = TheDude::Command.new 'hello', 'hello world'
22
+ TheDude.register_command @command
23
+
24
+ TheDude.commands.length.should == 1
25
+ TheDude.commands[/^hello$/].should == @command
26
+ end
27
+ end
28
+ end
29
+
30
+ describe '.register_variable' do
31
+ context 'when passed a variable' do
32
+ it 'should add the variable to the variables collection' do
33
+ @variable = TheDude::Variable.new :placeholder, /\S+/
34
+ TheDude.register_variable @variable
35
+
36
+ TheDude.variables.length.should == 1
37
+ TheDude.variables[:placeholder].should == @variable
38
+ end
39
+ end
40
+ end
41
+
42
+ describe '.reset' do
43
+ context 'when there are commands' do
44
+ before :each do
45
+ TheDude::Command.new 'hello', 'hello world'
46
+ end
47
+
48
+ it 'should empty the commands collection' do
49
+ TheDude.reset
50
+ TheDude.commands.should == {}
51
+ end
52
+ end
53
+ end
54
+
55
+ describe '.reset' do
56
+ context 'when there are variables' do
57
+ before :each do
58
+ @var = TheDude::Variable.new :placeholder, /\S+/
59
+ TheDude.register_variable @var
60
+ end
61
+
62
+ it 'should empty the variables collection' do
63
+ TheDude.reset
64
+ TheDude.variables.should == {}
65
+ end
66
+ end
67
+ end
68
+ end
data/the_dude.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # Ensure we require the local version and not one we might have installed already
2
+ require File.join([File.dirname(__FILE__),'lib','the_dude','version.rb'])
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = 'the_dude'
5
+ s.version = TheDude::VERSION
6
+ s.author = 'Adam Phillips'
7
+ s.email = 'adam@29ways.co.uk'
8
+ s.homepage = 'http://github.com/adamphillips/the_dude'
9
+ s.platform = Gem::Platform::RUBY
10
+ s.summary = 'The Dude helps chill out your command line life'
11
+ # Add your other files here if you make them
12
+ s.files = `git ls-files`.split("\n")
13
+ s.test_files = `git ls-files -- test/*`.split("\n")
14
+ s.require_paths << 'lib'
15
+ s.bindir = 'bin'
16
+ s.executables << 'dude'
17
+ s.add_development_dependency('rake')
18
+ s.add_development_dependency('rdoc')
19
+ s.add_development_dependency('aruba')
20
+ s.add_development_dependency('rspec')
21
+ s.add_development_dependency('fakeweb')
22
+ s.add_runtime_dependency('nokogiri')
23
+ s.add_runtime_dependency('hirb')
24
+ s.add_runtime_dependency('colored')
25
+ end
metadata ADDED
@@ -0,0 +1,212 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: the_dude
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Adam Phillips
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
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: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
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
+ - !ruby/object:Gem::Dependency
47
+ name: aruba
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: fakeweb
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: nokogiri
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: hirb
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: colored
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ description:
143
+ email: adam@29ways.co.uk
144
+ executables:
145
+ - dude
146
+ extensions: []
147
+ extra_rdoc_files: []
148
+ files:
149
+ - .gitignore
150
+ - .rspec
151
+ - .rvmrc
152
+ - Gemfile
153
+ - Gemfile.lock
154
+ - README.md
155
+ - Rakefile
156
+ - bin/dude
157
+ - features/basic.feature
158
+ - features/duderc.feature
159
+ - features/step_definitions/the_dude_steps.rb
160
+ - features/support/env.rb
161
+ - lib/the_dude.rb
162
+ - lib/the_dude/command.rb
163
+ - lib/the_dude/config.rb
164
+ - lib/the_dude/dsl.rb
165
+ - lib/the_dude/expression.rb
166
+ - lib/the_dude/http.rb
167
+ - lib/the_dude/setup.rb
168
+ - lib/the_dude/variable.rb
169
+ - lib/the_dude/version.rb
170
+ - spec/spec_helper.rb
171
+ - spec/support/webmocks.rb
172
+ - spec/support/webmocks/google2.html
173
+ - spec/the_dude/command_spec.rb
174
+ - spec/the_dude/config_spec.rb
175
+ - spec/the_dude/dsl_spec.rb
176
+ - spec/the_dude/expression_spec.rb
177
+ - spec/the_dude/http_spec.rb
178
+ - spec/the_dude/variable_spec.rb
179
+ - spec/the_dude_spec.rb
180
+ - the_dude.gemspec
181
+ homepage: http://github.com/adamphillips/the_dude
182
+ licenses: []
183
+ post_install_message:
184
+ rdoc_options: []
185
+ require_paths:
186
+ - lib
187
+ - lib
188
+ required_ruby_version: !ruby/object:Gem::Requirement
189
+ none: false
190
+ requirements:
191
+ - - ! '>='
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ segments:
195
+ - 0
196
+ hash: -1710943047893443555
197
+ required_rubygems_version: !ruby/object:Gem::Requirement
198
+ none: false
199
+ requirements:
200
+ - - ! '>='
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ segments:
204
+ - 0
205
+ hash: -1710943047893443555
206
+ requirements: []
207
+ rubyforge_project:
208
+ rubygems_version: 1.8.25
209
+ signing_key:
210
+ specification_version: 3
211
+ summary: The Dude helps chill out your command line life
212
+ test_files: []