rhype 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ module RHype
2
+ VERSION = "0.1.0"
3
+ end
4
+
@@ -0,0 +1,77 @@
1
+ module RHype
2
+
3
+ # This is an Acts Project Management Standard.
4
+ #
5
+ class Metadata
6
+
7
+ ROOT = 'meta'
8
+
9
+ #
10
+ def initialize(root=nil)
11
+ @root = root || ROOT
12
+ @data = {}
13
+ @delta = []
14
+ end
15
+
16
+ #
17
+ def [](key)
18
+ key = key.to_s
19
+ return @data[key] if @data.key?(key)
20
+ path = File.join(@root, key.to_s)
21
+ if File.file?(path)
22
+ content = File.read(path).strip
23
+ @data[key] = content.empty? ? nil : content
24
+ elsif File.directory?(path)
25
+ self.class.new(path)
26
+ else
27
+ nil
28
+ end
29
+ end
30
+
31
+ #
32
+ def []=(key, value)
33
+ key = key.to_s
34
+ if @data.key?(key) && @data[key] != value
35
+ @data[key] = value
36
+ @delta << key
37
+ end
38
+ end
39
+
40
+ #
41
+ def key?(key)
42
+ key = key.to_s
43
+ path = File.join(@root, key)
44
+ File.exist?(path)
45
+ end
46
+
47
+ def save!
48
+ @delta.each do |key|
49
+ path = File.join(@root, key)
50
+ File.open(path,"w"){ |f| f << self[key] }
51
+ end
52
+ end
53
+
54
+ #
55
+ def method_missing(id, *a)
56
+ key = id.to_s
57
+ return @data[key] if @data.key?(key)
58
+ path = File.join(@root, key.to_s)
59
+ if File.file?(path)
60
+ content = File.read(path).strip
61
+ @data[key] = content.empty? ? nil : content
62
+ elsif File.directory?(path)
63
+ self.class.new(path)
64
+ else
65
+ super
66
+ end
67
+ end
68
+
69
+ #
70
+ def unixname
71
+ name
72
+ end
73
+
74
+ end
75
+
76
+ end
77
+
@@ -0,0 +1,90 @@
1
+ require 'fileutils'
2
+ require 'open-uri'
3
+ require 'openssl'
4
+ require 'tmpdir'
5
+ require 'enumerator'
6
+
7
+ require 'facets/module/alias_accessor'
8
+ require 'facets/hash/rekey'
9
+
10
+ require 'rhype/metadata'
11
+
12
+ module RHype
13
+
14
+ # Base class that provides methods generally
15
+ # needed to inteface to outside world.
16
+ #
17
+ class Service
18
+
19
+ attr_accessor :dryrun
20
+ attr_accessor :verbose
21
+ attr_accessor :quiet
22
+ attr_accessor :trace
23
+ attr_accessor :debug
24
+ attr_accessor :force
25
+
26
+ def metadata
27
+ @metadata ||= Metadata.new
28
+ end
29
+
30
+ private
31
+
32
+ def initialize(options)
33
+ initialize_defaults
34
+ options.each do |k,v|
35
+ send("#{k}=", v) if respond_to?("#{k}=")
36
+ end
37
+ yield(self) if block_given?
38
+ end
39
+
40
+ #
41
+ def initialize_defaults
42
+ end
43
+
44
+ #
45
+ def quiet? ; @quiet ; end
46
+ def verbose? ; @verbose ; end
47
+ def force? ; @force ; end
48
+ def dryrun? ; @dryrun ; end
49
+ def trace? ; @trace ; end
50
+ def debug? ; @debug ; end
51
+
52
+ #
53
+ def unfold_paragraphs(string)
54
+ blank = false
55
+ text = ''
56
+ string.split(/\n/).each do |line|
57
+ if /\S/ !~ line
58
+ text << "\n\n"
59
+ blank = true
60
+ else
61
+ if /^(\s+|[*])/ =~ line
62
+ text << (line.rstrip + "\n")
63
+ else
64
+ text << (line.rstrip + " ")
65
+ end
66
+ blank = false
67
+ end
68
+ end
69
+ return text
70
+ end
71
+
72
+
73
+ #
74
+ def mkdir_p(dir)
75
+ fu.mkdir_p(dir)
76
+ end
77
+
78
+ #
79
+ def fu
80
+ if dryrun?
81
+ FileUtils::DryRun
82
+ else
83
+ FileUtils
84
+ end
85
+ end
86
+
87
+ end
88
+
89
+ end
90
+
@@ -0,0 +1 @@
1
+ Trans <transfire@gmail.com>
@@ -0,0 +1 @@
1
+ Trans <transfire@gmail.com>
@@ -0,0 +1,2 @@
1
+ RHype is a commandline tool and reusable library for interfacing
2
+ with project management hosting services like Rubyforge.
@@ -0,0 +1 @@
1
+ http://rhype.rubyforge.org/
@@ -0,0 +1 @@
1
+ hype
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rhype
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Trans <transfire@gmail.com>
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-26 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: RHype is a commandline tool and reusable library for interfacing with project management hosting services like Rubyforge.
17
+ email: transfire@gmail.com
18
+ executables:
19
+ - rhype
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - MANIFEST
25
+ - HISTORY
26
+ - VERSION
27
+ - NEWS
28
+ - COPYING
29
+ files:
30
+ - bin
31
+ - lib
32
+ - meta
33
+ - README
34
+ - HISTORY
35
+ - VERSION
36
+ - NEWS
37
+ - COPYING
38
+ - bin/rhype
39
+ - lib/rhype
40
+ - lib/rhype/command.rb
41
+ - lib/rhype/host.rb
42
+ - lib/rhype/command.help
43
+ - lib/rhype/controller.rb
44
+ - lib/rhype/service.rb
45
+ - lib/rhype/metadata.rb
46
+ - lib/rhype/index.rb
47
+ - lib/rhype/hosts
48
+ - lib/rhype/hosts/rubyforge.rb
49
+ - lib/rhype/hosts/gforge.rb
50
+ - meta/homepage
51
+ - meta/unixname
52
+ - meta/author
53
+ - meta/description
54
+ - meta/contact
55
+ - MANIFEST
56
+ has_rdoc: true
57
+ homepage: http://rhype.rubyforge.org/
58
+ post_install_message:
59
+ rdoc_options:
60
+ - --inline-source
61
+ - --title
62
+ - rhype api
63
+ - --main
64
+ - README
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: "0"
72
+ version:
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ version:
79
+ requirements: []
80
+
81
+ rubyforge_project: rhype
82
+ rubygems_version: 1.2.0
83
+ signing_key:
84
+ specification_version: 2
85
+ summary: RHype is a commandline tool and reusable library for interfacing
86
+ test_files: []
87
+