neocitizen 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.ruby-version +1 -0
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +102 -0
- data/Rakefile +7 -0
- data/bin/neocitizen +3 -0
- data/lib/neocitizen.rb +4 -0
- data/lib/neocitizen/cli.rb +17 -0
- data/lib/neocitizen/client.rb +77 -0
- data/lib/neocitizen/version.rb +3 -0
- data/neocitizen.gemspec +33 -0
- data/spec/cassettes/Neocitizen_Client/_info/hits_the_/api/info_endpoint.json +1 -0
- data/spec/cassettes/Neocitizen_Client/_info/returns_the_info_as_a_Hash.json +1 -0
- data/spec/cassettes/Neocitizen_Client/_upload/hits_the_/api/upload_endpoint.json +1 -0
- data/spec/cassettes/Neocitizen_Client/_upload/returns_the_info_as_a_Hash.json +1 -0
- data/spec/fixtures/index.html +9 -0
- data/spec/lib/neocitizen/client_spec.rb +35 -0
- data/spec/spec_helper.rb +43 -0
- data/templates/newsite/Gemfile.tt +5 -0
- data/templates/newsite/content/index.html +9 -0
- metadata +243 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f7e1b98724ae5253e860ef4ac7fb0976c33f2209
|
4
|
+
data.tar.gz: 93eb1665a68655d752b7bf551b334bef461b8a8e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bfa526a85611c7145cfb6aae8fbf55001c8bafda4ea366a67ebe62c04615bdc285c9d8be2937ae7877ccd3976adbd9ff7f8f6bbab17a74a322f47a4c93069f70
|
7
|
+
data.tar.gz: 22193d1ac9f295dc9e5d3b8dc9d8bafaa4d54c3b30cf970e6cd6b53df7ec19c25479020642de702efadce2516d56f08905bca1973d6c2c24b8ab9c63461f7b7a
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p353
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Chris Fung
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# Neocitizen
|
2
|
+
|
3
|
+

|
4
|
+
|
5
|
+
**Neocitizen** is composed of two parts:
|
6
|
+
|
7
|
+
1. A Ruby wrapper for the [Neocities](http://neocities.org) API, and
|
8
|
+
2. A tool to create and publish Neocities sites from the command line.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
```
|
13
|
+
gem install neocitizen
|
14
|
+
```
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
### Creating a new site with the `neocitizen` tool
|
19
|
+
|
20
|
+
Run `neocitizen SITENAME` to generate a skeleton for a new site. That gives you a directory structure like this:
|
21
|
+
|
22
|
+
```
|
23
|
+
my-cool-site
|
24
|
+
├── .gitignore
|
25
|
+
├── Gemfile
|
26
|
+
├── Gemfile.lock
|
27
|
+
├── Rakefile
|
28
|
+
└── content
|
29
|
+
└── index.html
|
30
|
+
```
|
31
|
+
|
32
|
+
The `content` directory will contain all the files the will be uploaded to your site. Neocitizen will use Git to determine what files should be uploaded in order to minimize bandwidth usage.
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it ( https://github.com/aergonaut/neocitizen/fork )
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create a new Pull Request
|
41
|
+
|
42
|
+
### Running and writing new tests
|
43
|
+
|
44
|
+
Neocitizen uses [VCR](https://github.com/vcr/vcr) to record and playback HTTP requests during tests. These cassettes are stored in the `spec/cassettes` folder. If you're not recording new cassettes, you don't need to worry about anything and can run the specs with
|
45
|
+
|
46
|
+
```
|
47
|
+
script/test
|
48
|
+
```
|
49
|
+
|
50
|
+
Neocitizen uses environment variables to store credentials used in testing. Here is the full list of environment variables for testing Neocitizen:
|
51
|
+
|
52
|
+
ENV Variable | Description
|
53
|
+
:------------|:-----------
|
54
|
+
`NEOCITIZEN_TEST_USERNAME` | Neocities username (preferably one created specifically for testing)
|
55
|
+
`NEOCITIZEN_TEST_PASSWORD` | Password for test username
|
56
|
+
|
57
|
+
## Supported Ruby versions
|
58
|
+
|
59
|
+
This library is tested against the following versions of Ruby:
|
60
|
+
|
61
|
+
* Ruby 1.9.2
|
62
|
+
* Ruby 1.9.3
|
63
|
+
* Ruby 2.0.0
|
64
|
+
* Ruby 2.1.0
|
65
|
+
|
66
|
+
If something doesn't work in one of these versions, then it is a bug. This library may work inadvertently in other Ruby implementations, but support will only be provided for the versions listed.
|
67
|
+
|
68
|
+
## Versioning
|
69
|
+
|
70
|
+
This library aims to adhere to [Semantic Versioning 2.0.0](http://semver.org/). Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, that version should be immediately yanked and/or a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions. As a result of this policy, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision. For example:
|
71
|
+
|
72
|
+
```
|
73
|
+
spec.add_dependency 'neocitizen', '~> 0.0.1'
|
74
|
+
```
|
75
|
+
|
76
|
+
## Authors
|
77
|
+
|
78
|
+
Neocitizen is made by [@aergonaut](https://github.com/aergonaut).
|
79
|
+
|
80
|
+
## License
|
81
|
+
|
82
|
+
The MIT License (MIT)
|
83
|
+
|
84
|
+
Copyright (c) 2014 Chris Fung
|
85
|
+
|
86
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
87
|
+
of this software and associated documentation files (the "Software"), to deal
|
88
|
+
in the Software without restriction, including without limitation the rights
|
89
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
90
|
+
copies of the Software, and to permit persons to whom the Software is
|
91
|
+
furnished to do so, subject to the following conditions:
|
92
|
+
|
93
|
+
The above copyright notice and this permission notice shall be included in all
|
94
|
+
copies or substantial portions of the Software.
|
95
|
+
|
96
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
97
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
98
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
99
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
100
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
101
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
102
|
+
SOFTWARE.
|
data/Rakefile
ADDED
data/bin/neocitizen
ADDED
data/lib/neocitizen.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'neocitizen/version'
|
3
|
+
|
4
|
+
module Neocitizen
|
5
|
+
class CLI < Thor
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
desc "site SITENAME", "Creates a skeleton for a Neocities site"
|
9
|
+
def site(sitename)
|
10
|
+
directory("newsite", sitename)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.source_root
|
14
|
+
File.basename(File.expand_path(File.join("..", "..", "..", "templates"), __FILE__))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'excon'
|
3
|
+
require 'mimemagic'
|
4
|
+
|
5
|
+
module Neocitizen
|
6
|
+
class Client
|
7
|
+
attr_accessor :options
|
8
|
+
|
9
|
+
# Build a new Neocitizen client.
|
10
|
+
#
|
11
|
+
# @param [Hash] options initialization options
|
12
|
+
# @option options [String] :username Neocities username
|
13
|
+
# @option options [String] :password Neocities password
|
14
|
+
# @option options [String] :api_host (https://neocities.org)
|
15
|
+
#
|
16
|
+
# @return [Hash] JSON from the response
|
17
|
+
def initialize(options = {})
|
18
|
+
options = {
|
19
|
+
username: ENV["NEOCITIZEN_USERNAME"],
|
20
|
+
password: ENV["NEOCITIZEN_PASSWORD"]
|
21
|
+
}.merge(options)
|
22
|
+
|
23
|
+
raise ArgumentError, "Username and password are required" unless options[:username] && options[:password]
|
24
|
+
|
25
|
+
self.options = options
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get info about a Neocities site
|
29
|
+
#
|
30
|
+
# @example Get info on a site
|
31
|
+
# client.info("cool-site")
|
32
|
+
#
|
33
|
+
# @param [String] sitename Neocities site to get info about (defaults to the authenticated user)
|
34
|
+
#
|
35
|
+
# @return [Hash] JSON from the response
|
36
|
+
def info(sitename = nil)
|
37
|
+
sitename ||= options[:username]
|
38
|
+
response = connection.get "/api/info", { sitename: sitename }
|
39
|
+
MultiJson.load(response.body)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Upload one or more files to Neocities
|
43
|
+
#
|
44
|
+
# @example Upload files
|
45
|
+
# client.upload("index.html", "cool-graphic.gif")
|
46
|
+
#
|
47
|
+
# @param [Array] files file names to upload
|
48
|
+
#
|
49
|
+
# @returns [Hash] JSON from the response
|
50
|
+
def upload(*files)
|
51
|
+
payload = files.inject({}) do |hash, filename|
|
52
|
+
type = MimeMagic.by_path(filename)
|
53
|
+
basename = File.basename(filename)
|
54
|
+
hash[basename.to_sym] = Faraday::UploadIO.new(filename, type)
|
55
|
+
hash
|
56
|
+
end
|
57
|
+
|
58
|
+
response = connection.post "/api/upload", payload
|
59
|
+
MultiJson.load(response.body)
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def connection
|
65
|
+
@connection ||= Faraday.new(url: api_host) do |faraday|
|
66
|
+
faraday.request :basic_auth, self.options[:username], self.options[:password]
|
67
|
+
faraday.request :multipart
|
68
|
+
faraday.request :url_encoded
|
69
|
+
faraday.adapter :excon
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def api_host
|
74
|
+
self.options[:api_host] || ENV["NEOCITIZEN_API_HOST"] || "https://neocities.org"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/neocitizen.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'neocitizen/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "neocitizen"
|
8
|
+
spec.version = Neocitizen::VERSION
|
9
|
+
spec.authors = ["Chris Fung"]
|
10
|
+
spec.email = ["aergonaut@gmail.com"]
|
11
|
+
spec.summary = "Toolkit for creating sites on neocities.org"
|
12
|
+
spec.homepage = "https://github.com/aergonaut/neocitizen"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "vcr"
|
23
|
+
spec.add_development_dependency "webmock"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "yard"
|
26
|
+
|
27
|
+
spec.add_dependency "thor", "~> 0.19"
|
28
|
+
spec.add_dependency "faraday", "~> 0.9"
|
29
|
+
spec.add_dependency "excon", "~> 0.34"
|
30
|
+
spec.add_dependency "mimemagic", "~> 0.2"
|
31
|
+
spec.add_dependency "multi_json", "~> 1.10"
|
32
|
+
spec.add_dependency "json_pure", "~> 1.8"
|
33
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"http_interactions":[{"request":{"method":"get","uri":"https://neocities.org/api/info?sitename=superteamawesome","body":{"encoding":"US-ASCII","string":""},"headers":{"User-Agent":["Faraday v0.9.0"],"Authorization":["Basic <NEOCITIZEN_BASIC_AUTH>"]}},"response":{"status":{"code":200,"message":""},"headers":{"Server":["nginx"],"Date":["Sun, 01 Jun 2014 07:23:10 GMT"],"Content-Type":["application/json;charset=utf-8"],"Content-Length":["245"],"Connection":["close"],"Status":["200 OK"],"X-Content-Type-Options":["nosniff"]},"body":{"encoding":"UTF-8","string":"{\n \"result\": \"success\",\n \"info\": {\n \"sitename\": \"superteamawesome\",\n \"hits\": 147,\n \"created_at\": \"Thu, 15 May 2014 21:48:05 +0000\",\n \"last_updated\": \"Sun, 18 May 2014 04:09:19 +0000\",\n \"domain\": null,\n \"tags\": [\n\n ]\n }\n}\n"},"http_version":null},"recorded_at":"Sun, 01 Jun 2014 07:23:11 GMT"}],"recorded_with":"VCR 2.8.0"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"http_interactions":[{"request":{"method":"get","uri":"https://neocities.org/api/info?sitename=superteamawesome","body":{"encoding":"US-ASCII","string":""},"headers":{"User-Agent":["Faraday v0.9.0"],"Authorization":["Basic <NEOCITIZEN_BASIC_AUTH>"]}},"response":{"status":{"code":200,"message":""},"headers":{"Server":["nginx"],"Date":["Sun, 01 Jun 2014 01:37:20 GMT"],"Content-Type":["application/json;charset=utf-8"],"Content-Length":["245"],"Connection":["close"],"Status":["200 OK"],"X-Content-Type-Options":["nosniff"]},"body":{"encoding":"UTF-8","string":"{\n \"result\": \"success\",\n \"info\": {\n \"sitename\": \"superteamawesome\",\n \"hits\": 146,\n \"created_at\": \"Thu, 15 May 2014 21:48:05 +0000\",\n \"last_updated\": \"Sun, 18 May 2014 04:09:19 +0000\",\n \"domain\": null,\n \"tags\": [\n\n ]\n }\n}\n"},"http_version":null},"recorded_at":"Sun, 01 Jun 2014 01:37:20 GMT"}],"recorded_with":"VCR 2.8.0"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"http_interactions":[{"request":{"method":"post","uri":"https://neocities.org/api/upload","body":{"encoding":"UTF-8","string":"-------------RubyMultipartPost\r\nContent-Disposition: form-data; name=\"index.html\"; filename=\"index.html\"\r\nContent-Length: 115\r\nContent-Type: text/html\r\nContent-Transfer-Encoding: binary\r\n\r\n<!doctype html>\n<html>\n<head>\n <title>Hello world!</title>\n</head>\n<body>\n <h1>Hello world!</h1>\n</body>\n</html>\n\r\n-------------RubyMultipartPost--\r\n\r\n"},"headers":{"User-Agent":["Faraday v0.9.0"],"Authorization":["Basic <NEOCITIZEN_BASIC_AUTH>"],"Content-Type":["multipart/form-data; boundary=-----------RubyMultipartPost"],"Content-Length":["342"]}},"response":{"status":{"code":200,"message":""},"headers":{"Server":["nginx"],"Date":["Sun, 01 Jun 2014 07:34:45 GMT"],"Content-Type":["application/json;charset=utf-8"],"Content-Length":["87"],"Connection":["close"],"Status":["200 OK"],"Set-Cookie":["neocities=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiRWZjNDQyN2UxYmFkMjhmYWI2Mjgw%0AMDYwNDRkZTg5OGIwOTYzMTMxZDIxN2YyMWQyZjc2ODJmZDJmMmRhMTI0MTEG%0AOwBGSSIHaWQGOwBGaQK6Ug%3D%3D%0A--b037bda840083bd92e26a653b47c58e31e0b1ea0; path=/; expires=Mon, 01 Jun 2015 13:23:31 -0000; HttpOnly"],"X-Content-Type-Options":["nosniff"]},"body":{"encoding":"UTF-8","string":"{\n \"result\": \"success\",\n \"message\": \"your file(s) have been successfully uploaded\"\n}\n"},"http_version":null},"recorded_at":"Sun, 01 Jun 2014 07:34:46 GMT"}],"recorded_with":"VCR 2.8.0"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"http_interactions":[{"request":{"method":"post","uri":"https://neocities.org/api/upload","body":{"encoding":"UTF-8","string":"-------------RubyMultipartPost\r\nContent-Disposition: form-data; name=\"index.html\"; filename=\"index.html\"\r\nContent-Length: 115\r\nContent-Type: text/html\r\nContent-Transfer-Encoding: binary\r\n\r\n<!doctype html>\n<html>\n<head>\n <title>Hello world!</title>\n</head>\n<body>\n <h1>Hello world!</h1>\n</body>\n</html>\n\r\n-------------RubyMultipartPost--\r\n\r\n"},"headers":{"User-Agent":["Faraday v0.9.0"],"Authorization":["Basic <NEOCITIZEN_BASIC_AUTH>"],"Content-Type":["multipart/form-data; boundary=-----------RubyMultipartPost"],"Content-Length":["342"]}},"response":{"status":{"code":200,"message":""},"headers":{"Server":["nginx"],"Date":["Sun, 01 Jun 2014 07:37:26 GMT"],"Content-Type":["application/json;charset=utf-8"],"Content-Length":["87"],"Connection":["close"],"Status":["200 OK"],"Set-Cookie":["neocities=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiRTA5ZTczNjY2YzA4ZDQ0NmJlY2Ix%0ANWNmZDVmMjk5M2UzMWI4MDAzYjlmYzFiYzJlZDBiN2YzMGVlYTM1NjhlOTgG%0AOwBGSSIHaWQGOwBGaQK6Ug%3D%3D%0A--e2019e00caac0e1e2d7501fc75530641c1858df5; path=/; expires=Mon, 01 Jun 2015 13:26:12 -0000; HttpOnly"],"X-Content-Type-Options":["nosniff"]},"body":{"encoding":"UTF-8","string":"{\n \"result\": \"success\",\n \"message\": \"your file(s) have been successfully uploaded\"\n}\n"},"http_version":null},"recorded_at":"Sun, 01 Jun 2014 07:37:27 GMT"}],"recorded_with":"VCR 2.8.0"}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Neocitizen::Client, :vcr do
|
4
|
+
let(:client) { Neocitizen::Client.new username: test_neocitizen_username, password: test_neocitizen_password }
|
5
|
+
|
6
|
+
describe "#info" do
|
7
|
+
let(:sitename) { "superteamawesome" }
|
8
|
+
|
9
|
+
subject(:response) { client.info(sitename) }
|
10
|
+
|
11
|
+
it "hits the /api/info endpoint" do
|
12
|
+
response
|
13
|
+
a_request(:get, "https://neocities.org/api/info").with(query: { sitename: sitename }).should have_been_made
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns the info as a Hash" do
|
17
|
+
expect(response).to be_a(Hash)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#upload" do
|
22
|
+
subject(:response) { client.upload(*files) }
|
23
|
+
|
24
|
+
let(:files) { [File.expand_path(File.join("..", "..", "..", "fixtures", "index.html"), __FILE__)] }
|
25
|
+
|
26
|
+
it "hits the /api/upload endpoint" do
|
27
|
+
response
|
28
|
+
a_request(:post, "https://neocities.org/api/upload").should have_been_made
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns the info as a Hash" do
|
32
|
+
expect(response).to be_a(Hash)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'vcr'
|
3
|
+
require 'webmock/rspec'
|
4
|
+
require 'neocitizen'
|
5
|
+
require 'base64'
|
6
|
+
|
7
|
+
RSpec.configure do |rspec|
|
8
|
+
rspec.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
end
|
10
|
+
|
11
|
+
WebMock.disable_net_connect!
|
12
|
+
|
13
|
+
VCR.configure do |vcr|
|
14
|
+
vcr.configure_rspec_metadata!
|
15
|
+
vcr.cassette_library_dir = "spec/cassettes"
|
16
|
+
vcr.hook_into :webmock
|
17
|
+
|
18
|
+
vcr.default_cassette_options = {
|
19
|
+
serialize_with: :json,
|
20
|
+
decode_compressed_response: true,
|
21
|
+
record: ENV["TRAVIS"] ? :none : :once
|
22
|
+
}
|
23
|
+
|
24
|
+
vcr.filter_sensitive_data("<NEOCITIZEN_USERNAME>") do
|
25
|
+
test_neocitizen_username
|
26
|
+
end
|
27
|
+
|
28
|
+
vcr.filter_sensitive_data("<NEOCITIZEN_PASSWORD>") do
|
29
|
+
test_neocitizen_password
|
30
|
+
end
|
31
|
+
|
32
|
+
vcr.filter_sensitive_data("<NEOCITIZEN_BASIC_AUTH>") do
|
33
|
+
Base64.strict_encode64("#{test_neocitizen_username}:#{test_neocitizen_password}")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_neocitizen_username
|
38
|
+
ENV["NEOCITIZEN_TEST_USERNAME"]
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_neocitizen_password
|
42
|
+
ENV["NEOCITIZEN_TEST_PASSWORD"]
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,243 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neocitizen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Fung
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: vcr
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: thor
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.19'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.19'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: faraday
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.9'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.9'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: excon
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.34'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ~>
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.34'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: mimemagic
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ~>
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.2'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ~>
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.2'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: multi_json
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ~>
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '1.10'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ~>
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '1.10'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: json_pure
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ~>
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '1.8'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ~>
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '1.8'
|
181
|
+
description:
|
182
|
+
email:
|
183
|
+
- aergonaut@gmail.com
|
184
|
+
executables:
|
185
|
+
- neocitizen
|
186
|
+
extensions: []
|
187
|
+
extra_rdoc_files: []
|
188
|
+
files:
|
189
|
+
- .gitignore
|
190
|
+
- .ruby-version
|
191
|
+
- .travis.yml
|
192
|
+
- Gemfile
|
193
|
+
- LICENSE.txt
|
194
|
+
- README.md
|
195
|
+
- Rakefile
|
196
|
+
- bin/neocitizen
|
197
|
+
- lib/neocitizen.rb
|
198
|
+
- lib/neocitizen/cli.rb
|
199
|
+
- lib/neocitizen/client.rb
|
200
|
+
- lib/neocitizen/version.rb
|
201
|
+
- neocitizen.gemspec
|
202
|
+
- spec/cassettes/Neocitizen_Client/_info/hits_the_/api/info_endpoint.json
|
203
|
+
- spec/cassettes/Neocitizen_Client/_info/returns_the_info_as_a_Hash.json
|
204
|
+
- spec/cassettes/Neocitizen_Client/_upload/hits_the_/api/upload_endpoint.json
|
205
|
+
- spec/cassettes/Neocitizen_Client/_upload/returns_the_info_as_a_Hash.json
|
206
|
+
- spec/fixtures/index.html
|
207
|
+
- spec/lib/neocitizen/client_spec.rb
|
208
|
+
- spec/spec_helper.rb
|
209
|
+
- templates/newsite/Gemfile.tt
|
210
|
+
- templates/newsite/content/index.html
|
211
|
+
homepage: https://github.com/aergonaut/neocitizen
|
212
|
+
licenses:
|
213
|
+
- MIT
|
214
|
+
metadata: {}
|
215
|
+
post_install_message:
|
216
|
+
rdoc_options: []
|
217
|
+
require_paths:
|
218
|
+
- lib
|
219
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
221
|
+
- - '>='
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '0'
|
224
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
|
+
requirements:
|
226
|
+
- - '>='
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: '0'
|
229
|
+
requirements: []
|
230
|
+
rubyforge_project:
|
231
|
+
rubygems_version: 2.0.14
|
232
|
+
signing_key:
|
233
|
+
specification_version: 4
|
234
|
+
summary: Toolkit for creating sites on neocities.org
|
235
|
+
test_files:
|
236
|
+
- spec/cassettes/Neocitizen_Client/_info/hits_the_/api/info_endpoint.json
|
237
|
+
- spec/cassettes/Neocitizen_Client/_info/returns_the_info_as_a_Hash.json
|
238
|
+
- spec/cassettes/Neocitizen_Client/_upload/hits_the_/api/upload_endpoint.json
|
239
|
+
- spec/cassettes/Neocitizen_Client/_upload/returns_the_info_as_a_Hash.json
|
240
|
+
- spec/fixtures/index.html
|
241
|
+
- spec/lib/neocitizen/client_spec.rb
|
242
|
+
- spec/spec_helper.rb
|
243
|
+
has_rdoc:
|