moobooks 0.1.0
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/bin/plushies +75 -0
- data/lib/moobooks.rb +24 -0
- data/lib/moobooks/database.rb +43 -0
- data/lib/moobooks/twitter.rb +22 -0
- data/lib/moobooks/twitter/app.rb +102 -0
- data/lib/moobooks/version.rb +29 -0
- data/spec/database_spec.rb +28 -0
- data/spec/spec_helper.rb +103 -0
- data/spec/twitter_app_spec.rb +60 -0
- metadata +184 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fd922053fc3d55e178f3229b909f1c5431da9fd2f3725bfde50327974f032f70
|
4
|
+
data.tar.gz: f2084ba2051a98ff2e5cf96a681be6ebb565e89d854b77ae84cc3f580f4637f0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7ea4ad75982c356fb346944859a701fb6df631bac1c7d823a18f6b5fcfd4cca1bd8f9c26cea6b84e10f0ccd383fcd09573f15d603421004357f896106a11ff41
|
7
|
+
data.tar.gz: 290f95b1dddc80a61889e495cee7cb1581523443bd44905643dffb7ae37b7af5700dbf612b5a986f164b4bef51b161be893cf48a1c705d42c8dd7d45794d3534
|
data/bin/plushies
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Copyright 2018 Maxine Michalski <maxine@furfind.net>
|
5
|
+
#
|
6
|
+
# This file is part of MooBooks.
|
7
|
+
#
|
8
|
+
# MooBooks is free software: you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation, either version 3 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# MooBooks is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with MooBooks. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
require_relative '../lib/moobooks'
|
22
|
+
|
23
|
+
def print_help
|
24
|
+
puts 'Usage: `plushies <app|account> <command> [<arguments>]',
|
25
|
+
' plushies app add <twitter|mastoon> [app_name]'
|
26
|
+
' plushies app list <twitter|mastoon>'
|
27
|
+
end
|
28
|
+
|
29
|
+
case cmd = ARGV.shift(2)
|
30
|
+
when ['-h']
|
31
|
+
print_help
|
32
|
+
when %w[app add]
|
33
|
+
platform = ARGV.shift
|
34
|
+
name = ARGV.shift
|
35
|
+
warn 'Name can\'t be empty.' if name.nil?
|
36
|
+
case platform
|
37
|
+
when 'twitter'
|
38
|
+
puts 'Please check your app\'s developer page to get it\'s data.'
|
39
|
+
print 'Consumer key: '
|
40
|
+
consumer_key = $stdin.gets.chomp
|
41
|
+
print 'Consumer secret: '
|
42
|
+
consumer_secret = $stdin.gets.chomp
|
43
|
+
Moobooks::Twitter::App.create(name, consumer_key, consumer_secret)
|
44
|
+
when 'mastodon'
|
45
|
+
Moobooks::Mastodon::App.create(name)
|
46
|
+
else
|
47
|
+
warn "Unrecognized platform: #{platform}"
|
48
|
+
print_add_help
|
49
|
+
exit 1
|
50
|
+
end
|
51
|
+
puts 'Your app was successfully saved.'
|
52
|
+
when %w[app list]
|
53
|
+
platform = ARGV.shift
|
54
|
+
case platform
|
55
|
+
when 'twitter'
|
56
|
+
apps = Moobooks::Twitter::App.list.map(&:to_s).map { |a| " #{a}" }
|
57
|
+
puts 'Known twitter apps', apps
|
58
|
+
when 'mastodon'
|
59
|
+
Moobooks::Mastodon::App.create(name)
|
60
|
+
else
|
61
|
+
warn "Unrecognized platform: #{platform}"
|
62
|
+
print_help
|
63
|
+
exit 1
|
64
|
+
end
|
65
|
+
# when 'update'
|
66
|
+
# when 'post'
|
67
|
+
# when 'profile'
|
68
|
+
# when 'follow'
|
69
|
+
# when 'favorite'
|
70
|
+
# when 'read'
|
71
|
+
else
|
72
|
+
warn "Unknown command: #{cmd.join(' ')}"
|
73
|
+
print_help
|
74
|
+
exit 1
|
75
|
+
end
|
data/lib/moobooks.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Maxine Michalski <maxine@furfind.net>
|
4
|
+
#
|
5
|
+
# This file is part of MooBooks.
|
6
|
+
#
|
7
|
+
# MooBooks is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# MooBooks is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with MooBooks. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
require 'json'
|
21
|
+
require 'mastodon'
|
22
|
+
|
23
|
+
require_relative 'moobooks/twitter'
|
24
|
+
require_relative 'moobooks/database'
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Maxine Michalski <maxine@furfind.net>
|
4
|
+
#
|
5
|
+
# This file is part of MooBooks.
|
6
|
+
#
|
7
|
+
# MooBooks is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# MooBooks is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with MooBooks. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
require 'pg'
|
21
|
+
|
22
|
+
module Moobooks
|
23
|
+
# @author Maxine Michalski
|
24
|
+
# @since 0.1.0
|
25
|
+
#
|
26
|
+
# A general purpose database connection module.
|
27
|
+
#
|
28
|
+
# @return Result of the given block
|
29
|
+
module Database
|
30
|
+
# @author Maxine Michalski
|
31
|
+
#
|
32
|
+
# Spawns a database connection and yields it
|
33
|
+
#
|
34
|
+
# @return object Result of the database block
|
35
|
+
def self.connect
|
36
|
+
pg = PG::Connection.new(dbname: 'moobooks')
|
37
|
+
pg.type_map_for_results = PG::BasicTypeMapForResults.new(pg)
|
38
|
+
result = yield pg
|
39
|
+
pg.close
|
40
|
+
result
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Maxine Michalski <maxine@furfind.net>
|
4
|
+
#
|
5
|
+
# This file is part of MooBooks.
|
6
|
+
#
|
7
|
+
# MooBooks is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# MooBooks is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with MooBooks. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
require 'twitter'
|
21
|
+
|
22
|
+
require_relative 'twitter/app'
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Maxine Michalski <maxine@furfind.net>
|
4
|
+
#
|
5
|
+
# This file is part of MooBooks.
|
6
|
+
#
|
7
|
+
# MooBooks is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# MooBooks is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with MooBooks. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
module Moobooks
|
21
|
+
module Twitter
|
22
|
+
# @author Maxine Michalski
|
23
|
+
# @since 0.1.0
|
24
|
+
class AppNotFound < StandardError; end
|
25
|
+
# @author Maxine Michalski
|
26
|
+
# @since 0.1.0
|
27
|
+
#
|
28
|
+
# A class to handle Twitter apps.
|
29
|
+
class App
|
30
|
+
# @return [Integer] ID of this app
|
31
|
+
attr_reader :id
|
32
|
+
|
33
|
+
# @return [String] Name of this app
|
34
|
+
attr_reader :name
|
35
|
+
|
36
|
+
# @return [String] Consumer key of this app
|
37
|
+
attr_reader :consumer_key
|
38
|
+
|
39
|
+
# @return [String] Consumer secret of this app
|
40
|
+
attr_reader :consumer_secret
|
41
|
+
# @author Maxine Michalski
|
42
|
+
#
|
43
|
+
# Create a new app, by storing it's credentials into databse.
|
44
|
+
#
|
45
|
+
# @param name [String] Name of the app
|
46
|
+
# @param consumer_key [String] Twitter app consumer key
|
47
|
+
# @param consumer_secret [String] Twitter app consumer secret
|
48
|
+
def self.create(name, consumer_key, consumer_secret)
|
49
|
+
if consumer_key.empty? || consumer_secret.empty?
|
50
|
+
raise ArgumentError, 'Consumer data can\'t be empty.'
|
51
|
+
end
|
52
|
+
Moobooks::Database.connect do |pg|
|
53
|
+
pg.exec('INSERT INTO twitter.apps (name, consumer_key, '\
|
54
|
+
'consumer_secret) VALUES ($1, $2, $3);',
|
55
|
+
[name, consumer_key, consumer_secret])
|
56
|
+
end
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
|
60
|
+
# @author Maxine Michalski
|
61
|
+
#
|
62
|
+
# Creates a list of all Twitter apps in database
|
63
|
+
#
|
64
|
+
# @return [Array<Moobooks::Twitter::App>] A list Twitter apps
|
65
|
+
def self.list
|
66
|
+
apps = Moobooks::Database.connect do |pg|
|
67
|
+
pg.exec('SELECT id FROM twitter.apps ORDER BY id;').to_a
|
68
|
+
end
|
69
|
+
apps.map do |a|
|
70
|
+
Moobooks::Twitter::App.new(a['id'])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# @author Maxine Michalski
|
75
|
+
#
|
76
|
+
# Initializer for Twitter appps
|
77
|
+
#
|
78
|
+
# @param id [Integer] The ID of an app we want to fetch
|
79
|
+
def initialize(id)
|
80
|
+
app = Moobooks::Database.connect do |pg|
|
81
|
+
pg.exec('SELECT id, name, consumer_key, consumer_secret, '\
|
82
|
+
'created_at FROM twitter.apps WHERE id = $1;', [id]).first
|
83
|
+
end
|
84
|
+
raise AppNotFoundError if app.nil?
|
85
|
+
app.each do |k, v|
|
86
|
+
instance_variable_set("@#{k}", v)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# @author Maxine Michalski
|
91
|
+
#
|
92
|
+
# Turn this App into a string representation
|
93
|
+
#
|
94
|
+
# @notice The returned string will be in the form of '<id> <name>'
|
95
|
+
#
|
96
|
+
# @return [String] A formatted string representation of this App
|
97
|
+
def to_s
|
98
|
+
"#{@id} #{@name}"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Maxine Michalski <maxine@furfind.net>
|
4
|
+
#
|
5
|
+
# This file is part of MooBooks.
|
6
|
+
#
|
7
|
+
# MooBooks is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# MooBooks is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with MooBooks. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
# Namespace for all classes in this gem.
|
21
|
+
# @author Maxine Michalski
|
22
|
+
# @since 0.1.0
|
23
|
+
module Moobooks
|
24
|
+
MAJOR = 0
|
25
|
+
MINOR = 1
|
26
|
+
PATCH = 0
|
27
|
+
NAME = 'moobooks'
|
28
|
+
VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Maxine Michalski <maxine@furfind.net>
|
4
|
+
#
|
5
|
+
# This file is part of MooBooks.
|
6
|
+
#
|
7
|
+
# MooBooks is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# MooBooks is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with MooBooks. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
describe Moobooks::Database, '.conect' do
|
21
|
+
context 'a consumer key and secret are given' do
|
22
|
+
it 'saves them in a database' do
|
23
|
+
expect do |b|
|
24
|
+
Moobooks::Database.connect(&b)
|
25
|
+
end.to yield_with_args
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
5
|
+
require_relative '../lib/moobooks'
|
6
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
7
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
8
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
9
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
10
|
+
# files.
|
11
|
+
#
|
12
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
13
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
14
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
15
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
16
|
+
# a separate helper file that requires the additional dependencies and performs
|
17
|
+
# the additional setup, and require it from the spec files that actually need
|
18
|
+
# it.
|
19
|
+
#
|
20
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
21
|
+
RSpec.configure do |config|
|
22
|
+
# rspec-expectations config goes here. You can use an alternate
|
23
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
24
|
+
# assertions if you prefer.
|
25
|
+
config.expect_with :rspec do |expectations|
|
26
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
27
|
+
# and `failure_message` of custom matchers include text for helper methods
|
28
|
+
# defined using `chain`, e.g.:
|
29
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
30
|
+
# # => "be bigger than 2 and smaller than 4"
|
31
|
+
# ...rather than:
|
32
|
+
# # => "be bigger than 2"
|
33
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
34
|
+
end
|
35
|
+
|
36
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
37
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
38
|
+
config.mock_with :rspec do |mocks|
|
39
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
40
|
+
# a real object. This is generally recommended, and will default to
|
41
|
+
# `true` in RSpec 4.
|
42
|
+
mocks.verify_partial_doubles = true
|
43
|
+
end
|
44
|
+
|
45
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
46
|
+
# have no way to turn it off -- the option exists only for backwards
|
47
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
48
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
49
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
50
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
51
|
+
|
52
|
+
# The settings below are suggested to provide a good initial experience
|
53
|
+
# with RSpec, but feel free to customize to your heart's content.
|
54
|
+
# This allows you to limit a spec run to individual examples or groups
|
55
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
56
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
57
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
58
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
59
|
+
# config.filter_run_when_matching :focus
|
60
|
+
#
|
61
|
+
# Allows RSpec to persist some state between runs in order to support
|
62
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
63
|
+
# you configure your source control system to ignore this file.
|
64
|
+
# config.example_status_persistence_file_path = "spec/examples.txt"
|
65
|
+
#
|
66
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
67
|
+
# recommended. For more details, see:
|
68
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
69
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
70
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
71
|
+
# config.disable_monkey_patching!
|
72
|
+
#
|
73
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
74
|
+
# be too noisy due to issues in dependencies.
|
75
|
+
# config.warnings = true
|
76
|
+
#
|
77
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
78
|
+
# file, and it's useful to allow more verbose output when running an
|
79
|
+
# individual spec file.
|
80
|
+
# if config.files_to_run.one?
|
81
|
+
# # Use the documentation formatter for detailed output,
|
82
|
+
# # unless a formatter has already been configured
|
83
|
+
# # (e.g. via a command-line flag).
|
84
|
+
# config.default_formatter = "doc"
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
# Print the 10 slowest examples and example groups at the
|
88
|
+
# end of the spec run, to help surface which specs are running
|
89
|
+
# particularly slow.
|
90
|
+
# config.profile_examples = 10
|
91
|
+
#
|
92
|
+
# Run specs in random order to surface order dependencies. If you find an
|
93
|
+
# order dependency and want to debug it, you can fix the order by providing
|
94
|
+
# the seed, which is printed after each run.
|
95
|
+
# --seed 1234
|
96
|
+
# config.order = :random
|
97
|
+
#
|
98
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
99
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
100
|
+
# test failures related to randomization by passing the same `--seed` value
|
101
|
+
# as the one that triggered the failure.
|
102
|
+
# Kernel.srand config.seed
|
103
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Maxine Michalski <maxine@furfind.net>
|
4
|
+
#
|
5
|
+
# This file is part of MooBooks.
|
6
|
+
#
|
7
|
+
# MooBooks is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# MooBooks is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with MooBooks. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
describe Moobooks::Twitter::App, '.create' do
|
21
|
+
context 'a consumer key and secret are given' do
|
22
|
+
it 'saves them in a database' do
|
23
|
+
pg = double(PG::Connection)
|
24
|
+
expect(pg).to receive(:exec).and_return(true)
|
25
|
+
expect(Moobooks::Database).to receive(:connect).and_yield(pg)
|
26
|
+
expect(Moobooks::Twitter::App.create('', '1', '1')).to be nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
context 'an empty consumer key and secret are given' do
|
30
|
+
it 'raises an argument error' do
|
31
|
+
expect { Moobooks::Twitter::App.create('', '', '') }.to(
|
32
|
+
raise_error(ArgumentError)
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe Moobooks::Twitter::App, '.list' do
|
39
|
+
it 'returns an array of Twitte::App objects' do
|
40
|
+
pg = double(PG::Connection)
|
41
|
+
data = [{ 'id' => 1, 'name' => 'test' }]
|
42
|
+
allow(pg).to receive(:exec).and_return(data, data)
|
43
|
+
allow(Moobooks::Database).to receive(:connect).and_yield(pg)
|
44
|
+
list = Moobooks::Twitter::App.list
|
45
|
+
expect(list).to be_an Array
|
46
|
+
expect(list.first).to be_a Moobooks::Twitter::App
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe Moobooks::Twitter::App, '#to_s' do
|
51
|
+
it 'returns a string representation of an App' do
|
52
|
+
pg = double(PG::Connection)
|
53
|
+
data = [{ 'id' => 1, 'name' => 'test' }]
|
54
|
+
expect(pg).to receive(:exec).and_return(data)
|
55
|
+
expect(Moobooks::Database).to receive(:connect).and_yield(pg)
|
56
|
+
app = Moobooks::Twitter::App.new(1)
|
57
|
+
expect(app.to_s).to be_a String
|
58
|
+
expect(app.to_s).to eq '1 test'
|
59
|
+
end
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: moobooks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Maxine Michalski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.58.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.58.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: simplecov
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.16.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.16.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.9.12
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.9.12
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: mastodon
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.1'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.1'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: moo_ebooks
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pg
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: twitter
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '6.0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '6.0'
|
139
|
+
description: |-
|
140
|
+
A framework and CLI to create and manage ebook accounts.
|
141
|
+
Keep in mind that actual accounts need to be created manually, but can be linked with this tool.
|
142
|
+
email: maxine@furfind.net
|
143
|
+
executables:
|
144
|
+
- plushies
|
145
|
+
extensions: []
|
146
|
+
extra_rdoc_files: []
|
147
|
+
files:
|
148
|
+
- bin/plushies
|
149
|
+
- lib/moobooks.rb
|
150
|
+
- lib/moobooks/database.rb
|
151
|
+
- lib/moobooks/twitter.rb
|
152
|
+
- lib/moobooks/twitter/app.rb
|
153
|
+
- lib/moobooks/version.rb
|
154
|
+
- spec/database_spec.rb
|
155
|
+
- spec/spec_helper.rb
|
156
|
+
- spec/twitter_app_spec.rb
|
157
|
+
homepage: https://github.com/maxine-red/moobooks
|
158
|
+
licenses:
|
159
|
+
- GPL-3.0
|
160
|
+
metadata: {}
|
161
|
+
post_install_message:
|
162
|
+
rdoc_options: []
|
163
|
+
require_paths:
|
164
|
+
- lib
|
165
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - "~>"
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '2.3'
|
170
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
requirements: []
|
176
|
+
rubyforge_project:
|
177
|
+
rubygems_version: 2.7.7
|
178
|
+
signing_key:
|
179
|
+
specification_version: 4
|
180
|
+
summary: Mooing bots for your friends.
|
181
|
+
test_files:
|
182
|
+
- spec/database_spec.rb
|
183
|
+
- spec/spec_helper.rb
|
184
|
+
- spec/twitter_app_spec.rb
|