saber 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source :rubygems
2
+
3
+ gem "optimism", :path => "/home/guten/dev/one/optimism"
4
+ gem "pa", :path => "/home/guten/dev/one/pa"
5
+ gem "retort"
6
+ gem "thor"
7
+
8
+ group :development do
9
+ gem "rspec"
10
+ gem "watchr"
11
+ #gem "rag"
12
+ end
13
+
14
+ # gemspec
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: /home/guten/dev/one/optimism
3
+ specs:
4
+ optimism (3.0.4)
5
+ hike (~> 1.2.0)
6
+
7
+ PATH
8
+ remote: /home/guten/dev/one/pa
9
+ specs:
10
+ pa (1.1.4)
11
+
12
+ GEM
13
+ remote: http://rubygems.org/
14
+ specs:
15
+ diff-lcs (1.1.3)
16
+ hike (1.2.1)
17
+ retort (0.0.6)
18
+ rspec (2.8.0)
19
+ rspec-core (~> 2.8.0)
20
+ rspec-expectations (~> 2.8.0)
21
+ rspec-mocks (~> 2.8.0)
22
+ rspec-core (2.8.0)
23
+ rspec-expectations (2.8.0)
24
+ diff-lcs (~> 1.1.2)
25
+ rspec-mocks (2.8.0)
26
+ thor (0.14.6)
27
+ watchr (0.7)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ optimism!
34
+ pa!
35
+ retort
36
+ rspec
37
+ thor
38
+ watchr
@@ -0,0 +1,59 @@
1
+ Foo, a very good library
2
+ ========================
3
+
4
+ | Homepage: | https://github.com/GutenYe/saber |
5
+ |----------------|------------------------------------------------------ |
6
+ | Author: | Guten Ye |
7
+ | License: | MIT-LICENSE |
8
+ | Documentation: | http://rubydoc.info/gems/saber/frames |
9
+ | Issue Tracker: | https://github.com/GutenYe/saber/issues |
10
+
11
+ Overview
12
+ --------
13
+
14
+ still under very early development.
15
+
16
+ Features
17
+ --------
18
+
19
+ a clearly list of features.
20
+
21
+ Usage
22
+ -----
23
+
24
+ how to use
25
+
26
+ Install
27
+ ----------
28
+
29
+ gem install saber
30
+
31
+ Contributing
32
+ -------------
33
+
34
+ * Feel free to join the project and make contributions (by submitting a pull request)
35
+ * Submit any bugs/features/ideas to issue tracker
36
+ * Coding Style Guide: https://gist.github.com/1105334
37
+
38
+ Credits
39
+ --------
40
+
41
+ * [Contributors](https://github.com/GutenYe/saber/contributors)
42
+
43
+ Resources
44
+ ---------
45
+
46
+ some related resources to help each other.
47
+
48
+ Copyright
49
+ ---------
50
+
51
+ (the MIT License)
52
+
53
+ Copyright (c) 2011 Guten Ye
54
+
55
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
56
+
57
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
58
+
59
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Ragfile ADDED
@@ -0,0 +1,5 @@
1
+ # add your own task in Ragfile or in tasks/*.rag
2
+ class Rag < Thor
3
+ end
4
+
5
+ # vim: filetype=ruby
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/saber"
4
+
5
+ begin
6
+ Saber::CLI.start
7
+ rescue Saber::Error => e
8
+ Saber.ui.error e.message
9
+ Saber.ui.debug e.backtrace.join("\n")
10
+ exit 1
11
+ rescue Interrupt => e
12
+ Saber.ui.error "\nQuitting..."
13
+ Saber.ui.debug e.backtrace.join("\n")
14
+ exit 1
15
+ end
@@ -0,0 +1,25 @@
1
+ libdir = File.dirname(__FILE__)
2
+ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
3
+
4
+ ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
5
+ require "bundler/setup"
6
+ Bundler.require
7
+
8
+ module Saber
9
+ autoload :VERSION, "saber/version"
10
+ autoload :UI, "saber/ui"
11
+ autoload :Task, "saber/task"
12
+ autoload :CLI, "saber/cli"
13
+
14
+ Error = Class.new Exception
15
+ FatalError = Class.new Exception
16
+ Rc = Optimism.require "saber/rc", "~/.saberrc"
17
+
18
+ class << self
19
+ attr_accessor :ui
20
+
21
+ def ui
22
+ @ui ||= UI.new
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,27 @@
1
+ module Saber
2
+ class CLI < Thor
3
+ include Thor::Actions
4
+
5
+ # check_unknown_options!
6
+
7
+ # default_task :install
8
+ class_option "no-color", :type => :boolean, :banner => "Disable colorization in output"
9
+ class_option "verbose", :aliases => "-V", :type => :boolean, :banner => "Enable verbose output mode"
10
+
11
+ def initialize(*)
12
+ super
13
+ the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
14
+ Bundler.ui = UI::Shell.new(the_shell)
15
+ Bundler.ui.debug! if options["verbose"]
16
+ end
17
+
18
+ desc "clean", "clean up files doesn't in rtorrent client"
19
+ def clean
20
+ Task.new.clean
21
+ end
22
+
23
+ private
24
+ # helper methods
25
+
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ scgi_server = "http://localhost/RPC2"
2
+
3
+ download_dir = Pa.join(ENV["HOME"], "bt")
@@ -0,0 +1,18 @@
1
+ module Saber
2
+ class Task
3
+ def initialize
4
+ Retort::Service.configure do |c|
5
+ c.url = Rc.scgi_server
6
+ end
7
+ end
8
+
9
+ def clean
10
+ disk_files = Rc.download_dir.ls2(:absolute => true)
11
+ bt_files = Retort::Torrent.all.map{|t| Retort::Torrent.action("name", t.info_hash) }.map{|n| Rc.download_dir.join2(n)}
12
+
13
+ (disk_files - bt_files).each { |file|
14
+ Pa.rm_r file, :verbose => true
15
+ }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,56 @@
1
+ module Saber
2
+ class UI
3
+ def warn(message)
4
+ end
5
+
6
+ def debug(message)
7
+ end
8
+
9
+ def error(message)
10
+ end
11
+
12
+ def info(message)
13
+ end
14
+
15
+ def confirm(message)
16
+ end
17
+
18
+ class Shell < UI
19
+ attr_writer :shell
20
+
21
+ def initialize(shell)
22
+ @shell = shell
23
+ @quiet = false
24
+ @debug = ENV['DEBUG']
25
+ end
26
+
27
+ def debug(msg)
28
+ @shell.say(msg) if @debug && !@quiet
29
+ end
30
+
31
+ def info(msg)
32
+ @shell.say(msg) if !@quiet
33
+ end
34
+
35
+ def confirm(msg)
36
+ @shell.say(msg, :green) if !@quiet
37
+ end
38
+
39
+ def warn(msg)
40
+ @shell.say(msg, :yellow)
41
+ end
42
+
43
+ def error(msg)
44
+ @shell.say(msg, :red)
45
+ end
46
+
47
+ def be_quiet!
48
+ @quiet = true
49
+ end
50
+
51
+ def debug!
52
+ @debug = true
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,3 @@
1
+ module Saber
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ $: << "."
2
+ require "lib/saber/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "saber"
6
+ s.version = Saber::VERSION
7
+ s.summary = "the saber"
8
+ s.description = <<-EOF
9
+ the saber
10
+ EOF
11
+
12
+ s.author = "GutenYe"
13
+ s.email = "ywzhaifei@gmail.com"
14
+ s.homepage = "http://github.com/GutenYe/saber"
15
+ s.rubyforge_project = "xx"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ #s.executables = ["x"]
19
+
20
+ #s.add_dependency "x"
21
+ end
@@ -0,0 +1,23 @@
1
+ # lib/**/*.rb
2
+ watch %r~lib/(.*)\.rb~ do |m|
3
+ test "spec/#{m[1]}_spec.rb"
4
+ end
5
+
6
+ # spec/**/*_spec.rb
7
+ watch %r~spec/.*_spec\.rb~ do |m|
8
+ test m[0]
9
+ end
10
+
11
+ # Ctrl-\
12
+ Signal.trap('QUIT') do
13
+ puts "--- Running all tests ---\n\n"
14
+ test "spec"
15
+ end
16
+
17
+ def test(path)
18
+ system "clear"
19
+ cmd = "rspec #{path}"
20
+ puts cmd
21
+ system cmd
22
+ end
23
+
File without changes
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: saber
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - GutenYe
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-30 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: ! 'the saber
15
+
16
+ '
17
+ email: ywzhaifei@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - README.md
25
+ - Ragfile
26
+ - bin/saber
27
+ - lib/saber.rb
28
+ - lib/saber/cli.rb
29
+ - lib/saber/rc.rb
30
+ - lib/saber/task.rb
31
+ - lib/saber/ui.rb
32
+ - lib/saber/version.rb
33
+ - saber.gemspec
34
+ - saber.watchr
35
+ - spec/spec_helper.rb
36
+ homepage: http://github.com/GutenYe/saber
37
+ licenses: []
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project: xx
56
+ rubygems_version: 1.8.11
57
+ signing_key:
58
+ specification_version: 3
59
+ summary: the saber
60
+ test_files: []
61
+ has_rdoc: