gisty 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,178 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+
8
+ <title>Gist &mdash; GitHub</title>
9
+
10
+ <link href="/stylesheets/facebox.css" media="screen" rel="stylesheet" type="text/css" />
11
+ <link href="/stylesheets/gist/screen.css" media="screen" rel="stylesheet" type="text/css" />
12
+ <link href="/stylesheets/pygment_trac.css" media="screen" rel="stylesheet" type="text/css" />
13
+
14
+
15
+
16
+ </head>
17
+
18
+ <body>
19
+ <div id="main">
20
+ <div id="header" class="">
21
+ <div class="site">
22
+ <div class="logo">
23
+ <a href="/"><img src="/images/modules/header/logo_gist.png" alt="git-hub" /></a>
24
+ </div>
25
+
26
+ <div class="actions">
27
+ <a href="/">New</a>
28
+ <a href="/gists">All Gists</a>
29
+ <a href="/login?return_to=gist">Login</a>
30
+ <a href="http://github.com/signup?return_to=gist">Signup for a GitHub Account</a>
31
+ </div>
32
+
33
+ </div>
34
+ </div>
35
+
36
+ <div class="site">
37
+ <div id="gist_data">
38
+
39
+ <div class="right">
40
+ <a href="http://github.com/swdyh">Visit swdyh on GitHub</a>
41
+ </div>
42
+
43
+ <h2>Public Gists by swdyh</h2>
44
+
45
+
46
+
47
+ <div id="files">
48
+
49
+
50
+
51
+
52
+ <div class="file">
53
+ <div class="meta public inline-gravatar" style="padding-right:45px; background:#eaeaea url('http://www.gravatar.com/avatar/465e43442fc3604b4a7ad9c55bc52066?s=20&d=http%3A%2F%2Fgithub.com%2Fimages%2Fgravatars%2Fgravatar-20.png') no-repeat scroll 98.5% 50%;">
54
+ <div class="info">
55
+ <span><a href="/6938">gist: 6938</a></span>
56
+ <span></span>
57
+ </div>
58
+ <div class="right">
59
+ <span class="date">
60
+ <abbr class="relatize" title="2008-08-23 13:21:34">Sat Aug 23 13:21:34 -0700 2008</abbr>
61
+
62
+ </span>
63
+ <br style="clear:both;"/>
64
+ </div>
65
+ </div>
66
+ <div class="data syntax">
67
+
68
+ <table cellpadding="0" cellspacing="0">
69
+ <tr>
70
+ <td>
71
+ <pre class="line_numbers">
72
+ <span id="LID1" rel="#L1">1</span>
73
+ <span id="LID2" rel="#L2">2</span>
74
+ <span id="LID3" rel="#L3">3</span>
75
+ </pre>
76
+ </td>
77
+ <td width="100%">
78
+
79
+
80
+
81
+ <div class="highlight"><pre><div class="line" id="LC1"><span class="nb">Array</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="nb">document</span><span class="p">.</span><span class="nx">images</span><span class="o">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span> <span class="p">{</span></div><div class="line" id="LC2">&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">pa</span> <span class="o">=</span> <span class="nx">i</span><span class="p">.</span><span class="nx">parentNode</span></div><div class="line" id="LC3">&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">pa</span><span class="p">.</span><span class="nx">rel</span> <span class="o">&amp;&amp;</span> <span class="nx">pa</span><span class="p">.</span><span class="nx">rel</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/^lightbox/</span><span class="p">))</span> <span class="p">{</span></div></pre></div>
82
+
83
+ </td>
84
+ </tr>
85
+ </table>
86
+ </div>
87
+ </div>
88
+
89
+
90
+
91
+
92
+
93
+ <div class="file">
94
+ <div class="meta public inline-gravatar" style="padding-right:45px; background:#eaeaea url('http://www.gravatar.com/avatar/465e43442fc3604b4a7ad9c55bc52066?s=20&d=http%3A%2F%2Fgithub.com%2Fimages%2Fgravatars%2Fgravatar-20.png') no-repeat scroll 98.5% 50%;">
95
+ <div class="info">
96
+ <span><a href="/3668">gist: 3668</a></span>
97
+ <span></span>
98
+ </div>
99
+ <div class="right">
100
+ <span class="date">
101
+ <abbr class="relatize" title="2008-08-01 12:15:00">Fri Aug 01 12:15:00 -0700 2008</abbr>
102
+
103
+ </span>
104
+ <br style="clear:both;"/>
105
+ </div>
106
+ </div>
107
+ <div class="data syntax">
108
+
109
+ <table cellpadding="0" cellspacing="0">
110
+ <tr>
111
+ <td>
112
+ <pre class="line_numbers">
113
+ <span id="LID1" rel="#L1">1</span>
114
+ <span id="LID2" rel="#L2">2</span>
115
+ <span id="LID3" rel="#L3">3</span>
116
+ </pre>
117
+ </td>
118
+ <td width="100%">
119
+
120
+
121
+
122
+ <div class="highlight"><pre><div class="line" id="LC1"><span class="c">// jsactions script.</span></div><div class="line" id="LC2"><span class="c">// download http://www.humberthumbert.net/code/codelist.html</span></div><div class="line" id="LC3">&nbsp;</div></pre></div>
123
+
124
+ </td>
125
+ </tr>
126
+ </table>
127
+ </div>
128
+ </div>
129
+
130
+
131
+ </div>
132
+
133
+ <div class="pagination"><a href="/swdyh?page=3" hotkey="h" rel="prev">&laquo; Previous</a> <a href="/swdyh?page=1" rel="start">1</a> <a href="/swdyh?page=2">2</a> <a href="/swdyh?page=3" rel="prev">3</a> <span class="current">4</span> <span class="disabled">Next &raquo;</span></div>
134
+
135
+
136
+
137
+ <br/>
138
+
139
+ </div> <!-- gist_data -->
140
+
141
+ <div id="gist_meta">
142
+ </div>
143
+
144
+ </div> <!-- site -->
145
+
146
+ <div class="push"></div>
147
+
148
+ </div>
149
+
150
+ <div id="footer">
151
+ <div class="site">
152
+ <div class="info">
153
+ <div style="float: left; margin-right: 2em; margin-top: -.6em;">
154
+ <a href="http://github.com/">
155
+ <img src="/images/modules/header/logo_white.png" alt="GitHub" />
156
+ </a>
157
+ </div>
158
+ <div class="links" style="float: left; width: 18em;">
159
+ <a href="http://github.com/blog"><strong>The Github Blog</strong></a> |
160
+ <a href="http://support.github.com/">Support</a> |
161
+ <a href="http://github.com/contact">Contact Us</a>
162
+ </div>
163
+ <div class="company">
164
+ <span id="_rrt" title="0.34286s from gist.github.com">It's</span>
165
+ <a href="http://logicalawesome.com/">Logical Awesome</a> | &copy;2008
166
+ </div>
167
+ </div>
168
+ <div class="sponsor">
169
+ <a href="http://engineyard.com">Hosting provided by</a>&nbsp;
170
+ <a href="http://engineyard.com">
171
+ <img src="/images/modules/footer/engine_yard_logo.gif" alt="Hosted by Engine Yard" />
172
+ </a>
173
+ </div>
174
+
175
+ </div>
176
+ </div>
177
+ </body>
178
+ </html>
@@ -0,0 +1,175 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+ require "test/unit"
3
+ require 'pp'
4
+ require 'rr'
5
+
6
+ class GistyTest < Test::Unit::TestCase
7
+ include RR::Adapters::TestUnit
8
+
9
+ def setup
10
+ @gisty_dir = Pathname.new('tmp').realpath.join('gists')
11
+ @gisty = Gisty.new @gisty_dir, 'foo', 'bar'
12
+ stub_open_uri!
13
+ stub_kernel_system!
14
+ end
15
+
16
+ def teardown
17
+ FileUtils.rm_rf @gisty_dir
18
+ end
19
+
20
+ def stub_open_uri!
21
+ stub(OpenURI).open_uri do |uri|
22
+ path = url2fixture uri
23
+ # puts "stub open_uri: #{uri} -> #{path}"
24
+ open url2fixture(uri)
25
+ end
26
+ end
27
+
28
+ def url2fixture url
29
+ filename = url.to_s.split('/').last.gsub(/[&?=]/, '_')
30
+ File.join File.dirname(__FILE__), 'fixtures', filename
31
+ end
32
+
33
+ def stub_kernel_system!
34
+ stub(Kernel).system do |cmd|
35
+ # puts "* '#{cmd}' *"
36
+ case cmd
37
+ when /^git clone/
38
+ id = cmd.split(/[:.]/)[-2]
39
+ system "mkdir -p #{id}"
40
+ system "touch #{File.join(id, id)}"
41
+ else
42
+ end
43
+ end
44
+ end
45
+
46
+ def stub_post_form! dummy = 'http://gist.github.com/111111'
47
+ stub(Net::HTTP).post_form do |uri, opt|
48
+ { 'Location' => dummy }
49
+ end
50
+ end
51
+
52
+ def test_extract_ids
53
+ path = File.join 'test', 'fixtures', 'swdyh_page_4'
54
+ ids = Gisty.extract_ids IO.read(path)
55
+ assert ids.include?("6938")
56
+ assert ids.include?("3668")
57
+ end
58
+
59
+ def test_extract
60
+ meta = Gisty.extract 'http://gist.github.com/30119'
61
+ assert_equal 'brianleroux', meta[:author]
62
+ assert_equal 4, meta[:files].size
63
+ end
64
+
65
+ def test_new
66
+ assert_instance_of Gisty, @gisty
67
+ end
68
+
69
+ def test_next_link
70
+ path1 = url2fixture('http://gist.github.com/mine?page=1&login=foo&token=bar')
71
+ path2 = url2fixture('http://gist.github.com/mine?page=2&login=foo&token=bar')
72
+ path3 = url2fixture('http://gist.github.com/mine?page=3&login=foo&token=bar')
73
+ assert_equal '/mine?page=2', @gisty.next_link(IO.read(path1))
74
+ assert_equal '/mine?page=3', @gisty.next_link(IO.read(path2))
75
+ assert_nil @gisty.next_link(IO.read(path3))
76
+ end
77
+
78
+ def test_map_page_urls
79
+ mapped = @gisty.map_pages do |url, page|
80
+ assert url.match(/page=\d/)
81
+ end
82
+ assert_equal 3, mapped.size
83
+ end
84
+
85
+ def test_remote_ids
86
+ ids = @gisty.remote_ids
87
+ # assert_equal 20, ids.size
88
+ # assert ids.include?('7205')
89
+ # assert ids.include?('bc82698ab357bd8bb433')
90
+ end
91
+
92
+ def test_clone
93
+ id = @gisty.remote_ids.first
94
+ pn = @gisty_dir.join id
95
+ @gisty.clone id
96
+ end
97
+
98
+ def test_list
99
+ ids = @gisty.remote_ids
100
+ @gisty.clone ids[0]
101
+ @gisty.clone ids[1]
102
+ list = @gisty.list[:public].map { |i| i.first }
103
+ assert list.include?(ids[0])
104
+ assert list.include?(ids[1])
105
+ end
106
+
107
+ def test_delete
108
+ id = '11111'
109
+ pn = @gisty_dir.join id
110
+ FileUtils.mkdir(pn)
111
+ @gisty.delete id
112
+ assert !pn.exist?
113
+ end
114
+
115
+ def test_sync
116
+ ids = @gisty.remote_ids
117
+ assert !ids.all? { |i| @gisty_dir.join(i).exist? }
118
+ @gisty.sync
119
+ assert ids.all? { |i| @gisty_dir.join(i).exist? }
120
+ end
121
+
122
+ # def test_sync_delete
123
+ # id = '12345'
124
+ # assert !@gisty.remote_ids.include?(id)
125
+ # @gisty.clone id
126
+ # assert @gisty_dir.join(id).exist?
127
+ # @gisty.sync true
128
+ # assert !@gisty_dir.join(id).exist?
129
+ # end
130
+
131
+ def test_build_params
132
+ path = File.join('test', 'fixtures', 'foo.user.js')
133
+ params = @gisty.build_params path
134
+
135
+ assert_equal '.js', params['file_ext[gistfile1]']
136
+ assert_equal 'foo.user.js', params['file_name[gistfile1]']
137
+ assert_equal "// foo.user.js\n", params['file_contents[gistfile1]']
138
+ end
139
+
140
+ def test_build_params_multi
141
+ path1 = File.join('test', 'fixtures', 'foo.user.js')
142
+ path2 = File.join('test', 'fixtures', 'bar.user.js')
143
+ params = @gisty.build_params [path1, path2]
144
+
145
+ assert_equal '.js', params['file_ext[gistfile1]']
146
+ assert_equal 'foo.user.js', params['file_name[gistfile1]']
147
+ assert_equal "// foo.user.js\n", params['file_contents[gistfile1]']
148
+ assert_equal '.js', params['file_ext[gistfile2]']
149
+ assert_equal 'bar.user.js', params['file_name[gistfile2]']
150
+ assert_equal "// bar.user.js\n", params['file_contents[gistfile2]']
151
+ end
152
+
153
+ def test_create
154
+ stub_post_form!
155
+ path = File.join('test', 'fixtures', 'foo.user.js')
156
+ @gisty.create path
157
+ end
158
+
159
+ def test_create_multi
160
+ path1 = File.join('test', 'fixtures', 'foo.user.js')
161
+ path2 = File.join('test', 'fixtures', 'bar.user.js')
162
+ @gisty.create [path1, path2]
163
+ end
164
+
165
+ def test_post_failure
166
+ stub(Net::HTTP).post_form do |uri, opt|
167
+ Net::HTTPClientError.new 'foo', 'bar', 'baz'
168
+ end
169
+ path = File.join('test', 'fixtures', 'foo.user.js')
170
+ assert_raise Gisty::PostFailureException do
171
+ @gisty.create path
172
+ end
173
+ end
174
+ end
175
+
@@ -0,0 +1,3 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/gisty'
3
+
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gisty
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.15
5
+ platform: ruby
6
+ authors:
7
+ - swdyh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-08 00:00:00 +09:00
13
+ default_executable: gisty
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: nokogiri
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.0
24
+ version:
25
+ description: yet another command line client for gist
26
+ email: http://mailhide.recaptcha.net/d?k=01AhB7crgrlHptVaYRD0oPwA==&c=L_iqOZrGmo6hcGpPTFg1QYnjr-WpAStyQ4Y8ShfgOHs=
27
+ executables:
28
+ - gisty
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.rdoc
33
+ files:
34
+ - README.rdoc
35
+ - Rakefile
36
+ - bin/gisty
37
+ - test/fixtures/24835
38
+ - test/fixtures/30119
39
+ - test/fixtures/bar.user.js
40
+ - test/fixtures/foo.user.js
41
+ - test/fixtures/mine_login_foo_token_bar
42
+ - test/fixtures/mine_page_1_login_foo_token_bar
43
+ - test/fixtures/mine_page_2_login_foo_token_bar
44
+ - test/fixtures/mine_page_3_login_foo_token_bar
45
+ - test/fixtures/swdyh
46
+ - test/fixtures/swdyh_page_4
47
+ - test/gisty_test.rb
48
+ - test/test_helper.rb
49
+ - lib/gisty.rb
50
+ has_rdoc: true
51
+ homepage: http://github.com/swdyh/gisty/tree/master
52
+ licenses: []
53
+
54
+ post_install_message:
55
+ rdoc_options:
56
+ - --title
57
+ - gisty documentation
58
+ - --charset
59
+ - utf-8
60
+ - --line-numbers
61
+ - --main
62
+ - README.rdoc
63
+ - --inline-source
64
+ - --exclude
65
+ - ^(examples|extras)/
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ requirements: []
81
+
82
+ rubyforge_project: gisty
83
+ rubygems_version: 1.3.5
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: yet another command line client for gist
87
+ test_files:
88
+ - test/gisty_test.rb