rMAL 0.0.2 → 0.0.3

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +55 -5
  3. data/lib/rMAL.rb +65 -1
  4. data/lib/rMAL/version.rb +1 -1
  5. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46b95f5e3e81314a460fbf51e9acf806c3e1b0d6
4
- data.tar.gz: d6036a8dfb970e104edfaacecb8a7d7ce50a6ed9
3
+ metadata.gz: a02ab8cb0341bd397f199fc400ad58d0d6a89e87
4
+ data.tar.gz: 28cbd886164e92ed3eb07a9e701bdc5826d35a82
5
5
  SHA512:
6
- metadata.gz: f8c48d8e4c3bb6b76ce1b4d523b857bb5115a777dfb77a2646fe68ce804fef08c19ee63fc584c831eeb78709420e34a3819914a1d14f024d62216eee4164a6a3
7
- data.tar.gz: 2c2eb9a2589f443c87c4ca270bd39aa3063ce96c4cbfb21cf936c7ce239eb46d3c466d65dfc735df15cca37b718e8e807d4de3a5d77bc7243f51797dc0b23222
6
+ metadata.gz: 4def24973de57061764c92a3c88e283ee3b0230b96b622bbcaa4fd40fde66d62392cb4133b30207eb3fde3a9b35b9cba6d3f805643f3897e6803a2ea4ccbac53
7
+ data.tar.gz: a17f56c9ba8d86e5b916204f17e6f05f55fa771280ef2e0d3908a6be61e7eca35c567f0736f66258ff5c4dfa767da31641dad8bb57f6e4f0766ef248ea40d094
data/README.md CHANGED
@@ -4,7 +4,7 @@ MyAnimeList backend Ruby API
4
4
 
5
5
  ## Under Development
6
6
 
7
- I have recieved my development user agent from MyAnimeList, so I can now continue with development, therefore, a functional (not to mention stable) release of this library is forth-coming.
7
+ This project hasn't even finished adding the basic functionality yet, and so, it is certainly not ready for actual use.
8
8
 
9
9
  ## Installation
10
10
 
@@ -22,7 +22,46 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ So far, one can do the following.
26
+
27
+ ### Settings
28
+
29
+ Settings include the username, password and api-key and are all saved in a `settings.yml` file in a directory of choice.
30
+
31
+ #### Init
32
+
33
+ ```ruby
34
+ RMAL::Settings.init(dir) # dir should be where you want to store your settings (default is "/")
35
+ ```
36
+ Note that this stores the directory you've chosen as the global variable `$path`.
37
+
38
+ #### Set
39
+
40
+ ```ruby
41
+ RMAL::Settings.set(username, password, apikey) # self-explanatory, no defaults
42
+ ```
43
+
44
+ #### Load
45
+
46
+ ```ruby
47
+ RMAL::Settings.load(path) # Load settings, takes path to settings.yml
48
+ ```
49
+ This will create the global variables `$w_username`, `$w_password` and `w_apikey`.
50
+
51
+ ### Login
52
+
53
+ This just verifies credentials.
54
+ ```ruby
55
+ RMAL.login
56
+ ```
57
+ It'll output your login ID and username.
58
+
59
+ ### Search (Not even remotely complete)
60
+
61
+ ```ruby
62
+ RMAL.search(type, query) # type is manga/anime (default anime), and query is your search query
63
+ ```
64
+ So far, this just dumps the entire XML result on you. Parsing comes next.
26
65
 
27
66
  ## Contributing
28
67
 
@@ -34,10 +73,21 @@ TODO: Write usage instructions here
34
73
 
35
74
  ## Changelog(ue)
36
75
 
37
- ### 0.0.1
76
+ ### 0.0.3
38
77
 
39
- Just getting it up to wait for MAL development user agent.
78
+ Added functional settings and login functionality, started on search. There seems to be an issue with use:
79
+ ```ruby
80
+ # Usage
81
+ RMAL::Settings.init("C:\\Users\\username\\Desktop\\Wherever") # Windows filesystem annoyances
82
+ RMAL::Settings.set("username", "password", "apikey")
83
+ RMAL.login # or search or whatever
84
+ # However, the first two lines seem to be required for execution each time, which they shouldn't. Research into this issue has yet to be started, so hopefully it's trivial.
85
+ ```
40
86
 
41
87
  ### 0.0.2
42
88
 
43
- Updating README and Gemfile for documentation purposes.
89
+ Updating README and Gemfile for documentation purposes.
90
+
91
+ ### 0.0.1
92
+
93
+ Just getting it up to wait for MAL development user agent.
@@ -1,5 +1,69 @@
1
1
  require "rMAL/version"
2
+ require "yaml"
3
+ require "ox"
2
4
 
3
5
  module RMAL
4
- # Your code goes here...
6
+ # Configuration of password, username and apikey, for use by other modules
7
+ module Settings
8
+ # Create the settings.yml file
9
+ def self.init(dir = "/") # Default dir may not have the correct access rights granted
10
+ # Allows user to not bother with the trailing / if so desired
11
+ if !(dir.end_with? "/")
12
+ dir = dir + "/"
13
+ end
14
+ # Create a settings.yml file
15
+ File.open("#{dir}settings.yml", "w") do |file|
16
+ end
17
+ # Create global path variable for ease of use
18
+ $path = "#{dir}/settings.yml"
19
+ end
20
+ # Allows the user to change the settings where necessary (and rMAL where necessary)
21
+ def self.set(username, password, apikey)
22
+ configuration = {
23
+ 'username' => username,
24
+ 'password' => password,
25
+ 'apikey' => apikey
26
+ }
27
+ open($path, 'w') { |f| YAML.dump(configuration, f) }
28
+ open($path) { |f| return f.read }
29
+ end
30
+ # Load the settings for use in other modules
31
+ public # I know this isn't necessary, will remove later
32
+
33
+ def self.load(path)
34
+ # Load the file
35
+ settings = YAML::load_file path
36
+ # I am aware of the serious security implications of this eval(). This needs a better fix ASAP.
37
+ working = eval(settings.inspect)
38
+ # Load the settings into working variables
39
+ $w_username = working["username"]
40
+ $w_password = working["password"]
41
+ $w_apikey = working["apikey"]
42
+ end
43
+ end
44
+ # Verify Credentials
45
+ def self.login
46
+ RMAL::Settings.load($path)
47
+ # Curl into MAL with the request
48
+ IO.popen("curl -u #{$w_username}:#{$w_password} http://myanimelist.net/api/account/verify_credentials.xml -A #{$w_apikey}") { |f| $login_response = f.read }
49
+ # Parse out the user id
50
+ login_id = Ox.parse($login_response).user.id.text
51
+ # Parse out the username
52
+ login_username = Ox.parse($login_response).user.username.text
53
+ # Display both bits of info
54
+ puts "Login ID: " + login_id, "Login Username: " + login_username
55
+ # Return both bits of info
56
+ return login_id, login_username
57
+ end
58
+ # Search anime/manga
59
+ def self.search(type = "anime", query)
60
+ RMAL::Settings.load($path)
61
+ # Replace spaces with '+'s
62
+ query = query.gsub(/\s/, "+")
63
+ # Curl into MAL with the request
64
+ IO.popen("curl -u #{$w_username}:#{$w_password} http://myanimelist.net/api/#{type}/search.xml?q=#{query} -A #{$w_apikey}") { |f| $search_response = f.read }
65
+ p $search_response # temporary
66
+ end
5
67
  end
68
+
69
+ # Not done yet
@@ -1,3 +1,3 @@
1
1
  module RMAL
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rMAL
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jude Rosen (foogit)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-21 00:00:00.000000000 Z
11
+ date: 2014-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,11 +94,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  version: '0'
95
95
  requirements: []
96
96
  rubyforge_project:
97
- rubygems_version: 2.2.2
97
+ rubygems_version: 2.0.14
98
98
  signing_key:
99
99
  specification_version: 4
100
100
  summary: MyAnimeList backend Ruby API (stable release forth-coming)
101
101
  test_files:
102
102
  - spec/rMAL_spec.rb
103
103
  - spec/spec_helper.rb
104
- has_rdoc: