cliqr 0.0.1 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64c9b1b3318e0cd2646101dbfc3cb974cd1d891d
4
- data.tar.gz: b4a65fe6d1b0140db0ea977f7451fedb6940c0e3
3
+ metadata.gz: 79c47830a838dbb29465c407eab7a17226ba1999
4
+ data.tar.gz: 7194f0d76b8f37fba854fbeae463e4ffd7cb1053
5
5
  SHA512:
6
- metadata.gz: 98f2dc57afa45411eefb719490b7f093ac8f257e4489a76f1954fcacd63d81f1578d20133558dcc0b812c78c09b986224f9226cfd26dbca18ad5e88a14b6b6a8
7
- data.tar.gz: 143079da7b58f455e98c15c7d65524005f8190455464a0861c87aaac4aa3966f14d1dd9d1771009d48c426ed9b97dea1cc7ef6d4da1fdb71c975b8670efcb181
6
+ metadata.gz: 14d192c7b142d1cf0183466b118c4a7090de49698c0aa8c2e99bbda36e7adba1cc1ea32ffd1a792a2c14133af73b2dc62425f66099d07a5c21f5515864b62cae
7
+ data.tar.gz: df85568578f3aedd565a82c6ba9e5a25fb3d2747d877dc8cc096bec11f435ab85834b08c430dd89de0501de55a7bfa6ad08ffd39cb0effc0dff46b6888ec81ff
data/CHANGELOG.md CHANGED
@@ -1,4 +1,32 @@
1
1
 
2
+ 0.0.2 / 2015-05-07
3
+ ==================
4
+
5
+ * add rake cleanup task
6
+ * adding rdoc rake task
7
+ * adding yard for checking documentation coverage
8
+ * use shields.io badges
9
+ * fix readme toc
10
+ * add codeclimate and coveralls badges to readme
11
+ * add coveralls for code coverage reporting
12
+ * load source code after starting codeclimate reporter
13
+ * add codeclimate code coverage report
14
+ * adding example to readme
15
+ * add travis CI build badge
16
+ * add build matrix to travis CI settings
17
+ * set ruby gem name
18
+ * set ruby version
19
+ * list files to document
20
+ * fix rake default task
21
+ * bring down bundler version to 1.6 for travis CI
22
+ * adding missing comment in version.rb
23
+ * enabling Travis CI build
24
+ * add test to test for non-nil config
25
+ * separate dsl methods in config class
26
+ * ignore auto-generated documentation
27
+ * add ability to provide a name for top level command
28
+ * adding gem badge to readme
29
+
2
30
  0.0.1 / 2015-04-29
3
31
  ==================
4
32
 
data/README.md CHANGED
@@ -1,12 +1,20 @@
1
- # Cliqr
1
+ # cliqr
2
+
3
+ [![Build](http://img.shields.io/travis-ci/anshulverma/cliqr.svg?style=flat-square)](https://travis-ci.org/anshulverma/cliqr)
4
+ [![Coverage](http://img.shields.io/codeclimate/coverage/github/anshulverma/cliqr.svg?style=flat-square)](https://codeclimate.com/github/anshulverma/cliqr)
5
+ [![Quality](http://img.shields.io/codeclimate/github/anshulverma/cliqr.svg?style=flat-square)](https://codeclimate.com/github/anshulverma/cliqr)
6
+ [![Dependencies](http://img.shields.io/gemnasium/anshulverma/cliqr.svg?style=flat-square)](https://gemnasium.com/anshulverma/cliqr)
7
+ [![Downloads](http://img.shields.io/gem/dtv/cliqr.svg?style=flat-square)](https://rubygems.org/gems/cliqr)
8
+ [![Version](http://img.shields.io/gem/v/cliqr.svg?style=flat-square)](https://rubygems.org/gems/cliqr)
2
9
 
3
10
  <!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc/generate-toc again -->
4
11
  **Table of Contents**
5
12
 
6
- - [Cliqr](#cliqr)
13
+ - [cliqr](#cliqr)
7
14
  - [Summary](#summary)
15
+ - [Examples](#examples)
16
+ - [Simple CLI app with basename and description](#simple-cli-app-with-basename-and-description)
8
17
  - [Installation](#installation)
9
- - [Usage](#usage)
10
18
  - [Contributing](#contributing)
11
19
 
12
20
  <!-- markdown-toc end -->
@@ -14,7 +22,35 @@
14
22
 
15
23
  ## Summary
16
24
 
17
- TODO: Write a gem description
25
+ `cliqr` is a lightweight framework and DSL to easily build a command
26
+ line application. Features include:
27
+
28
+ - Command Routing
29
+ - DSL for simple interface definition
30
+ - Usage info generation
31
+ - Error handling
32
+
33
+ ## Examples
34
+
35
+ The DSL provides several helper methods to build interfaces of different
36
+ styles. Here are some examples.
37
+
38
+ ### Simple CLI app with basename and description
39
+
40
+ Here is a simple hello-world example for using Cliqr.
41
+
42
+ ``` ruby
43
+ cli = Cliqr.interface do
44
+ basename 'my-command'
45
+ end
46
+ puts cli.usage
47
+ ```
48
+
49
+ This should print
50
+
51
+ ```
52
+ USAGE: my-command
53
+ ```
18
54
 
19
55
  ## Installation
20
56
 
@@ -32,10 +68,6 @@ Or install it yourself as:
32
68
 
33
69
  $ gem install cliqr
34
70
 
35
- ## Usage
36
-
37
- TODO: Write usage instructions here
38
-
39
71
  ## Contributing
40
72
 
41
73
  1. Fork it ( https://github.com/anshulverma/cliqr/fork )
data/Rakefile CHANGED
@@ -1,2 +1,27 @@
1
1
  require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rake/clean'
2
4
 
5
+ RSpec::Core::RakeTask.new(:spec) do |spec|
6
+ spec.pattern = FileList['spec/**/*_spec.rb']
7
+ end
8
+
9
+ FileList['tasks/*.rake'].each(&method(:import))
10
+
11
+ desc 'default rake task'
12
+ task default: [:clean, :spec, :verify_measurements, :yardstick_measure]
13
+
14
+ desc 'run CI tasks'
15
+ task ci: [:default]
16
+
17
+ desc 'Load gem inside irb console'
18
+ task :console do
19
+ require 'irb'
20
+ require 'irb/completion'
21
+ require File.join(__FILE__, '../lib/cliqr')
22
+ ARGV.clear
23
+ IRB.start
24
+ end
25
+
26
+ # temporary files for cleanup
27
+ CLEAN.include('coverage')
data/lib/cliqr.rb CHANGED
@@ -1,6 +1,21 @@
1
1
  require 'cliqr/version'
2
- require 'cliqr/dsl/cli'
2
+ require 'cliqr/error'
3
3
 
4
+ require 'cliqr/cli/config'
5
+ require 'cliqr/cli/builder'
6
+
7
+ # Top level namespace for the Cliqr gem
4
8
  module Cliqr
5
- # Your code goes here...
9
+ class << self
10
+ # Invokes the CLI::Config builder DSL to prepare config for command line
11
+ # application. Then uses that config to build a instance of type Cliqr::CLI
12
+ #
13
+ # @return [Cliqr::CLI]
14
+ #
15
+ # @api public
16
+ def interface(&block)
17
+ config = CLI::Config.build(&block)
18
+ CLI::Builder.new(config)
19
+ end
20
+ end
6
21
  end
@@ -0,0 +1,31 @@
1
+ require 'cliqr/cli/validator'
2
+
3
+ module Cliqr
4
+ module CLI
5
+ # Builds usage information from [CLI::Config]
6
+ class Builder
7
+ # Start building a command line interface
8
+ #
9
+ # @param [Hash] config
10
+ # the configuration options for the interface (validated using
11
+ # CLI::Validator)
12
+ #
13
+ # @return [Cliqr::CLI::Builder]
14
+ def initialize(config)
15
+ CLI::Validator.validate config
16
+ @basename = config[:basename]
17
+ end
18
+
19
+ # Get usage information of this command line interface instance
20
+ #
21
+ # @return [String]
22
+ #
23
+ # @api public
24
+ def usage
25
+ <<-EOS
26
+ USAGE: #{@basename}
27
+ EOS
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,47 @@
1
+ require 'cliqr/dsl'
2
+
3
+ module Cliqr
4
+ module CLI
5
+ # The configuration setting to build a cli application with its own dsl
6
+ class Config
7
+ extend Cliqr::DSL
8
+
9
+ def initialize
10
+ @config = {}
11
+ end
12
+
13
+ # Set value for a config option
14
+ #
15
+ # @param name
16
+ # name of the config parameter
17
+ #
18
+ # @param value
19
+ # value for the config parameter
20
+ #
21
+ # @return [String] value that was set for the parameter
22
+ def set_config(name, value)
23
+ @config[name.to_sym] = value
24
+ end
25
+
26
+ # Finalize config by adding default values for unset values.
27
+ #
28
+ # @return [Hash]
29
+ def finalize
30
+ {
31
+ basename: ''
32
+ }.merge(@config)
33
+ end
34
+
35
+ # dsl methods
36
+ dsl do
37
+ # Set basename for the command line interface
38
+ #
39
+ # @param [String] basename
40
+ # name of the top level command
41
+ def basename(basename)
42
+ set_config :basename, basename
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,12 @@
1
+ require 'cliqr/error'
2
+
3
+ module Cliqr
4
+ module CLI
5
+ # Validator for the command line interface configuration
6
+ class Validator
7
+ def self.validate(config)
8
+ fail Cliqr::Error::ConfigNotFound, 'config is nil' if config.nil?
9
+ end
10
+ end
11
+ end
12
+ end
data/lib/cliqr/dsl.rb ADDED
@@ -0,0 +1,59 @@
1
+ require 'delegate'
2
+
3
+ module Cliqr
4
+ # Used to separate all dsl methods in a separate block, thus allowing
5
+ # separation of concerns between non-dsl methods with dsl methods which
6
+ # improves maintainability.
7
+ module DSL
8
+ # Entry point for invoking dsl methods
9
+ #
10
+ # @param args Arguments to be used to build the DSL instance
11
+ #
12
+ # @param block The block to evaluate the DSL
13
+ #
14
+ # @return [Cliqr::DSL]
15
+ def build(*args, &block)
16
+ base = new(*args)
17
+ if block_given?
18
+ delegator_klass = const_get('DSLDelegator')
19
+ delegator = delegator_klass.new(base)
20
+ delegator.instance_eval(&block)
21
+ end
22
+ base.finalize
23
+ end
24
+
25
+ # Delegates all DSL methods to the base class. Can be used to keep DSL
26
+ # methods separate from non-dsl methods.
27
+ #
28
+ # @param block Block containing all dsl methods
29
+ #
30
+ # Allows separating dsl methods as:
31
+ #
32
+ # class MyDSLClass
33
+ # extends Cliqr::DSL
34
+ #
35
+ # def set_value(value)
36
+ # @value = value
37
+ # end
38
+ #
39
+ # # ... other non-dsl methods ...
40
+ #
41
+ # dsl do
42
+ # def value(value)
43
+ # set_value value
44
+ # end
45
+ # end
46
+ #
47
+ # end
48
+ #
49
+ # This will be invoked as:
50
+ #
51
+ # MyDSLClass.build do
52
+ # value 'some-value'
53
+ # end
54
+ def dsl(&block)
55
+ delegator_klass = Class.new(SimpleDelegator, &block)
56
+ const_set('DSLDelegator', delegator_klass)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,5 @@
1
+ module Cliqr
2
+ module Error
3
+ class ConfigNotFound < StandardError; end
4
+ end
5
+ end
data/lib/cliqr/version.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # Versioned gem
1
2
  module Cliqr
2
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
3
4
  end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cliqr::CLI::Builder do
4
+ it 'does not allow empty config' do
5
+ expect { Cliqr::CLI::Builder.new(nil) }.to raise_error(Cliqr::Error::ConfigNotFound)
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cliqr do
4
+ it 'builds a base command with name' do
5
+ cli = Cliqr.interface do
6
+ basename 'tinbox'
7
+ end
8
+
9
+ expect(cli.usage).to eq <<-EOS
10
+ USAGE: tinbox
11
+ EOS
12
+ end
13
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,14 @@
1
+ # enable code climate
2
+ require 'codeclimate-test-reporter'
3
+ CodeClimate::TestReporter.configure do |config|
4
+ config.logger.level = Logger::WARN
5
+ end
6
+ CodeClimate::TestReporter.start
7
+
8
+ # enable coveralls
9
+ require 'coveralls'
10
+ Coveralls.wear!
11
+
1
12
  require 'bundler/setup'
2
13
  Bundler.setup
3
14
 
@@ -5,7 +16,6 @@ require 'cliqr'
5
16
 
6
17
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
18
  RSpec.configure do |config|
8
-
9
19
  config.expect_with :rspec do |expectations|
10
20
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
11
21
  end
metadata CHANGED
@@ -1,71 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cliqr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anshul Verma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-30 00:00:00.000000000 Z
11
+ date: 2015-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: log4r
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '1.7'
33
+ version: '1.6'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '1.7'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '10.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '10.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '3.2'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '3.2'
40
+ version: '1.6'
69
41
  description: |2
70
42
  Allows you to easily define the interface for a CLI app
71
43
  using an easy to use DSL.
@@ -78,19 +50,19 @@ executables: []
78
50
  extensions: []
79
51
  extra_rdoc_files: []
80
52
  files:
81
- - ".gitignore"
82
- - ".projectile"
83
- - ".rspec"
84
53
  - CHANGELOG.md
85
- - Gemfile
86
54
  - LICENSE.txt
87
55
  - README.md
88
56
  - Rakefile
89
- - cliqr.gemspec
90
57
  - lib/cliqr.rb
91
- - lib/cliqr/dsl/cli.rb
58
+ - lib/cliqr/cli/builder.rb
59
+ - lib/cliqr/cli/config.rb
60
+ - lib/cliqr/cli/validator.rb
61
+ - lib/cliqr/dsl.rb
62
+ - lib/cliqr/error.rb
92
63
  - lib/cliqr/version.rb
93
- - spec/dsl/subcommand_spec.rb
64
+ - spec/dsl/interface_builder_spec.rb
65
+ - spec/dsl/interface_spec.rb
94
66
  - spec/spec_helper.rb
95
67
  homepage: https://github.com/anshulverma/cliqr
96
68
  licenses:
@@ -102,20 +74,22 @@ require_paths:
102
74
  - lib
103
75
  required_ruby_version: !ruby/object:Gem::Requirement
104
76
  requirements:
105
- - - ">="
77
+ - - '>='
106
78
  - !ruby/object:Gem::Version
107
79
  version: 1.9.3
108
80
  required_rubygems_version: !ruby/object:Gem::Requirement
109
81
  requirements:
110
- - - ">="
82
+ - - '>='
111
83
  - !ruby/object:Gem::Version
112
84
  version: 1.3.6
113
85
  requirements: []
114
86
  rubyforge_project:
115
- rubygems_version: 2.2.2
87
+ rubygems_version: 2.4.6
116
88
  signing_key:
117
89
  specification_version: 4
118
90
  summary: A framework and DSL for defining CLI interface
119
91
  test_files:
120
- - spec/dsl/subcommand_spec.rb
92
+ - spec/dsl/interface_builder_spec.rb
93
+ - spec/dsl/interface_spec.rb
121
94
  - spec/spec_helper.rb
95
+ has_rdoc:
data/.gitignore DELETED
@@ -1,16 +0,0 @@
1
- # Temporary files
2
- *~
3
- *#*
4
-
5
- # Log files
6
- *.log
7
-
8
- # IDEA
9
- .idea/
10
- *.iml
11
- *.ipr
12
- *.iws
13
-
14
- # Ruby gem
15
- *.gem
16
- Gemfile.lock
data/.projectile DELETED
@@ -1,19 +0,0 @@
1
- # SCM
2
- -.git/
3
-
4
- # Temporary files
5
- *~
6
- *#*
7
-
8
- # Log files
9
- *.log
10
-
11
- # Ruby gem
12
- *.gem
13
- Gemfile.lock
14
-
15
- # IDEA
16
- .idea/
17
- *.iml
18
- *.ipr
19
- *.iws
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --require spec_helper
3
- --format documentation
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in cliqr.gemspec
4
- gemspec
data/cliqr.gemspec DELETED
@@ -1,40 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'cliqr/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'cliqr'
8
- spec.version = Cliqr::VERSION
9
- spec.authors = ['Anshul Verma']
10
- spec.email = ['ansverma@adobe.com']
11
- spec.summary = %q{A framework and DSL for defining CLI interface}
12
- spec.homepage = 'https://github.com/anshulverma/cliqr'
13
- spec.description = <<-EOS
14
- Allows you to easily define the interface for a CLI app
15
- using an easy to use DSL.
16
-
17
- Includes a lightweight framework for a CLI app.
18
- Features: command routing, error handling, usage generation...more to come
19
- EOS
20
- spec.license = 'MIT'
21
-
22
- spec.files = `git ls-files -z`.split("\x0")
23
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
- spec.require_paths = ['lib']
25
-
26
- spec.required_ruby_version = '>= 1.9.3'
27
- spec.required_rubygems_version = '>= 1.3.6'
28
-
29
- # runtime dependencies
30
- {
31
- :log4r => '~> 1.1'
32
- }.each { |dependency, version| spec.add_runtime_dependency dependency.to_s, version }
33
-
34
- # development dependencies
35
- {
36
- :bundler => '~> 1.7',
37
- :rake => '~> 10.0',
38
- :rspec => '~> 3.2'
39
- }.each { |dependency, version| spec.add_development_dependency dependency.to_s, version }
40
- end
data/lib/cliqr/dsl/cli.rb DELETED
@@ -1,7 +0,0 @@
1
- module Cliqr
2
- module DSL
3
- class CLI
4
-
5
- end
6
- end
7
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
-
3
-
4
- describe Cliqr::DSL do
5
- it 'executes dummy test' do
6
- expect(1).to eq 1
7
- end
8
- end