gyazz 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/History.txt +4 -0
- data/Manifest.txt +11 -0
- data/PostInstall.txt +0 -0
- data/README.rdoc +40 -0
- data/Rakefile +26 -0
- data/lib/gyazz.rb +77 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/test_gyazz.rb +34 -0
- data/test/test_helper.rb +3 -0
- metadata +126 -0
data/.gemtest
ADDED
File without changes
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/PostInstall.txt
ADDED
File without changes
|
data/README.rdoc
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
= gyazz
|
2
|
+
|
3
|
+
* http://github.com/masui/gyazz-ruby
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
* Read/write Gyazz data
|
8
|
+
|
9
|
+
== SYNOPSIS:
|
10
|
+
|
11
|
+
# read/write data at http://Gyazz.com/test/test
|
12
|
+
require 'gyazz'
|
13
|
+
g = Gyazz.new('test')
|
14
|
+
text = g.get('test')
|
15
|
+
g.set('test','abcdefg')
|
16
|
+
|
17
|
+
== LICENSE:
|
18
|
+
|
19
|
+
(The MIT License)
|
20
|
+
|
21
|
+
Copyright (c) 2012 Toshiyuki Masui
|
22
|
+
|
23
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
24
|
+
a copy of this software and associated documentation files (the
|
25
|
+
'Software'), to deal in the Software without restriction, including
|
26
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
27
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
28
|
+
permit persons to whom the Software is furnished to do so, subject to
|
29
|
+
the following conditions:
|
30
|
+
|
31
|
+
The above copyright notice and this permission notice shall be
|
32
|
+
included in all copies or substantial portions of the Software.
|
33
|
+
|
34
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
35
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
36
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
37
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
38
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
39
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
40
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/gyazz'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
# Hoe.plugin :website
|
9
|
+
# Hoe.plugin :cucumberfeatures
|
10
|
+
|
11
|
+
# Generate all the Rake tasks
|
12
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
+
$hoe = Hoe.spec 'gyazz' do
|
14
|
+
self.developer 'Toshiyuki Masui', 'masui@pitecan.com'
|
15
|
+
self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
16
|
+
self.rubyforge_name = self.name # TODO this is default value
|
17
|
+
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'newgem/tasks'
|
22
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
23
|
+
|
24
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
25
|
+
# remove_task :default
|
26
|
+
# task :default => [:spec, :features]
|
data/lib/gyazz.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require 'net/http'
|
5
|
+
|
6
|
+
class Gyazz
|
7
|
+
VERSION = '0.0.2'
|
8
|
+
|
9
|
+
def initialize(name,user=nil,pass=nil)
|
10
|
+
@name = name
|
11
|
+
@user = user
|
12
|
+
@pass = pass
|
13
|
+
end
|
14
|
+
|
15
|
+
def http_get(addr)
|
16
|
+
ret = ''
|
17
|
+
begin
|
18
|
+
Net::HTTP.start('gyazz.com', 80) {|http|
|
19
|
+
req = Net::HTTP::Get.new(addr)
|
20
|
+
req.basic_auth @user,@pass if @user
|
21
|
+
response = http.request(req)
|
22
|
+
ret = response.body
|
23
|
+
}
|
24
|
+
rescue
|
25
|
+
end
|
26
|
+
ret.chomp
|
27
|
+
end
|
28
|
+
|
29
|
+
def list
|
30
|
+
ret = nil
|
31
|
+
begin
|
32
|
+
s = http_get("/#{@name}/__list")
|
33
|
+
ret = eval(s).collect { |e|
|
34
|
+
e[0]
|
35
|
+
}
|
36
|
+
rescue
|
37
|
+
end
|
38
|
+
return ret
|
39
|
+
end
|
40
|
+
|
41
|
+
def text(title)
|
42
|
+
s = nil
|
43
|
+
begin
|
44
|
+
s = http_get("/#{@name}/#{title.gsub(/ /,'%20')}/text")
|
45
|
+
rescue
|
46
|
+
end
|
47
|
+
return s
|
48
|
+
end
|
49
|
+
|
50
|
+
def settext(title,val)
|
51
|
+
if val.class == Array then
|
52
|
+
val = val.join("\n")
|
53
|
+
end
|
54
|
+
data = @name + "\n" + title + "\n" + val
|
55
|
+
Net::HTTP.start('gyazz.com', 80) {|http|
|
56
|
+
req = Net::HTTP::Post.new('/__write__')
|
57
|
+
req.set_form_data('data' => data)
|
58
|
+
req.basic_auth @user,@pass if @user
|
59
|
+
response = http.request(req)
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
def get(title)
|
64
|
+
text(title)
|
65
|
+
end
|
66
|
+
|
67
|
+
def set(title,val)
|
68
|
+
settext(title,val)
|
69
|
+
end
|
70
|
+
|
71
|
+
def each
|
72
|
+
list.each { |title|
|
73
|
+
yield title
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/gyazz.rb'}"
|
9
|
+
puts "Loading gyazz gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/test/test_gyazz.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestGyazz < Test::Unit::TestCase
|
4
|
+
def test_text
|
5
|
+
g = Gyazz.new('test')
|
6
|
+
g.set('test','bbbbb')
|
7
|
+
assert_equal(g.get('test'),"bbbbb")
|
8
|
+
|
9
|
+
val = ["abc", "def"]
|
10
|
+
g.settext('test',val)
|
11
|
+
assert_equal(g.text('test'),"abc\ndef")
|
12
|
+
|
13
|
+
val = ["abc\ndef"]
|
14
|
+
g.settext('test',val)
|
15
|
+
assert_equal(g.text('test'),"abc\ndef")
|
16
|
+
|
17
|
+
list = g.list
|
18
|
+
assert_equal(list.class,Array)
|
19
|
+
assert(list.length > 0)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_auth
|
23
|
+
#
|
24
|
+
# http://Gyazz.com/test_auth/
|
25
|
+
# user: test_username
|
26
|
+
# pass: test_password
|
27
|
+
#
|
28
|
+
g = Gyazz.new('test_auth','test_username','test_password')
|
29
|
+
g.set('test','abcdefg')
|
30
|
+
assert_equal(g.get('test'),'abcdefg')
|
31
|
+
g.set('test','99999')
|
32
|
+
assert_equal(g.get('test'),'99999')
|
33
|
+
end
|
34
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gyazz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Toshiyuki Masui
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-01-10 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rdoc
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 19
|
29
|
+
segments:
|
30
|
+
- 3
|
31
|
+
- 10
|
32
|
+
version: "3.10"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: newgem
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 5
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 5
|
47
|
+
- 3
|
48
|
+
version: 1.5.3
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: hoe
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 27
|
60
|
+
segments:
|
61
|
+
- 2
|
62
|
+
- 12
|
63
|
+
version: "2.12"
|
64
|
+
type: :development
|
65
|
+
version_requirements: *id003
|
66
|
+
description: "* Read/write Gyazz data"
|
67
|
+
email:
|
68
|
+
- masui@pitecan.com
|
69
|
+
executables: []
|
70
|
+
|
71
|
+
extensions: []
|
72
|
+
|
73
|
+
extra_rdoc_files:
|
74
|
+
- History.txt
|
75
|
+
- Manifest.txt
|
76
|
+
- PostInstall.txt
|
77
|
+
files:
|
78
|
+
- History.txt
|
79
|
+
- Manifest.txt
|
80
|
+
- PostInstall.txt
|
81
|
+
- README.rdoc
|
82
|
+
- Rakefile
|
83
|
+
- lib/gyazz.rb
|
84
|
+
- script/console
|
85
|
+
- script/destroy
|
86
|
+
- script/generate
|
87
|
+
- test/test_gyazz.rb
|
88
|
+
- test/test_helper.rb
|
89
|
+
- .gemtest
|
90
|
+
homepage: http://github.com/masui/gyazz-ruby
|
91
|
+
licenses: []
|
92
|
+
|
93
|
+
post_install_message: PostInstall.txt
|
94
|
+
rdoc_options:
|
95
|
+
- --main
|
96
|
+
- README.rdoc
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
hash: 3
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
version: "0"
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
hash: 3
|
114
|
+
segments:
|
115
|
+
- 0
|
116
|
+
version: "0"
|
117
|
+
requirements: []
|
118
|
+
|
119
|
+
rubyforge_project: gyazz
|
120
|
+
rubygems_version: 1.7.2
|
121
|
+
signing_key:
|
122
|
+
specification_version: 3
|
123
|
+
summary: "* Read/write Gyazz data"
|
124
|
+
test_files:
|
125
|
+
- test/test_gyazz.rb
|
126
|
+
- test/test_helper.rb
|