kinja 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ea1a752d777fa593bbdbbcf75ccf665bd00abe76
4
+ data.tar.gz: 84e633a5f48efeaece4fe150dc15c78309b7448a
5
+ SHA512:
6
+ metadata.gz: 5865341f8dac7bd0701b043f2de4451148202830d10b03faa5c18583c69d51ba75997c304962ae93f5470c8a39455cca1e7cf88bacb869b674dba011da531e21
7
+ data.tar.gz: 0e8b67a30cfa3bdda390eea4f58c133ec193d5d0cf766c3d15607c99d2e7cc287451ba65e9b5c1d5a93515e6883e61e6a5b5f8862665136228e4a92e8a3dfb29
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .env
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kinja.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,77 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ # clearing :on
9
+
10
+ ## Guard internally checks for changes in the Guardfile and exits.
11
+ ## If you want Guard to automatically start up again, run guard in a
12
+ ## shell loop, e.g.:
13
+ ##
14
+ ## $ while bundle exec guard; do echo "Restarting Guard..."; done
15
+ ##
16
+ ## Note: if you are using the `directories` clause above and you are not
17
+ ## watching the project directory ('.'), then you will want to move
18
+ ## the Guardfile to a watched dir and symlink it back, e.g.
19
+ #
20
+ # $ mkdir config
21
+ # $ mv Guardfile config/
22
+ # $ ln -s config/Guardfile .
23
+ #
24
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
25
+
26
+ # Note: The cmd option is now required due to the increasing number of ways
27
+ # rspec may be run, below are examples of the most common uses.
28
+ # * bundler: 'bundle exec rspec'
29
+ # * bundler binstubs: 'bin/rspec'
30
+ # * spring: 'bin/rspec' (This will use spring if running and you have
31
+ # installed the spring binstubs per the docs)
32
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
33
+ # * 'just' rspec: 'rspec'
34
+
35
+ guard :rspec, cmd: "bundle exec rspec" do
36
+ require "guard/rspec/dsl"
37
+ dsl = Guard::RSpec::Dsl.new(self)
38
+
39
+ # Feel free to open issues for suggestions and improvements
40
+
41
+ # RSpec files
42
+ rspec = dsl.rspec
43
+ watch(rspec.spec_helper) { rspec.spec_dir }
44
+ watch(rspec.spec_support) { rspec.spec_dir }
45
+ watch(rspec.spec_files)
46
+
47
+ # Ruby files
48
+ ruby = dsl.ruby
49
+ dsl.watch_spec_files_for(ruby.lib_files)
50
+
51
+ # Rails files
52
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
53
+ dsl.watch_spec_files_for(rails.app_files)
54
+ dsl.watch_spec_files_for(rails.views)
55
+
56
+ watch(rails.controllers) do |m|
57
+ [
58
+ rspec.spec.("routing/#{m[1]}_routing"),
59
+ rspec.spec.("controllers/#{m[1]}_controller"),
60
+ rspec.spec.("acceptance/#{m[1]}")
61
+ ]
62
+ end
63
+
64
+ # Rails config changes
65
+ watch(rails.spec_helper) { rspec.spec_dir }
66
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
67
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
68
+
69
+ # Capybara features specs
70
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
71
+
72
+ # Turnip features and steps
73
+ watch(%r{^spec/acceptance/(.+)\.feature$})
74
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
75
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
76
+ end
77
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Adam Pash
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Kinja
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'kinja'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install kinja
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/kinja/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/kinja.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kinja/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kinja"
8
+ spec.version = Kinja::VERSION
9
+ spec.authors = ["Adam Pash"]
10
+ spec.email = ["adam.pash@gmail.com"]
11
+ spec.summary = %q{Simple gem for creating posts on Kinja}
12
+ spec.description = %q{}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "httparty"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "guard-rspec"
27
+ spec.add_development_dependency "dotenv"
28
+ spec.add_development_dependency "pry"
29
+ spec.add_development_dependency "vcr"
30
+ spec.add_development_dependency "webmock"
31
+ end
@@ -0,0 +1,3 @@
1
+ module Kinja
2
+ VERSION = "0.0.1"
3
+ end
data/lib/kinja.rb ADDED
@@ -0,0 +1,58 @@
1
+ require "kinja/version"
2
+ require 'httparty'
3
+
4
+ module Kinja
5
+ class Client
6
+ API_ROOT = "http://kinja.com/api"
7
+ LOGIN_PATH = "/profile/account/burner/login"
8
+ TOKEN_PATH = "/profile/token"
9
+ POST_PATH = "/core/post/add"
10
+ AUTHOR_PATH = "/profile/user/views/asAuthor"
11
+
12
+ def initialize(opts={})
13
+ @username = opts[:user]
14
+ @pass = opts[:password]
15
+ end
16
+
17
+ def post(opts={})
18
+ opts[:status] = opts[:status] || "DRAFT"
19
+ opts[:replies] = opts[:replies] || true
20
+ api_token(login)
21
+
22
+ HTTParty.post "#{API_ROOT}#{POST_PATH}?token=#{@api_token}",
23
+ body: {
24
+ headline: opts[:headline],
25
+ original: opts[:body],
26
+ defaultBlogId: get_default_blog_id(@user),
27
+ status: opts[:status],
28
+ allowReplies: opts[:replies]
29
+ }.to_json,
30
+ headers: { 'Content-Type' => 'application/json' }
31
+ end
32
+
33
+ def get_author(user)
34
+ HTTParty.get "#{API_ROOT}#{AUTHOR_PATH}?ids=#{user["id"]}"
35
+ end
36
+
37
+ def get_default_blog_id(user)
38
+ get_author(user)["data"][0]["defaultBlogId"]
39
+ end
40
+
41
+ def login
42
+ response = HTTParty.get "#{API_ROOT}#{LOGIN_PATH}?screenName=#{@username}&token=#{@pass}"
43
+ @user = response["data"]
44
+ response
45
+ end
46
+
47
+ def api_token(response)
48
+ @api_token = HTTParty.get("#{API_ROOT}#{TOKEN_PATH}",
49
+ cookies: {KinjaSession: session_token(response)}
50
+ )['data']['token']
51
+ end
52
+
53
+ def session_token(response)
54
+ re = /KinjaSession=([\w-]+);/
55
+ response.headers["set-cookie"].match(re)[1]
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,66 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://kinja.com/api/profile/token
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Cookie:
11
+ - KinjaSession=a72c7535-20c9-447d-b22c-a502af7be233
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Access-Control-Allow-Origin:
18
+ - "*"
19
+ Access-Control-Allow-Headers:
20
+ - Content-Type
21
+ X-Kinja-Version:
22
+ - '20141118'
23
+ Access-Control-Allow-Methods:
24
+ - POST, GET, OPTIONS, PUT, DELETE
25
+ Cache-Control:
26
+ - no-cache, no-store, private
27
+ P3p:
28
+ - CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ X-Robots-Tag:
32
+ - noindex
33
+ Set-Cookie:
34
+ - KinjaSession=a72c7535-20c9-447d-b22c-a502af7be233; Expires=Mon, 02 Mar 2015
35
+ 23:19:02 GMT; Path=/; HTTPOnly
36
+ - geocc=US;path=/;
37
+ X-Kinja:
38
+ - 'app04.bfc.kinja-ops.com #993'
39
+ Content-Length:
40
+ - '172'
41
+ Accept-Ranges:
42
+ - none
43
+ Date:
44
+ - Mon, 23 Feb 2015 23:19:02 GMT
45
+ Via:
46
+ - 1.1 varnish
47
+ Age:
48
+ - '0'
49
+ Connection:
50
+ - keep-alive
51
+ X-Served-By:
52
+ - cache-jfk1031-JFK
53
+ X-Cache:
54
+ - MISS
55
+ X-Cache-Hits:
56
+ - '0'
57
+ X-Timer:
58
+ - S1424733542.342583,VS0,VE5
59
+ Vary:
60
+ - X-Feature-Hash
61
+ body:
62
+ encoding: UTF-8
63
+ string: '{"meta":{"error":null,"warnings":[]},"data":{"token":"78c7e184-d9da-4555-b8c3-f488e6a7a343","session":"a72c7535-20c9-447d-b22c-a502af7be233","createdMillis":1424733542346}}'
64
+ http_version:
65
+ recorded_at: Mon, 23 Feb 2015 23:19:02 GMT
66
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,66 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://kinja.com/api/profile/user/views/asAuthor?ids=5876237249235511023
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Access-Control-Allow-Origin:
22
+ - "*"
23
+ Access-Control-Allow-Headers:
24
+ - Content-Type
25
+ X-Kinja-Version:
26
+ - '20141118'
27
+ Access-Control-Allow-Methods:
28
+ - POST, GET, OPTIONS, PUT, DELETE
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ X-Robots-Tag:
32
+ - noindex
33
+ X-Kinja:
34
+ - 'app19.bfc.kinja-ops.com #993'
35
+ X-Cdn-Fetch:
36
+ - mantle-origin-cache
37
+ Content-Length:
38
+ - '184'
39
+ Accept-Ranges:
40
+ - none
41
+ Date:
42
+ - Mon, 23 Feb 2015 23:19:02 GMT
43
+ Via:
44
+ - 1.1 varnish
45
+ Age:
46
+ - '0'
47
+ Connection:
48
+ - keep-alive
49
+ X-Served-By:
50
+ - cache-jfk1023-JFK
51
+ X-Cache:
52
+ - MISS
53
+ X-Cache-Hits:
54
+ - '0'
55
+ X-Timer:
56
+ - S1424733542.303613,VS0,VE7
57
+ Vary:
58
+ - Accept-Encoding
59
+ Set-Cookie:
60
+ - geocc=US;path=/;
61
+ body:
62
+ encoding: ASCII-8BIT
63
+ string: '{"meta":{"error":null,"warnings":[]},"data":[{"id":"5876237249235511023","screenName":"gemtest","displayName":"gemtest","superUser":false,"defaultBlogId":1634457255,"avatar":{"id":"17jcxk0ml1k8qpng","format":"png"}}]}'
64
+ http_version:
65
+ recorded_at: Mon, 23 Feb 2015 23:19:02 GMT
66
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,74 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://kinja.com/api/profile/account/burner/login?screenName=gemtest&token=mzjjk%20judly%20bjysk%20ujnbv
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Access-Control-Allow-Origin:
22
+ - "*"
23
+ Access-Control-Allow-Headers:
24
+ - Content-Type
25
+ X-Kinja-Version:
26
+ - '20141118'
27
+ Access-Control-Allow-Methods:
28
+ - POST, GET, OPTIONS, PUT, DELETE
29
+ Cache-Control:
30
+ - no-cache, no-store, private
31
+ P3p:
32
+ - CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ X-Robots-Tag:
36
+ - noindex
37
+ Set-Cookie:
38
+ - KinjaBurner="d41d8cd98f00b204e9800998ecf8427e|mzjjk judly bjysk ujnbv"; Expires=Thu,
39
+ 20 Feb 2025 23:19:02 GMT; Path=/; HTTPOnly
40
+ - KinjaRememberMe=5876237249235511023|a72c7535-20c9-447d-b22c-a502af7be233;
41
+ Expires=Thu, 20 Feb 2025 23:19:02 GMT; Path=/; HTTPOnly
42
+ - KinjaSession=a72c7535-20c9-447d-b22c-a502af7be233; Expires=Mon, 02 Mar 2015
43
+ 23:19:02 GMT; Path=/; HTTPOnly
44
+ - geocc=US;path=/;
45
+ X-Kinja:
46
+ - 'app08.xyz.kinja-ops.com #993'
47
+ Content-Length:
48
+ - '239'
49
+ Accept-Ranges:
50
+ - none
51
+ Date:
52
+ - Mon, 23 Feb 2015 23:19:02 GMT
53
+ Via:
54
+ - 1.1 varnish
55
+ Age:
56
+ - '0'
57
+ Connection:
58
+ - keep-alive
59
+ X-Served-By:
60
+ - cache-jfk1024-JFK
61
+ X-Cache:
62
+ - MISS
63
+ X-Cache-Hits:
64
+ - '0'
65
+ X-Timer:
66
+ - S1424733542.252049,VS0,VE38
67
+ Vary:
68
+ - Accept-Encoding
69
+ body:
70
+ encoding: ASCII-8BIT
71
+ string: '{"meta":{"error":null,"warnings":[]},"data":{"id":"5876237249235511023","screenName":"gemtest","displayName":"gemtest","authType":4,"authName":"burner","createdMillis":1424733492000,"updatedMillis":1424733493000,"converted":3,"status":"enabled","avatar":{"id":"17jcxk0ml1k8qpng","format":"png"},"superUser":false,"remoteAccounts":[]}}'
72
+ http_version:
73
+ recorded_at: Mon, 23 Feb 2015 23:19:02 GMT
74
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,255 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://kinja.com/api/profile/account/burner/login?screenName=gemtest&token=mzjjk%20judly%20bjysk%20ujnbv
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Access-Control-Allow-Origin:
16
+ - "*"
17
+ Access-Control-Allow-Headers:
18
+ - Content-Type
19
+ X-Kinja-Version:
20
+ - '20141118'
21
+ Access-Control-Allow-Methods:
22
+ - POST, GET, OPTIONS, PUT, DELETE
23
+ Cache-Control:
24
+ - no-cache, no-store, private
25
+ P3p:
26
+ - CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ X-Robots-Tag:
30
+ - noindex
31
+ Set-Cookie:
32
+ - KinjaBurner="d41d8cd98f00b204e9800998ecf8427e|mzjjk judly bjysk ujnbv"; Expires=Thu,
33
+ 20 Feb 2025 23:19:02 GMT; Path=/; HTTPOnly
34
+ - KinjaRememberMe=5876237249235511023|a796ca55-f22b-4047-be8b-3d9777d3b12e;
35
+ Expires=Thu, 20 Feb 2025 23:19:02 GMT; Path=/; HTTPOnly
36
+ - KinjaSession=a796ca55-f22b-4047-be8b-3d9777d3b12e; Expires=Mon, 02 Mar 2015
37
+ 23:19:02 GMT; Path=/; HTTPOnly
38
+ - geocc=US;path=/;
39
+ X-Kinja:
40
+ - 'app01.bfc.kinja-ops.com #993'
41
+ Content-Length:
42
+ - '334'
43
+ Accept-Ranges:
44
+ - none
45
+ Date:
46
+ - Mon, 23 Feb 2015 23:19:02 GMT
47
+ Via:
48
+ - 1.1 varnish
49
+ Age:
50
+ - '0'
51
+ Connection:
52
+ - keep-alive
53
+ X-Served-By:
54
+ - cache-jfk1031-JFK
55
+ X-Cache:
56
+ - MISS
57
+ X-Cache-Hits:
58
+ - '0'
59
+ X-Timer:
60
+ - S1424733542.367708,VS0,VE32
61
+ Vary:
62
+ - X-Feature-Hash
63
+ body:
64
+ encoding: UTF-8
65
+ string: '{"meta":{"error":null,"warnings":[]},"data":{"id":"5876237249235511023","screenName":"gemtest","displayName":"gemtest","authType":4,"authName":"burner","createdMillis":1424733492000,"updatedMillis":1424733493000,"converted":3,"status":"enabled","avatar":{"id":"17jcxk0ml1k8qpng","format":"png"},"superUser":false,"remoteAccounts":[]}}'
66
+ http_version:
67
+ recorded_at: Mon, 23 Feb 2015 23:19:02 GMT
68
+ - request:
69
+ method: get
70
+ uri: http://kinja.com/api/profile/token
71
+ body:
72
+ encoding: US-ASCII
73
+ string: ''
74
+ headers:
75
+ Cookie:
76
+ - KinjaSession=a796ca55-f22b-4047-be8b-3d9777d3b12e
77
+ response:
78
+ status:
79
+ code: 200
80
+ message: OK
81
+ headers:
82
+ Access-Control-Allow-Origin:
83
+ - "*"
84
+ Access-Control-Allow-Headers:
85
+ - Content-Type
86
+ X-Kinja-Version:
87
+ - '20141118'
88
+ Access-Control-Allow-Methods:
89
+ - POST, GET, OPTIONS, PUT, DELETE
90
+ Cache-Control:
91
+ - no-cache, no-store, private
92
+ P3p:
93
+ - CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"
94
+ Content-Type:
95
+ - application/json; charset=utf-8
96
+ X-Robots-Tag:
97
+ - noindex
98
+ Set-Cookie:
99
+ - KinjaSession=a796ca55-f22b-4047-be8b-3d9777d3b12e; Expires=Mon, 02 Mar 2015
100
+ 23:19:02 GMT; Path=/; HTTPOnly
101
+ - geocc=US;path=/;
102
+ X-Kinja:
103
+ - 'app14.bfc.kinja-ops.com #993'
104
+ Content-Length:
105
+ - '172'
106
+ Accept-Ranges:
107
+ - none
108
+ Date:
109
+ - Mon, 23 Feb 2015 23:19:02 GMT
110
+ Via:
111
+ - 1.1 varnish
112
+ Age:
113
+ - '0'
114
+ Connection:
115
+ - keep-alive
116
+ X-Served-By:
117
+ - cache-jfk1027-JFK
118
+ X-Cache:
119
+ - MISS
120
+ X-Cache-Hits:
121
+ - '0'
122
+ X-Timer:
123
+ - S1424733542.411984,VS0,VE7
124
+ Vary:
125
+ - X-Feature-Hash
126
+ body:
127
+ encoding: UTF-8
128
+ string: '{"meta":{"error":null,"warnings":[]},"data":{"token":"b088e5f6-2d47-450a-b31d-d76b805d6f33","session":"a796ca55-f22b-4047-be8b-3d9777d3b12e","createdMillis":1424733542412}}'
129
+ http_version:
130
+ recorded_at: Mon, 23 Feb 2015 23:19:02 GMT
131
+ - request:
132
+ method: get
133
+ uri: http://kinja.com/api/profile/user/views/asAuthor?ids=5876237249235511023
134
+ body:
135
+ encoding: US-ASCII
136
+ string: ''
137
+ headers: {}
138
+ response:
139
+ status:
140
+ code: 200
141
+ message: OK
142
+ headers:
143
+ Access-Control-Allow-Origin:
144
+ - "*"
145
+ Access-Control-Allow-Headers:
146
+ - Content-Type
147
+ X-Kinja-Version:
148
+ - '20141118'
149
+ Access-Control-Allow-Methods:
150
+ - POST, GET, OPTIONS, PUT, DELETE
151
+ Content-Type:
152
+ - application/json; charset=utf-8
153
+ X-Robots-Tag:
154
+ - noindex
155
+ X-Kinja:
156
+ - 'app16.bfc.kinja-ops.com #993'
157
+ X-Cdn-Fetch:
158
+ - mantle-origin-cache
159
+ Content-Length:
160
+ - '217'
161
+ Accept-Ranges:
162
+ - none
163
+ Date:
164
+ - Mon, 23 Feb 2015 23:19:02 GMT
165
+ Via:
166
+ - 1.1 varnish
167
+ Age:
168
+ - '0'
169
+ Connection:
170
+ - keep-alive
171
+ X-Served-By:
172
+ - cache-jfk1027-JFK
173
+ X-Cache:
174
+ - MISS
175
+ X-Cache-Hits:
176
+ - '0'
177
+ X-Timer:
178
+ - S1424733542.438524,VS0,VE5
179
+ Vary:
180
+ - X-Feature-Hash
181
+ Set-Cookie:
182
+ - geocc=US;path=/;
183
+ body:
184
+ encoding: UTF-8
185
+ string: '{"meta":{"error":null,"warnings":[]},"data":[{"id":"5876237249235511023","screenName":"gemtest","displayName":"gemtest","superUser":false,"defaultBlogId":1634457255,"avatar":{"id":"17jcxk0ml1k8qpng","format":"png"}}]}'
186
+ http_version:
187
+ recorded_at: Mon, 23 Feb 2015 23:19:02 GMT
188
+ - request:
189
+ method: post
190
+ uri: http://kinja.com/api/core/post/add?token=b088e5f6-2d47-450a-b31d-d76b805d6f33
191
+ body:
192
+ encoding: UTF-8
193
+ string: '{"headline":"","original":"<p>[<a data-attr=\"http://gawker.com/no-playlist-1685415865\"
194
+ href=\"http://gawker.com/no-playlist-1685415865\">Gawker</a>]</p>","defaultBlogId":1634457255,"status":"PUBLISHED","allowReplies":true}'
195
+ headers:
196
+ Content-Type:
197
+ - application/json
198
+ response:
199
+ status:
200
+ code: 200
201
+ message: OK
202
+ headers:
203
+ Access-Control-Allow-Origin:
204
+ - "*"
205
+ Access-Control-Allow-Headers:
206
+ - Content-Type
207
+ Access-Control-Allow-Methods:
208
+ - POST, GET, OPTIONS, PUT, DELETE
209
+ Content-Type:
210
+ - application/json; charset=utf-8
211
+ X-Kinja:
212
+ - 'app01.bfc.kinja-ops.com #5968'
213
+ X-Cdn-Fetch:
214
+ - mantle-default
215
+ Content-Length:
216
+ - '3047'
217
+ Accept-Ranges:
218
+ - none
219
+ Date:
220
+ - Mon, 23 Feb 2015 23:19:02 GMT
221
+ Via:
222
+ - 1.1 varnish
223
+ Connection:
224
+ - keep-alive
225
+ X-Served-By:
226
+ - cache-jfk1020-JFK
227
+ X-Cache:
228
+ - MISS
229
+ X-Cache-Hits:
230
+ - '0'
231
+ X-Timer:
232
+ - S1424733542.455929,VS0,VE162
233
+ Vary:
234
+ - X-Feature-Hash
235
+ Set-Cookie:
236
+ - geocc=US;path=/;
237
+ body:
238
+ encoding: UTF-8
239
+ string: '{"meta":{"error":null,"warnings":[]},"data":{"id":1687581385,"parentId":null,"parentAuthorId":null,"starterId":1687581385,"publishTimeMillis":1424733542575,"lastUpdateTimeMillis":1424733542575,"timezone":"America/New_York","shareBlogId":null,"sharedPostId":null,"sharedUrl":null,"salesAvatar":null,"sponsored":false,"status":"PUBLISHED","authorId":"5876237249235511023","allowReplies":true,"byline":"","showByline":true,"properties":"","xmliId":null,"blogId":[1634457255],"defaultBlogId":1634457255,"authorBlogId":1634457255,"liveBlog":false,"approved":true,"headline":"","original":"<p>[<a
240
+ data-attr=\"http://gawker.com/no-playlist-1685415865\" href=\"http://gawker.com/no-playlist-1685415865\">Gawker</a>]</p>","display":"<body><p>[<a
241
+ href=\"http://gawker.com/no-playlist-1685415865\">Gawker</a><inset id=\"1685415865\"></inset>]</p></body>","excerpt":"","source":"wysiwyg","images":[],"videos":[],"videoThumbs":[],"author":{"id":"5876237249235511023","screenName":"gemtest","displayName":"gemtest","defaultBlogId":1634457255,"defaultBlog":null,"avatar":{"id":"17jcxk0ml1k8qpng","format":"png"}},"tags":[],"blogs":[{"id":1634457255,"name":"gemtest","displayName":"gemtest","canonicalHost":"gemtest.kinja.com","hosts":[],"applicationHost":"kinja.com","status":"ENABLED","timezone":"America/New_York","timezoneOffset":-18000000,"timezoneShortname":"EST","properties":"","adminProperties":"","mergedProperties":null}],"annotation":null,"viewstats":null,"promotions":[],"replyMeta":null,"replyCount":null,"parent":null,"starter":null,"blogPostAction":null,"score":null,"insets":[],"referencedBy":[],"likes":null,"sharedPost":null,"reframes":[],"noindex":null,"isRecommended":null,"permalink":"http://gemtest.kinja.com/gawker-1687581385","permalinkHost":"http://gemtest.kinja.com","permalinkPath":"/gawker-1687581385","parsedBody":{"display":"<p
242
+ class=\"first-text\">[<a href=\"http://gawker.com/no-playlist-1685415865\"
243
+ target=\"_blank\">Gawker</a><inset id=\"1685415865\"></inset>]</p><!-- core-decorated
244
+ -->","excerpt":"<p class=\"first-text\">[<a href=\"http://gawker.com/no-playlist-1685415865\"
245
+ target=\"_blank\">Gawker</a>]</p>","compact":"[Gawker]...","plaintext":"[Gawker]","shortHeadline":"","shortExcerpt":"<p
246
+ class=\"first-text\">[<a href=\"http://gawker.com/no-playlist-1685415865\"
247
+ target=\"_blank\">Gawker</a>]</p>","excerptWithAssets":"<p class=\"first-text\">[<a
248
+ href=\"http://gawker.com/no-playlist-1685415865\" target=\"_blank\">Gawker</a>\n
249
+ <inset id=\"1685415865\"></inset>]</p>","aboveHeadline":null,"leftOfHeadline":null,"firstAsset":"","length":8,"postId":1687581385,"isBlip":true,"sharingMainImage":null,"facebookImage":null,"decorationFlags":["Default"]},"publishTime":{"timestamp":1424733542575,"timezone":"America/New_York","MdyHm":"02/23/2015
250
+ 18:19","MdyatHm":"02/23/2015 at 18:19","rfc822":"Mon, 23 Feb 2015 23:19:02
251
+ GMT","yMdHmsZ":"2015-02-23T18:19:02-05:00","hmma":"6:19pm","day":"Monday","Mddyyhmma":"2/23/15
252
+ 6:19pm","fullDate":"February 23, 2015","relative":{"amount":null,"type":"now"}},"authorBlogName":"gemtest"}}'
253
+ http_version:
254
+ recorded_at: Mon, 23 Feb 2015 23:19:02 GMT
255
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,67 @@
1
+ require_relative '../../lib/kinja'
2
+
3
+ require 'vcr'
4
+ VCR.configure do |config|
5
+ config.cassette_library_dir = "spec/fixtures/vcr_cassettes"
6
+ config.hook_into :webmock # or :fakeweb
7
+ config.allow_http_connections_when_no_cassette = true
8
+ end
9
+
10
+ require 'dotenv'
11
+ ENV = Dotenv.load
12
+
13
+ describe Kinja do
14
+
15
+ let(:kinja) {
16
+ Kinja::Client.new(
17
+ user: ENV["USER"],
18
+ password: ENV["PASS"]
19
+ )
20
+ }
21
+
22
+ let(:response) {
23
+ VCR.use_cassette('login') do
24
+ kinja.login
25
+ end
26
+ }
27
+
28
+ it "logs in" do
29
+ expect(response["data"]["id"]).to eq '5876237249235511023'
30
+ end
31
+
32
+ it "gets session token from login data" do
33
+ expect(kinja.session_token response).to eq 'a72c7535-20c9-447d-b22c-a502af7be233'
34
+ end
35
+
36
+ it "gets an API token" do
37
+ VCR.use_cassette('api-token-test') do
38
+ expect(kinja.api_token response).to eq '78c7e184-d9da-4555-b8c3-f488e6a7a343'
39
+ end
40
+ end
41
+
42
+ it "gets the author profile" do
43
+ VCR.use_cassette('author-path-er') do
44
+ blog_id = kinja.get_author(response["data"])["data"][0]["defaultBlogId"]
45
+ expect(blog_id).to eq 1634457255
46
+ end
47
+ end
48
+
49
+ it "gets the default blog id" do
50
+ VCR.use_cassette('author-path-er') do
51
+ blog_id = kinja.get_default_blog_id(response["data"])
52
+ expect(blog_id).to eq 1634457255
53
+ end
54
+ end
55
+
56
+ it "posts stuff" do
57
+ VCR.use_cassette('write-post') do
58
+ post = kinja.post(
59
+ headline: '',
60
+ body: '<p>[<a data-attr="http://gawker.com/no-playlist-1685415865" href="http://gawker.com/no-playlist-1685415865">Gawker</a>]</p>',
61
+ status: 'PUBLISHED',
62
+ replies: false
63
+ )
64
+ expect(post.code).to be 200
65
+ end
66
+ end
67
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kinja
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Adam Pash
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
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: guard-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: dotenv
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: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: vcr
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: ''
140
+ email:
141
+ - adam.pash@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - Gemfile
148
+ - Guardfile
149
+ - LICENSE.txt
150
+ - README.md
151
+ - Rakefile
152
+ - kinja.gemspec
153
+ - lib/kinja.rb
154
+ - lib/kinja/version.rb
155
+ - spec/fixtures/vcr_cassettes/api-token-test.yml
156
+ - spec/fixtures/vcr_cassettes/author-path-er.yml
157
+ - spec/fixtures/vcr_cassettes/login.yml
158
+ - spec/fixtures/vcr_cassettes/write-post.yml
159
+ - spec/lib/kinja_spec.rb
160
+ homepage: ''
161
+ licenses:
162
+ - MIT
163
+ metadata: {}
164
+ post_install_message:
165
+ rdoc_options: []
166
+ require_paths:
167
+ - lib
168
+ required_ruby_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ required_rubygems_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ requirements: []
179
+ rubyforge_project:
180
+ rubygems_version: 2.4.5
181
+ signing_key:
182
+ specification_version: 4
183
+ summary: Simple gem for creating posts on Kinja
184
+ test_files:
185
+ - spec/fixtures/vcr_cassettes/api-token-test.yml
186
+ - spec/fixtures/vcr_cassettes/author-path-er.yml
187
+ - spec/fixtures/vcr_cassettes/login.yml
188
+ - spec/fixtures/vcr_cassettes/write-post.yml
189
+ - spec/lib/kinja_spec.rb