<commit_before>This is a Ruby library to read/write files/spreadsheets in Google Drive/Docs.

NOTE: This is NOT a library to create Google Drive App.


= Migration from 0.3.x or before to ver. 1.0.x

Ver. 0.3.x and the versions before no longer works, because the API used was deprecated and shut down. You need to migrate to ver. 1.0.x.

Ver. 1.0.x is not 100% backward compatible with 0.3.x. Some methods have been removed. Especially, GoogleDrive.login has been removed, and you must use GoogleDrive.saved_session or GoogleDrive.login_with_oauth instead, as in the example code below.


= How to install

  $ sudo gem install google_drive


= How to use

First, follow "Create a client ID and client secret" in {this page}[https://developers.google.com/drive/web/auth/web-server] to get a client ID and client secret for OAuth. Set "Application type" to "Other" in the form to create a client ID if you use GoogleDrive.saved_session method as in the example below.


The client ID and client secret you obtained in the step above.
You can keep them in a config file, it should look like this one below:

  {
    "client_id": "xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
    "client_secret": "<KEY>",
    "scope": [
      "https://www.googleapis.com/auth/drive ",
      "https://spreadsheets.google.com/feeds/"
    ],
    "refresh_token": ""
  }

Example to read/write files in Google Drive:

  require "google/api_client"
  require "google_drive"



  # Creates a session. This will prompt the credential via command line for the
  # first time and save it to ./config.json file for later usages.
  #
  # If you are developing a Web app, and you want to ask the user to log in in
  # the Web app instead of via command line, follow the example code in:
  # http://gimite.net/doc/google-drive-ruby/GoogleDrive.html#method-c-login_with_oauth
  session = GoogleDrive.saved_session("./config.json")

  # where first argument is a path to your config file with credentials.

  # Gets list of remote files.
  session.files.each do |file|
    p file.title
  end

  # Uploads a local file.
  session.upload_from_file("/path/to/hello.txt", "hello.txt", convert: false)
<commit_msg>update readme and use English in more smoothly way<commit_after>This is a Ruby library to read/write files/spreadsheets in Google Drive/Docs.

NOTE: This is NOT a library to create Google Drive App.


= Migration from 0.3.x or before to ver. 1.0.x

Ver. 0.3.x and the versions before no longer works, because the API used was deprecated and shut down. You need to migrate to ver. 1.0.x.

Ver. 1.0.x is not 100% backward compatible with 0.3.x. Some methods have been removed. Especially, GoogleDrive.login has been removed, and you must use GoogleDrive.saved_session or GoogleDrive.login_with_oauth instead, as in the example code below.


= How to install

  $ sudo gem install google_drive


= How to use

First, follow "Create a client ID and client secret" in {this page}[https://developers.google.com/drive/web/auth/web-server] to get a client ID and client secret for OAuth. Set "Application type" to "Other" in the form to create a client ID if you use GoogleDrive.saved_session method as in the example below.


Create config.json file which contains the generated client ID and client secret, which looks like this:

  {
    "client_id": "xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
    "client_secret": "<KEY>",
  }

Example to read/write files in Google Drive:

  require "google/api_client"
  require "google_drive"



  # Creates a session. This will prompt the credential via command line for the
  # first time and save it to ./config.json file for later usages.
  #
  # If you are developing a Web app, and you want to ask the user to log in in
  # the Web app instead of via command line, follow the example code in:
  # http://gimite.net/doc/google-drive-ruby/GoogleDrive.html#method-c-login_with_oauth
  session = GoogleDrive.saved_session("./config.json")

  # where first argument is a path to your config file with credentials.

  # Gets list of remote files.
  session.files.each do |file|
    p file.title
  end

  # Uploads a local file.
  session.upload_from_file("/path/to/hello.txt", "hello.txt", convert: false)

{'fraction_non_alphanumeric': 0.08089782557867664, 'fraction_numerical': 0.007014262333411269, 'mean_word_length': 3.6399132321041217, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '44278', 'n_tokens_mistral': 1333, 'n_tokens_neox': 1228, 'n_words': 549}