refh 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ gem "rubyheap", "~> 0.1.1"
6
+ gem "trollop", "~> 1.16.2"
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "shoulda", ">= 0"
12
+ gem "bundler", "~> 1.0.0"
13
+ gem "jeweler", "~> 1.6.4"
14
+ gem "rcov", ">= 0"
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ httparty (0.8.1)
6
+ multi_json
7
+ multi_xml
8
+ jeweler (1.6.4)
9
+ bundler (~> 1.0)
10
+ git (>= 1.2.5)
11
+ rake
12
+ multi_json (1.0.4)
13
+ multi_xml (0.4.1)
14
+ rake (0.9.2.2)
15
+ rcov (0.9.9)
16
+ rubyheap (0.1.1)
17
+ httparty (~> 0.8.1)
18
+ shoulda (2.11.3)
19
+ trollop (1.16.2)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ bundler (~> 1.0.0)
26
+ jeweler (~> 1.6.4)
27
+ rcov
28
+ rubyheap (~> 0.1.1)
29
+ shoulda
30
+ trollop (~> 1.16.2)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Anthony Grimes
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.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # refh
2
+
3
+ This is a little command-line tool for pasting to <https://refheap.com>.
4
+ It requires at least version 1.9.2 of Ruby.
5
+
6
+ ```
7
+ 68-245-171-115:refh anthony$ refh --help
8
+ Refh is a simple command-line application for pasting to https://refheap.com
9
+
10
+ Usage:
11
+ refh [options] <filename>
12
+ refh [options]
13
+
14
+ If the second form is used, input will be expected on stdin.
15
+
16
+ Options are:
17
+ --private, -p: Make the paste private.
18
+ --language, -l <s>: Set the language for this paste.
19
+ --user, -u <s>: Set username.
20
+ --token, -t <s>: Set token.
21
+ --anon, -a: Make this paste anonymous, regardless of username and
22
+ token settings.
23
+ --version, -v: Print version and exit
24
+ --help, -h: Show this message
25
+ ```
26
+
27
+ If you don't explicitly set `--language`, refh will try to determine it
28
+ from the file extension. `--language` must be set to a string that is of
29
+ the same format as the language appears in the dropdown box on the
30
+ [refheap website](https://refheap.com).
31
+
32
+ If you don't want to pass your `--user` and `--token` each time, you can
33
+ set it in `~/.refh.yml`. The file should look like this:
34
+
35
+ ```yaml
36
+ 68-245-171-115:refh anthony$ cat ~/.refh.yml
37
+ ---
38
+ user: Raynes
39
+ token: REMOVED
40
+ ```
data/Rakefile ADDED
@@ -0,0 +1,53 @@
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 = "refh"
18
+ gem.homepage = "http://github.com/Raynes/refh"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A command-line application for pasting to RefHeap.}
21
+ gem.description = %Q{A command-line application for pasting to https://refheap.com.}
22
+ gem.email = "i@raynes.me"
23
+ gem.authors = ["Anthony Grimes"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "refh #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/refh ADDED
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubyheap'
4
+ require 'trollop'
5
+ require 'yaml'
6
+
7
+ opts = Trollop::options do
8
+ version "refh 0.1.0 -- https://github.com/Raynes/refh"
9
+ banner <<-EOS
10
+ Refh is a simple command-line application for pasting to https://refheap.com
11
+
12
+ Usage:
13
+ refh [options] <filename>
14
+ refh [options]
15
+
16
+ If the second form is used, input will be expected on stdin.
17
+
18
+ Options are:
19
+ EOS
20
+
21
+ opt :private, "Make the paste private."
22
+ opt :language, "Set the language for this paste.", :type => String
23
+ opt :user, "Set username.", :type => String
24
+ opt :token, "Set token.", :type => String
25
+ opt :anon, "Make this paste anonymous, regardless of username and token settings."
26
+ end
27
+
28
+ config = YAML.load_file File.expand_path("~/.refh.yml")
29
+ # The user and token options override the default settings in the yaml
30
+ # config.
31
+ user = opts[:user] || config['user']
32
+ token = opts[:token] || config['token']
33
+
34
+ heap = nil
35
+
36
+ languages = {"clj" => "Clojure",
37
+ "cljs" => "Clojure",
38
+ "fy" => "Fancy",
39
+ "groovy" => "Groovy",
40
+ "factor" => "Factor",
41
+ "io" => "Io",
42
+ "ioke" => "Ioke",
43
+ "lua" => "Lua",
44
+ "pl" => "Perl",
45
+ "perl" => "Perl",
46
+ "py" => "Python",
47
+ "rb" => "Ruby",
48
+ "mirah" => "Duby",
49
+ "tcl" => "Tcl",
50
+ "ada" => "Ada",
51
+ "c" => "C",
52
+ "cpp" => "C++",
53
+ "d" => "D",
54
+ "dylan" => "Dylan",
55
+ "flx" => "Felix",
56
+ "fortran" => "Fortran",
57
+ "nim" => "Nimrod",
58
+ "go" => "Go",
59
+ "java" => "Java",
60
+ "def" => "Modula-2",
61
+ "mod" => "Module-2",
62
+ "ooc" => "ooc",
63
+ "m" => "Objective-C",
64
+ "pro" => "Prolog",
65
+ "prolog" => "Prolog",
66
+ "scala" => "Scala",
67
+ "vala" => "Vala",
68
+ "boo" => "Boo",
69
+ "cs" => "C#",
70
+ "fs" => "F#",
71
+ "n" => "Nemerle",
72
+ "vb" => "VB.NET",
73
+ "lisp" => "Common Lisp",
74
+ "erl" => "Erlang",
75
+ "hs" => "Haskell",
76
+ "lhs" => "Literate Haskell",
77
+ "ml" => "OCaml",
78
+ "scm" => "Scheme",
79
+ "rkt" => "Scheme",
80
+ "ss" => "Scheme",
81
+ "v" => "Verilog",
82
+ "r" => "R",
83
+ "abap" => "ABAP",
84
+ "applescript" => "AppleScript",
85
+ "ahk" => "Autohotkey",
86
+ "awk" => "Awk",
87
+ "sh" => "Bash",
88
+ "bat" => "Batch",
89
+ "bf" => "Brainfuck",
90
+ "befunge" => "Befunge",
91
+ "ns2" => "NewSpeak",
92
+ "ps" => "PostScript",
93
+ "proto" => "Protobuf",
94
+ "r3" => "REBOL",
95
+ "st" => "Smalltalk",
96
+ "cmake" => "CMake",
97
+ "dpatch" => "Darcs Patch",
98
+ "diff" => "Diff",
99
+ "init" => "INI",
100
+ "properties" => "Java Properties",
101
+ "rst" => "rST",
102
+ "tex" => "LaTeX",
103
+ "vim" => "VimL",
104
+ "yaml" => "YAML",
105
+ "coffeescript" => "CoffeeScript",
106
+ "css" => "CSS",
107
+ "html" => "HTML",
108
+ "xml" => "XML",
109
+ "haml" => "HAML",
110
+ "js" => "Javascript",
111
+ "php" => "PHP",
112
+ "sass" => "SASS",
113
+ "txt" => "Plain Text",
114
+ "scaml" => "Scaml"}
115
+
116
+ languages.default("Plain Text")
117
+
118
+ if user && token && !opts[:anon]
119
+ heap = Refheap::Paste.new user, token
120
+ else
121
+ heap = Refheap::Paste.new
122
+ end
123
+
124
+ create_opts = {:private => opts[:private],
125
+ :language => opts[:language]}
126
+
127
+ file = ARGV.first
128
+ if file
129
+ unless create_opts[:language]
130
+ file = File.expand_path(file)
131
+ create_opts['language'] = languages[File.extname(file)[1..-1]]
132
+ end
133
+ puts heap.create(File.open(file).read, create_opts)['url']
134
+ else
135
+ puts heap.create(STDIN.read, create_opts)['url']
136
+ end
data/test/helper.rb ADDED
@@ -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 'refh'
16
+
17
+ class Test::Unit::TestCase
18
+ end
data/test/test_refh.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestRefh < 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,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refh
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Anthony Grimes
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-25 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rubyheap
16
+ requirement: &2153817860 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.1.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2153817860
25
+ - !ruby/object:Gem::Dependency
26
+ name: trollop
27
+ requirement: &2153816800 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.16.2
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2153816800
36
+ - !ruby/object:Gem::Dependency
37
+ name: shoulda
38
+ requirement: &2153815840 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2153815840
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: &2153814960 !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: *2153814960
58
+ - !ruby/object:Gem::Dependency
59
+ name: jeweler
60
+ requirement: &2153809440 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 1.6.4
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2153809440
69
+ - !ruby/object:Gem::Dependency
70
+ name: rcov
71
+ requirement: &2153808380 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *2153808380
80
+ description: A command-line application for pasting to https://refheap.com.
81
+ email: i@raynes.me
82
+ executables:
83
+ - refh
84
+ extensions: []
85
+ extra_rdoc_files:
86
+ - LICENSE.txt
87
+ - README.md
88
+ files:
89
+ - .document
90
+ - Gemfile
91
+ - Gemfile.lock
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - VERSION
96
+ - bin/refh
97
+ - test/helper.rb
98
+ - test/test_refh.rb
99
+ homepage: http://github.com/Raynes/refh
100
+ licenses:
101
+ - MIT
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ segments:
113
+ - 0
114
+ hash: -284725031871549987
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 1.8.10
124
+ signing_key:
125
+ specification_version: 3
126
+ summary: A command-line application for pasting to RefHeap.
127
+ test_files: []