radon 0.1.7 → 0.1.8

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
- SHA1:
3
- metadata.gz: 5515b97faa858c1b14972922c8c322293a77c372
4
- data.tar.gz: e0a45f9ac9d2f641383b349838a970b8b15cfee0
2
+ SHA256:
3
+ metadata.gz: ba90180b85e4799d91289a2f4bb3755e23ed6836c9e4ef6d16f0746c96648c99
4
+ data.tar.gz: e2939a9722fdb9e7517e634a5e34119c7230db168955deaa747199713644eece
5
5
  SHA512:
6
- metadata.gz: cf83d062b71768802e340cb125a33e485e2acdd1a9175f87148c3fdb68f79ead59847f33eabfc238fb4eb8590d6ec9bc65b477cecb03bb46caa5518fbb28d195
7
- data.tar.gz: a4c5bce4416cc1d8e38a82ef386be534091a99d52a4aa9ad3cd7c3b8d77ca97e905192959c89ca1ee5c399fd8460761e4717d1f1e0be2cca9c6ef4be02e78a4f
6
+ metadata.gz: f06e0447ab89c23aeffeccc69e16c80cbd51b41a295be0c08a00d912ce6177bbdde235a7d992be8658f8d3c2f65a33a5b02108c1413860f1f70919696e9be025
7
+ data.tar.gz: 1db14960b18241053e68b15b997ea3685ea765897866a1e336d2fd12cca85830baad15a2d3bca18da2e20c8668a46eed0bd109d458fac9f60a2c364687fc4aab
data/README.md CHANGED
@@ -53,6 +53,18 @@ Creating project under /mnt/c/Users/Carter/Desktop/projects/MyGradleProject
53
53
  Done! Your project is set up in /mnt/c/Users/Carter/Desktop/projects/MyGradleProject.
54
54
  ```
55
55
 
56
+ ## Supported Environments
57
+ As of v0.1.7, the current supported environments are:
58
+ * Gradle
59
+ * Java
60
+ * Maven
61
+ * Python
62
+ * C
63
+ * Ruby
64
+ * Crystal
65
+ * Go (simple)
66
+ * Website
67
+
56
68
  ## Development
57
69
 
58
70
  #### Adding an environment
data/bin/radon CHANGED
@@ -3,33 +3,43 @@ $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib
3
3
 
4
4
  require 'core'
5
5
 
6
- Signal.trap("INT"){}
6
+ Signal.trap('INT'){}
7
7
 
8
8
  ARGV << '-h' if ARGV.empty?
9
9
  options = {}
10
10
 
11
11
  OptionParser.new do |opts|
12
- opts.banner = "Generate starter code for different coding environments.\n\nUsage: #{File.basename($PROGRAM_NAME)} [options] [task] NewProjectName\nRadon version: #{Paint[VERSION, '#2ecc71']}"
12
+ opts.banner = "Generate starter code for different coding environments.\n\nUsage: #{File.basename($PROGRAM_NAME)} [options] [env] NewProjectName\nRadon version: #{Paint[VERSION, '#2ecc71']}"
13
13
  opts.separator Paint["\nGlobal Options: ", '#95a5a6']
14
14
 
15
15
 
16
16
  opts.on('--list-env', 'List all supported environments') do
17
- all = Radon::Environments.getAllNames
18
- puts "Supported environments are:"
17
+ all = Radon::Environments.get_all_names
18
+ puts 'Supported environments are:'
19
19
  all.each do |e|
20
20
  puts " #{e}"
21
21
  end
22
22
  end
23
23
 
24
- opts.on('-q', '--quiet', 'Run with suppresed console output.') do
24
+ opts.on('-q', '--quiet', 'Run with suppressed console output.') do
25
25
  $quiet = true
26
26
  end
27
27
 
28
+ opts.on('-O', '--open-vscode', 'Open the project in Visual Studio Code (if installed).') do
29
+ options[:open_vscode] = true
30
+ fail_with('You cannot open your project in both VSCode and Atom.') if options[:open_atom]
31
+ end
32
+
33
+ opts.on('-a', '--open-atom', 'Open the project in Atom (if installed).') do
34
+ options[:open_atom] = true
35
+ fail_with('You cannot open your project in both VSCode and Atom.') if options[:open_vscode]
36
+ end
37
+
28
38
  opts.on('--verbose', 'Run verbosely') do
29
39
  $verbose = true
30
40
  end
31
41
 
32
- opts.on('-v', '--version', 'Show the krypton version and exit') do
42
+ opts.on('-v', '--version', 'Show the radon version and exit') do
33
43
  puts "Krypton version: #{Paint[VERSION, '#2ecc71']}"
34
44
  exit 0
35
45
  end
@@ -42,11 +52,13 @@ OptionParser.new do |opts|
42
52
 
43
53
  end.parse!(ARGV)
44
54
 
45
- while (opt = ARGV.shift) do
55
+ while (opt = ARGV.shift)
46
56
  Radon::Util.first_run
47
- if Radon::Environments.getAllNames.include? opt
57
+ if Radon::Environments.get_all_names.include? opt
48
58
  Radon::Environments.extract(opt, ARGV[0])
49
59
  puts Paint["Done! Your project is set up in #{File.expand_path(ARGV[0])}.", :bold, :bright]
60
+ Radon::Util.open_in_editor(options, ARGV[0]) if options[:open_vscode] || options[:open_atom]
61
+
50
62
  exit 0
51
63
  else
52
64
  error "#{opt} is not a supported environment!"
@@ -1,5 +1,5 @@
1
1
  # The version
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
 
4
4
  # The root of this project
5
5
  PROJECT_ROOT = File.absolute_path(File.join(File.dirname(__FILE__), "..", ".."))
@@ -1,37 +1,37 @@
1
- require "core/constants"
1
+ require 'core/constants'
2
2
  module Radon
3
3
  class Environments
4
4
 
5
5
  # The list of all supported environments and their associeted data paths
6
6
  @@all = {
7
- 'gradle' => File.join(DATA_DIR, "gradle.zip"),
8
- 'java' => File.join(DATA_DIR, "java.zip"),
9
- 'maven' => File.join(DATA_DIR, "maven.zip"),
10
- 'python' => File.join(DATA_DIR, "python.zip"),
11
- 'c' => File.join(DATA_DIR, "c.zip"),
12
- 'ruby' => File.join(DATA_DIR, "ruby.zip"),
13
- 'crystal'=> File.join(DATA_DIR, "crystal_app.zip"),
14
- 'go_s' => File.join(DATA_DIR, "go_s.zip"),
15
- 'website'=> File.join(DATA_DIR, "website.zip")
7
+ 'gradle' => File.join(DATA_DIR, 'gradle.zip'),
8
+ 'java' => File.join(DATA_DIR, 'java.zip'),
9
+ 'maven' => File.join(DATA_DIR, 'maven.zip'),
10
+ 'python' => File.join(DATA_DIR, 'python.zip'),
11
+ 'c' => File.join(DATA_DIR, 'c.zip'),
12
+ 'ruby' => File.join(DATA_DIR, 'ruby.zip'),
13
+ 'crystal'=> File.join(DATA_DIR, 'crystal_app.zip'),
14
+ 'go_s' => File.join(DATA_DIR, 'go_s.zip'),
15
+ 'website'=> File.join(DATA_DIR, 'website.zip')
16
16
  }
17
17
 
18
- # Gets all environments as an array of strings
19
- def self.getAllNames
18
+ # Gets all environments as an array of strings
19
+ def self.get_all_names
20
20
  @@all.keys
21
21
  end
22
22
 
23
23
  # Gets the value (corrosponding zip) of the key
24
- def self.getTargetOf(key)
24
+ def self.get_target_of(key)
25
25
  @@all[key]
26
26
  end
27
27
 
28
- # Extract the zip
28
+ # Extract the zip
29
29
  def self.extract(key, target)
30
- envs = self.getAllNames
30
+ envs = get_all_names
31
31
  if envs.include? key
32
32
  send "extract_#{key}", target
33
33
  else
34
- error("#{key} is not a supported environment.\nYou can suggest it be added at https://github.com/cbrnrd/radon/issues")
34
+ fail_with("#{key} is not a supported environment.\nYou can suggest it be added at https://github.com/cbrnrd/radon/issues")
35
35
  end
36
36
  end
37
37
 
@@ -3,41 +3,41 @@ require "tempfile"
3
3
  require "zip"
4
4
 
5
5
  def extract_gradle(target)
6
- extract_zip(Radon::Environments.getTargetOf('gradle'), target)
6
+ extract_zip(Radon::Environments.get_target_of('gradle'), target)
7
7
  end
8
8
 
9
9
  def extract_java(target)
10
- extract_zip(Radon::Environments.getTargetOf('java'), target)
10
+ extract_zip(Radon::Environments.get_target_of('java'), target)
11
11
  end
12
12
 
13
13
  def extract_maven(target)
14
- extract_zip(Radon::Environments.getTargetOf('maven'), target)
14
+ extract_zip(Radon::Environments.get_target_of('maven'), target)
15
15
  end
16
16
 
17
17
  def extract_python(target)
18
- extract_zip(Radon::Environments.getTargetOf('python'), target)
18
+ extract_zip(Radon::Environments.get_target_of('python'), target)
19
19
  end
20
20
 
21
21
  def extract_ruby(target)
22
- extract_zip(Radon::Environments.getTargetOf('ruby'), target)
22
+ extract_zip(Radon::Environments.get_target_of('ruby'), target)
23
23
  replace_all_tokens(target)
24
24
  end
25
25
 
26
26
  def extract_c(target)
27
- extract_zip(Radon::Environments.getTargetOf('c'), target)
27
+ extract_zip(Radon::Environments.get_target_of('c'), target)
28
28
  end
29
29
 
30
30
  def extract_crystal(target)
31
- extract_zip(Radon::Environments.getTargetOf('crystal'), target)
31
+ extract_zip(Radon::Environments.get_target_of('crystal'), target)
32
32
  replace_all_tokens(target)
33
33
  end
34
34
 
35
35
  def extract_go_s(target)
36
- extract_zip(Radon::Environments.getTargetOf('go_s'), target)
36
+ extract_zip(Radon::Environments.get_target_of('go_s'), target)
37
37
  end
38
38
 
39
39
  def extract_website(target)
40
- extract_zip(Radon::Environments.getTargetOf('website'), target)
40
+ extract_zip(Radon::Environments.get_target_of('website'), target)
41
41
  end
42
42
 
43
43
  # Extracts some zip data to the passed destination
@@ -5,12 +5,12 @@ def vprint(*args)
5
5
  end
6
6
 
7
7
  def error(*args)
8
- puts Paint["ERROR", '#e74c3c'] + " - #{args.join(' ')}"
8
+ puts Paint['ERROR', '#e74c3c'] + " - #{args.join(' ')}"
9
9
  end
10
10
 
11
11
  def report_error_to_github(trace)
12
12
  commit_string = File.directory?(File.join(PROJECT_ROOT, '.git')) ? "Commit `#{File.read(File.join(PROJECT_ROOT, '.git', 'refs', 'heads', 'master')).strip}`" : nil
13
- puts %Q{
13
+ puts %(
14
14
  :::::::::::::::::: COPY BELOW ::::::::::::::::::
15
15
  ### Ruby version
16
16
 
@@ -36,22 +36,22 @@ def report_error_to_github(trace)
36
36
  #{commit_string}
37
37
  :::::::::::::::::: COPY ABOVE ::::::::::::::::::
38
38
  #{Paint["Whoops! Looks like you've found a bug in radon. Please copy the text above and open a new issue at ", '#e74c3c'] + Paint['https://github.com/cbrnrd/radon/issues', :bold, :bright]}
39
- }
39
+ )
40
40
 
41
41
  end
42
42
 
43
43
  def create(fname)
44
- puts Paint[" create", '#2ecc71'] + " #{fname}" unless $quiet
44
+ puts Paint[' create', '#2ecc71'] + " #{fname}" unless $quiet
45
45
  end
46
46
 
47
47
  def skip(fname)
48
- puts Paint[" skip", '#f1c40f'] + " #{fname}" unless $quiet
48
+ puts Paint[' skip', '#f1c40f'] + " #{fname}" unless $quiet
49
49
  end
50
50
 
51
51
  # Gets the project name in capitalized format. Eg: MyProjectName
52
52
  def projectify(name)
53
53
  # Name becomes frozen for some reason
54
- name = name.gsub(/(.)([A-Z])/,'\1-\2')
54
+ name = name.gsub(/(.)([A-Z])/, '\1-\2')
55
55
  name.downcase!
56
56
  name.gsub!('..', '')
57
57
  name.gsub!('/', '')
@@ -1,5 +1,6 @@
1
1
  require 'fileutils'
2
2
  require 'json'
3
+
3
4
  module Radon
4
5
  class Util
5
6
  def self.first_run
@@ -10,7 +11,7 @@ class Util
10
11
  FileUtils.mkdir_p(SETTINGS_DIR)
11
12
  vprint("Creating #{SETTINGS_DIR}")
12
13
 
13
- puts "Welcome to radon! It looks like it's your first time running radon."
14
+ puts "Welcome to radon! It looks like it's your first time running."
14
15
  email = ask " Email: "
15
16
  gh_uname = ask " GitHub username: "
16
17
 
@@ -30,6 +31,43 @@ class Util
30
31
  def self.get_github_username
31
32
  JSON.parse(File.read(SETTINGS_FILE))['username']
32
33
  end
33
-
34
+
35
+ # Cross-platform way of finding an executable in the $PATH.
36
+ #
37
+ # which('ruby') #=> /usr/bin/ruby
38
+ def self.which(cmd)
39
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
40
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
41
+ exts.each { |ext|
42
+ exe = File.join(path, "#{cmd}#{ext}")
43
+ return exe if File.executable?(exe) && !File.directory?(exe)
44
+ }
45
+ end
46
+ return nil
47
+ end
48
+
49
+ def open_in_vscode(path)
50
+ fail_with('`code` program is not in $PATH') if Radon::Util.which('code').nil?
51
+ `cd #{path} && code .`
52
+ end
53
+
54
+ def open_in_atom(path)
55
+ fail_with('`atom` program is not in $PATH') if Radon::Util.which('atom').nil?
56
+ `cd #{path} && atom .`
57
+ end
58
+
59
+ def open_in_editor(opts, path)
60
+ open_in_vscode(path) if opts[:open_vscode]
61
+ rescue StandardError => e
62
+ report_error_to_github(e)
63
+ end
64
+
34
65
  end
35
66
  end
67
+
68
+ def fail_with(reason)
69
+ error(reason)
70
+ exit 1
71
+ end
72
+
73
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - cbrnrd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-02 00:00:00.000000000 Z
11
+ date: 2019-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paint
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  requirements: []
153
153
  rubyforge_project:
154
- rubygems_version: 2.6.14
154
+ rubygems_version: 2.7.6
155
155
  signing_key:
156
156
  specification_version: 4
157
157
  summary: Radon generates starter code for all kinds of environments.