snip 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ gem "trollop", "~> 1.16"
6
+
7
+ # Add dependencies to develop your gem here.
8
+ # Include everything needed to run rake, tests, features, etc.
9
+ group :development do
10
+ gem "shoulda", ">= 0"
11
+ gem "rdoc", "~> 3.12"
12
+ gem "bundler", "~> 1.0.0"
13
+ gem "jeweler", "~> 1.8.3"
14
+ end
@@ -0,0 +1,25 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.8.3)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rdoc
10
+ json (1.6.5)
11
+ rake (0.9.2.2)
12
+ rdoc (3.12)
13
+ json (~> 1.4)
14
+ shoulda (2.11.3)
15
+ trollop (1.16.2)
16
+
17
+ PLATFORMS
18
+ ruby
19
+
20
+ DEPENDENCIES
21
+ bundler (~> 1.0.0)
22
+ jeweler (~> 1.8.3)
23
+ rdoc (~> 3.12)
24
+ shoulda
25
+ trollop (~> 1.16)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Boris Searles
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = snip
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to snip
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 Boris Searles. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "snip"
18
+ gem.homepage = "http://github.com/bozz/snip"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{command line snippet manager}
21
+ gem.description = %Q{command line snippet manager}
22
+ gem.email = "boris@lucidgardens.com"
23
+ gem.authors = ["Boris Searles"]
24
+ gem.executable = "snip"
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ task :default => :test
37
+
38
+ require 'rdoc/task'
39
+ Rake::RDocTask.new do |rdoc|
40
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
41
+
42
+ rdoc.rdoc_dir = 'rdoc'
43
+ rdoc.title = "snip #{version}"
44
+ rdoc.rdoc_files.include('README*')
45
+ rdoc.rdoc_files.include('lib/**/*.rb')
46
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'snip'
4
+ require 'trollop'
5
+
6
+ SUB_COMMANDS = %w(add edit list rm show run)
7
+ global_opts = Trollop::options do
8
+ version "snip 0.1.0 (c) 2012 Boris Searles"
9
+ banner "command line snippet manager"
10
+ stop_on SUB_COMMANDS
11
+ end
12
+
13
+ cmd = ARGV.shift # get the subcommand
14
+ cmd_opts = case cmd
15
+ when "add"
16
+ Snip.add(ARGV[0])
17
+ when "edit"
18
+ Snip.edit(ARGV[0])
19
+ when "list"
20
+ Snip.list(ARGV[0])
21
+ when "rm"
22
+ Snip.rm(ARGV[0])
23
+ when "show"
24
+ Snip.show(ARGV[0])
25
+ when "run"
26
+ Snip.run(ARGV[0])
27
+ else
28
+ Trollop::die "unknown subcommand #{cmd.inspect}"
29
+ end
30
+
31
+ #puts "Global options: #{global_opts.inspect}"
32
+ #puts "Subcommand: #{cmd.inspect}"
33
+ #puts "Subcommand options: #{cmd_opts.inspect}"
34
+ #puts "Remaining arguments: #{ARGV.inspect}"
35
+
36
+
@@ -0,0 +1,78 @@
1
+ class Snip
2
+
3
+ def self.init
4
+ root_dir = File.expand_path('~')
5
+ unless File.exists?("#{root_dir}/.snips")
6
+ puts "...initializing ~/.snips directory"
7
+ `mkdir $HOME/.snips`
8
+ end
9
+ end
10
+
11
+
12
+ def self.add(snippet)
13
+ Snip.init
14
+ `vim "$HOME/.snips/#{snippet}" 3>&1 1>&2 2>&3`
15
+ puts "...added new snippet: #{snippet}"
16
+ end
17
+
18
+
19
+ def self.edit(snippet)
20
+ Snip.init
21
+ root_dir = File.expand_path('~')
22
+ target_file = "#{root_dir}/.snips/#{snippet}"
23
+ if File.exists?(target_file)
24
+ `vim "#{target_file}" 3>&1 1>&2 2>&3`
25
+ else
26
+ puts "Snippet #{snippet} could not be found"
27
+ end
28
+ end
29
+
30
+
31
+ def self.list(query)
32
+ Snip.init
33
+ root_dir = File.expand_path('~')
34
+ Dir.foreach("#{root_dir}/.snips") do |file|
35
+ unless File.directory?(file)
36
+ puts file
37
+ end
38
+ end
39
+ end
40
+
41
+
42
+ def self.rm(snippet)
43
+ Snip.init
44
+ root_dir = File.expand_path('~')
45
+ target_file = "#{root_dir}/.snips/#{snippet}"
46
+ if File.exists?(target_file)
47
+ `rm #{target_file}`
48
+ puts "Snippet #{snippet} was deleted"
49
+ else
50
+ puts "Snippet #{snippet} could not be found"
51
+ end
52
+ end
53
+
54
+
55
+ def self.show(snippet)
56
+ Snip.init
57
+ root_dir = File.expand_path('~')
58
+ target_file = "#{root_dir}/.snips/#{snippet}"
59
+ if File.exists?(target_file)
60
+ puts `cat #{target_file}`
61
+ else
62
+ puts "Snippet #{snippet} could not be found"
63
+ end
64
+ end
65
+
66
+
67
+ def self.run(snippet)
68
+ Snip.init
69
+ root_dir = File.expand_path('~')
70
+ target_file = "#{root_dir}/.snips/#{snippet}"
71
+ if File.exists?(target_file)
72
+ puts `cat #{target_file}`
73
+ puts `cat #{target_file} | sh`
74
+ else
75
+ puts "Snippet #{snippet} could not be found"
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'snip'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestSnip < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: snip
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Boris Searles
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-04 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: trollop
16
+ requirement: &24388840 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.16'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *24388840
25
+ - !ruby/object:Gem::Dependency
26
+ name: shoulda
27
+ requirement: &24388280 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *24388280
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdoc
38
+ requirement: &24387800 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '3.12'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *24387800
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: &24387020 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *24387020
58
+ - !ruby/object:Gem::Dependency
59
+ name: jeweler
60
+ requirement: &24386480 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 1.8.3
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *24386480
69
+ description: command line snippet manager
70
+ email: boris@lucidgardens.com
71
+ executables:
72
+ - snip
73
+ extensions: []
74
+ extra_rdoc_files:
75
+ - LICENSE.txt
76
+ - README.rdoc
77
+ files:
78
+ - .document
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE.txt
82
+ - README.rdoc
83
+ - Rakefile
84
+ - VERSION
85
+ - bin/snip
86
+ - lib/snip.rb
87
+ - test/helper.rb
88
+ - test/test_snip.rb
89
+ homepage: http://github.com/bozz/snip
90
+ licenses:
91
+ - MIT
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ segments:
103
+ - 0
104
+ hash: -2118759123288687265
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 1.8.10
114
+ signing_key:
115
+ specification_version: 3
116
+ summary: command line snippet manager
117
+ test_files: []