ignoring 0.0.1 → 1.0.0

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: 6b3326d681317d030f02b99ea271947e6b441be9
4
- data.tar.gz: 527983bd00b456d3d6f6b26d160c154edceaa56e
3
+ metadata.gz: 9270dab31b4d8bc99f17a6a6e4d3bfeedac4b732
4
+ data.tar.gz: 384edaaccdba075470e24d20f80473242091faf4
5
5
  SHA512:
6
- metadata.gz: f78f320d5036711a922adff7f77dbb23853453b772179171515dfeb1e8243229eb61de56189d8ad0c70e27e73627b97877953f52249b15ccec402a258a5316bb
7
- data.tar.gz: cea4297c2537de5441ad773d31415a4f8b4371a5e7476b35f0ab5b42a1f2d7064855a4d4f230cbf2ef161412b8a7577d3bc2fa04da2ec38225d9a16ed69669b4
6
+ metadata.gz: 3cd691caf038ed6c66ceb7a66f4af1fbfb0f9a9c113151931c9c7c2fe14c58095c4bc06439530087c80273be9aaef8857add146c5583a0653e200d6ecdba90e3
7
+ data.tar.gz: 387a99266910fd758a5c44f3af648dcca068ce619c72e94e08394d724c2dbea519cf2acc15e3030e336dda03d9b12333c68f3d5d3f0d43f3308d55074385d781
data/README.md CHANGED
@@ -18,12 +18,64 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ This tool is realtively simple to use. You can use either `ignoring` or `gitignore`. For these examples, I will be using `gitignore`.
22
+
23
+ ### Creating a gitignore
24
+
25
+ Creating a .gitignore file in your currrent directory
26
+
27
+ $ gitignore create
28
+
29
+ Creating a global gitignore (You will be prompted for a location)
30
+
31
+ $ gitignore create -g
32
+ $ gitignore create --global
33
+
34
+ ### Adding to a gitignore
35
+
36
+ Adding items to the gitignore
37
+
38
+ $ gitignore add tmp Gemfile.lock
39
+ $ gitignore add -g .DS_Store
40
+ $ gitignore add --global .DS_Store
41
+
42
+ Adding languages to the gitignore. (These are retrieved from github's gitignores)
43
+
44
+ $ gitignore add -l Ruby Rails
45
+ $ gitignore add -gl Ruby Rails
46
+ $ gitignore add --global --languages Ruby Rails
47
+
48
+ ### List languages
49
+
50
+ List languages from github's gitignores
51
+
52
+ $ gitignore list
53
+
54
+ ### Show gitignores
55
+
56
+ Print your local gitignore to STDOUT
57
+
58
+ $ gitignore show
59
+
60
+ Print your global gitignore to STDOUT
61
+
62
+ $ gitignore show -g
63
+ $ gitignore show --global
64
+
65
+ Print a specific language to STDOUT
66
+
67
+ $ gitignore show -l Ruby
68
+ $ gitignore show --language Ruby
69
+
70
+ ## Future
71
+
72
+ * Create your own templates
73
+
22
74
 
23
75
  ## Contributing
24
76
 
25
- 1. Fork it ( http://github.com/<my-github-username>/ignoring/fork )
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
77
+ 1. Fork it ( http://github.com/kristenmills/ignoring/fork )
78
+ 2. Create your feature branch (`git checkout -b feature/my-new-feature`)
27
79
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
80
+ 4. Push to the branch (`git push origin feature/my-new-feature`)
29
81
  5. Create new Pull Request
data/bin/gitignore ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ignoring'
4
+
5
+ Ignoring::CLI.start(ARGV)
data/bin/ignoring ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ignoring'
4
+
5
+ Ignoring::CLI.start(ARGV)
data/ignoring.gemspec CHANGED
@@ -21,5 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.5"
22
22
  spec.add_development_dependency "rake"
23
23
 
24
- spec.add_dependency "thor", '~>0.19'
24
+ spec.add_dependency "thor", "~> 0.19"
25
+ spec.add_dependency "git", "~> 1.2.8"
26
+ spec.add_dependency "highline", "~> 1.6"
27
+ spec.add_dependency "terminal-table", "~> 1.4.5"
25
28
  end
@@ -0,0 +1,32 @@
1
+ require "thor"
2
+
3
+ # CLI class
4
+ module Ignoring
5
+ class CLI < Thor
6
+
7
+ desc "create", "creates a new gitignore if one doesn't exist in the directory"
8
+ option :global, type: :boolean, desc: "whether to use global gitignore", aliases: :g
9
+ def create
10
+ Helpers::create(options)
11
+ end
12
+
13
+ desc "add [ITEM/LANGUAGE...]", "Adds a new item to the gitignore if it isn't already added"
14
+ option :global, type: :boolean, desc: "use global gitignore", aliases: :g
15
+ option :languages, type: :boolean, desc: "get language templates from github", aliases: :l
16
+ def add(*items)
17
+ Helpers::add(options, items)
18
+ end
19
+
20
+ desc "list", "lists the different languages available from github/gitignore"
21
+ def list
22
+ Helpers::list
23
+ end
24
+
25
+ desc "show", "displays a gitignore"
26
+ option :global, type: :boolean, desc: "whether to use global gitignore", aliases: :g
27
+ option :language, desc: "displays gitignore for language from github/gitignore repo", aliases: :l
28
+ def show
29
+ Helpers::show(options)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,96 @@
1
+ require "fileutils"
2
+ require "octokit"
3
+ require "highline/import"
4
+ require "git"
5
+ require "terminal-table"
6
+
7
+ module Ignoring
8
+ module Helpers
9
+ extend self
10
+
11
+ # Logic for creating a gitignore
12
+ #
13
+ # @param options the options hash
14
+ def create(options)
15
+ if options[:global]
16
+ file = Git.global_config("core.excludesfile")
17
+ if file.empty?
18
+ file = ask("Where would you like your global gitignore? ")
19
+ Git.global_config("core.excludesfile", file)
20
+ end
21
+ else
22
+ file = '.gitignore'
23
+ end
24
+ FileUtils.touch(file)
25
+ end
26
+
27
+ # Logic for adding an item to a gitignore
28
+ #
29
+ # @param options the options hash
30
+ # @param items the items/languages to add
31
+ def add(options, items)
32
+ if options[:global]
33
+ file = Git.global_config("core.excludesfile")
34
+ else
35
+ file = ".gitignore" if File.exist?(".gitignore")
36
+ end
37
+ if file.empty? or file.nil?
38
+ puts "No gitignore. run create first." if file.empty?
39
+ else
40
+ combined = File.open(file).read.split("\n")
41
+ if options[:languages]
42
+ languages = items
43
+ items = []
44
+ languages.each do |lang|
45
+ items += language_array(lang) || []
46
+ end
47
+ end
48
+ items.each { |item| combined << item if !combined.include? item or item.start_with? "#" or item.empty? }
49
+ File.open(file, "w") do |file|
50
+ combined.each do |item|
51
+ file.puts item
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ # Logic for listing the languages
58
+ def list
59
+ langs = Octokit.gitignore_templates
60
+ lang_rows = []
61
+ langs.each_slice(4) do |group|
62
+ lang_rows << group
63
+ end
64
+ table = Terminal::Table.new(rows: lang_rows)
65
+ table.style = {border_x: "", border_i: "", border_y: ""}
66
+ puts table
67
+ rescue
68
+ puts "Error gitting language information. You might have reached your rate limit for the hour."
69
+ end
70
+
71
+ # logic for showing gitignores
72
+ #
73
+ # @param options the options hash
74
+ def show(options)
75
+ if options[:global]
76
+ file = Git.global_config("core.excludesfile")
77
+ puts File.read(file) if File.exists?(file)
78
+ elsif options[:language]
79
+ puts Octokit.gitignore_template(options[:language])[:source]
80
+ else
81
+ puts File.read('.gitignore') if File.exists?('.gitignore')
82
+ end
83
+ rescue
84
+ puts "#{language} is not a valid language."
85
+ end
86
+
87
+ private
88
+
89
+ # Helper method for parsing github language template
90
+ def language_array(language)
91
+ Octokit.gitignore_template(language)[:source].split("\n")
92
+ rescue
93
+ puts "#{language} is not a valid language."
94
+ end
95
+ end
96
+ end
@@ -1,3 +1,3 @@
1
1
  module Ignoring
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/ignoring.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require "ignoring/version"
2
+ require "ignoring/helpers"
3
+ require "ignoring/cli"
2
4
 
5
+ # Ignoring module
3
6
  module Ignoring
4
- # Your code goes here...
5
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ignoring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristen Mills
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-19 00:00:00.000000000 Z
11
+ date: 2014-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,10 +52,54 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.19'
55
+ - !ruby/object:Gem::Dependency
56
+ name: git
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2.8
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.2.8
69
+ - !ruby/object:Gem::Dependency
70
+ name: highline
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.6'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: terminal-table
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.4.5
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.4.5
55
97
  description: Tool for managing gitignores
56
98
  email:
57
99
  - kristen@kristen-mills.com
58
- executables: []
100
+ executables:
101
+ - gitignore
102
+ - ignoring
59
103
  extensions: []
60
104
  extra_rdoc_files: []
61
105
  files:
@@ -64,8 +108,12 @@ files:
64
108
  - LICENSE.txt
65
109
  - README.md
66
110
  - Rakefile
111
+ - bin/gitignore
112
+ - bin/ignoring
67
113
  - ignoring.gemspec
68
114
  - lib/ignoring.rb
115
+ - lib/ignoring/cli.rb
116
+ - lib/ignoring/helpers.rb
69
117
  - lib/ignoring/version.rb
70
118
  homepage: https://github.com/kristenmills/ignoring
71
119
  licenses: