rst 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ script: "bundle exec rake"
data/README.md CHANGED
@@ -1,8 +1,21 @@
1
1
  rst
2
2
  ---
3
3
 
4
+ [![Build Status](https://secure.travis-ci.org/clnclarinet/rst.png?branch=master)](http://travis-ci.org/clnclarinet/rst)
5
+
4
6
  A command line client for [rstat.us](http://rstat.us). Heavily influenced by [t](https://github.com/sferik/t).
5
7
 
8
+ Usage
9
+ -----
10
+
11
+ Install the gem:
12
+
13
+ gem install rst
14
+
15
+ Run with no arguments to see the help:
16
+
17
+ rst
18
+
6
19
  Current Functionality
7
20
  ---------------------
8
21
 
data/bin/rst CHANGED
@@ -1,51 +1,49 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- require 'optparse'
4
- require 'methadone'
5
- require 'rst'
6
-
7
- class App
8
- include Methadone::Main
9
- include Methadone::CLILogging
10
-
11
- main do |command|
12
- case command
13
- when "world"
14
- puts "\n"
15
- puts Rst::CLI.world.join("\n\n")
16
- else
17
- puts opts
2
+ # 1.9 adds realpath to resolve symlinks; 1.8 doesn't
3
+ # have this method, so we add it so we get resolved symlinks
4
+ # and compatibility
5
+ unless File.respond_to? :realpath
6
+ class File #:nodoc:
7
+ def self.realpath path
8
+ return realpath(File.readlink(path)) if symlink?(path)
9
+ path
18
10
  end
19
- exit 0
20
11
  end
12
+ end
13
+ $: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
14
+
15
+ require 'gli'
16
+ require 'rst'
21
17
 
22
- # supplemental methods here
18
+ include GLI
23
19
 
24
- # Declare command-line interface here
20
+ program_desc 'A command line interface for rstat.us'
25
21
 
26
- arg :command, :optional
22
+ version Rst::VERSION
27
23
 
28
- description "A command line interface for rstat.us"
24
+ desc 'Display the version and exit.'
25
+ switch [:v, :version]
29
26
 
30
- #
31
- # Accept flags via:
32
- # on("--flag VAL","Some flag")
33
- # options[flag] will contain VAL
34
- #
35
- # Specify switches via:
36
- # on("--[no-]switch","Some switch")
37
- #
38
- # Or, just call OptionParser methods on opts
39
- #
40
- # Require an argument
41
- # arg :some_arg
42
- #
43
- # # Make an argument optional
44
- # arg :optional_arg, :optional
27
+ desc 'Get the latest statuses from the whole rstat.us world'
28
+ command :world do |c|
29
+ c.action do |global_options, options, args|
30
+ puts Rst::CLI.world.join("\n\n")
31
+ end
32
+ end
45
33
 
46
- version Rst::VERSION
34
+ pre do |global, command, options, args|
35
+ if global[:v]
36
+ puts "version #{Rst::VERSION}"
37
+ exit! 0
38
+ end
39
+ true
40
+ end
47
41
 
48
- use_log_level_option
42
+ post do |global, command, options, args|
43
+ end
49
44
 
50
- go!
45
+ on_error do |exception|
46
+ true
51
47
  end
48
+
49
+ exit GLI.run(ARGV)
@@ -10,7 +10,7 @@ Feature: Help text
10
10
  And the banner should document that this app takes options
11
11
  And the following options should be documented:
12
12
  |--version|
13
- |--log-level|
13
+ |--help|
14
14
 
15
15
  Scenario: rst --help
16
16
  When I get help for "rst"
@@ -19,7 +19,8 @@ Feature: Help text
19
19
  And the banner should document that this app takes options
20
20
  And the following options should be documented:
21
21
  |--version|
22
+ |--help|
22
23
  And the output should contain:
23
24
  """
24
- Usage: rst [options] [command]
25
+ usage: rst [global options] command
25
26
  """
@@ -0,0 +1,56 @@
1
+ # Cucumber step definitions from
2
+ # http://github.com/davetron5000/methadone/blob/master/lib/methadone/cucumber.rb
3
+
4
+ When /^I get help for "([^"]*)"$/ do |app_name|
5
+ @app_name = app_name
6
+ step %(I run `#{app_name} --help`)
7
+ end
8
+
9
+ Then /^the following options should be documented:$/ do |options|
10
+ options.raw.each do |option|
11
+ step %(the option "#{option[0]}" should be documented)
12
+ end
13
+ end
14
+
15
+ Then /^the option "([^"]*)" should be documented$/ do |option|
16
+ step %(the output should match /\\s*#{Regexp.escape(option)}[\\s\\W]+\\w\\w\\w+/)
17
+ end
18
+
19
+ Then /^the banner should be present$/ do
20
+ step %(the output should match /usage: #{@app_name}/)
21
+ end
22
+
23
+ Then /^the banner should document that this app takes options$/ do
24
+ step %(the output should match /\[options\]/)
25
+ step %(the output should contain "Options")
26
+ end
27
+
28
+ Then /^the banner should document that this app's arguments are:$/ do |table|
29
+ expected_arguments = table.raw.map { |row|
30
+ option = row[0]
31
+ option = "[#{option}]" if row[1] == 'optional' || row[1] == 'which is optional'
32
+ option
33
+ }.join(' ')
34
+ step %(the output should contain "#{expected_arguments}")
35
+ end
36
+
37
+ Then /^the banner should document that this app takes no options$/ do
38
+ step %(the output should not contain "[options]")
39
+ step %(the output should not contain "Options")
40
+ end
41
+
42
+ Then /^the banner should document that this app takes no arguments$/ do
43
+ step %(the output should match /Usage: #{@app_name}\\s*\(\\[options\\]\)?$/)
44
+ end
45
+
46
+ Then /^the banner should include the version$/ do
47
+ step %(the output should match /v\\d+\\.\\d+\\.\\d+/)
48
+ end
49
+
50
+ Then /^there should be a one line summary of what the app does$/ do
51
+ output_lines = all_output.split(/\n/)
52
+ output_lines.should have_at_least(3).items
53
+ # [0] is our banner, which we've checked for
54
+ output_lines[1].should match(/^\s*$/)
55
+ output_lines[2].should match(/^\w\w+\s+\w\w+/)
56
+ end
@@ -1,4 +1,4 @@
1
- # Put your step definitions here
1
+ # Custom rst steps
2
2
 
3
3
  Then /^the output should contain (\d+) updates$/ do |num|
4
4
  num = num.to_i
@@ -1,5 +1,4 @@
1
1
  require 'aruba/cucumber'
2
- require 'methadone/cucumber'
3
2
 
4
3
  ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
5
4
  LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
@@ -1,3 +1,3 @@
1
1
  module Rst
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.add_development_dependency('rake','~> 0.9.2')
22
22
  gem.add_development_dependency('vcr', '~> 2.1.1')
23
23
 
24
- gem.add_dependency('methadone', '~> 1.2.0')
24
+ gem.add_dependency('gli', '~> 1.6.0')
25
25
  gem.add_dependency('typhoeus', '~> 0.3.3')
26
26
  gem.add_dependency('nokogiri', '~> 1.5.2')
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rst
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -108,13 +108,13 @@ dependencies:
108
108
  - !ruby/object:Gem::Version
109
109
  version: 2.1.1
110
110
  - !ruby/object:Gem::Dependency
111
- name: methadone
111
+ name: gli
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 1.2.0
117
+ version: 1.6.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: 1.2.0
125
+ version: 1.6.0
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: typhoeus
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -165,12 +165,14 @@ extra_rdoc_files: []
165
165
  files:
166
166
  - .gitignore
167
167
  - .rvmrc
168
+ - .travis.yml
168
169
  - Gemfile
169
170
  - LICENSE
170
171
  - README.md
171
172
  - Rakefile
172
173
  - bin/rst
173
174
  - features/help.feature
175
+ - features/step_definitions/methadone_steps.rb
174
176
  - features/step_definitions/rst_steps.rb
175
177
  - features/support/env.rb
176
178
  - features/world.feature
@@ -211,6 +213,7 @@ specification_version: 3
211
213
  summary: A command line client for rstat.us
212
214
  test_files:
213
215
  - features/help.feature
216
+ - features/step_definitions/methadone_steps.rb
214
217
  - features/step_definitions/rst_steps.rb
215
218
  - features/support/env.rb
216
219
  - features/world.feature