thorium 0.4.1 → 0.5.0.beta1

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: 16fe44b66185584d67b94f3bdb347c982313c19a
4
- data.tar.gz: 47b8a0e66776e16736c26ef9076b5b6d016016a7
3
+ metadata.gz: f4aa141b84f6d6bd6a5a049518fb64fd117d4fa8
4
+ data.tar.gz: dd37e57f50379c1b6061687d2d9fea8392f017dc
5
5
  SHA512:
6
- metadata.gz: 55a49994ae5936413da602792bbb3dd0193bad18aefeccb0f351e74cbcb88710722b5a7b1657baa88790b3daa4ce13663d909bf5a059edb96cafdba373aec5b8
7
- data.tar.gz: 813c0d90393e839bd9f679a8148724a834a2f01b2b12bfcbfb68c5dc6598f109736103c5bfef55acdb308c0d01f1b705f2b31bda604220d468ba46208420811d
6
+ metadata.gz: 5a736969b178a6f683f4c18e486552a3a7cd062686bccfb6658c749690ca02796c06f4accf4a6a505c94ae223a9b27fbbad41d0a9dcc3a26b8f0623e4567be91
7
+ data.tar.gz: 14b5c574d0a322a0a5aad2600fd21b7125131c9e4f4acb646d18e80bcf8b81bd01623828d27367efa945d3f5496f6ea03727e57fe36e59981040b4c5cf33354c
@@ -18,17 +18,20 @@ class Thor
18
18
 
19
19
  def correct_answer(answer_set, options, color, statement)
20
20
  result = nil
21
-
21
+ answers = answer_set.join(', ')
22
+ statement += " [#{answers}]" unless options[:mute_limit_set]
22
23
  until result
23
- answers = answer_set.join(', ')
24
- answer = ask_simply("#{statement} [#{answers}]", color, options)
24
+ answer = ask_simply(statement, color, options)
25
25
  skipped = (options.key?(:skip) && (answer == options[:skip].chomp))
26
26
  result = answer_set.include?(answer) || skipped ? answer : nil
27
27
  unless result
28
- say("Your response must be one of: [#{answers}]. Please try again.")
28
+ if options[:mute_limit_set]
29
+ say('Your response is invalid. Please try again.')
30
+ else
31
+ say("Your response must be one of: [#{answers}]. Please try again.")
32
+ end
29
33
  end
30
34
  end
31
-
32
35
  result
33
36
  end
34
37
  end
@@ -3,7 +3,8 @@ module GitCLI
3
3
  # Listing and cloning of repositories (Github support included)
4
4
  class Git < Thor
5
5
  package_name 'Thorium | Git'
6
- GH_API_URL = 'https://api.github.com'
6
+ GH_API_URL = 'https://api.github.com'
7
+ GITIGNORE_REPO = 'https://raw.githubusercontent.com/github/gitignore/master/'
7
8
 
8
9
  require 'json'
9
10
  include Thor::Actions
@@ -11,11 +12,14 @@ module GitCLI
11
12
  class_option :verbose, type: :boolean, default: 1
12
13
 
13
14
  desc 'list', 'Lists repositories (Github)'
14
- def list
15
- gh_uname = ask('Enter Github username: ', :green)
16
- abort if gh_uname.empty?
17
- puts "\nFetching Github repositories (#{gh_uname})..."
18
- puts '------------------------------------------'
15
+ def list(username = nil)
16
+ if username.nil?
17
+ gh_uname = ask('Enter Github username: ', :green)
18
+ abort if gh_uname.empty?
19
+ else
20
+ gh_uname = username
21
+ end
22
+ say msg = "Fetching Github repositories (#{gh_uname})..." and say '-' * msg.size
19
23
  @repos = get_gh_repos(gh_uname).each_with_index.map do |e, i|
20
24
  e.values_at('name', 'ssh_url', 'clone_url').unshift("[#{i + 1}]")
21
25
  end
@@ -23,8 +27,8 @@ module GitCLI
23
27
  end
24
28
 
25
29
  desc 'clone', 'Clones a repository from the list (Github)'
26
- def clone
27
- list
30
+ def clone(username = nil)
31
+ list(username)
28
32
  # Do not do anything if list is empty
29
33
  ask_options = { limited_to: ('1'..@repos.size.to_s).to_a, skip: '' }
30
34
  answer = ask('Which repository would you like to clone?', :green, ask_options)
@@ -38,9 +42,29 @@ module GitCLI
38
42
  run "git clone #{url}"
39
43
  end
40
44
 
45
+ desc 'ignore', 'Creates a specific .gitignore file in the current folder'
46
+ method_option aliases: 'i'
47
+ def ignore
48
+ say msg = 'Fetching a list of gitignore files...' and say '-' * msg.size
49
+ files = get_gitignore_list.map { |e| e['name'] }
50
+ gitignore_files = files.each_with_index.map do |e, i|
51
+ "[#{i + 1}] #{File.basename(e, '.*')}"
52
+ end
53
+ print_in_columns gitignore_files
54
+ ask_options = {
55
+ mute_limit_set: true,
56
+ limited_to: ('1'..files.size.to_s).to_a,
57
+ skip: ''
58
+ }
59
+ answer = ask('Which file would you like to copy?', :green, ask_options)
60
+ abort if answer == ask_options[:skip]
61
+ create_gitignore(Dir.pwd + '/.gitignore', files[answer.to_i - 1])
62
+ end
63
+
41
64
  no_commands do
42
65
 
43
66
  private
67
+
44
68
  # Fetches Github repositories for a given user
45
69
  def get_gh_repos(uname)
46
70
  url = "#{GH_API_URL}/users/#{uname}/repos"
@@ -48,6 +72,20 @@ module GitCLI
48
72
  get url, gh_repos_filepath, verbose: false
49
73
  JSON.parse File.read(gh_repos_filepath)
50
74
  end
75
+
76
+ # Fetches a list of predefined gitignore files from github/gitignore repo
77
+ def get_gitignore_list
78
+ url = "#{GH_API_URL}/repos/github/gitignore/contents"
79
+ gitignore_list_filepath = ENV['HOME'] + '/.thorium/gh_gitignore_list.json'
80
+ get url, gitignore_list_filepath, verbose: false
81
+ JSON.parse File.read(gitignore_list_filepath)
82
+ end
83
+
84
+ # Fetch gitignore file
85
+ def create_gitignore(file_path, file_url)
86
+ url = GITIGNORE_REPO + file_url
87
+ get url, file_path
88
+ end
51
89
  end
52
90
  end
53
91
  end
@@ -1,4 +1,4 @@
1
1
  # Top level comment for thorium
2
2
  module Thorium
3
- VERSION = '0.4.1'
3
+ VERSION = '0.5.0.beta1'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thorium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Stankevich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-11 00:00:00.000000000 Z
11
+ date: 2014-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -83,9 +83,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
83
  version: 2.0.0
84
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - '>='
86
+ - - '>'
87
87
  - !ruby/object:Gem::Version
88
- version: '0'
88
+ version: 1.3.1
89
89
  requirements: []
90
90
  rubyforge_project:
91
91
  rubygems_version: 2.2.2