renuo-cli 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea4d424a283f3ee6479f46ec48a27529568e7a88
4
- data.tar.gz: 67fd3687792a837d1e5acad6bbe3570d6efda24b
3
+ metadata.gz: 5ca0b886873fc443268d1be527323bbcfc602444
4
+ data.tar.gz: d6c7bc7bee5e6f11f9cd56c2f5faf8b8ff46f55e
5
5
  SHA512:
6
- metadata.gz: 9d43ef8c0ef3fec4900cf44ecaa34d0a871f1ef13d685afb5be0c3eead3bd8396bd3ad60feb3460c609bf171ce8a00c1bcdda75a373468ab9c24d594695e2d1a
7
- data.tar.gz: b62c416bbb58ca1aca630426fb107f7bb0927dc0cb6973b6364957deaaaeae6e6bffee68aa8a29c9815e4fae8569e4327eeb02e222ecca7d942cac507a0b13ce
6
+ metadata.gz: 231db98fd2899c4971509dcda214128749a599032b632c51dcfa6ebeb47f92bc3a788e9284dc2656eaf4f5b4fc3fe8744c27be14a6a1765f119b103f7ee5c8ba
7
+ data.tar.gz: 68a1ff5c7681070401dfb9c1ad6e1685b7890f50142adb065593c679e04183a2012d2d7428fc8205ed1c018e670380789939951eabe521f469778dbc25379aec
data/.gitignore CHANGED
@@ -101,3 +101,4 @@ build/
101
101
  /pkg/
102
102
  /spec/reports/
103
103
  /tmp/
104
+ .rubocop-https---raw-githubusercontent-com-renuo-rails-application-setup-guide-master-templates--rubocop-base-yml
data/.mdlrc ADDED
@@ -0,0 +1,2 @@
1
+ rules "~MD013"
2
+ git_recurse true
data/.rubocop.yml CHANGED
@@ -1,25 +1,17 @@
1
- AllCops:
2
- RunRailsCops: false
3
-
4
- Metrics/LineLength:
5
- Max: 120
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/renuo/rails-application-setup-guide/master/templates/.rubocop_base.yml
6
3
 
7
- Style/Documentation:
8
- Enabled: false
9
-
10
- Style/NonNilCheck:
11
- IncludeSemanticChanges: true
4
+ Rails:
5
+ Enabled: false
12
6
 
13
7
  Metrics/ClassLength:
14
8
  Max: 160
15
9
 
16
10
  AllCops:
17
11
  Include:
18
- - '**/Rakefile'
19
12
  - 'lib/**/*'
20
13
  - 'spec/**/*'
21
14
  - '*.gemspec'
22
15
  Exclude:
23
16
  - 'bin/**/*'
24
17
  - 'lib/renuo/cli.rb'
25
-
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.0
1
+ 2.3.1
data/.travis.yml CHANGED
@@ -3,7 +3,7 @@ cache: bundler
3
3
  rvm:
4
4
  - 2.1
5
5
  - 2.2
6
- - 2.3.0
6
+ - 2.3.1
7
7
  before_install: gem install bundler -v 1.10.6
8
8
  install:
9
9
  - bundle install --retry=3
data/README.md CHANGED
@@ -16,11 +16,15 @@ gem 'renuo-cli'
16
16
 
17
17
  And then execute:
18
18
 
19
- $ bundle
19
+ ```sh
20
+ bundle
21
+ ```
20
22
 
21
23
  Or install it yourself as:
22
24
 
23
- $ gem install renuo-cli
25
+ ```sh
26
+ gem install renuo-cli
27
+ ```
24
28
 
25
29
  ## Usage
26
30
 
@@ -54,11 +58,10 @@ git checkout develop
54
58
 
55
59
  ## Contributing
56
60
 
57
- Bug reports and pull requests are welcome on GitHub at https://github.com/renuo/renuo-cli. This project is intended to
61
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/renuo/renuo-cli>. This project is intended to
58
62
  be a safe, welcoming space for collaboration, and contributors are expected to adhere to
59
63
  the [Contributor Covenant](contributor-covenant.org) code of conduct.
60
64
 
61
-
62
65
  ## License
63
66
 
64
67
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/bin/check CHANGED
@@ -13,6 +13,12 @@ if [ ! $RC -eq 0 ]; then
13
13
  exit 1
14
14
  fi
15
15
 
16
+ mdl .
17
+ if [ ! $? -eq 0 ]; then
18
+ echo 'Violated markdown rules, see https://github.com/mivok/markdownlint/blob/master/docs/RULES.md, commit aborted'
19
+ exit 1
20
+ fi
21
+
16
22
  bundle exec rspec
17
23
  if [ ! $RC -eq 0 ]; then
18
24
  echo 'rspec errors'
data/exe/renuo CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
+
2
3
  require 'renuo/cli'
3
4
  Renuo::CLI.new.start
@@ -0,0 +1,65 @@
1
+ require 'net/http'
2
+ require 'json'
3
+ require 'csv'
4
+
5
+ class ImportRedmineIssues
6
+ def initialize(redmine_api_key)
7
+ @redmine_api_key = redmine_api_key
8
+ @html_uri = URI('https://redmine.renuo.ch/issues')
9
+ @json_uri = URI('https://redmine.renuo.ch/issues.json')
10
+ end
11
+
12
+ def run(csv_path)
13
+ https = Net::HTTP.new(@json_uri.host, @json_uri.port)
14
+ https.use_ssl = true
15
+
16
+ parsed_issues(csv_path).each do |issue|
17
+ request = build_request(issue)
18
+ response = https.request(request)
19
+ handle_response(response)
20
+ end
21
+
22
+ rescue SocketError => details
23
+ say "Are you connected to the internet? SocketError: #{details}"
24
+ exit 1
25
+ end
26
+
27
+ private
28
+
29
+ def build_request(issue)
30
+ request = Net::HTTP::Post.new(@json_uri)
31
+ request.add_field('Content-Type', 'application/json')
32
+ request.add_field('X-Redmine-API-Key', @redmine_api_key)
33
+ request.body = JSON.generate(issue)
34
+ request
35
+ end
36
+
37
+ def handle_response(response)
38
+ if response.is_a? Net::HTTPCreated
39
+ issue_id = JSON.parse(response.body)['issue']['id']
40
+ issue_url = URI.join(@html_uri, issue_id.to_s)
41
+ say issue_url
42
+ else
43
+ say "#{response.code} #{response.message}"
44
+ end
45
+ end
46
+
47
+ def parsed_issues(csv_path)
48
+ issues = []
49
+
50
+ CSV.foreach(csv_path) do |row|
51
+ issues << { 'issue' => parse_issue(row) }
52
+ end
53
+
54
+ issues
55
+ end
56
+
57
+ def parse_issue(csv_row)
58
+ {
59
+ 'project_id' => csv_row[0],
60
+ 'subject' => csv_row[1],
61
+ 'description' => csv_row[2],
62
+ 'estimated_hours' => csv_row[3]
63
+ }
64
+ end
65
+ end
@@ -21,7 +21,7 @@ class LocalStorage
21
21
 
22
22
  def write_config(config)
23
23
  File.write('.local_storage', config.to_json)
24
- File.chmod(0600, '.local_storage')
24
+ File.chmod(0o600, '.local_storage')
25
25
  end
26
26
 
27
27
  def setup
@@ -0,0 +1,6 @@
1
+ module RunCommand
2
+ def run_command(command)
3
+ say "\n#{command.yellow}"
4
+ system command
5
+ end
6
+ end
@@ -0,0 +1,38 @@
1
+ class UpgradeLaptopExecution
2
+ include RunCommand
3
+
4
+ def initialize(upgrade_mac_os)
5
+ @upgrade_mac_os = upgrade_mac_os
6
+ end
7
+
8
+ def run
9
+ upgrade_apps
10
+ upgrade_mac_os
11
+ upgrade_brew unless mac_os_upgrade_needs_a_restart?
12
+ end
13
+
14
+ private
15
+
16
+ def upgrade_apps
17
+ setup_mas
18
+ run_command 'mas upgrade'
19
+ end
20
+
21
+ def setup_mas
22
+ `which mas || brew install mas`
23
+ end
24
+
25
+ def upgrade_mac_os
26
+ @upgrade_mac_os.run
27
+ end
28
+
29
+ def mac_os_upgrade_needs_a_restart?
30
+ @upgrade_mac_os.reboot_required?
31
+ end
32
+
33
+ def upgrade_brew
34
+ run_command 'brew update'
35
+ run_command 'brew upgrade'
36
+ run_command 'brew cleanup'
37
+ end
38
+ end
@@ -0,0 +1,47 @@
1
+ class UpgradeMacOS
2
+ include RunCommand
3
+
4
+ def run
5
+ find_software_upgrades
6
+ return unless upgrade_available?
7
+
8
+ return if reboot_required_and_not_agreed_to?
9
+
10
+ execute_upgrade
11
+ end
12
+
13
+ def reboot_required?
14
+ @output.include? '[restart]'
15
+ end
16
+
17
+ private
18
+
19
+ def find_software_upgrades
20
+ say "\nUpdating  macOS.\nFinding available software (this may take a while)".yellow
21
+
22
+ @output = `softwareupdate --list 2>&1`
23
+ say @output
24
+ end
25
+
26
+ def upgrade_available?
27
+ @output.include? 'Software Update found'
28
+ end
29
+
30
+ def reboot_required_and_not_agreed_to?
31
+ reboot_required? && !agree_for_reboot?
32
+ end
33
+
34
+ def agree_for_reboot?
35
+ agree "\nYour Mac needs to be rebooted, Still continue?".red + ' (Yes / No)'
36
+ end
37
+
38
+ def execute_upgrade
39
+ run_command 'softwareupdate --install --all'
40
+ reboot if reboot_required?
41
+ end
42
+
43
+ def reboot
44
+ say 'Rebooting Now'.white.on_red
45
+ say `osascript -e 'tell app "System Events" to restart'`
46
+ end
47
+ end
@@ -0,0 +1,20 @@
1
+ require_relative 'upgrade_laptop/run_command'
2
+ require_relative 'upgrade_laptop/upgrade_laptop_execution'
3
+ require_relative 'upgrade_laptop/upgrade_mac_os'
4
+
5
+ class UpgradeLaptop
6
+ def run
7
+ say_hi
8
+ run_upgrade
9
+ end
10
+
11
+ private
12
+
13
+ def say_hi
14
+ say 'Start Update'
15
+ end
16
+
17
+ def run_upgrade
18
+ UpgradeLaptopExecution.new(UpgradeMacOS.new).run
19
+ end
20
+ end
@@ -1,6 +1,5 @@
1
- # frozen_string_literal: true
2
1
  module Renuo
3
2
  module Cli
4
- VERSION = '0.0.9'.freeze
3
+ VERSION = '0.0.10'.freeze
5
4
  end
6
5
  end
data/lib/renuo/cli.rb CHANGED
@@ -1,11 +1,14 @@
1
1
  require 'renuo/cli/version'
2
2
  require 'rubygems'
3
+ require 'colorize'
3
4
  require 'renuo/cli/app/name_display'
4
5
  require 'renuo/cli/app/local_storage'
5
6
  require 'renuo/cli/app/migrate_to_github'
6
7
  require 'renuo/cli/app/list_large_git_files'
7
8
  require 'renuo/cli/app/generate_password'
9
+ require 'renuo/cli/app/upgrade_laptop.rb'
8
10
  require 'renuo/cli/app/application_setup_auto_config'
11
+ require 'renuo/cli/app/import_redmine_issues'
9
12
 
10
13
  module Renuo
11
14
  class CLI
@@ -69,6 +72,16 @@ module Renuo
69
72
  end
70
73
  end
71
74
 
75
+ command 'upgrade-laptop' do |c|
76
+ c.syntax = 'renuo upgrade-laptop'
77
+ c.summary = 'Upgrades the installed apps from the app store, macOS and homebrew'
78
+ c.description = 'Upgrades the installed apps from the app store, macOS and homebrew'
79
+ c.example 'renuo upgrade-laptop', 'upgrades your laptop'
80
+ c.action do
81
+ UpgradeLaptop.new.run
82
+ end
83
+ end
84
+
72
85
  command 'application-setup-auto-config' do |c|
73
86
  c.syntax = 'renuo application-setup-auto-config'
74
87
  c.summary = 'Sets up the application setup using the default config'
@@ -78,6 +91,17 @@ module Renuo
78
91
  ApplicationSetupAutoConfig.new.run
79
92
  end
80
93
  end
94
+
95
+ command 'import-redmine-issues' do |c|
96
+ c.syntax = 'renuo import-redmine-issues [csv_path]'
97
+ c.summary = 'Import Redmine Issues from CSV'
98
+ c.description = 'Automatically create redmine issues from a CSV file (format project_id,subject,description,estimated_hours)'
99
+ c.example 'Create Redmine issues from downloaded CSV file', 'renuo import-redmine-issues ~/Downloads/issues.csv'
100
+ c.action do |args, _options|
101
+ api_key = ask('Redmine API Key: ') { |q| q.echo = '*' }
102
+ ImportRedmineIssues.new(api_key).run(args.first)
103
+ end
104
+ end
81
105
  end
82
106
  end
83
107
  end
data/renuo-cli.gemspec CHANGED
@@ -27,7 +27,9 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'cucumber'
28
28
  spec.add_development_dependency 'aruba'
29
29
  spec.add_development_dependency 'rubocop'
30
+ spec.add_development_dependency 'mdl'
30
31
  spec.add_development_dependency 'pry'
31
32
  spec.add_development_dependency 'coveralls'
32
33
  spec.add_development_dependency 'redcarpet'
34
+ spec.add_development_dependency 'colorize'
33
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renuo-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Elmer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-19 00:00:00.000000000 Z
11
+ date: 2016-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: mdl
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: pry
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +164,20 @@ dependencies:
150
164
  - - ">="
151
165
  - !ruby/object:Gem::Version
152
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: colorize
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
153
181
  description: The Renuo CLI automates some commonly used workflows by providing a command
154
182
  line interface.
155
183
  email:
@@ -162,6 +190,7 @@ files:
162
190
  - ".coveralls.yml"
163
191
  - ".editorconfig"
164
192
  - ".gitignore"
193
+ - ".mdlrc"
165
194
  - ".rspec"
166
195
  - ".rubocop.yml"
167
196
  - ".ruby-version"
@@ -178,11 +207,16 @@ files:
178
207
  - lib/renuo/cli.rb
179
208
  - lib/renuo/cli/app/application_setup_auto_config.rb
180
209
  - lib/renuo/cli/app/generate_password.rb
210
+ - lib/renuo/cli/app/import_redmine_issues.rb
181
211
  - lib/renuo/cli/app/list_large_git_files.rb
182
212
  - lib/renuo/cli/app/local_storage.rb
183
213
  - lib/renuo/cli/app/migrate_to_github.rb
184
214
  - lib/renuo/cli/app/name_display.rb
185
215
  - lib/renuo/cli/app/services/markdown_parser_service.rb
216
+ - lib/renuo/cli/app/upgrade_laptop.rb
217
+ - lib/renuo/cli/app/upgrade_laptop/run_command.rb
218
+ - lib/renuo/cli/app/upgrade_laptop/upgrade_laptop_execution.rb
219
+ - lib/renuo/cli/app/upgrade_laptop/upgrade_mac_os.rb
186
220
  - lib/renuo/cli/version.rb
187
221
  - renuo-cli.gemspec
188
222
  homepage: https://github.com/renuo/renuo-cli