forgitter 0.0.1

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: 7d7c40460230e6a4a951ff2ec52d74684c24329f
4
+ data.tar.gz: 9fe63ce763a4145bafd1ec03ae8b0467e3f6dcd6
5
+ SHA512:
6
+ metadata.gz: 5e180b47bdf7670216935b1da0fbd2d93a68401f13ff7ce8845ed2c5d90b5505b16dd412d36b023679b8034c8a39b547fd90fd4a00506a3fd307dac40add54fe
7
+ data.tar.gz: f253a03c085b00bb2421b79637ffd208792a4982b44c79ce8b6743e68e2dab099a02a97c51174f0cf6f2ae3f36e792c8859b6bbb21dfeaa8756d8f2b1e5dfc11
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in forgitter.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Cloudspace
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Forgitter
2
+
3
+ .gitignore generator
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'forgitter'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install forgitter
18
+
19
+ ## Usage
20
+
21
+ forgitter TYPE1 [TYPE2 [TYPE3] ...]
22
+
23
+ See `forgitter -h` for more options.
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( http://github.com/cloudspace/forgitter/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/bin/forgitter ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'forgitter'
4
+ require 'forgitter/cli'
5
+
6
+ option_parser = Forgitter::CLI::OptionParser.new
7
+ options = option_parser.parse(ARGV)
8
+
9
+ unless ARGV.empty?
10
+ options[:types] = []
11
+ options[:types] << ARGV.pop until ARGV.empty?
12
+ end
13
+
14
+ runner = Forgitter::Runner.new(options)
15
+ runner.run
data/forgitter.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'forgitter/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'forgitter'
8
+ spec.version = Forgitter::VERSION
9
+ spec.authors = ['Adam Dunson', 'Jeremiah Hemphill']
10
+ spec.email = ['adam@cloudspace.com', 'jeremiah@cloudspace.com']
11
+ spec.summary = %q{.gitignore generator}
12
+ spec.description = %q{.gitignore generator}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.5'
22
+ spec.add_development_dependency 'rake'
23
+
24
+ spec.add_dependency 'octokit'
25
+ end
@@ -0,0 +1,68 @@
1
+ require 'optparse'
2
+ require 'optparse/time'
3
+ require 'ostruct'
4
+
5
+ module Forgitter
6
+ module CLI
7
+ class OptionParser
8
+ attr_accessor :options, :opt_parser
9
+
10
+ def initialize
11
+ # The options specified on the command line will be collected in *options*.
12
+ # We set default values here.
13
+ @options = Forgitter::DEFAULT_OPTIONS
14
+
15
+ @opt_parser = ::OptionParser.new do |opts|
16
+ opts.banner = 'Usage: forgitter TYPE1 [TYPE2 ...]'
17
+
18
+ opts.separator ''
19
+ opts.separator 'Specific options:'
20
+
21
+ opts.on('-c', '--stdout',
22
+ 'Write the combined .gitignore to the standard output stream and not to disk.') do
23
+ options[:stdout] = true
24
+ end
25
+
26
+ opts.on('-t', '--token TOKEN',
27
+ 'Provide a GitHub access token for a higher rate limit (see https://developer.github.com/v3/#rate-limiting).') do |token|
28
+ options[:access_token] = token
29
+ end
30
+
31
+ opts.separator ''
32
+ opts.separator 'Common options:'
33
+
34
+ # No argument, shows at tail. This will print an options summary.
35
+ # Try it and see!
36
+ opts.on_tail('-h', '--help', 'Show this message') do
37
+ puts opts
38
+ exit
39
+ end
40
+
41
+ # Another typical switch to print the version.
42
+ opts.on_tail('-v', '--version', 'Show version') do
43
+ puts Forgitter::VERSION
44
+ exit
45
+ end
46
+ end
47
+
48
+ end
49
+
50
+ def help
51
+ opt_parser.help
52
+ end
53
+
54
+ #
55
+ # Return a structure describing the options.
56
+ #
57
+ def parse(args)
58
+ begin
59
+ opt_parser.parse!(args)
60
+ rescue ::OptionParser::InvalidOption => e
61
+ puts help
62
+ exit(1)
63
+ end
64
+ options
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,6 @@
1
+ require 'forgitter/cli/option_parser'
2
+
3
+ module Forgitter
4
+ module CLI
5
+ end
6
+ end
@@ -0,0 +1,46 @@
1
+ module Forgitter
2
+ DEFAULT_EDITORS = ['eclipse', 'emacs', 'osx', 'linux', 'xcode', 'vim', 'textmate', 'sublimetext']
3
+ EDITORS = {
4
+ 'archives' => 'Global/Archives.gitignore',
5
+ 'bricxcc' => 'Global/BricxCC.gitignore',
6
+ 'cvs' => 'Global/CVS.gitignore',
7
+ 'cloud' => 'Global/Cloud9.gitignore',
8
+ 'darteditor' => 'Global/DartEditor.gitignore',
9
+ 'dreamweaver' => 'Global/Dreamweaver.gitignore',
10
+ 'eclipse' => 'Global/Eclipse.gitignore',
11
+ 'eiffelstudio' => 'Global/EiffelStudio.gitignore',
12
+ 'emacs' => 'Global/Emacs.gitignore',
13
+ 'ensime' => 'Global/Ensime.gitignore',
14
+ 'espresso' => 'Global/Espresso.gitignore',
15
+ 'flexbuilder' => 'Global/FlexBuilder.gitignore',
16
+ 'ipythonnotebook' => 'Global/IPythonNotebook.gitignore',
17
+ 'jetbrains' => 'Global/JetBrains.gitignore',
18
+ 'kdevelop' => 'Global/KDevelop4.gitignore',
19
+ 'kate' => 'Global/Kate.gitignore',
20
+ 'lazarus' => 'Global/Lazarus.gitignore',
21
+ 'linux' => 'Global/Linux.gitignore',
22
+ 'matlab' => 'Global/Matlab.gitignore',
23
+ 'mercurial' => 'Global/Mercurial.gitignore',
24
+ 'modelsim' => 'Global/ModelSim.gitignore',
25
+ 'monodevelop' => 'Global/MonoDevelop.gitignore',
26
+ 'netbeans' => 'Global/NetBeans.gitignore',
27
+ 'notepad' => 'Global/NotepadPP.gitignore',
28
+ 'notepadpp' => 'Global/NotepadPP.gitignore',
29
+ 'osx' => 'Global/OSX.gitignore',
30
+ 'quartus' => 'Global/Quartus2.gitignore',
31
+ 'redcar' => 'Global/Redcar.gitignore',
32
+ 'sbt' => 'Global/SBT.gitignore',
33
+ 'svn' => 'Global/SVN.gitignore',
34
+ 'slickedit' => 'Global/SlickEdit.gitignore',
35
+ 'sublimetext' => 'Global/SublimeText.gitignore',
36
+ 'tags' => 'Global/Tags.gitignore',
37
+ 'textmate' => 'Global/TextMate.gitignore',
38
+ 'vagrant' => 'Global/Vagrant.gitignore',
39
+ 'virtualenv' => 'Global/VirtualEnv.gitignore',
40
+ 'windows' => 'Global/Windows.gitignore',
41
+ 'xcode' => 'Global/Xcode.gitignore',
42
+ 'xilinxise' => 'Global/XilinxISE.gitignore',
43
+ 'vim' => 'Global/vim.gitignore',
44
+ 'webmethods' => 'Global/webMethods.gitignore'
45
+ }
46
+ end
@@ -0,0 +1,8 @@
1
+ module Forgitter
2
+ DEFAULT_OPTIONS = {
3
+ :types => Forgitter::DEFAULT_TYPES,
4
+ :editors => Forgitter::DEFAULT_EDITORS,
5
+ :stdout => false,
6
+ :access_token => ''
7
+ }
8
+ end
@@ -0,0 +1,57 @@
1
+ require 'octokit'
2
+
3
+ module Forgitter
4
+ class Runner
5
+ def initialize(options = Forgitter::DEFAULT_OPTIONS)
6
+ @types = convert_to_filenames(options[:types])
7
+ @editors = convert_to_filenames(options[:editors])
8
+ @stdout = options[:stdout]
9
+
10
+ @client = Octokit
11
+ @client = Octokit::Client.new(:access_token => options[:access_token]) unless options[:access_token].empty?
12
+ end
13
+
14
+ def run
15
+ output = ""
16
+ (@types | @editors).each do |type|
17
+ ignore_file = get_ignore_file(type)
18
+ if ignore_file
19
+ output += "# Information from #{type}\n"
20
+ output += ignore_file
21
+ end
22
+ end
23
+
24
+ if @stdout
25
+ puts output
26
+ else
27
+ File.open('.gitignore', 'w') do |file|
28
+ file.write(output)
29
+ end
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ # Given a filename on the gitignore repo, return a string with the contents of the file
36
+ def get_ignore_file(filename)
37
+ puts "Fetching #{filename}"
38
+ begin
39
+ api_response = @client.contents('github/gitignore', :ref => 'master', :path => filename)
40
+ Base64.decode64( api_response.content )
41
+ rescue Octokit::TooManyRequests
42
+ puts "You are being rate limited! Failed to fetch #{filename}."
43
+ end
44
+ end
45
+
46
+ # converts "rails" or "Rails" into "Rails.gitignore"
47
+ def convert_to_filenames(names)
48
+ names.map do |name|
49
+ conversion_table[name.downcase.gsub(/[^+a-z]/i, '')]
50
+ end.compact
51
+ end
52
+
53
+ def conversion_table
54
+ @conversion_table ||= Forgitter::TYPES.merge(Forgitter::EDITORS)
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,110 @@
1
+ module Forgitter
2
+ DEFAULT_TYPES = ['rails']
3
+ TYPES = {
4
+ 'actionscript' => 'Actionscript.gitignore',
5
+ 'ada' => 'Ada.gitignore',
6
+ 'agda' => 'Agda.gitignore',
7
+ 'android' => 'Android.gitignore',
8
+ 'appceleratortitanium' => 'AppceleratorTitanium.gitignore',
9
+ 'archlinuxpackages' => 'ArchLinuxPackages.gitignore',
10
+ 'autotools' => 'Autotools.gitignore',
11
+ 'bancha' => 'Bancha.gitignore',
12
+ 'c++' => 'C++.gitignore',
13
+ 'c' => 'C.gitignore',
14
+ 'cfwheels' => 'CFWheels.gitignore',
15
+ 'cmake' => 'CMake.gitignore',
16
+ 'cakephp' => 'CakePHP.gitignore',
17
+ 'chefcookbook' => 'ChefCookbook.gitignore',
18
+ 'clojure' => 'Clojure.gitignore',
19
+ 'codeigniter' => 'CodeIgniter.gitignore',
20
+ 'commonlisp' => 'CommonLisp.gitignore',
21
+ 'composer' => 'Composer.gitignore',
22
+ 'concrete' => 'Concrete5.gitignore',
23
+ 'coq' => 'Coq.gitignore',
24
+ 'dm' => 'DM.gitignore',
25
+ 'dart' => 'Dart.gitignore',
26
+ 'delphi' => 'Delphi.gitignore',
27
+ 'drupal' => 'Drupal.gitignore',
28
+ 'episerver' => 'EPiServer.gitignore',
29
+ 'eagle' => 'Eagle.gitignore',
30
+ 'elisp' => 'Elisp.gitignore',
31
+ 'elixir' => 'Elixir.gitignore',
32
+ 'erlang' => 'Erlang.gitignore',
33
+ 'expressionengine' => 'ExpressionEngine.gitignore',
34
+ 'fancy' => 'Fancy.gitignore',
35
+ 'finale' => 'Finale.gitignore',
36
+ 'forcedotcom' => 'ForceDotCom.gitignore',
37
+ 'fuelphp' => 'FuelPHP.gitignore',
38
+ 'gwt' => 'GWT.gitignore',
39
+ 'go' => 'Go.gitignore',
40
+ 'gradle' => 'Gradle.gitignore',
41
+ 'grails' => 'Grails.gitignore',
42
+ 'haskell' => 'Haskell.gitignore',
43
+ 'idris' => 'Idris.gitignore',
44
+ 'java' => 'Java.gitignore',
45
+ 'jboss' => 'Jboss.gitignore',
46
+ 'jekyll' => 'Jekyll.gitignore',
47
+ 'joomla' => 'Joomla.gitignore',
48
+ 'jython' => 'Jython.gitignore',
49
+ 'kohana' => 'Kohana.gitignore',
50
+ 'laravel' => 'Laravel4.gitignore',
51
+ 'leiningen' => 'Leiningen.gitignore',
52
+ 'lemonstand' => 'LemonStand.gitignore',
53
+ 'lilypond' => 'Lilypond.gitignore',
54
+ 'lithium' => 'Lithium.gitignore',
55
+ 'magento' => 'Magento.gitignore',
56
+ 'maven' => 'Maven.gitignore',
57
+ 'mercury' => 'Mercury.gitignore',
58
+ 'meteor' => 'Meteor.gitignore',
59
+ 'node' => 'Node.gitignore',
60
+ 'ocaml' => 'OCaml.gitignore',
61
+ 'objcetivec' => 'Objective-C.gitignore',
62
+ 'opa' => 'Opa.gitignore',
63
+ 'opencart' => 'OpenCart.gitignore',
64
+ 'oracleforms' => 'OracleForms.gitignore',
65
+ 'packer' => 'Packer.gitignore',
66
+ 'perl' => 'Perl.gitignore',
67
+ 'phalcon' => 'Phalcon.gitignore',
68
+ 'playframework' => 'PlayFramework.gitignore',
69
+ 'plone' => 'Plone.gitignore',
70
+ 'prestashtop' => 'Prestashop.gitignore',
71
+ 'processing' => 'Processing.gitignore',
72
+ 'python' => 'Python.gitignore',
73
+ 'qooxdoo' => 'Qooxdoo.gitignore',
74
+ 'qt' => 'Qt.gitignore',
75
+ 'r' => 'R.gitignore',
76
+ 'ros' => 'ROS.gitignore',
77
+ 'rails' => 'Rails.gitignore',
78
+ 'rhodesrhomobile' => 'RhodesRhomobile.gitignore',
79
+ 'ruby' => 'Ruby.gitignore',
80
+ 'scons' => 'SCons.gitignore',
81
+ 'sass' => 'Sass.gitignore',
82
+ 'scala' => 'Scala.gitignore',
83
+ 'scrivener' => 'Scrivener.gitignore',
84
+ 'sdcc' => 'Sdcc.gitignore',
85
+ 'seamgen' => 'SeamGen.gitignore',
86
+ 'sketchup' => 'SketchUp.gitignore',
87
+ 'sugarcrm' => 'SugarCRM.gitignore',
88
+ 'symfony' => 'Symfony.gitignore',
89
+ 'symfonytwo' => 'Symfony2.gitignore',
90
+ 'symphonycms' => 'SymphonyCMS.gitignore',
91
+ 'target' => 'Target3001.gitignore',
92
+ 'tasm' => 'Tasm.gitignore',
93
+ 'tex' => 'TeX.gitignore',
94
+ 'textpattern' => 'Textpattern.gitignore',
95
+ 'turbogears' => 'TurboGears2.gitignore',
96
+ 'typo' => 'Typo3.gitignore',
97
+ 'umbraco' => 'Umbraco.gitignore',
98
+ 'unity' => 'Unity.gitignore',
99
+ 'vvvv' => 'VVVV.gitignore',
100
+ 'visualstudio' => 'VisualStudio.gitignore',
101
+ 'waf' => 'Waf.gitignore',
102
+ 'wordpress' => 'WordPress.gitignore',
103
+ 'yeoman' => 'Yeoman.gitignore',
104
+ 'yii' => 'Yii.gitignore',
105
+ 'zendframework' => 'ZendFramework.gitignore',
106
+ 'gcov' => 'gcov.gitignore',
107
+ 'nanoc' => 'nanoc.gitignore',
108
+ 'stella' => 'stella.gitignore',
109
+ }
110
+ end
@@ -0,0 +1,3 @@
1
+ module Forgitter
2
+ VERSION = '0.0.1'
3
+ end
data/lib/forgitter.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'forgitter/editors'
2
+ require 'forgitter/types'
3
+ require 'forgitter/options'
4
+ require 'forgitter/runner'
5
+ require 'forgitter/version'
6
+
7
+ module Forgitter
8
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: forgitter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Adam Dunson
8
+ - Jeremiah Hemphill
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-05-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.5'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.5'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: octokit
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description: ".gitignore generator"
57
+ email:
58
+ - adam@cloudspace.com
59
+ - jeremiah@cloudspace.com
60
+ executables:
61
+ - forgitter
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - ".gitignore"
66
+ - Gemfile
67
+ - LICENSE
68
+ - README.md
69
+ - Rakefile
70
+ - bin/forgitter
71
+ - forgitter.gemspec
72
+ - lib/forgitter.rb
73
+ - lib/forgitter/cli.rb
74
+ - lib/forgitter/cli/option_parser.rb
75
+ - lib/forgitter/editors.rb
76
+ - lib/forgitter/options.rb
77
+ - lib/forgitter/runner.rb
78
+ - lib/forgitter/types.rb
79
+ - lib/forgitter/version.rb
80
+ homepage: ''
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.2.2
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: ".gitignore generator"
104
+ test_files: []