valet 0.0.5 → 0.0.6

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/.travis.yml CHANGED
@@ -6,11 +6,6 @@ rvm:
6
6
  - rbx
7
7
  - jruby
8
8
 
9
- matrix:
10
- allow_failures:
11
- - rvm: rbx
12
- - rvm: jruby
13
-
14
9
  branches:
15
10
  only:
16
11
  - master
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Valet - CHANGELOG
2
2
 
3
+ ### 0.0.6 / 08.07.2012
4
+
5
+ * New GNU compliant feature: "Version"
6
+ * Basic Mustache views and templates integration
7
+ * Postponed Valet's own CLI in favor of creating a general API first
8
+ * Minor improvements to the development and testing environment
9
+ * Refactored features and step definitions
10
+ * New skeleton feature for next iteration: "Help"
11
+
3
12
  ### 0.0.5 / 06.07.2012
4
13
 
5
14
  * Allowed jruby and rbx to fail a build on Travis
data/Guardfile CHANGED
@@ -4,7 +4,8 @@ guard 'rspec', all_on_start: false, all_after_pass: false do
4
4
  watch('spec/spec_helper.rb') { 'spec' }
5
5
  end
6
6
 
7
- guard 'cucumber', all_on_start: false, all_after_pass: false do
7
+ guard 'cucumber', all_on_start: false, all_after_pass: false,
8
+ cli: '--format progress --color --strict --tags ~@wip' do
8
9
  watch(%r{features/.+\.feature$})
9
10
  watch(%r{^features/support/.+$}) { 'features' }
10
11
  watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
data/README.md CHANGED
@@ -7,8 +7,8 @@ __Git Repository__: <https://github.com/gitkeeper/valet>
7
7
  __Author__: Alexander Baumann
8
8
  __Copyright__: 2012
9
9
  __License__: MIT License
10
- __Latest Version__: 0.0.5
11
- __Release Date__: 06.07.2012
10
+ __Latest Version__: 0.0.6
11
+ __Release Date__: 08.07.2012
12
12
 
13
13
  ## Introduction
14
14
 
data/bin/valet CHANGED
@@ -1,5 +1 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- require 'valet/cli'
4
-
5
- Valet::CLI.start
@@ -0,0 +1,39 @@
1
+ @wip
2
+ Feature: Help (--help)
3
+
4
+ In order to get standard help on how to use the application
5
+ As a software developer and user of the application
6
+ I want to print out its usage with syntax, description, examples, available
7
+ global options and commands
8
+
9
+ Usage: ls [OPTION]... [FILE]...
10
+ List information about the FILEs (the current directory by default).
11
+ Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
12
+
13
+ Mandatory arguments to long options are mandatory for short options too.
14
+ -a, --all do not ignore entries starting with .
15
+ -A, --almost-all do not list implied . and ..
16
+ --author with -l, print the author of each file
17
+ -b, --escape print C-style escapes for nongraphic characters
18
+ --block-size=SIZE scale sizes by SIZE before printing them. E.g.,
19
+ '--block-size=M' prints sizes in units of
20
+ 1,048,576 bytes. See SIZE format below.
21
+
22
+ (...)
23
+
24
+ Report ls bugs to bug-coreutils@gnu.org
25
+ GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
26
+ General help using GNU software: <http://www.gnu.org/gethelp/>
27
+ For complete documentation, run: info coreutils 'ls invocation'
28
+
29
+ GNU Coding Standards:
30
+ http://www.gnu.org/prep/standards/standards.html#g_t_002d_002dhelp
31
+
32
+ Scenario: Usage and syntax reference
33
+ Scenario: Short description about the application's purpose
34
+ Scenario: List of examples
35
+ Scenario: Available global options
36
+ Scenario: Available sub-commands
37
+ Scenario: Bug reporting address
38
+ Scenario: Application homepage
39
+ Scenario: Other commands, options and operands are ignored
@@ -0,0 +1,3 @@
1
+ When /^I successfully run the script `([^`]*)`$/ do |script|
2
+ run_simple("ruby -S #{unescape(script)}")
3
+ end
@@ -0,0 +1,3 @@
1
+ Given /^a Valet application named "([^"]*)" with:$/ do |file_name, file_content|
2
+ write_file(file_name, new_cli(file_content).source)
3
+ end
@@ -0,0 +1,23 @@
1
+ module CLIHelper
2
+ class CLI
3
+ def initialize(content = nil)
4
+ @content = content
5
+ end
6
+
7
+ def source
8
+ <<-CLI_FILE.gsub(/^ {8}/, '')
9
+ require 'valet'
10
+
11
+ class CLI < Valet::Application
12
+ #{@content ? @content.gsub(/^/, ' ') : '# No content has been given'}
13
+ end
14
+
15
+ CLI.start
16
+ CLI_FILE
17
+ end
18
+ end
19
+
20
+ def new_cli(content = nil)
21
+ CLI.new(content)
22
+ end
23
+ end
@@ -0,0 +1 @@
1
+ World(CLIHelper)
@@ -1,32 +1,118 @@
1
- Feature: Version
1
+ Feature: Version (--version)
2
2
 
3
- In order to check Valet's version and legal information
4
- As a software developer
3
+ In order to check an application's version and legal information
4
+ As a software developer and user of the application
5
5
  I want to print out its version summary
6
6
 
7
- A version summary may look like this:
7
+ A complete version summary may look like this:
8
8
 
9
9
  Valet 1.2.3
10
10
  Copyright (c) 2012 Alexander Baumann
11
11
  License: <http://www.opensource.org/licenses/MIT> MIT License
12
12
 
13
+ Written by Alexander Baumann
14
+
13
15
  GNU Coding Standards:
14
16
  http://www.gnu.org/prep/standards/standards.html#g_t_002d_002dversion
15
17
 
16
- Scenario: Print out version summary
17
- When I successfully run `valet --version`
18
- Then the output should match:
18
+ Scenario: Print out application name
19
+ Given a Valet application named "name.rb" with:
19
20
  """
20
- Valet \d+\.\d+\.\d+(\.rc\d+)?
21
- Copyright \(c\) \d{4}(-\d{4})? Alexander Baumann
22
- License: <http://www\.opensource\.org/licenses/MIT> MIT License
21
+ self.name = 'Backup'
23
22
  """
23
+ When I successfully run the script `name.rb --version`
24
+ Then the stdout should contain "Backup"
24
25
 
25
- Scenario: Other commands, options and operands are ignored
26
- When I successfully run `valet command --option operand --version`
27
- Then the output should match:
26
+ Scenario: Print out application name and version
27
+ Given a Valet application named "name_and_version.rb" with:
28
+ """
29
+ self.name = 'Backup'
30
+ self.version = '1.2.3'
31
+ """
32
+ When I successfully run the script `name_and_version.rb --version`
33
+ Then the stdout should contain "Backup 1.2.3"
34
+
35
+ Scenario: Print out authors
36
+ Given a Valet application named "authors.rb" with:
37
+ """
38
+ self.authors = ['Alexander Baumann', 'Bob the Builder']
39
+ """
40
+ When I successfully run the script `authors.rb --version`
41
+ Then the stdout should contain:
42
+ """
43
+ Written by Alexander Baumann, Bob the Builder
44
+ """
45
+
46
+ Scenario: Print out copyright notice
47
+ Given a Valet application named "copyright.rb" with:
48
+ """
49
+ self.copyright = 'Copyright (c) 2012 Free Software Foundation, Inc.'
50
+ """
51
+ When I successfully run the script `copyright.rb --version`
52
+ Then the stdout should contain:
53
+ """
54
+ Copyright (c) 2012 Free Software Foundation, Inc.
55
+ """
56
+
57
+ Scenario: Print out legal status
58
+ Given a Valet application named "legal_status.rb" with:
59
+ """
60
+ self.license = <<-LICENSE.gsub(/^ {4}/, '').strip
61
+ License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
62
+ This is free software: You are free to change and redistribute it.
63
+ There is NO WARRANTY, to the extent permitted by law.
64
+ LICENSE
28
65
  """
29
- Valet \d+\.\d+\.\d+(\.rc\d+)?
30
- Copyright \(c\) \d{4}(-\d{4})? Alexander Baumann
31
- License: <http://www\.opensource\.org/licenses/MIT> MIT License
66
+ When I successfully run the script `legal_status.rb --version`
67
+ Then the stdout should contain:
32
68
  """
69
+ License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
70
+ This is free software: You are free to change and redistribute it.
71
+ There is NO WARRANTY, to the extent permitted by law.
72
+ """
73
+
74
+ Scenario: Print out the complete version summary
75
+ Given a Valet application named "version.rb" with:
76
+ """
77
+ self.name = 'Backup'
78
+ self.version = '1.2.3'
79
+ self.authors = ['Alexander Baumann', 'Bob the Builder']
80
+ self.copyright = 'Copyright (c) 2012 Free Software Foundation, Inc.'
81
+ self.license = <<-LICENSE.gsub(/^ {4}/, '').strip
82
+ License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
83
+ This is free software: You are free to change and redistribute it.
84
+ There is NO WARRANTY, to the extent permitted by law.
85
+ LICENSE
86
+ """
87
+ When I successfully run the script `version.rb --version`
88
+ Then the stdout should contain:
89
+ """
90
+ Backup 1.2.3
91
+ Copyright (c) 2012 Free Software Foundation, Inc.
92
+ License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
93
+ This is free software: You are free to change and redistribute it.
94
+ There is NO WARRANTY, to the extent permitted by law.
95
+
96
+ Written by Alexander Baumann, Bob the Builder
97
+ """
98
+
99
+ Scenario: Customizable/Overridable version summary template
100
+ Given a file named "templates/version.mustache" with:
101
+ """
102
+ {{name}} {{version}}
103
+ For more information, please visit http://gitkeeper.github.com/valet
104
+ """
105
+ And a Valet application named "custom_version_template.rb" with:
106
+ """
107
+ self.name = 'Backup'
108
+ self.version = '1.2.3'
109
+ """
110
+ When I successfully run the script `custom_version_template.rb --version`
111
+ Then the stdout should contain:
112
+ """
113
+ Backup 1.2.3
114
+ For more information, please visit http://gitkeeper.github.com/valet
115
+ """
116
+
117
+ @wip
118
+ Scenario: Other commands, options and operands are ignored
data/lib/valet.rb CHANGED
@@ -21,5 +21,9 @@
21
21
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
22
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
 
24
+ require 'mustache'
25
+
24
26
  require 'valet/version'
25
27
  require 'valet/application'
28
+ require 'valet/view'
29
+ require 'valet/views/version'
@@ -1,11 +1,22 @@
1
1
  module Valet
2
- module Application
3
- attr_accessor :name, :version, :copyright, :license
2
+ class Application
3
+ class << self
4
+ attr_accessor :name, :version, :authors, :copyright, :license
4
5
 
5
- def start
6
- puts "#{name} #{version}"
7
- puts "#{copyright}"
8
- puts "#{license}"
6
+ def start(args = ARGV)
7
+ new(args)
8
+ end
9
+ end
10
+
11
+ attr_reader :args
12
+
13
+ def initialize(args)
14
+ @args = args
15
+ render_version
16
+ end
17
+
18
+ def render_version
19
+ puts Views::Version.new(self.class).render.strip
9
20
  end
10
21
  end
11
22
  end
@@ -0,0 +1,5 @@
1
+ {{name}} {{version}}
2
+ {{copyright}}
3
+ {{license}}
4
+
5
+ {{authors}}
data/lib/valet/version.rb CHANGED
@@ -2,7 +2,7 @@ module Valet
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- BUILD = 5
5
+ BUILD = 6
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, BUILD, PRE].compact.join('.')
data/lib/valet/view.rb ADDED
@@ -0,0 +1,29 @@
1
+ module Valet
2
+ class View < Mustache
3
+ self.view_namespace = 'Valet::Views'
4
+ self.template_path = 'templates'
5
+
6
+ def render
7
+ fall_back_to_valet unless template_exists?
8
+ super
9
+ end
10
+
11
+ def escapeHTML(string)
12
+ string
13
+ end
14
+
15
+ private
16
+
17
+ def fall_back_to_valet
18
+ self.template_path = valet_template_path
19
+ end
20
+
21
+ def valet_template_path
22
+ File.expand_path('../templates', __FILE__)
23
+ end
24
+
25
+ def template_exists?
26
+ File.exists?(template_file)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,31 @@
1
+ module Valet
2
+ module Views
3
+ class Version < View
4
+ def initialize(application)
5
+ @app = application
6
+ end
7
+
8
+ def name
9
+ @app.name
10
+ end
11
+
12
+ def version
13
+ @app.version
14
+ end
15
+
16
+ def copyright
17
+ @app.copyright
18
+ end
19
+
20
+ def license
21
+ @app.license
22
+ end
23
+
24
+ def authors
25
+ if @app.authors.respond_to?(:join) && @app.authors.count > 0
26
+ "Written by #{@app.authors.join(', ')}"
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
data/spec/spec_helper.rb CHANGED
@@ -13,11 +13,16 @@ Dir[File.expand_path('spec/support/**/*.rb')].each { |file| require file }
13
13
 
14
14
  # Load the application
15
15
  require 'valet'
16
- require 'valet/cli'
17
-
18
- # Include the application
19
16
  include Valet
20
17
 
18
+ # Capture STDOUT and STDIN in new IO streams
19
+ require 'stringio'
20
+ $stdout = StringIO.new
21
+ $stderr = StringIO.new
22
+
23
+ # Reset ARGV to contain no arguments
24
+ ARGV.clear
25
+
21
26
  # Configure RSpec
22
27
  RSpec.configure do |config|
23
28
  config.treat_symbols_as_metadata_keys_with_true_values = true
@@ -1,29 +1,52 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Valet::Application do
4
- let(:app) { Class.new.extend(Valet::Application) }
4
+ let(:app) { Application.new }
5
5
 
6
- it "has a name" do
7
- app.name = 'Backup'
8
- app.name.should == 'Backup'
9
- end
6
+ describe "class attributes" do
7
+ it "can have a name" do
8
+ Application.name = 'Backup'
9
+ Application.name.should == 'Backup'
10
+ end
10
11
 
11
- it "can a version" do
12
- app.version = '1.2.3'
13
- app.version.should == '1.2.3'
14
- end
12
+ it "can have a version" do
13
+ Application.version = '1.2.3'
14
+ Application.version.should == '1.2.3'
15
+ end
16
+
17
+ it "can have authors" do
18
+ Application.authors = ['Alexander Baumann', 'Bob the Builder']
19
+ Application.authors.should == ['Alexander Baumann', 'Bob the Builder']
20
+ end
15
21
 
16
- it "can have a copyright notice" do
17
- app.copyright = 'Copyright (c) 2007 Free Software Foundation, Inc.'
18
- app.copyright.should == 'Copyright (c) 2007 Free Software Foundation, Inc.'
22
+ it "can have a copyright notice" do
23
+ Application.copyright = 'Copyright (c) 2012 Free Software Foundation, Inc.'
24
+ Application.copyright.should == 'Copyright (c) 2012 Free Software Foundation, Inc.'
25
+ end
26
+
27
+ it "can have a license" do
28
+ Application.license = <<-LICENSE.gsub(/^ {6}/, '').strip
29
+ License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
30
+ This is free software: You are free to change and redistribute it.
31
+ There is NO WARRANTY, to the extent permitted by law.
32
+ LICENSE
33
+ Application.license.should include('GNU GPL version 3 or later')
34
+ end
19
35
  end
20
36
 
21
- it "can have a license" do
22
- app.license = <<-LICENSE.gsub(/^ {6}/, '')
23
- License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
24
- This is free software: You are free to change and redistribute it.
25
- There is NO WARRANTY, to the extent permitted by law.
26
- LICENSE
27
- app.license.should include('GNU GPL version 3 or later')
37
+ describe ".start" do
38
+ it "passes ARGV as arguments to it's new instance by default" do
39
+ app = Application.start
40
+ app.args.should == ARGV
41
+ end
42
+
43
+ it "can pass custom arguments to it's new instance" do
44
+ app = Application.start(%w( --custom arguments ))
45
+ app.args.should == %w( --custom arguments )
46
+ end
47
+
48
+ it "returns the new application" do
49
+ Application.start.should be_an_instance_of(Application)
50
+ end
28
51
  end
29
52
  end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Valet::View do
4
+ let(:view) { View.new }
5
+ let(:mustache) { double("Mustache") }
6
+
7
+ describe "#render" do
8
+ it "creates a new Mustache object and renders it" do
9
+ Mustache.stub(new: mustache)
10
+ mustache.stub(render: 'Render output!')
11
+ view.render.should == 'Render output!'
12
+ end
13
+ end
14
+
15
+ describe "#escapeHTML" do
16
+ it "overwrites Mustache's #escapeHTML to not escape at all" do
17
+ view.escapeHTML('<html>').should == '<html>'
18
+ end
19
+ end
20
+ end
data/valet.gemspec CHANGED
@@ -33,6 +33,8 @@ Gem::Specification.new do |gem|
33
33
  gem.test_files = gem.files.grep(%r{^(spec|features)/})
34
34
  gem.require_paths = ['lib']
35
35
 
36
+ gem.add_dependency 'mustache', '~> 0.99'
37
+
36
38
  gem.add_development_dependency 'rake', '~> 0.9'
37
39
  gem.add_development_dependency 'rspec', '~> 2.10'
38
40
  gem.add_development_dependency 'cucumber', '~> 1.2'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-06 00:00:00.000000000 Z
12
+ date: 2012-07-08 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mustache
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.99'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.99'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: rake
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -161,15 +177,23 @@ files:
161
177
  - README.md
162
178
  - Rakefile
163
179
  - bin/valet
180
+ - features/help.feature
181
+ - features/step_definitions/command_line_steps.rb
182
+ - features/step_definitions/file_steps.rb
164
183
  - features/support/env.rb
184
+ - features/support/helpers/cli_helper.rb
185
+ - features/support/world_extensions.rb
165
186
  - features/version.feature
166
187
  - lib/valet.rb
167
188
  - lib/valet/application.rb
168
- - lib/valet/cli.rb
189
+ - lib/valet/templates/version.mustache
169
190
  - lib/valet/version.rb
191
+ - lib/valet/view.rb
192
+ - lib/valet/views/version.rb
170
193
  - spec/spec_helper.rb
171
194
  - spec/valet/application_spec.rb
172
195
  - spec/valet/version_spec.rb
196
+ - spec/valet/view_spec.rb
173
197
  - tasks/clean.rake
174
198
  - tasks/cucumber.rake
175
199
  - tasks/spec.rake
@@ -179,7 +203,7 @@ homepage: http://gitkeeper.github.com/valet
179
203
  licenses:
180
204
  - MIT
181
205
  post_install_message: ! "\n# --------------------------------------------------------------------
182
- #\n\n Thank you for installing Valet 0.0.5!\n\n Valet is still in development
206
+ #\n\n Thank you for installing Valet 0.0.6!\n\n Valet is still in development
183
207
  and not yet intended to be used.\n\n# --------------------------------------------------------------------
184
208
  #\n\n"
185
209
  rdoc_options: []
@@ -193,7 +217,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
217
  version: '0'
194
218
  segments:
195
219
  - 0
196
- hash: -599914499916021276
220
+ hash: 2757034433655035454
197
221
  required_rubygems_version: !ruby/object:Gem::Requirement
198
222
  none: false
199
223
  requirements:
@@ -202,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
226
  version: '0'
203
227
  segments:
204
228
  - 0
205
- hash: -599914499916021276
229
+ hash: 2757034433655035454
206
230
  requirements: []
207
231
  rubyforge_project:
208
232
  rubygems_version: 1.8.24
@@ -210,9 +234,15 @@ signing_key:
210
234
  specification_version: 3
211
235
  summary: A framework for creating GNU compliant command-line interfaces.
212
236
  test_files:
237
+ - features/help.feature
238
+ - features/step_definitions/command_line_steps.rb
239
+ - features/step_definitions/file_steps.rb
213
240
  - features/support/env.rb
241
+ - features/support/helpers/cli_helper.rb
242
+ - features/support/world_extensions.rb
214
243
  - features/version.feature
215
244
  - spec/spec_helper.rb
216
245
  - spec/valet/application_spec.rb
217
246
  - spec/valet/version_spec.rb
247
+ - spec/valet/view_spec.rb
218
248
  has_rdoc:
data/lib/valet/cli.rb DELETED
@@ -1,12 +0,0 @@
1
- require 'valet'
2
-
3
- module Valet
4
- class CLI
5
- extend Valet::Application
6
-
7
- self.name = 'Valet'
8
- self.version = Valet::VERSION::STRING
9
- self.copyright = 'Copyright (c) 2012 Alexander Baumann'
10
- self.license = 'License: <http://www.opensource.org/licenses/MIT> MIT License'
11
- end
12
- end