redmine_cli 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 97c8fe7610bf14e98e31cd06ecd5bd1fef70ba09
4
+ data.tar.gz: 20e0a9f511c6225149c8e45bf9937699202b8161
5
+ SHA512:
6
+ metadata.gz: 235aa01145508dd3568adc818d23a9b9e344179a3596c85939864d98d8cc35af3218421a4ae176355fdef17188f77317fd545b82d0fdbb1ac4dcd519bae983ed
7
+ data.tar.gz: 0eab2ada375a2bbcc2324fc03498d89a66a3ade1c3e828fe5eeec92f4e5c5525848fbeddd396f5f3174aa66571388a490d9e435c3f5a55560e9ad3d5bf5c777f
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ Metrics/LineLength:
2
+ Max: 120
3
+
4
+ Style/Documentation:
5
+ Exclude:
6
+ - 'spec/**/*'
7
+ - 'test/**/*'
8
+ - 'lib/redmine_cli/helpers/monkey_patching.rb'
data/.rvmrc ADDED
@@ -0,0 +1,9 @@
1
+ rvm use 2.2.1@redmine_cli --create
2
+ if [ -z "$(gem list | grep '^bundler\s')" ]; then
3
+ echo
4
+ echo '--- WARNING ---'
5
+ echo 'I cannot find "bundler" gem.'
6
+ echo 'Looks like you use gemset "profit-gis" at first time.'
7
+ echo 'Please, execute: gem install bundler; bundle install'
8
+ echo
9
+ fi
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in redmine_cli.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Dmitriy Non
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # RedmineCLI
2
+
3
+ Command-Line Interface for Redmine.
4
+
5
+ Why? Because web-browser + mouse sucks
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'redmine_cli'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install redmine_cli
22
+
23
+ ## Usage
24
+
25
+
26
+ ## Contributing
27
+
28
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/redmine_cli.
29
+
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
34
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'redmine_cli'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/redmine ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'redmine_cli'
4
+
5
+ RedmineCLI::Client.start(ARGV)
@@ -0,0 +1,5 @@
1
+ ---
2
+
3
+ user: nil
4
+ password: nil
5
+ site: nil
@@ -0,0 +1,7 @@
1
+ en:
2
+ test: '1234'
3
+ desc:
4
+ client:
5
+ :issue: 'Command for working with issues. See "redmine issue help"'
6
+ issue:
7
+ list: 'Lists issues of user. By default it is you'
@@ -0,0 +1,12 @@
1
+ % max_id_len = issues.max_by { |i| i.id.size }.id.size
2
+ % subject_limit = 60
3
+ %
4
+ % issues.group_by { |i| i.project.name }.each do |project, project_issues|
5
+
6
+ <%= "[ #{project} ]".center(max_id_len + 3 + subject_limit + 3 + 8).red + "\n" %>
7
+ <%= '(id)'.center(max_id_len).yellow %> | <%= '(subject)'.center(subject_limit).yellow %> | <%= "(status)\n".yellow %>
8
+ <% project_issues.each do |i| %>
9
+ <%= i.id.ljust(max_id_len) %> <%= i.subject.cut(subject_limit).ljust(subject_limit) %> <%= i.status.name %><%= "\n" %>
10
+ <% end %>
11
+
12
+ % end
@@ -0,0 +1,36 @@
1
+ require 'non_config'
2
+ require 'redmine_rest'
3
+
4
+ module RedmineCLI
5
+ #
6
+ # Class that stores configuration and manipulates with it
7
+ #
8
+ class Config < NonConfig::Base
9
+ @path_to_config = File.expand_path('.redmine_cli', Dir.home)
10
+
11
+ def self.configure_rest
12
+ RedmineRest::Models.configure_models user: user,
13
+ password: password,
14
+ site: site
15
+ end
16
+
17
+ def self.create_config
18
+ defaults = { 'just_created' => true,
19
+ 'user' => 'login',
20
+ 'password' => 'password',
21
+ 'site' => 'URL to Redmine' }
22
+ File.open(@path_to_config, 'w') { |f| f.write defaults.to_yaml }
23
+ end
24
+
25
+ def self.new?
26
+ self['just_created']
27
+ end
28
+
29
+ create_config unless File.exist? @path_to_config
30
+
31
+ source :default, File.expand_path('../../assets/default_config.yml', __FILE__)
32
+ source :user, @path_to_config
33
+
34
+ configure_rest
35
+ end
36
+ end
@@ -0,0 +1,10 @@
1
+ class String
2
+ #
3
+ # If string doesnt fit in `max_chars` then it will cut it and add '...'
4
+ #
5
+ def cut(max_chars)
6
+ return self if size <= max_chars
7
+
8
+ self[0...max_chars - 3] + '...'
9
+ end
10
+ end
@@ -0,0 +1,32 @@
1
+ module RedmineCLI
2
+ module Helpers
3
+ #
4
+ # Helpers for output
5
+ #
6
+ module Output
7
+ #
8
+ # Alias for TemplateRenderer#render
9
+ #
10
+ def erb(template, vars = {})
11
+ RedmineCLI::TemplateRenderer.render(template, vars)
12
+ end
13
+
14
+ #
15
+ # Gets text from I18n and replaces params
16
+ # e.g.
17
+ # I18n.t(:hello) => 'Hello, {{ user }}'
18
+ # message(:hello, user: 'Vasya') => 'Hello, Vasya'
19
+ #
20
+ # @param name [Symbol]
21
+ # @param params [Hash] optional
22
+ #
23
+ def message(name, params = {})
24
+ result = I18n.t name
25
+ params.each { |k, e| result.gsub!("{{ #{k} }}", e.to_s) }
26
+ result
27
+ end
28
+
29
+ alias m message
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,23 @@
1
+ require 'thor'
2
+ require 'redmine_rest'
3
+
4
+ module RedmineCLI
5
+ module Subcommands
6
+ #
7
+ # All methods for working with issues, e.g. listing, linking, updating...
8
+ #
9
+ class Issue < Thor
10
+ extend Helpers::Output
11
+
12
+ include RedmineRest
13
+ include Helpers::Output
14
+
15
+ desc 'list [user]', m('desc.issue.list')
16
+ def list(id = 'current')
17
+ fail('new config') if Config.new?
18
+
19
+ puts erb('issue/list', issues: Models::User.find(id).issues)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,45 @@
1
+ require 'erb'
2
+ require 'colorize'
3
+
4
+ module RedmineCLI
5
+ #
6
+ # Renders templates
7
+ #
8
+ module TemplateRenderer
9
+ @template_directory = File.expand_path('../../assets/templates', __FILE__)
10
+
11
+ #
12
+ # finds template and renders it
13
+ #
14
+ # @param template [String, Symbol] name of template. Use 'dir1/dir2/name' means assets/templates/dir1/dir2/name.erb
15
+ #
16
+ def self.render(template, variables = {})
17
+ path = File.expand_path(template.to_s, @template_directory) + '.erb'
18
+ fail "Template not found: #{path}" unless File.exist? path
19
+
20
+ ErbEnvironment.new(File.read(path), variables).render
21
+ end
22
+
23
+ #
24
+ # Class for renderer. Don't use it outside
25
+ #
26
+ class ErbEnvironment
27
+ include Helpers::Output
28
+
29
+ def initialize(template, vars = {})
30
+ @template = template
31
+ @vars = vars
32
+ end
33
+
34
+ def method_missing(m, *args)
35
+ return @vars[m] if args.empty? && @vars[m]
36
+
37
+ super
38
+ end
39
+
40
+ def render
41
+ ERB.new(@template, nil, '%<>').result(binding)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,3 @@
1
+ module RedmineCLI
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,32 @@
1
+ require 'thor'
2
+ require 'redmine_rest'
3
+ require 'i18n'
4
+
5
+ I18n.load_path = Dir["#{File.dirname __FILE__}/assets/messages/*"]
6
+
7
+ # helpers
8
+ Dir[File.expand_path('../redmine_cli/helpers/*.rb', __FILE__)].each { |f| require f }
9
+
10
+ require 'redmine_cli/version'
11
+ require 'redmine_cli/config'
12
+ I18n.locale = RedmineCLI::Config['locale'] || :en
13
+
14
+ require 'redmine_cli/template_renderer'
15
+ Dir[File.expand_path('../redmine_cli/subcommands/*.rb', __FILE__)].each { |f| require f }
16
+
17
+ #
18
+ # base namespace
19
+ #
20
+ module RedmineCLI
21
+ include RedmineRest
22
+
23
+ #
24
+ # Main CLI class
25
+ #
26
+ class Client < Thor
27
+ extend Helpers::Output
28
+
29
+ desc 'issue ...', m('desc.client.issue')
30
+ subcommand 'issue', Subcommands::Issue
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'redmine_cli/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'redmine_cli'
8
+ spec.version = RedmineCLI::VERSION
9
+ spec.authors = ['Dmitriy Non']
10
+ spec.email = ['non.dmitriy@gmail.com']
11
+
12
+ spec.summary = 'CLI for Redmine'
13
+ spec.homepage = 'https://github.com/Nondv/redmine_cli'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.required_ruby_version = '>= 2.1.1'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.11'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.0'
26
+ spec.add_development_dependency 'rubocop', '0.36.0'
27
+
28
+ spec.add_dependency 'thor', '~> 0.19'
29
+ spec.add_dependency 'i18n', '~> 0.7'
30
+ spec.add_dependency 'redmine_rest', '0.1.1'
31
+ spec.add_dependency 'non_config', '0.1.2'
32
+ spec.add_dependency 'colorize', '~> 0.7'
33
+ end
metadata ADDED
@@ -0,0 +1,193 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redmine_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dmitriy Non
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.36.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.36.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.19'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.19'
83
+ - !ruby/object:Gem::Dependency
84
+ name: i18n
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.7'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: redmine_rest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.1.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.1.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: non_config
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 0.1.2
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 0.1.2
125
+ - !ruby/object:Gem::Dependency
126
+ name: colorize
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.7'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.7'
139
+ description:
140
+ email:
141
+ - non.dmitriy@gmail.com
142
+ executables:
143
+ - redmine
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - ".rubocop.yml"
150
+ - ".rvmrc"
151
+ - Gemfile
152
+ - LICENSE.txt
153
+ - README.md
154
+ - Rakefile
155
+ - bin/console
156
+ - bin/setup
157
+ - exe/redmine
158
+ - lib/assets/default_config.yml
159
+ - lib/assets/messages/en.yml
160
+ - lib/assets/templates/issue/list.erb
161
+ - lib/redmine_cli.rb
162
+ - lib/redmine_cli/config.rb
163
+ - lib/redmine_cli/helpers/monkey_patching.rb
164
+ - lib/redmine_cli/helpers/output.rb
165
+ - lib/redmine_cli/subcommands/issue.rb
166
+ - lib/redmine_cli/template_renderer.rb
167
+ - lib/redmine_cli/version.rb
168
+ - redmine_cli.gemspec
169
+ homepage: https://github.com/Nondv/redmine_cli
170
+ licenses:
171
+ - MIT
172
+ metadata: {}
173
+ post_install_message:
174
+ rdoc_options: []
175
+ require_paths:
176
+ - lib
177
+ required_ruby_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: 2.1.1
182
+ required_rubygems_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ requirements: []
188
+ rubyforge_project:
189
+ rubygems_version: 2.4.6
190
+ signing_key:
191
+ specification_version: 4
192
+ summary: CLI for Redmine
193
+ test_files: []